A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
editor: fix editor warnings
ammarahm-ed0774326941ad
diff --git a/packages/editor-mobile/src/App.tsx b/packages/editor-mobile/src/App.tsxindex cc8174297..e660c339d 100644--- a/packages/editor-mobile/src/App.tsx+++ b/packages/editor-mobile/src/App.tsx@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.import "./App.css";import Tiptap from "./components/editor";-function App() {+function App(): JSX.Element {return <Tiptap />;}diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsxindex 501abd82d..9e191c8e9 100644--- a/packages/editor-mobile/src/components/editor.tsx+++ b/packages/editor-mobile/src/components/editor.tsx@@ -297,7 +297,7 @@ const modifyToolbarTheme = (toolbarTheme: Theme) => {};};-const TiptapProvider = () => {+const TiptapProvider = (): JSX.Element => {const settings = useSettings();const theme = useEditorThemeStore((state) => state.colors);const toolbarTheme = useTheme({diff --git a/packages/editor-mobile/src/components/header.tsx b/packages/editor-mobile/src/components/header.tsxindex b53a3f8a6..a1d1db383 100644--- a/packages/editor-mobile/src/components/header.tsx+++ b/packages/editor-mobile/src/components/header.tsx@@ -65,7 +65,7 @@ export default function Header({settings: Settings;hasUndo: boolean;hasRedo: boolean;-}) {+}): JSX.Element {const insets = useSafeArea();return (<divdiff --git a/packages/editor-mobile/src/components/tags.tsx b/packages/editor-mobile/src/components/tags.tsxindex 150728475..b0ab11543 100644--- a/packages/editor-mobile/src/components/tags.tsx+++ b/packages/editor-mobile/src/components/tags.tsx@@ -21,7 +21,7 @@ import { useRef, useState } from "react";import { EventTypes } from "../utils";import styles from "./styles.module.css";-export default function Tags() {+export default function Tags(): JSX.Element {const [tags, setTags] = useState<{ title: string; alias: string }[]>([]);const editorTags = useRef({setTags: setTagsdiff --git a/packages/editor-mobile/src/hooks/useSafeArea.ts b/packages/editor-mobile/src/hooks/useSafeArea.tsindex 41bbabe6d..03468212f 100644--- a/packages/editor-mobile/src/hooks/useSafeArea.ts+++ b/packages/editor-mobile/src/hooks/useSafeArea.ts@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { useState } from "react";+import { SafeAreaType } from "../utils";const insetsStorage = localStorage.getItem("safeAreaInsets");const initialState =@@ -42,7 +43,7 @@ global.safeAreaController = {previous: initialState};-export const useSafeArea = () => {+export const useSafeArea = ():SafeAreaType => {const [safeArea, setSafeArea] = useState(global.safeAreaController.previous);global.safeAreaController.set = setSafeArea;diff --git a/packages/editor-mobile/src/hooks/useSettings.ts b/packages/editor-mobile/src/hooks/useSettings.tsindex e41b57ca0..2776b4092 100644--- a/packages/editor-mobile/src/hooks/useSettings.ts+++ b/packages/editor-mobile/src/hooks/useSettings.ts@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.import { getDefaultPresets } from "@notesnook/editor";import { useState } from "react";+import { Settings } from "../utils";const settingsJson = localStorage.getItem("editorSettings");const initialState = {@@ -61,7 +62,7 @@ global.settingsController.previous.noHeader = globalThis.noHeader;global.settingsController.previous.noToolbar = globalThis.noToolbar;global.settingsController.previous.readonly = globalThis.readonly;-export const useSettings = () => {+export const useSettings = ():Settings => {const [settings, setSettings] = useState({...global.settingsController.previous});diff --git a/packages/editor-mobile/src/utils/css.js b/packages/editor-mobile/src/utils/css.tssimilarity index 52%rename from packages/editor-mobile/src/utils/css.jsrename to packages/editor-mobile/src/utils/css.tsindex 9b61e2e16..0d6a42702 100644--- a/packages/editor-mobile/src/utils/css.js+++ b/packages/editor-mobile/src/utils/css.ts@@ -16,15 +16,16 @@ GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/+import type { Colors } from "../state/theme";-export function removeCss(id) {- var link = document.getElementById(id);- link.remove();+export function removeCss(id: string): void {+ const link = document.getElementById(id);+ link?.remove();}-export function injectCssSrc(id, src) {- var head = document.head;- var link = document.createElement("link");+export function injectCssSrc(id: string, src: string): void {+ const head = document.head;+ const link = document.createElement("link");link.id = id;link.type = "text/css";@@ -34,40 +35,37 @@ export function injectCssSrc(id, src) {head.appendChild(link);}-export function injectCss(rule) {- let variableCss = document.getElementById("variables-nn");- let head = document.getElementsByTagName("head")[0];+export function injectCss(rule: string): void {+ const variableCss = document.getElementById("variables-nn");+ const head = document.getElementsByTagName("head")[0];if (variableCss) {head.removeChild(variableCss);}- let css = document.createElement("style");+ const css = document.createElement("style");css.type = "text/css";css.id = "variables-nn";- // Support for IE- if (css.styleSheet) css.styleSheet.cssText = rule;- // Support for the rest- else css.appendChild(document.createTextNode(rule));- head.insertBefore(css, getRootStylesheet());+ css.appendChild(document.createTextNode(rule));+ head.insertBefore(css, getRootStylesheet() as Node);}-function getRootStylesheet() {- for (let sty of document.getElementsByTagName("style")) {+function getRootStylesheet(): HTMLStyleElement | undefined {+ for (const sty of document.getElementsByTagName("style")) {if (sty.innerHTML.includes("#root")) {return sty;}}}-export function changeSvgTheme(newAccent) {- var nodes = document.querySelectorAll('*[fill="#0560ff"]');- for (var n = 0; n < nodes.length; ++n)+export function changeSvgTheme(newAccent: string): void {+ const nodes = document.querySelectorAll('*[fill="#0560ff"]');+ for (let n = 0; n < nodes.length; ++n)nodes[n].setAttribute("fill", newAccent);}-export function transform(colors) {+export function transform(colors: Colors):string {let root = ":root {";- for (let color in colors) {- root += `--nn_${color}: ${colors[color]};`;+ for (const color in colors) {+ root += `--nn_${color}: ${colors[color as keyof Colors]};`;}return root + "}";}diff --git a/packages/editor-mobile/src/utils/index.ts b/packages/editor-mobile/src/utils/index.tsindex d6032f03a..030aae2ab 100644--- a/packages/editor-mobile/src/utils/index.ts+++ b/packages/editor-mobile/src/utils/index.ts@@ -149,7 +149,7 @@ export function isReactNative(): boolean {return !!window.ReactNativeWebView;}-export function logger(type: "info" | "warn" | "error", ...logs: unknown[]) {+export function logger(type: "info" | "warn" | "error", ...logs: unknown[]):void {const logString = logs.map((log) => {return typeof log !== "string" ? JSON.stringify(log) : log;@@ -162,7 +162,7 @@ export function logger(type: "info" | "warn" | "error", ...logs: unknown[]) {export function post<T extends keyof typeof EventTypes>(type: typeof EventTypes[T],value?: unknown-) {+):void {if (isReactNative()) {window.ReactNativeWebView.postMessage(JSON.stringify({