@atlaskit/editor-plugin-loom 3.0.2 → 3.0.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,13 @@
1
1
  # @atlaskit/editor-plugin-loom
2
2
 
3
+ ## 3.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#146839](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/146839)
8
+ [`5150b3ba1d31d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5150b3ba1d31d) -
9
+ Subscribe to plugin state changes within custom Loom editor toolbar button
10
+
3
11
  ## 3.0.2
4
12
 
5
13
  ### Patch Changes
@@ -12,7 +12,6 @@ var _react = _interopRequireWildcard(require("react"));
12
12
  var _react2 = require("@emotion/react");
13
13
  var _hooks = require("@atlaskit/editor-common/hooks");
14
14
  var _commands = require("../commands");
15
- var _pmPlugin = require("../pm-plugin");
16
15
  var _ToolbarButtonComponent = _interopRequireDefault(require("./ToolbarButtonComponent"));
17
16
  var _excluded = ["onClickBeforeInit", "isDisabled", "href"];
18
17
  /**
@@ -22,15 +21,16 @@ var _excluded = ["onClickBeforeInit", "isDisabled", "href"];
22
21
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
23
22
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
24
23
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
25
- var CustomisableLoomToolbarButton = function CustomisableLoomToolbarButton(editorView, disabled, appearance, api) {
24
+ var CustomisableLoomToolbarButton = function CustomisableLoomToolbarButton(disabled, appearance, api) {
26
25
  return /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
27
- var _loomPluginKey$getSta;
28
26
  var onClickBeforeInit = props.onClickBeforeInit,
29
27
  _props$isDisabled = props.isDisabled,
30
28
  isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
31
29
  href = props.href,
32
30
  restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
33
- var isLoomEnabled = (_loomPluginKey$getSta = _pmPlugin.loomPluginKey.getState(editorView.state)) === null || _loomPluginKey$getSta === void 0 ? void 0 : _loomPluginKey$getSta.isEnabled;
31
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['loom']),
32
+ loomState = _useSharedPluginState.loomState;
33
+ var isLoomEnabled = !!(loomState !== null && loomState !== void 0 && loomState.isEnabled);
34
34
  var handleOnClick = (0, _react.useCallback)(function (e) {
35
35
  if (isLoomEnabled) {
36
36
  (0, _commands.executeRecordVideo)(api);
@@ -60,8 +60,8 @@ var LoomToolbarButtonWrapper = function LoomToolbarButtonWrapper(_ref) {
60
60
  var handleOnClick = (0, _react.useCallback)(function () {
61
61
  return (0, _commands.executeRecordVideo)(api);
62
62
  }, [api]);
63
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['loom']),
64
- loomState = _useSharedPluginState.loomState;
63
+ var _useSharedPluginState2 = (0, _hooks.useSharedPluginState)(api, ['loom']),
64
+ loomState = _useSharedPluginState2.loomState;
65
65
  if (!loomState) {
66
66
  return null;
67
67
  }
@@ -77,13 +77,12 @@ var LoomToolbarButtonWrapper = function LoomToolbarButtonWrapper(_ref) {
77
77
  var loomPrimaryToolbarComponent = exports.loomPrimaryToolbarComponent = function loomPrimaryToolbarComponent(config, api) {
78
78
  return function (_ref2) {
79
79
  var disabled = _ref2.disabled,
80
- appearance = _ref2.appearance,
81
- editorView = _ref2.editorView;
80
+ appearance = _ref2.appearance;
82
81
  if (config.shouldShowToolbarButton === false) {
83
82
  return null;
84
83
  }
85
84
  if (config.renderButton) {
86
- return config.renderButton(CustomisableLoomToolbarButton(editorView, disabled, appearance, api));
85
+ return config.renderButton(CustomisableLoomToolbarButton(disabled, appearance, api));
87
86
  }
88
87
  if (config.shouldShowToolbarButton) {
89
88
  return (0, _react2.jsx)(LoomToolbarButtonWrapper
@@ -9,17 +9,18 @@ import React, { useCallback } from 'react';
9
9
  import { jsx } from '@emotion/react';
10
10
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
11
11
  import { executeRecordVideo } from '../commands';
12
- import { loomPluginKey } from '../pm-plugin';
13
12
  import ToolbarButtonComponent from './ToolbarButtonComponent';
14
- const CustomisableLoomToolbarButton = (editorView, disabled, appearance, api) => /*#__PURE__*/React.forwardRef((props, ref) => {
15
- var _loomPluginKey$getSta;
13
+ const CustomisableLoomToolbarButton = (disabled, appearance, api) => /*#__PURE__*/React.forwardRef((props, ref) => {
16
14
  const {
17
15
  onClickBeforeInit,
18
16
  isDisabled = false,
19
17
  href,
20
18
  ...restProps
21
19
  } = props;
22
- const isLoomEnabled = (_loomPluginKey$getSta = loomPluginKey.getState(editorView.state)) === null || _loomPluginKey$getSta === void 0 ? void 0 : _loomPluginKey$getSta.isEnabled;
20
+ const {
21
+ loomState
22
+ } = useSharedPluginState(api, ['loom']);
23
+ const isLoomEnabled = !!(loomState !== null && loomState !== void 0 && loomState.isEnabled);
23
24
  const handleOnClick = useCallback(e => {
24
25
  if (isLoomEnabled) {
25
26
  executeRecordVideo(api);
@@ -62,14 +63,13 @@ const LoomToolbarButtonWrapper = ({
62
63
  };
63
64
  export const loomPrimaryToolbarComponent = (config, api) => ({
64
65
  disabled,
65
- appearance,
66
- editorView
66
+ appearance
67
67
  }) => {
68
68
  if (config.shouldShowToolbarButton === false) {
69
69
  return null;
70
70
  }
71
71
  if (config.renderButton) {
72
- return config.renderButton(CustomisableLoomToolbarButton(editorView, disabled, appearance, api));
72
+ return config.renderButton(CustomisableLoomToolbarButton(disabled, appearance, api));
73
73
  }
74
74
  if (config.shouldShowToolbarButton) {
75
75
  return jsx(LoomToolbarButtonWrapper
@@ -11,17 +11,17 @@ import React, { useCallback } from 'react';
11
11
  import { jsx } from '@emotion/react';
12
12
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
13
13
  import { executeRecordVideo } from '../commands';
14
- import { loomPluginKey } from '../pm-plugin';
15
14
  import ToolbarButtonComponent from './ToolbarButtonComponent';
16
- var CustomisableLoomToolbarButton = function CustomisableLoomToolbarButton(editorView, disabled, appearance, api) {
15
+ var CustomisableLoomToolbarButton = function CustomisableLoomToolbarButton(disabled, appearance, api) {
17
16
  return /*#__PURE__*/React.forwardRef(function (props, ref) {
18
- var _loomPluginKey$getSta;
19
17
  var onClickBeforeInit = props.onClickBeforeInit,
20
18
  _props$isDisabled = props.isDisabled,
21
19
  isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
22
20
  href = props.href,
23
21
  restProps = _objectWithoutProperties(props, _excluded);
24
- var isLoomEnabled = (_loomPluginKey$getSta = loomPluginKey.getState(editorView.state)) === null || _loomPluginKey$getSta === void 0 ? void 0 : _loomPluginKey$getSta.isEnabled;
22
+ var _useSharedPluginState = useSharedPluginState(api, ['loom']),
23
+ loomState = _useSharedPluginState.loomState;
24
+ var isLoomEnabled = !!(loomState !== null && loomState !== void 0 && loomState.isEnabled);
25
25
  var handleOnClick = useCallback(function (e) {
26
26
  if (isLoomEnabled) {
27
27
  executeRecordVideo(api);
@@ -51,8 +51,8 @@ var LoomToolbarButtonWrapper = function LoomToolbarButtonWrapper(_ref) {
51
51
  var handleOnClick = useCallback(function () {
52
52
  return executeRecordVideo(api);
53
53
  }, [api]);
54
- var _useSharedPluginState = useSharedPluginState(api, ['loom']),
55
- loomState = _useSharedPluginState.loomState;
54
+ var _useSharedPluginState2 = useSharedPluginState(api, ['loom']),
55
+ loomState = _useSharedPluginState2.loomState;
56
56
  if (!loomState) {
57
57
  return null;
58
58
  }
@@ -68,13 +68,12 @@ var LoomToolbarButtonWrapper = function LoomToolbarButtonWrapper(_ref) {
68
68
  export var loomPrimaryToolbarComponent = function loomPrimaryToolbarComponent(config, api) {
69
69
  return function (_ref2) {
70
70
  var disabled = _ref2.disabled,
71
- appearance = _ref2.appearance,
72
- editorView = _ref2.editorView;
71
+ appearance = _ref2.appearance;
73
72
  if (config.shouldShowToolbarButton === false) {
74
73
  return null;
75
74
  }
76
75
  if (config.renderButton) {
77
- return config.renderButton(CustomisableLoomToolbarButton(editorView, disabled, appearance, api));
76
+ return config.renderButton(CustomisableLoomToolbarButton(disabled, appearance, api));
78
77
  }
79
78
  if (config.shouldShowToolbarButton) {
80
79
  return jsx(LoomToolbarButtonWrapper
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-loom",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Loom plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@atlaskit/button": "^20.2.0",
38
- "@atlaskit/editor-common": "^91.1.0",
38
+ "@atlaskit/editor-common": "^91.2.0",
39
39
  "@atlaskit/editor-plugin-analytics": "^1.8.0",
40
40
  "@atlaskit/editor-plugin-hyperlink": "^2.9.0",
41
41
  "@atlaskit/editor-plugin-primary-toolbar": "^2.0.0",
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@atlaskit/editor-plugin-base": "^1.11.0",
62
- "@atlaskit/editor-plugin-card": "^3.2.0",
62
+ "@atlaskit/editor-plugin-card": "^3.3.0",
63
63
  "@atlaskit/editor-plugin-copy-button": "^1.3.0",
64
64
  "@atlaskit/editor-plugin-decorations": "^1.3.0",
65
65
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",