Implement WYSIWYG to edit the website content #272

Merged
bustikiller merged 6 commits from website-editor into main 2025-06-08 19:10:42 +00:00
Showing only changes of commit 0b8a444b39 - Show all commits

View File

@ -13,15 +13,25 @@ export default function Page() {
const api = new AbstractApi<Website>();
const serializer = new WebsiteSerializer();
const [timeoutId, setTimeoutId] = useState<NodeJS.Timeout | null>(null);
useEffect(() => {
api.get(serializer, undefined, (loadedWebsite) => {
setWebsite(loadedWebsite);
console.log('Website loaded:', loadedWebsite);
});
}, []);
const updateWebsite = (newContent: string) => {
api.update(serializer, new Website('', newContent), () => { });
// Debounce API update: send after 500ms of no further changes
if (timeoutId) {
clearTimeout(timeoutId);
}
setTimeoutId(
setTimeout(() => {
api.update(serializer, new Website('', newContent), () => { });
}, 500)
);
}
return (