@seafile/sdoc-editor 1.0.157 → 1.0.158

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.
@@ -4,7 +4,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.PAGE_EDIT_AREA_WIDTH = exports.MODIFY_TYPE = exports.LEFT_OUTLINE_WIDTH = exports.INTERNAL_EVENT = exports.HEADER_OUTLINE_WIDTH_MAPPING = exports.FULL_WIDTH_MODE = exports.DOCUMENT_PLUGIN_EDITOR = exports.DIFF_VIEWER = exports.COMMENT_EDITOR_EDIT_AREA_WIDTH = exports.COMMENT_EDITOR = exports.ARTICLE_MIN_WIDTH = exports.ARTICLE_FULL_WIDTH = void 0;
7
+ exports.PAGE_EDIT_AREA_WIDTH = exports.MODIFY_TYPE = exports.LEFT_OUTLINE_WIDTH = exports.INTERNAL_EVENT = exports.HEADER_OUTLINE_WIDTH_MAPPING = exports.FULL_WIDTH_MODE = exports.DOCUMENT_PLUGIN_EDITOR = exports.DIFF_VIEWER = exports.COMMENT_EDITOR_EDIT_AREA_WIDTH = exports.COMMENT_EDITOR = exports.ARTICLE_FULL_WIDTH = exports.ARTICLE_FULL_MIN_WIDTH = exports.ARTICLE_DEFAULT_WIDTH = void 0;
8
8
  Object.defineProperty(exports, "PLUGIN_BTN_POSITION", {
9
9
  enumerable: true,
10
10
  get: function () {
@@ -93,6 +93,8 @@ const SDOC_STORAGE = exports.SDOC_STORAGE = 'sdoc';
93
93
  const LEFT_OUTLINE_WIDTH = exports.LEFT_OUTLINE_WIDTH = 280;
94
94
  const RIGHT_COMMENT_WIDTH = exports.RIGHT_COMMENT_WIDTH = 314;
95
95
 
96
- // min width and full width
97
- const ARTICLE_MIN_WIDTH = exports.ARTICLE_MIN_WIDTH = '794px';
98
- const ARTICLE_FULL_WIDTH = exports.ARTICLE_FULL_WIDTH = 'calc(100% - 50px - 50px)'; // The left and right sides are 50
96
+ // Default mode width
97
+ const ARTICLE_DEFAULT_WIDTH = exports.ARTICLE_DEFAULT_WIDTH = '794px';
98
+ // Width in full width mode
99
+ const ARTICLE_FULL_WIDTH = exports.ARTICLE_FULL_WIDTH = 'calc(100% - 50px - 50px)'; // The left and right sides are 50
100
+ const ARTICLE_FULL_MIN_WIDTH = exports.ARTICLE_FULL_MIN_WIDTH = '400px';
@@ -12,6 +12,9 @@ var _outline = _interopRequireDefault(require("../outline"));
12
12
  var _classnames = _interopRequireDefault(require("classnames"));
13
13
  var _provider = _interopRequireDefault(require("../comment/provider"));
14
14
  var _rightPanel = _interopRequireDefault(require("../right-panel"));
15
+ var _localStorageUtils = _interopRequireDefault(require("../../utils/local-storage-utils"));
16
+ var _fullWidthMode = require("../utils/full-width-mode");
17
+ var _constants = require("../../basic-sdk/constants");
15
18
  const EditorContent = _ref => {
16
19
  let {
17
20
  readonly,
@@ -29,6 +32,20 @@ const EditorContent = _ref => {
29
32
  } = event.target;
30
33
  setScrollLeft(scrollLeft);
31
34
  }, []);
35
+ const onBodyScroll = (0, _react.useCallback)(() => {
36
+ const scrollLeft = window.scrollX;
37
+ setScrollLeft(scrollLeft);
38
+ }, []);
39
+ (0, _react.useEffect)(() => {
40
+ // Modify the outline position even when scrolling the window
41
+ if (_localStorageUtils.default.getItem(_constants.FULL_WIDTH_MODE)) {
42
+ document.addEventListener('scroll', onBodyScroll);
43
+ }
44
+ return () => {
45
+ document.removeEventListener('scroll', onBodyScroll);
46
+ };
47
+ // eslint-disable-next-line react-hooks/exhaustive-deps
48
+ }, []);
32
49
  const className = (0, _classnames.default)('sdoc-editor-content', {
33
50
  'readonly': readonly,
34
51
  'no-outline': !showOutline
@@ -50,7 +67,8 @@ const EditorContent = _ref => {
50
67
  scrollRef
51
68
  }
52
69
  }, /*#__PURE__*/_react.default.createElement("div", {
53
- className: className
70
+ className: className,
71
+ style: (0, _fullWidthMode.getContentStyleByFullModeStyle)()
54
72
  }, showOutline && /*#__PURE__*/_react.default.createElement(_outline.default, {
55
73
  scrollLeft: scrollLeft,
56
74
  doc: docValue
@@ -14,20 +14,20 @@ const getStyleByDefaultMode = (scrollRef, editor) => {
14
14
  isShowComments
15
15
  } = sdocStorage;
16
16
  const containerStyle = {
17
- width: _constants.ARTICLE_MIN_WIDTH
17
+ width: _constants.ARTICLE_DEFAULT_WIDTH
18
18
  };
19
19
 
20
20
  // Has outline
21
21
  if (isShowOutline && editor.editorType !== _constants.WIKI_EDITOR) {
22
22
  const rect = scrollRef.current.getBoundingClientRect();
23
23
  if (isShowComments) {
24
- const outlineRightWidth = Number(_constants.ARTICLE_MIN_WIDTH.slice(0, 3)) + _constants.RIGHT_COMMENT_WIDTH;
24
+ const outlineRightWidth = Number(_constants.ARTICLE_DEFAULT_WIDTH.slice(0, 3)) + _constants.RIGHT_COMMENT_WIDTH;
25
25
  if (rect.width - outlineRightWidth < 280) {
26
26
  containerStyle['marginLeft'] = `${_constants.LEFT_OUTLINE_WIDTH}px`;
27
27
  return containerStyle;
28
28
  }
29
29
  }
30
- if ((rect.width - Number(_constants.ARTICLE_MIN_WIDTH.slice(0, 3))) / 2 < 280) {
30
+ if ((rect.width - Number(_constants.ARTICLE_DEFAULT_WIDTH.slice(0, 3))) / 2 < 280) {
31
31
  containerStyle['marginLeft'] = `${_constants.LEFT_OUTLINE_WIDTH}px`;
32
32
  }
33
33
  }
@@ -4,9 +4,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.getStyleByFullWidthMode = void 0;
7
+ exports.getStyleByFullWidthMode = exports.getContentStyleByFullModeStyle = void 0;
8
8
  var _localStorageUtils = _interopRequireDefault(require("../../utils/local-storage-utils"));
9
- var _defaultMode = require("./default-mode");
10
9
  var _constants = require("../constants");
11
10
  const getStyleByFullWidthMode = (scrollRef, editor) => {
12
11
  const sdocStorage = _localStorageUtils.default.getItem(_constants.SDOC_STORAGE) || {};
@@ -16,23 +15,7 @@ const getStyleByFullWidthMode = (scrollRef, editor) => {
16
15
  } = sdocStorage;
17
16
  let containerStyle = {};
18
17
  containerStyle['width'] = _constants.ARTICLE_FULL_WIDTH;
19
-
20
- // Has outline and comments
21
- if (isShowOutline && editor.editorType !== _constants.WIKI_EDITOR && isHasComments) {
22
- const rect = scrollRef.current.getBoundingClientRect();
23
- const currentMaxWidth = rect.width - 100;
24
- const leftWidth = _constants.LEFT_OUTLINE_WIDTH - 50;
25
- const rightWidth = _constants.RIGHT_COMMENT_WIDTH - 50;
26
- // Enough width to enable widescreen mode
27
- if (currentMaxWidth - leftWidth - rightWidth > _constants.ARTICLE_MIN_WIDTH.slice(0, -2)) {
28
- containerStyle['marginLeft'] = `${_constants.LEFT_OUTLINE_WIDTH}px`;
29
- containerStyle['width'] = containerStyle['width'].slice(0, -1) + ` - ${leftWidth + rightWidth}px`;
30
- } else {
31
- _localStorageUtils.default.setItem(_constants.FULL_WIDTH_MODE, false);
32
- containerStyle = (0, _defaultMode.getStyleByDefaultMode)(scrollRef, editor);
33
- }
34
- return containerStyle;
35
- }
18
+ containerStyle['minWidth'] = _constants.ARTICLE_FULL_MIN_WIDTH;
36
19
 
37
20
  // Has outline
38
21
  if (isShowOutline && editor.editorType !== _constants.WIKI_EDITOR) {
@@ -40,7 +23,7 @@ const getStyleByFullWidthMode = (scrollRef, editor) => {
40
23
  const adjustWidth = ` - ${_constants.LEFT_OUTLINE_WIDTH - 50}px`; // One side is 50
41
24
  containerStyle['width'] = containerStyle['width'].slice(0, -1) + adjustWidth;
42
25
  }
43
- // Has comments
26
+ // Has comments right list
44
27
  if (isHasComments) {
45
28
  containerStyle['marginRight'] = `${_constants.RIGHT_COMMENT_WIDTH}px`;
46
29
  const adjustWidth = ` - ${_constants.RIGHT_COMMENT_WIDTH - 50}px`; // One side is 50
@@ -48,4 +31,13 @@ const getStyleByFullWidthMode = (scrollRef, editor) => {
48
31
  }
49
32
  return containerStyle;
50
33
  };
51
- exports.getStyleByFullWidthMode = getStyleByFullWidthMode;
34
+ exports.getStyleByFullWidthMode = getStyleByFullWidthMode;
35
+ const getContentStyleByFullModeStyle = () => {
36
+ if (_localStorageUtils.default.getItem(_constants.FULL_WIDTH_MODE)) {
37
+ return {
38
+ 'minWidth': `${Number(_constants.ARTICLE_FULL_MIN_WIDTH.slice(0, -2)) + _constants.RIGHT_COMMENT_WIDTH}px`
39
+ };
40
+ }
41
+ return {};
42
+ };
43
+ exports.getContentStyleByFullModeStyle = getContentStyleByFullModeStyle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.157",
3
+ "version": "1.0.158",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",