@seafile/sdoc-editor 2.0.37-alpg-0.1.0 → 2.0.37-alpg-0.1.2

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.
@@ -15,15 +15,15 @@ var _menu = require("../menu");
15
15
 
16
16
  const TableRoot = _ref => {
17
17
  let {
18
- editor,
19
18
  attributes,
20
19
  columns = [],
21
20
  children
22
21
  } = _ref;
23
- // const editor = editor || useSlateStatic();
22
+ const editor = (0, _slateReact.useSlateStatic)();
24
23
  const readonly = (0, _slateReact.useReadOnly)();
25
24
  const tableScrollWrapper = (0, _react.useRef)(null);
26
25
  const [scrollLeft, setScrollLeft] = (0, _react.useState)(0);
26
+ const [editorWidth, setEditorWidth] = (0, _react.useState)(editor.width);
27
27
  const allWidth = columns.reduce((pre, cur) => pre + cur.width, 0);
28
28
  const onScroll = (0, _react.useCallback)(event => {
29
29
  setScrollLeft(event.target.scrollLeft);
@@ -34,18 +34,11 @@ const TableRoot = _ref => {
34
34
  onContextMenu
35
35
  } = (0, _hooks.useContextMenu)(tableScrollWrapper);
36
36
  console.log(2, editor, editor.width, columns, allWidth);
37
- let editorWidth = editor.width;
38
- if (readonly) {
39
- setTimeout(() => {
40
- editorWidth = editor.width;
41
- console.log(2, editorWidth);
42
- }, 100);
43
- }
44
-
45
- // useEffect(() => {
46
- // editorWidth = editor.width;
47
- // console.log(5, editorWidth)
48
- // }, [editor]);
37
+ (0, _react.useLayoutEffect)(() => {
38
+ if (readonly) {
39
+ setEditorWidth(editor.width);
40
+ }
41
+ }, [editor.width, readonly]);
49
42
  console.log(6, editorWidth);
50
43
  return /*#__PURE__*/_react.default.createElement(_hooks.TableRootContext.Provider, {
51
44
  value: tableScrollWrapper.current
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "2.0.37-alpg-0.1.0",
3
+ "version": "2.0.37-alpg-0.1.2",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",