@seafile/sdoc-editor 1.0.66-beta4 → 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.
@@ -26,11 +26,9 @@ const RightPanel = _ref => {
26
26
  const {
27
27
  collaborators
28
28
  } = (0, _hooks.useCollaborators)();
29
+ const [width, setWidth] = (0, _react.useState)(MIN_PANEL_WIDTH);
29
30
  const panelWrapperStyle = (0, _react.useMemo)(() => {
30
31
  if (!displayPluginName) return null;
31
- const panelWidth = JSON.parse(window.localStorage.getItem('sdoc-panel-width', '{}')) || {};
32
- console.log(panelWidth);
33
- const width = panelWidth[displayPluginName] || MIN_PANEL_WIDTH;
34
32
  let style = {
35
33
  width,
36
34
  zIndex: 101
@@ -41,11 +39,9 @@ const RightPanel = _ref => {
41
39
  style.width = MAX_PANEL_WIDTH;
42
40
  }
43
41
  return style;
44
- }, [displayPluginName]);
42
+ }, [width, displayPluginName]);
45
43
  const resizeWidth = (0, _react.useCallback)(width => {
46
- if (panelWrapperRef.current) {
47
- panelWrapperRef.current.style.width = `${width}px`;
48
- }
44
+ setWidth(width);
49
45
  }, [panelWrapperRef]);
50
46
  const resizeWidthEnd = (0, _react.useCallback)(width => {
51
47
  const panelWidth = JSON.parse(window.localStorage.getItem('sdoc-panel-width', '{}'));
@@ -54,6 +50,11 @@ const RightPanel = _ref => {
54
50
  [displayPluginName]: width
55
51
  }));
56
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]);
57
58
  if (!displayPluginName) return null;
58
59
  const plugin = plugins.find(p => p.name === displayPluginName);
59
60
  if (!plugin) return null;
@@ -75,7 +76,8 @@ const RightPanel = _ref => {
75
76
  editor: editor,
76
77
  type: "global",
77
78
  collaborators: collaborators,
78
- onClose: closePlugin
79
+ onClose: closePlugin,
80
+ width: width
79
81
  })));
80
82
  };
81
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.66beta4",
3
+ "version": "1.0.66beta5",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",