Studio document-editor layout, typography, and writing features#5
Studio document-editor layout, typography, and writing features#5bnz183 wants to merge 1 commit into
Conversation
| res.status(result.status).json(result.body); | ||
| }); | ||
|
|
||
| app.get("/api/media", requireAuth, async (_req, res) => { |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be22b69b60
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } = useDocumentAutosave({ | ||
| snapshot: documentSnapshot, | ||
| publishing, | ||
| enabled: authenticated && view === "editor", |
There was a problem hiding this comment.
Rebaseline autosave after loading project config
When the project config loads, the effect above can replace the initial fallback form with createInitialFormState(config.categories[0]), but this autosave hook has already captured its baseline from the fallback snapshot. In any project whose first configured category differs from the fallback Guides, an untouched editor becomes dirty immediately, triggers the beforeunload warning, and writes a blank local draft/restore prompt after the debounce. Defer enabling autosave until the config-backed form is established or call commitBaseline when applying the loaded config.
Useful? React with 👍 / 👎.
|
|
||
| files.push({ | ||
| repoPath: safe.path, | ||
| publicPath: joinPublicMediaPath(env.publicMediaPath, filename), |
There was a problem hiding this comment.
Preserve subfolders when building media URLs
When the media library includes files inside subdirectories of mediaDir, publisher.listFiles recurses into those directories but this line builds the public URL from only the basename. For example, public/images/posts/photo.png is shown/inserted as /images/photo.png instead of /images/posts/photo.png, so choosing existing nested media creates broken cover images or Markdown links. Build the public path from the path relative to mediaDir, not just filename.
Useful? React with 👍 / 👎.
| const path = | ||
| latestImagePath?.trim() || | ||
| window.prompt("Image path (public URL or repo path)", "/images/")?.trim() || |
There was a problem hiding this comment.
Scope cached image paths to the current post
After any image upload, the toolbar silently prefers latestImagePath over prompting. If a writer uploads an image for one post, then opens or creates another post in the same session and clicks the Image toolbar button, it inserts the previous post's image without confirmation. Clear this cached path when switching documents or require the user to confirm/select the image before insertion.
Useful? React with 👍 / 👎.
| onOpenSettings={() => | ||
| setView((current) => (current === "settings" ? "editor" : "settings")) |
There was a problem hiding this comment.
Keep draft protection active in Settings
If a writer has unsaved editor changes and opens Settings, this view switch disables useDocumentAutosave because it is only enabled for view === "editor"; that removes the beforeunload guard and can also cancel the pending debounce. Closing or reloading the tab from Settings then loses recent edits without warning, even though the draft is still in memory. Keep autosave/unload protection enabled while Settings is open or flush the draft before switching views.
Useful? React with 👍 / 👎.
|
Closing retroactive split-stack review PR. Continuing from protected main with scoped feature PRs. |
PR 4 of 11. Document-editor refactor, IBM Plex, autosave, toolbar, post list, media library, internal linking.