@seafile/sdoc-editor 2.0.127-test-0.0.4 → 2.0.127-test-0.0.6
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.
|
@@ -9,7 +9,9 @@ exports.renderWhiteboard = renderWhiteboard;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _slateReact = require("@seafile/slate-react");
|
|
11
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
|
+
var _constants = require("../../../constants");
|
|
12
13
|
var _context = _interopRequireDefault(require("../../../context"));
|
|
14
|
+
var _eventBus = _interopRequireDefault(require("../../../utils/event-bus"));
|
|
13
15
|
require("./index.css");
|
|
14
16
|
var Whiteboard = function Whiteboard(_ref) {
|
|
15
17
|
var editor = _ref.editor,
|
|
@@ -20,6 +22,31 @@ var Whiteboard = function Whiteboard(_ref) {
|
|
|
20
22
|
link = element.link;
|
|
21
23
|
var whiteboardRef = (0, _react.useRef)();
|
|
22
24
|
var isSelected = (0, _slateReact.useSelected)();
|
|
25
|
+
(0, _react.useEffect)(function () {
|
|
26
|
+
var handleMessage = function handleMessage(event) {
|
|
27
|
+
var _event$data;
|
|
28
|
+
if (((_event$data = event.data) === null || _event$data === void 0 ? void 0 : _event$data.type) === 'checkSdocParent') {
|
|
29
|
+
var isSdocClass = whiteboardRef === null || whiteboardRef === void 0 ? void 0 : whiteboardRef.current.classList.contains('sdoc-whiteboard-element');
|
|
30
|
+
whiteboardRef === null || whiteboardRef === void 0 ? void 0 : whiteboardRef.current.contentWindow.postMessage({
|
|
31
|
+
type: 'checkSdocParentResult',
|
|
32
|
+
isInSdoc: isSdocClass
|
|
33
|
+
}, '*');
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var handleWindowResize = function handleWindowResize() {
|
|
37
|
+
whiteboardRef === null || whiteboardRef === void 0 ? void 0 : whiteboardRef.current.contentWindow.postMessage({
|
|
38
|
+
type: 'resizeWindowWidth',
|
|
39
|
+
isResize: true
|
|
40
|
+
}, '*');
|
|
41
|
+
};
|
|
42
|
+
var eventBus = _eventBus["default"].getInstance();
|
|
43
|
+
var unsubscribeResizeArticle = eventBus.subscribe(_constants.INTERNAL_EVENT.RESIZE_ARTICLE, handleWindowResize);
|
|
44
|
+
window.addEventListener('message', handleMessage);
|
|
45
|
+
return function () {
|
|
46
|
+
window.removeEventListener('message', handleMessage);
|
|
47
|
+
unsubscribeResizeArticle();
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
23
50
|
var handleDoubleClick = function handleDoubleClick(event) {
|
|
24
51
|
event.preventDefault();
|
|
25
52
|
var siteRoot = _context["default"].getSetting('siteRoot');
|
|
@@ -31,7 +58,6 @@ var Whiteboard = function Whiteboard(_ref) {
|
|
|
31
58
|
className: (0, _classnames["default"])('sdoc-whiteboard-container', {
|
|
32
59
|
'isSelected': isSelected
|
|
33
60
|
}),
|
|
34
|
-
ref: whiteboardRef,
|
|
35
61
|
onDoubleClick: handleDoubleClick,
|
|
36
62
|
scrolling: "no"
|
|
37
63
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -44,7 +70,8 @@ var Whiteboard = function Whiteboard(_ref) {
|
|
|
44
70
|
width: '100%',
|
|
45
71
|
height: '100%',
|
|
46
72
|
border: 'none'
|
|
47
|
-
}
|
|
73
|
+
},
|
|
74
|
+
ref: whiteboardRef
|
|
48
75
|
}));
|
|
49
76
|
};
|
|
50
77
|
function renderWhiteboard(props, editor) {
|