remove logs, add explanation to collab

This commit is contained in:
Tom 2022-05-09 17:25:20 +02:00
parent 92adcf82e4
commit 065e4f55c3

View File

@ -108,13 +108,10 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
this.$widget.toggleClass("full-height", true); // only add this.$widget.toggleClass("full-height", true); // only add
this.$render = this.$widget.find('.canvas-note-render'); this.$render = this.$widget.find('.canvas-note-render');
this.renderElement = this.$render.get(0); this.renderElement = this.$render.get(0);
// this.log("doRender", this.$widget);
libraryLoader libraryLoader
.requireLibrary(libraryLoader.EXCALIDRAW) .requireLibrary(libraryLoader.EXCALIDRAW)
.then(() => { .then(() => {
this.log("react, react-dom, excalidraw loaded");
const React = window.React; const React = window.React;
const ReactDOM = window.ReactDOM; const ReactDOM = window.ReactDOM;
@ -150,7 +147,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
* before we load content into excalidraw, make sure excalidraw has loaded * before we load content into excalidraw, make sure excalidraw has loaded
*/ */
while (!this.excalidrawRef || !this.excalidrawRef.current) { while (!this.excalidrawRef || !this.excalidrawRef.current) {
this.log("doRefresh! excalidrawref not yet loeaded, sleep 200ms..."); this.log("excalidrawref not yet loeaded, sleep 200ms...");
await sleep(200); await sleep(200);
} }
@ -208,7 +205,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
fileArray.push(file); fileArray.push(file);
} }
this.log("doRefresh(note) sceneData, files", sceneData, files, fileArray); // this.log("doRefresh(note) sceneData, files", sceneData, files, fileArray);
this.sceneVersion = window.Excalidraw.getSceneVersion(elements); this.sceneVersion = window.Excalidraw.getSceneVersion(elements);
@ -274,7 +271,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
}; };
const contentString = JSON.stringify(content); const contentString = JSON.stringify(content);
this.log("getContent note size content.svg/content", `~${content.svg.length/1024}kB/${contentString.length/1024}kB`, content.svg.length/contentString.length, "% of svg"); // this.log("getContent note size content.svg/content", `~${content.svg.length/1024}kB/${contentString.length/1024}kB`, content.svg.length/contentString.length, "% of svg");
return contentString; return contentString;
} }
@ -285,12 +282,11 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
* spacedUpdate is kind of a debouncer. * spacedUpdate is kind of a debouncer.
*/ */
saveData() { saveData() {
this.log("saveData()");
this.spacedUpdate.scheduleUpdate(); this.spacedUpdate.scheduleUpdate();
} }
onChangeHandler() { onChangeHandler() {
this.log("onChangeHandler() =================", new Date(), this.isNewSceneVersion()); // this.log("onChangeHandler() =================", new Date(), this.isNewSceneVersion());
const appState = this.excalidrawRef.current.getAppState() || {}; const appState = this.excalidrawRef.current.getAppState() || {};
// changeHandler is called upon any tiny change in excalidraw. button clicked, hover, etc. // changeHandler is called upon any tiny change in excalidraw. button clicked, hover, etc.
@ -337,7 +333,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
width: excalidrawWrapperRef.current.getBoundingClientRect().width, width: excalidrawWrapperRef.current.getBoundingClientRect().width,
height: excalidrawWrapperRef.current.getBoundingClientRect().height height: excalidrawWrapperRef.current.getBoundingClientRect().height
}; };
this.log('effect, setdimensions', dimensions); // this.log('effect, setdimensions', dimensions);
setDimensions(dimensions); setDimensions(dimensions);
const onResize = () => { const onResize = () => {
@ -345,7 +341,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
width: excalidrawWrapperRef.current.getBoundingClientRect().width, width: excalidrawWrapperRef.current.getBoundingClientRect().width,
height: excalidrawWrapperRef.current.getBoundingClientRect().height height: excalidrawWrapperRef.current.getBoundingClientRect().height
}; };
this.log('onResize, setdimensions', dimensions); // this.log('onResize, setdimensions', dimensions);
setDimensions(dimensions); setDimensions(dimensions);
}; };
@ -362,7 +358,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
const isInternalLink = const isInternalLink =
link.startsWith("/") || link.includes(window.location.origin); link.startsWith("/") || link.includes(window.location.origin);
this.log("onLinkOpen", element, event, nativeEvent, "isinternallink", isInternalLink); // this.log("onLinkOpen", element, event, nativeEvent, "isinternallink", isInternalLink);
if (isInternalLink && !isNewTab && !isNewWindow) { if (isInternalLink && !isNewTab && !isNewWindow) {
// signal that we're handling the redirect ourselves // signal that we're handling the redirect ourselves
@ -394,7 +390,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
onChange: debounce(this.onChangeHandler, this.DEBOUNCE_TIME_ONCHANGEHANDLER), onChange: debounce(this.onChangeHandler, this.DEBOUNCE_TIME_ONCHANGEHANDLER),
// onPointerUpdate: (payload) => console.log(payload), // onPointerUpdate: (payload) => console.log(payload),
onCollabButtonClick: () => { onCollabButtonClick: () => {
window.alert("You clicked on collab button") window.alert("You clicked on collab button. No collaboration is implemented.");
}, },
viewModeEnabled: viewModeEnabled, viewModeEnabled: viewModeEnabled,
zenModeEnabled: zenModeEnabled, zenModeEnabled: zenModeEnabled,
@ -418,7 +414,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
*/ */
isNewSceneVersion() { isNewSceneVersion() {
const sceneVersion = this.getSceneVersion(); const sceneVersion = this.getSceneVersion();
// this.log("isNewSceneVersion()", this.currentSceneVersion, sceneVersion);
if ( if (
this.currentSceneVersion === this.SCENE_VERSION_INITIAL // initial scene version update this.currentSceneVersion === this.SCENE_VERSION_INITIAL // initial scene version update
|| this.currentSceneVersion !== sceneVersion || this.currentSceneVersion !== sceneVersion