fix theme

This commit is contained in:
ammarahm-ed
2022-07-20 23:15:04 +05:00
parent 765456cf8d
commit 17f3fe27e0
6 changed files with 28 additions and 41 deletions

View File

@@ -10,7 +10,7 @@
"hasInstallScript": true,
"dependencies": {
"@streetwriters/editor": "^1.1.2",
"@streetwriters/theme": "^1.0.0",
"@streetwriters/theme": "^1.0.1",
"framer-motion": "^4.1.17",
"mdi-react": "^8.4.0",
"react": "^17.0.1",
@@ -3063,9 +3063,9 @@
}
},
"node_modules/@streetwriters/theme": {
"version": "1.0.0",
"resolved": "https://npm.pkg.github.com/download/@streetwriters/theme/1.0.0/b1113ba8ad5388d2c6ad2d8d7b56e4a137fb37cd44c9c13449d0ae2bf12f27cb",
"integrity": "sha512-J5GrMHcFP4wD1oPNkBnDkruZWxaY8Pu6ovkAAZ3rnIDKxWPgjq9H57GG/eFgHG1qsOYEG9yHQMmqZ2vr6Cq63g==",
"version": "1.0.1",
"resolved": "https://npm.pkg.github.com/download/@streetwriters/theme/1.0.1/7b643b73581fba8bd8accb1a2795ecc9321b7edd51fc5333bdf14ad372c2e0c5",
"integrity": "sha512-ylsf67HVpxNlemnHCADTjKeNUKP04J7/k9pNgo6BuSa8N5K+zT8dgwwRhldzkVya8z/p7//hd2cG3fT8AHqZRg==",
"license": "GPL-3.0",
"dependencies": {
"@rebass/forms": "^4.0.6",
@@ -25821,9 +25821,9 @@
}
},
"@streetwriters/theme": {
"version": "1.0.0",
"resolved": "https://npm.pkg.github.com/download/@streetwriters/theme/1.0.0/b1113ba8ad5388d2c6ad2d8d7b56e4a137fb37cd44c9c13449d0ae2bf12f27cb",
"integrity": "sha512-J5GrMHcFP4wD1oPNkBnDkruZWxaY8Pu6ovkAAZ3rnIDKxWPgjq9H57GG/eFgHG1qsOYEG9yHQMmqZ2vr6Cq63g==",
"version": "1.0.1",
"resolved": "https://npm.pkg.github.com/download/@streetwriters/theme/1.0.1/7b643b73581fba8bd8accb1a2795ecc9321b7edd51fc5333bdf14ad372c2e0c5",
"integrity": "sha512-ylsf67HVpxNlemnHCADTjKeNUKP04J7/k9pNgo6BuSa8N5K+zT8dgwwRhldzkVya8z/p7//hd2cG3fT8AHqZRg==",
"requires": {
"@rebass/forms": "^4.0.6",
"@types/rebass": "^4.0.10",

View File

@@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@streetwriters/editor": "^1.1.2",
"@streetwriters/theme": "^1.0.0",
"@streetwriters/theme": "^1.0.1",
"framer-motion": "^4.1.17",
"mdi-react": "^8.4.0",
"react": "^17.0.1",

View File

@@ -25,14 +25,14 @@ const Tiptap = () => {
const [layout, setLayout] = useState(false);
const toolbarTheme = useTheme({
//todo
accent: "green",
accent: theme?.accent,
scale: 1,
theme: theme?.night ? "dark" : "light",
});
const editorTheme = useTheme({
//todo
accent: "green",
accent: theme?.accent,
scale: 1,
theme: theme?.night ? "dark" : "light",
});

View File

@@ -4,10 +4,10 @@ import {
useCallback,
useEffect,
useRef,
useState
useState,
} from "react";
import { useEditorThemeStore } from "../state/theme";
import { EventTypes, isReactNative, post, timerFn } from "../utils";
import { EventTypes, isReactNative, post } from "../utils";
type Attachment = {
hash: string;
@@ -54,7 +54,7 @@ export function useEditorController(
const htmlContentRef = useRef<string | null>(null);
const timers = useRef<Timers>({
selectionChange: null,
change: null
change: null,
});
const selectionChange = useCallback((editor: Editor) => {
@@ -95,21 +95,16 @@ export function useEditorController(
post(EventTypes.title, title);
};
const contentChange = useCallback(
(editor: Editor) => {
const contentChange = useCallback((editor: Editor) => {
if (!editor) return;
selectionChange(editor);
timers.current.change = timerFn(
() => {
if (typeof timers.current.change === "number") {
clearTimeout(timers.current?.change);
}
timers.current.change = setTimeout(() => {
htmlContentRef.current = editor.getHTML();
post(EventTypes.content, htmlContentRef.current);
},
300,
timers.current?.change
);
},
[selectionChange]
);
}, 300);
}, []);
const scroll = useCallback(
(event: React.UIEvent<HTMLDivElement, UIEvent>) => {
@@ -202,6 +197,6 @@ export function useEditorController(
openFilePicker,
downloadAttachment,
content: htmlContentRef,
onUpdate: onUpdate
onUpdate: onUpdate,
};
}

View File

@@ -68,7 +68,7 @@ const DefaultColors = {
injectCss(transform(DefaultColors));
interface ThemeState extends State {
colors: Colors | null;
colors: Colors;
setColors: (colors: Colors) => void;
}

View File

@@ -93,17 +93,9 @@ declare global {
}
}
export const timerFn = (
callback: () => void,
duration: number,
timer: NodeJS.Timeout | null
) => {
if (timer) {
clearTimeout(timer);
timer = null;
}
timer = setTimeout(callback, duration);
return timer;
export const timerFn = (callback: () => void, duration: number) => {
// timer = setTimeout(callback, duration);
// return timer;
};
export const EventTypes = {