@seafile/seafile-editor 1.0.119-beta → 1.0.119-beta2

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.
@@ -11,7 +11,8 @@ const INTERNAL_EVENTS = exports.INTERNAL_EVENTS = {
11
11
  ON_OPEN_FORMULA_DIALOG: 'on_open_formula_dialog',
12
12
  ON_SELECT_ALL_CELL: 'on_select_all_cell',
13
13
  ON_TOGGLE_IMAGE_POPOVER: 'on_toggle_image_popover',
14
- OUTLINE_STATE_CHANGED: 'outline_state_changed'
14
+ OUTLINE_STATE_CHANGED: 'outline_state_changed',
15
+ RESIZE_ARTICLE: 'resize_article'
15
16
  };
16
17
  const EXTERNAL_EVENTS = exports.EXTERNAL_EVENTS = {
17
18
  ON_HELP_INFO_TOGGLE: 'on_help_info_toggle',
@@ -35,6 +35,9 @@ const ArticleInfo = _ref => {
35
35
  const resizeWidth = (0, _react.useCallback)(width => {
36
36
  if (width >= MIN_PANEL_WIDTH && width <= MAX_PANEL_WIDTH) {
37
37
  setWidth(width);
38
+ console.log(_eventTypes.INTERNAL_EVENTS.RESIZE_ARTICLE);
39
+ const eventBus = _eventBus.default.getInstance();
40
+ eventBus.dispatch(_eventTypes.INTERNAL_EVENTS.RESIZE_ARTICLE);
38
41
  }
39
42
  }, []);
40
43
  const resizeWidthEnd = (0, _react.useCallback)(width => {
@@ -22,10 +22,14 @@ function EditorHelp(_ref) {
22
22
  const updateArticleInfoState = (0, _react.useCallback)(() => {
23
23
  setIsShowArticleInfo(prevState => !prevState);
24
24
  setIsShowHelpInfo(false);
25
+ const eventBus = _eventBus.default.getInstance();
26
+ eventBus.dispatch(_eventTypes.INTERNAL_EVENTS.RESIZE_ARTICLE);
25
27
  }, []);
26
28
  const updateHelpInfoState = (0, _react.useCallback)(state => {
27
29
  setIsShowHelpInfo(state);
28
30
  setIsShowArticleInfo(false);
31
+ const eventBus = _eventBus.default.getInstance();
32
+ eventBus.dispatch(_eventTypes.INTERNAL_EVENTS.RESIZE_ARTICLE);
29
33
  }, []);
30
34
  (0, _react.useEffect)(() => {
31
35
  const eventBus = _eventBus.default.getInstance();
@@ -47,6 +47,7 @@ function SlateEditor(_ref) {
47
47
 
48
48
  // Adjust article container margin-left value according to isShown of the outline and width of window
49
49
  const handleWindowResize = (0, _react.useCallback)(() => {
50
+ console.log('handleWindowResize');
50
51
  const rect = scrollRef.current.getBoundingClientRect();
51
52
  const articleElement = document.querySelector('.article');
52
53
  const articleRect = articleElement ? articleElement.getBoundingClientRect() : null;
@@ -59,22 +60,16 @@ function SlateEditor(_ref) {
59
60
  setContainerStyle({});
60
61
  }
61
62
  }, []);
62
- (0, _react.useEffect)(() => {
63
- const eventBus = _eventBus.default.getInstance();
64
- const unsubscribeOutline = eventBus.subscribe(_eventTypes.INTERNAL_EVENTS.OUTLINE_STATE_CHANGED, handleWindowResize);
65
- const unsubscribeArticleInfo = eventBus.subscribe(_eventTypes.EXTERNAL_EVENTS.ON_ARTICLE_INFO_TOGGLE, handleWindowResize);
66
- const unsubscribeHelpInfo = eventBus.subscribe(_eventTypes.EXTERNAL_EVENTS.ON_HELP_INFO_TOGGLE, handleWindowResize);
67
- return () => {
68
- unsubscribeHelpInfo();
69
- unsubscribeArticleInfo();
70
- unsubscribeOutline();
71
- };
72
- }, [handleWindowResize]);
73
63
  (0, _react.useEffect)(() => {
74
64
  handleWindowResize();
75
65
  window.addEventListener('resize', handleWindowResize);
66
+ const eventBus = _eventBus.default.getInstance();
67
+ const unsubscribeOutline = eventBus.subscribe(_eventTypes.INTERNAL_EVENTS.OUTLINE_STATE_CHANGED, handleWindowResize);
68
+ const unsubscribeResizeArticle = eventBus.subscribe(_eventTypes.INTERNAL_EVENTS.RESIZE_ARTICLE, handleWindowResize);
76
69
  return () => {
77
70
  window.removeEventListener('resize', handleWindowResize);
71
+ unsubscribeOutline();
72
+ unsubscribeResizeArticle();
78
73
  };
79
74
  // eslint-disable-next-line react-hooks/exhaustive-deps
80
75
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/seafile-editor",
3
- "version": "1.0.119beta",
3
+ "version": "1.0.119beta2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {