@seafile/sdoc-editor 1.0.66-beta3 → 1.0.66-beta5

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.
@@ -19,17 +19,16 @@ const RightPanel = _ref => {
19
19
  } = _ref;
20
20
  const {
21
21
  plugins,
22
- displayPluginName
22
+ displayPluginName,
23
+ closePlugin
23
24
  } = (0, _hooks.usePlugins)();
24
25
  const panelWrapperRef = (0, _react.useRef)(null);
25
26
  const {
26
27
  collaborators
27
28
  } = (0, _hooks.useCollaborators)();
29
+ const [width, setWidth] = (0, _react.useState)(MIN_PANEL_WIDTH);
28
30
  const panelWrapperStyle = (0, _react.useMemo)(() => {
29
31
  if (!displayPluginName) return null;
30
- const panelWidth = JSON.parse(window.localStorage.getItem('sdoc-panel-width', '{}')) || {};
31
- console.log(panelWidth);
32
- const width = panelWidth[displayPluginName] || MIN_PANEL_WIDTH;
33
32
  let style = {
34
33
  width,
35
34
  zIndex: 101
@@ -40,11 +39,9 @@ const RightPanel = _ref => {
40
39
  style.width = MAX_PANEL_WIDTH;
41
40
  }
42
41
  return style;
43
- }, [displayPluginName]);
42
+ }, [width, displayPluginName]);
44
43
  const resizeWidth = (0, _react.useCallback)(width => {
45
- if (panelWrapperRef.current) {
46
- panelWrapperRef.current.style.width = `${width}px`;
47
- }
44
+ setWidth(width);
48
45
  }, [panelWrapperRef]);
49
46
  const resizeWidthEnd = (0, _react.useCallback)(width => {
50
47
  const panelWidth = JSON.parse(window.localStorage.getItem('sdoc-panel-width', '{}'));
@@ -53,6 +50,11 @@ const RightPanel = _ref => {
53
50
  [displayPluginName]: width
54
51
  }));
55
52
  }, [displayPluginName]);
53
+ (0, _react.useEffect)(() => {
54
+ const panelWidth = JSON.parse(window.localStorage.getItem('sdoc-panel-width', '{}')) || {};
55
+ const width = Math.max(parseInt(panelWidth[displayPluginName] || MIN_PANEL_WIDTH), MAX_PANEL_WIDTH);
56
+ setWidth(width);
57
+ }, [displayPluginName]);
56
58
  if (!displayPluginName) return null;
57
59
  const plugin = plugins.find(p => p.name === displayPluginName);
58
60
  if (!plugin) return null;
@@ -73,7 +75,9 @@ const RightPanel = _ref => {
73
75
  }, /*#__PURE__*/_react.default.createElement(Component, {
74
76
  editor: editor,
75
77
  type: "global",
76
- collaborators: collaborators
78
+ collaborators: collaborators,
79
+ onClose: closePlugin,
80
+ width: width
77
81
  })));
78
82
  };
79
83
  var _default = exports.default = RightPanel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.66beta3",
3
+ "version": "1.0.66beta5",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",