@seafile/sdoc-editor 1.0.202-test-0.1 → 1.0.202-test-0.0.3

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.
@@ -53,18 +53,19 @@ const MultiColumn = _ref => {
53
53
  console.log(4, updatedColumns);
54
54
  setColumn(updatedColumns);
55
55
  setPageWidth(realTimeWidth);
56
+ } else {
57
+ const newStyle = {
58
+ ...element.style,
59
+ gridTemplateColumns: columnWidthList.join(' ')
60
+ };
61
+ console.log(100, newStyle);
62
+ setStyle(newStyle);
56
63
  }
57
64
  });
58
65
  resizeObserver.observe(sdocEditorPage);
59
66
  return () => {
60
67
  resizeObserver.disconnect();
61
68
  };
62
- } else {
63
- const newStyle = {
64
- ...element.style,
65
- gridTemplateColumns: columnWidthList.join(' ')
66
- };
67
- setStyle(newStyle);
68
69
  }
69
70
  }, [pageWidth, element.style, element.column, column]);
70
71
 
@@ -10,6 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _slate = require("@seafile/slate");
12
12
  var _slateReact = require("@seafile/slate-react");
13
+ var _helper = require("../helper");
13
14
  const Column = _ref => {
14
15
  let {
15
16
  attributes,
@@ -17,17 +18,36 @@ const Column = _ref => {
17
18
  children
18
19
  } = _ref;
19
20
  const editor = (0, _slateReact.useSlateStatic)();
21
+ console.log(1, attributes, element, children);
20
22
  const [columnWidth, setColumnWidth] = (0, _react.useState)(element.width || 0);
23
+ const [pageWidth, setPageWidth] = (0, _react.useState)((0, _helper.realTimePageWidth)());
21
24
  const path = _slateReact.ReactEditor.findPath(editor, element);
22
25
  const parentPath = _slate.Path.parent(path);
23
26
  const [parentNode] = _slate.Editor.node(editor, parentPath);
24
27
  (0, _react.useEffect)(() => {
25
- console.log(555, parentNode.column);
28
+ const sdocEditorPage = document.getElementById('sdoc-editor');
29
+ if (sdocEditorPage) {
30
+ const resizeObserver = new ResizeObserver(entries => {
31
+ const realTimeWidth = entries[0].contentRect.width;
32
+ if (realTimeWidth !== pageWidth) {
33
+ console.log(55, realTimeWidth, pageWidth);
34
+ const scaleFactor = realTimeWidth / pageWidth;
35
+ setColumnWidth(preColumnwidth => preColumnwidth * scaleFactor);
36
+ setPageWidth(realTimeWidth);
37
+ }
38
+ });
39
+ resizeObserver.observe(sdocEditorPage);
40
+ return () => {
41
+ resizeObserver.disconnect();
42
+ };
43
+ }
44
+ }, [editor, element, parentNode.column, pageWidth]);
45
+ (0, _react.useEffect)(() => {
26
46
  const matchingColumn = parentNode.column.find(column => column.key === element.id);
27
47
  if (matchingColumn) {
28
48
  setColumnWidth(matchingColumn.width);
29
49
  }
30
- }, [editor, element, parentNode.column, columnWidth]);
50
+ }, [editor, element, parentNode.column]);
31
51
  return /*#__PURE__*/_react.default.createElement("div", Object.assign({}, attributes, {
32
52
  className: (0, _classnames.default)('column', attributes.className),
33
53
  "data-id": element.id,
@@ -100,6 +100,7 @@ const ResizeHandlers = _ref => {
100
100
  ...column,
101
101
  left: column.width
102
102
  }));
103
+ console.log(3333, newColumn);
103
104
  handleResizeColumn(newColumn);
104
105
  (0, _helper.updateColumnWidth)(editor, element, newColumn);
105
106
  setIsDraggingResizeHandler(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.202-test-0.01",
3
+ "version": "1.0.202-test-0.0.3",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",