@seafile/sdoc-editor 1.0.202-test-0.1 → 1.0.202-test-0.0.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.
|
@@ -52,6 +52,7 @@ const generateEmptyMultiColumn = (editor, MultiColumnType) => {
|
|
|
52
52
|
id: columnWidthKey,
|
|
53
53
|
type: _constants.ELEMENT_TYPE.COLUMN,
|
|
54
54
|
width: columnWidth,
|
|
55
|
+
initialPageWith: realTimePageWidth(),
|
|
55
56
|
children: [{
|
|
56
57
|
id: _slugid.default.nice(),
|
|
57
58
|
type: _constants.PARAGRAPH,
|
|
@@ -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,46 @@ 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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
const scaleFactor = realTimeWidth / pageWidth;
|
|
34
|
+
const matchingColumn = parentNode.column.find(column => column.key === element.id);
|
|
35
|
+
if (matchingColumn) {
|
|
36
|
+
console.log(444444, matchingColumn.width, scaleFactor);
|
|
37
|
+
setColumnWidth(matchingColumn.width * scaleFactor);
|
|
38
|
+
}
|
|
39
|
+
setPageWidth(realTimeWidth);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
resizeObserver.observe(sdocEditorPage);
|
|
43
|
+
return () => {
|
|
44
|
+
resizeObserver.disconnect();
|
|
45
|
+
};
|
|
46
|
+
} else {
|
|
47
|
+
const matchingColumn = parentNode.column.find(column => column.key === element.id);
|
|
48
|
+
if (matchingColumn) {
|
|
49
|
+
setColumnWidth(matchingColumn.width);
|
|
50
|
+
}
|
|
29
51
|
}
|
|
30
|
-
}, [editor, element, parentNode.column,
|
|
52
|
+
}, [editor, element, parentNode.column, pageWidth]);
|
|
53
|
+
|
|
54
|
+
// useEffect(() => {
|
|
55
|
+
// const matchingColumn = parentNode.column.find(column => column.key === element.id);
|
|
56
|
+
// if (matchingColumn) {
|
|
57
|
+
// setColumnWidth(matchingColumn.width);
|
|
58
|
+
// }
|
|
59
|
+
// }, [editor, element, parentNode.column]);
|
|
60
|
+
|
|
31
61
|
return /*#__PURE__*/_react.default.createElement("div", Object.assign({}, attributes, {
|
|
32
62
|
className: (0, _classnames.default)('column', attributes.className),
|
|
33
63
|
"data-id": element.id,
|