@atlaskit/editor-plugin-loom 9.3.2 → 9.3.3

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,14 @@
1
1
  # @atlaskit/editor-plugin-loom
2
2
 
3
+ ## 9.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`52d4b8fab3118`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/52d4b8fab3118) -
8
+ Add platform_editor_toolbar_hide_overflow_menu experiment, add logic to hide menu button if there
9
+ are no menu items rendered
10
+ - Updated dependencies
11
+
3
12
  ## 9.3.2
4
13
 
5
14
  ### Patch Changes
@@ -4,7 +4,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.LoomMenuItem = void 0;
7
+ exports.LoomMenuItem = exports.CustomisableLoomMenuItem = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _reactIntlNext = require("react-intl-next");
10
10
  var _hooks = require("@atlaskit/editor-common/hooks");
@@ -40,7 +40,7 @@ var LoomMenuItem = exports.LoomMenuItem = function LoomMenuItem(_ref) {
40
40
  });
41
41
  }
42
42
  };
43
- var CustomisableLoomMenuItem = function CustomisableLoomMenuItem(api) {
43
+ var CustomisableLoomMenuItem = exports.CustomisableLoomMenuItem = function CustomisableLoomMenuItem(api) {
44
44
  return /*#__PURE__*/_react.default.forwardRef(function (_ref2, ref) {
45
45
  var _ref2$isDisabled = _ref2.isDisabled,
46
46
  isDisabled = _ref2$isDisabled === void 0 ? false : _ref2$isDisabled,
@@ -41,6 +41,14 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
41
41
  api: api,
42
42
  renderButton: config.renderButton
43
43
  });
44
+ },
45
+ isHidden: function isHidden() {
46
+ var _api$loom, _api$editorViewMode$s, _api$editorViewMode, _config$shouldRenderB, _config$shouldRenderB2;
47
+ var loomState = api === null || api === void 0 || (_api$loom = api.loom) === null || _api$loom === void 0 ? void 0 : _api$loom.sharedState.currentState();
48
+ var editorViewMode = (_api$editorViewMode$s = api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState()) !== null && _api$editorViewMode$s !== void 0 ? _api$editorViewMode$s : 'edit';
49
+ // if shouldRenderButton is not provided, default to true
50
+ var shouldRenderButton = (_config$shouldRenderB = config === null || config === void 0 || (_config$shouldRenderB2 = config.shouldRenderButton) === null || _config$shouldRenderB2 === void 0 ? void 0 : _config$shouldRenderB2.call(config)) !== null && _config$shouldRenderB !== void 0 ? _config$shouldRenderB : true;
51
+ return 'renderButton' in config && shouldRenderButton === false || (loomState === null || loomState === void 0 ? void 0 : loomState.isEnabled) === undefined || editorViewMode !== 'edit';
44
52
  }
45
53
  }];
46
54
  };
@@ -35,7 +35,7 @@ export const LoomMenuItem = ({
35
35
  });
36
36
  }
37
37
  };
38
- const CustomisableLoomMenuItem = api => /*#__PURE__*/React.forwardRef(({
38
+ export const CustomisableLoomMenuItem = api => /*#__PURE__*/React.forwardRef(({
39
39
  isDisabled = false,
40
40
  onClickBeforeInit,
41
41
  href,
@@ -35,6 +35,14 @@ export const getToolbarComponents = (config, api) => {
35
35
  api: api,
36
36
  renderButton: config.renderButton
37
37
  });
38
+ },
39
+ isHidden: () => {
40
+ var _api$loom, _api$editorViewMode$s, _api$editorViewMode, _config$shouldRenderB, _config$shouldRenderB2;
41
+ const loomState = api === null || api === void 0 ? void 0 : (_api$loom = api.loom) === null || _api$loom === void 0 ? void 0 : _api$loom.sharedState.currentState();
42
+ const editorViewMode = (_api$editorViewMode$s = api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState()) !== null && _api$editorViewMode$s !== void 0 ? _api$editorViewMode$s : 'edit';
43
+ // if shouldRenderButton is not provided, default to true
44
+ const shouldRenderButton = (_config$shouldRenderB = config === null || config === void 0 ? void 0 : (_config$shouldRenderB2 = config.shouldRenderButton) === null || _config$shouldRenderB2 === void 0 ? void 0 : _config$shouldRenderB2.call(config)) !== null && _config$shouldRenderB !== void 0 ? _config$shouldRenderB : true;
45
+ return 'renderButton' in config && shouldRenderButton === false || (loomState === null || loomState === void 0 ? void 0 : loomState.isEnabled) === undefined || editorViewMode !== 'edit';
38
46
  }
39
47
  }];
40
48
  };
@@ -32,7 +32,7 @@ export var LoomMenuItem = function LoomMenuItem(_ref) {
32
32
  });
