fix(editor): update alt text on asset rename to fix stale Lightbox title#1256
Merged
Conversation
Renaming an asset only rewrote the image src path in markdown, leaving the alt text (which defaults to the filename on insert) untouched. The Lightbox displays alt text verbatim, so it kept showing the old name after rename + save, even after a maintenance resync. Fixes #1251
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes stale Lightbox titles after asset renames by ensuring the markdown image/link text (alt/link label) is updated alongside the link target filename, so renamed assets display the new name in the Lightbox.
Changes:
- Refactors asset-rename markdown rewriting into a shared
replaceFilenameInTexthelper. - Updates rename behavior to also rewrite alt/link text when it exactly matches the old filename.
- Adds unit tests for the new filename-replacement helper.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ui/leafwiki-ui/src/features/editor/MarkdownEditor.tsx | Switches asset-rename handling to use a shared helper for updating markdown text. |
| ui/leafwiki-ui/src/features/editor/editorCommands.ts | Adds replaceFilenameInText (and escaping helper) to update both target filenames and matching alt/link text. |
| ui/leafwiki-ui/src/features/editor/editorCommands.test.ts | Adds unit tests validating filename + alt/link text replacement behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Prevent filename replacement from spanning across multiple markdown links or images on the same line. Add a regression test for adjacent inline markdown elements so asset renames keep the correct alt/link text and target pairing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Renaming an asset only rewrote the image src path in markdown, leaving the alt text (which defaults to the filename on insert) untouched. The Lightbox displays alt text verbatim, so it kept showing the old name after rename + save, even after a maintenance resync.
Fixes #1251