@seafile/sdoc-editor 0.1.144 → 0.1.145

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.
@@ -1,10 +1,9 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import React, { useEffect, useRef, useState } from 'react';
3
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
4
4
  import { useScrollContext } from '../hooks/use-scroll-context';
5
5
  export default function ArticleContainer(_ref) {
6
6
  var editor = _ref.editor,
7
- readOnly = _ref.readOnly,
8
7
  children = _ref.children;
9
8
  var articleRef = useRef(null);
10
9
  useEffect(function () {
@@ -16,24 +15,26 @@ export default function ArticleContainer(_ref) {
16
15
  _useState2 = _slicedToArray(_useState, 2),
17
16
  containerStyle = _useState2[0],
18
17
  setContainerStyle = _useState2[1];
18
+ var handleWindowResize = useCallback(function () {
19
+ var rect = scrollRef.current.getBoundingClientRect();
20
+ var articleRect = articleRef.current.getBoundingClientRect();
21
+ if ((rect.width - articleRect.width) / 2 < 280) {
22
+ setContainerStyle({
23
+ marginLeft: '280px'
24
+ });
25
+ } else {
26
+ setContainerStyle({});
27
+ }
28
+ // eslint-disable-next-line react-hooks/exhaustive-deps
29
+ }, []);
19
30
  useEffect(function () {
20
- if (readOnly) return;
21
- var handleWindowResize = function handleWindowResize() {
22
- var rect = scrollRef.current.getBoundingClientRect();
23
- var articleRect = articleRef.current.getBoundingClientRect();
24
- if ((rect.width - articleRect.width) / 2 < 280) {
25
- setContainerStyle({
26
- marginLeft: '280px'
27
- });
28
- } else {
29
- setContainerStyle({});
30
- }
31
- };
31
+ handleWindowResize();
32
32
  window.addEventListener('resize', handleWindowResize);
33
33
  return function () {
34
34
  window.removeEventListener('resize', handleWindowResize);
35
35
  };
36
- }, [readOnly, scrollRef]);
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ }, []);
37
38
  return /*#__PURE__*/React.createElement("div", {
38
39
  className: "sdoc-article-container",
39
40
  style: containerStyle
@@ -44,7 +45,4 @@ export default function ArticleContainer(_ref) {
44
45
  className: "article",
45
46
  ref: articleRef
46
47
  }, children[0]), _toConsumableArray(children.slice(1))));
47
- }
48
- ArticleContainer.defaultProps = {
49
- readOnly: false
50
- };
48
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.144",
3
+ "version": "0.1.145",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",