From 660a60f9ec4b2186bf90b203d4e0ccb5546c64d1 Mon Sep 17 00:00:00 2001 From: "Lu[ke] Wilson" Date: Sat, 15 Feb 2025 12:01:18 +0000 Subject: [PATCH] fix some more type issues --- src/declare.d.ts | 3 +++ src/main.js | 15 ++++----------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/declare.d.ts b/src/declare.d.ts index cf5c068..72ff5f2 100644 --- a/src/declare.d.ts +++ b/src/declare.d.ts @@ -14,6 +14,7 @@ interface Window { setSettingsFromDom: any; kabel: any; kabelsalat: any; + session: any; } // Pattern.prototype.p @@ -33,4 +34,6 @@ interface Element { close?: any; href?: string; click?: any; + contentWindow?: any; + innerText?: string; } diff --git a/src/main.js b/src/main.js index 91e6699..481cefe 100644 --- a/src/main.js +++ b/src/main.js @@ -13,18 +13,11 @@ window.editorViews = pastamirror.editorViews; export const session = new Session('pastagang2', { // changed this part to what flok.cc uses hostname: 'flok.cc', - port: '', //parseInt(port), + // port: '', //parseInt(port), isSecure: true, }); window.session = session; -/* session.on("change", (...args) => console.log("change", ...args)); -session.on("message", (msg) => console.log("message", msg)); */ -session.on('open', () => { - console.log('open'); - // clearGlobalError(); -}); - session.on('sync', () => { // If session is empty, create two documents if (session.getDocuments().length === 0) { @@ -101,7 +94,7 @@ let showLocalError = (docId, message) => { if (errorEl) { errorEl.innerText = message; } else { - slot.insertAdjacentHTML('beforeend', `
${message}
`); + slot?.insertAdjacentHTML('beforeend', `
${message}
`); } }; @@ -187,7 +180,7 @@ addEventListener( ); // add / remove panes -document.getElementById('add-pane-button').addEventListener('click', () => { +document.getElementById('add-pane-button')?.addEventListener('click', () => { if (!session) return; const documents = session.getDocuments(); if (documents.length >= 8) { @@ -200,7 +193,7 @@ document.getElementById('add-pane-button').addEventListener('click', () => { ]; session.setActiveDocuments(newDocs); }); -document.getElementById('remove-pane-button').addEventListener('click', () => { +document.getElementById('remove-pane-button')?.addEventListener('click', () => { if (!session) return; const documents = session.getDocuments(); session.setActiveDocuments([...documents.map((doc) => ({ id: doc.id, target: doc.target })).slice(0, -1)]);