33
33
  }
34
34
  };
35
- var CustomisableLoomMenuItem = function CustomisableLoomMenuItem(api) {
35
+ export var CustomisableLoomMenuItem = function CustomisableLoomMenuItem(api) {
36
36
  return /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
37
37
  var _ref2$isDisabled = _ref2.isDisabled,
38
38
  isDisabled = _ref2$isDisabled === void 0 ? false : _ref2$isDisabled,
@@ -34,6 +34,14 @@ export var getToolbarComponents = function getToolbarComponents(config, api) {
34
34
  api: api,
35
35
  renderButton: config.renderButton
36
36
  });
37
+ },
38
+ isHidden: function isHidden() {
39
+ var _api$loom, _api$editorViewMode$s, _api$editorViewMode, _config$shouldRenderB, _config$shouldRenderB2;
40
+ var loomState = api === null || api === void 0 || (_api$loom = api.loom) === null || _api$loom === void 0 ? void 0 : _api$loom.sharedState.currentState();
41
+ var editorViewMode = (_api$editorViewMode$s = api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.sharedState.currentState()) !== null && _api$editorViewMode$s !== void 0 ? _api$editorViewMode$s : 'edit';
42
+ // if shouldRenderButton is not provided, default to true
43
+ var shouldRenderButton = (_config$shouldRenderB = config === null || config === void 0 || (_config$shouldRenderB2 = config.shouldRenderButton) === null || _config$shouldRenderB2 === void 0 ? void 0 : _config$shouldRenderB2.call(config)) !== null && _config$shouldRenderB !== void 0 ? _config$shouldRenderB : true;
44
+ return 'renderButton' in config && shouldRenderButton === false || (loomState === null || loomState === void 0 ? void 0 : loomState.isEnabled) === undefined || editorViewMode !== 'edit';
37
45
  }
38
46
  }];
39
47
  };
