From 29fe6430ce583da460c522edf9979017974f957a Mon Sep 17 00:00:00 2001 From: Gazook89 Date: Tue, 4 Nov 2025 13:12:56 -0600 Subject: [PATCH 1/2] Move codeEditor to components directory This simply moves the codeEditor folder to the components directory. `codeEditor.jsx` simply builds a component which is then used elsewhere, and isn't shared between client and server, so it should be in the client directory. Arguably it could go in `client/homebrew/editor` but I think the `/homebrew/` folder should be eliminated down the line and it's contents just re-sorted. When working on the editor right now it's a pain to switch between `shared` and `client` hunting for the right file. --- .../components}/codeEditor/autocompleteEmoji.js | 0 .../naturalcrit => client/components}/codeEditor/close-tag.js | 0 .../naturalcrit => client/components}/codeEditor/codeEditor.jsx | 0 .../components}/codeEditor/codeEditor.less | 0 .../naturalcrit => client/components}/codeEditor/fold-css.js | 0 .../naturalcrit => client/components}/codeEditor/fold-pages.js | 0 client/homebrew/editor/editor.jsx | 2 +- 7 files changed, 1 insertion(+), 1 deletion(-) rename {shared/naturalcrit => client/components}/codeEditor/autocompleteEmoji.js (100%) rename {shared/naturalcrit => client/components}/codeEditor/close-tag.js (100%) rename {shared/naturalcrit => client/components}/codeEditor/codeEditor.jsx (100%) rename {shared/naturalcrit => client/components}/codeEditor/codeEditor.less (100%) rename {shared/naturalcrit => client/components}/codeEditor/fold-css.js (100%) rename {shared/naturalcrit => client/components}/codeEditor/fold-pages.js (100%) diff --git a/shared/naturalcrit/codeEditor/autocompleteEmoji.js b/client/components/codeEditor/autocompleteEmoji.js similarity index 100% rename from shared/naturalcrit/codeEditor/autocompleteEmoji.js rename to client/components/codeEditor/autocompleteEmoji.js diff --git a/shared/naturalcrit/codeEditor/close-tag.js b/client/components/codeEditor/close-tag.js similarity index 100% rename from shared/naturalcrit/codeEditor/close-tag.js rename to client/components/codeEditor/close-tag.js diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/client/components/codeEditor/codeEditor.jsx similarity index 100% rename from shared/naturalcrit/codeEditor/codeEditor.jsx rename to client/components/codeEditor/codeEditor.jsx diff --git a/shared/naturalcrit/codeEditor/codeEditor.less b/client/components/codeEditor/codeEditor.less similarity index 100% rename from shared/naturalcrit/codeEditor/codeEditor.less rename to client/components/codeEditor/codeEditor.less diff --git a/shared/naturalcrit/codeEditor/fold-css.js b/client/components/codeEditor/fold-css.js similarity index 100% rename from shared/naturalcrit/codeEditor/fold-css.js rename to client/components/codeEditor/fold-css.js diff --git a/shared/naturalcrit/codeEditor/fold-pages.js b/client/components/codeEditor/fold-pages.js similarity index 100% rename from shared/naturalcrit/codeEditor/fold-pages.js rename to client/components/codeEditor/fold-pages.js diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index d6fdf3f08..d7a037b97 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -6,7 +6,7 @@ const _ = require('lodash'); const dedent = require('dedent-tabs').default; import Markdown from '../../../shared/naturalcrit/markdown.js'; -const CodeEditor = require('naturalcrit/codeEditor/codeEditor.jsx'); +const CodeEditor = require('client/components/codeEditor/codeEditor.jsx'); const SnippetBar = require('./snippetbar/snippetbar.jsx'); const MetadataEditor = require('./metadataEditor/metadataEditor.jsx'); From 20d38d03d65d0c94772aaaeba23c6fda6606aa9f Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Thu, 6 Nov 2025 22:29:43 +1300 Subject: [PATCH 2/2] Rename New Page save function to trySave for better Edit Page compatibility --- client/homebrew/pages/newPage/newPage.jsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/client/homebrew/pages/newPage/newPage.jsx b/client/homebrew/pages/newPage/newPage.jsx index dccf7deb7..a8a7306e4 100644 --- a/client/homebrew/pages/newPage/newPage.jsx +++ b/client/homebrew/pages/newPage/newPage.jsx @@ -56,6 +56,10 @@ const NewPage = (props)=>{ const editorRef = useRef(null); const lastSavedBrew = useRef(_.cloneDeep(props.brew)); + // const saveTimeout = useRef(null); + // const warnUnsavedTimeout = useRef(null); + const trySaveRef = useRef(trySave); // CTRL+S listener lives outside React and needs ref to use trySave with latest copy of brew + const unsavedChangesRef = useRef(unsavedChanges); // Similarly, onBeforeUnload lives outside React and needs ref to unsavedChanges useEffect(()=>{ loadBrew(); @@ -114,6 +118,11 @@ const NewPage = (props)=>{ if(autoSaveEnabled) trySave(false, hasChange); }, [currentBrew]); + useEffect(()=>{ + trySaveRef.current = trySave; + unsavedChangesRef.current = unsavedChanges; + }); + const handleSplitMove = ()=>{ editorRef.current.update(); }; @@ -141,7 +150,7 @@ const NewPage = (props)=>{ } }; - const save = async ()=>{ + const trySave = async ()=>{ setIsSaving(true); const updatedBrew = { ...currentBrew }; @@ -190,7 +199,7 @@ const NewPage = (props)=>{ // #3 - Unsaved changes exist, click to save, show SAVE NOW if(unsavedChanges) - return save now; + return save now; // #4 - No unsaved changes, autosave is ON, show AUTO-SAVED if(autoSaveEnabled)