@@ -3,6 +3,7 @@ import { type INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
4
4
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
5
  import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
6
+ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
6
7
  import type { HyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
7
8
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
8
9
  import { type QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
@@ -41,7 +42,8 @@ export type LoomPlugin = NextEditorPlugin<'loom', {
41
42
  OptionalPlugin<PrimaryToolbarPlugin>,
42
43
  OptionalPlugin<QuickInsertPlugin>,
43
44
  OptionalPlugin<ConnectivityPlugin>,
44
- OptionalPlugin<ToolbarPlugin>
45
+ OptionalPlugin<ToolbarPlugin>,
46
+ OptionalPlugin<EditorViewModePlugin>
45
47
  ];
46
48
  pluginConfiguration: LoomPluginOptions;
47
49
  sharedState: LoomPluginState | undefined;
@@ -44,6 +44,11 @@ export type LoomPluginOptionsWithProvider = {
44
44
  * @param ButtonComponent Loom toolbar button component (mainly UI)
45
45
  */
46
46
  renderButton?: RenderButton;
47
+ /**
48
+ * Due to contrainsts with the toolbar model the menu needs to know if any menu items will truely render. Right now
49
+ * it's not possible to inspect the output of renderButton to detemine this so we need to pass it in as a prop.
50
+ */
51
+ shouldRenderButton?: () => boolean;
47
52
  shouldShowToolbarButton?: boolean;
48
53
  };
49
54
  export type LoomPluginOptionsWithoutProvider = {
@@ -55,6 +60,11 @@ export type LoomPluginOptionsWithoutProvider = {
55
60
  * @param ButtonComponent Loom toolbar button component (mainly UI)
56
61
  */
57
62
  renderButton: RenderButton;
63
+ /**
64
+ * Due to contrainsts with the toolbar model the menu needs to know if any menu items will truely render. Right now
65
+ * it's not possible to inspect the output of renderButton to detemine this so we need to pass it in as a prop.
66
+ */
67
+ shouldRenderButton?: () => boolean;
58
68
  shouldShowToolbarButton?: boolean;
59
69
  };
60
70
  export type LoomPluginOptions = LoomPluginOptionsWithProvider | LoomPluginOptionsWithoutProvider;
@@ -1,6 +1,8 @@
1
+ import React from 'react';
1
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
3
  import type { LoomPlugin } from '../loomPluginType';
3
- import type { LoomPluginOptions } from '../types';
4
+ import type { ButtonComponentProps, LoomPluginOptions } from '../types';
4
5
  export declare const LoomMenuItem: ({ api, renderButton, }: {
5
6
  api: ExtractInjectionAPI<LoomPlugin> | undefined;
6
7
  } & Pick<LoomPluginOptions, "renderButton">) => JSX.Element | null | undefined;
8
+ export declare const CustomisableLoomMenuItem: (api: ExtractInjectionAPI<LoomPlugin> | undefined) => React.ForwardRefExoticComponent<ButtonComponentProps & React.RefAttributes<HTMLElement>>;
@@ -3,6 +3,7 @@ import { type INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
4
4
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
5
  import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
6
+ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
6
7
  import type { HyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
7
8
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
8
9
  import { type QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
@@ -41,7 +42,8 @@ export type LoomPlugin = NextEditorPlugin<'loom', {
41
42
  OptionalPlugin<PrimaryToolbarPlugin>,
42
43
  OptionalPlugin<QuickInsertPlugin>,
43
44
  OptionalPlugin<ConnectivityPlugin>,
44
- OptionalPlugin<ToolbarPlugin>
45
+ OptionalPlugin<ToolbarPlugin>,
46
+ OptionalPlugin<EditorViewModePlugin>
45
47
  ];
46
48
  pluginConfiguration: LoomPluginOptions;
47
49
  sharedState: LoomPluginState | undefined;
@@ -44,6 +44,11 @@ export type LoomPluginOptionsWithProvider = {
44
44
  * @param ButtonComponent Loom toolbar button component (mainly UI)
45
45
  */
46
46
  renderButton?: RenderButton;
47
+ /**
48
+ * Due to contrainsts with the toolbar model the menu needs to know if any menu items will truely render. Right now
49
+ * it's not possible to inspect the output of renderButton to detemine this so we need to pass it in as a prop.
50
+ */
51
+ shouldRenderButton?: () => boolean;
47
52
  shouldShowToolbarButton?: boolean;
48
53
  };
49
54
  export type LoomPluginOptionsWithoutProvider = {
@@ -55,6 +60,11 @@ export type LoomPluginOptionsWithoutProvider = {
55
60
  * @param ButtonComponent Loom toolbar button component (mainly UI)
56
61
  */
57
62
  renderButton: RenderButton;
63
+ /**
64
+ * Due to contrainsts with the toolbar model the menu needs to know if any menu items will truely render. Right now
65
+ * it's not possible to inspect the output of renderButton to detemine this so we need to pass it in as a prop.
66
+ */
67
+ shouldRenderButton?: () => boolean;
58
68
  shouldShowToolbarButton?: boolean;
59
69
  };
60
70
  export type LoomPluginOptions = LoomPluginOptionsWithProvider | LoomPluginOptionsWithoutProvider;
@@ -1,6 +1,8 @@
1
+ import React from 'react';
1
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
3
  import type { LoomPlugin } from '../loomPluginType';
3
- import type { LoomPluginOptions } from '../types';
4
+ import type { ButtonComponentProps, LoomPluginOptions } from '../types';
4
5
  export declare const LoomMenuItem: ({ api, renderButton, }: {
5
6
  api: ExtractInjectionAPI<LoomPlugin> | undefined;
6
7
  } & Pick<LoomPluginOptions, "renderButton">) => JSX.Element | null | undefined;
8
+ export declare const CustomisableLoomMenuItem: (api: ExtractInjectionAPI<LoomPlugin> | undefined) => React.ForwardRefExoticComponent<ButtonComponentProps & React.RefAttributes<HTMLElement>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-loom",
3
- "version": "9.3.2",
3
+ "version": "9.3.3",
4
4
  "description": "Loom plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,9 +35,10 @@
35
35
  "@atlaskit/button": "^23.9.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^7.0.0",
37
37
  "@atlaskit/editor-plugin-connectivity": "^7.0.0",
38
+ "@atlaskit/editor-plugin-editor-viewmode": "^9.0.0",
38
39
  "@atlaskit/editor-plugin-hyperlink": "^9.0.0",
39
40
  "@atlaskit/editor-plugin-primary-toolbar": "^8.0.0",
40
- "@atlaskit/editor-plugin-quick-insert": "^7.3.0",
41
+ "@atlaskit/editor-plugin-quick-insert": "^7.4.0",
41
42
  "@atlaskit/editor-plugin-toolbar": "^4.1.0",
42
43
  "@atlaskit/editor-plugin-width": "^8.1.0",
43
44
  "@atlaskit/editor-prosemirror": "^7.3.0",
@@ -47,10 +48,10 @@
47
48
  "@atlaskit/tokens": "^11.0.0",
48
49
  "@babel/runtime": "^7.0.0",
49
50
  "@emotion/react": "^11.7.1",
50
- "@loomhq/record-sdk": "^4.9.0"
51
+ "@loomhq/record-sdk": "^4.9.1"
51
52
  },
52
53
  "peerDependencies": {
53
- "@atlaskit/editor-common": "^111.12.0",
54
+ "@atlaskit/editor-common": "^111.19.0",
54
55
  "react": "^18.2.0",
55
56
  "react-dom": "^18.2.0",
56
57
  "react-intl-next": "npm:react-intl@^5.18.1"