"Insert Image" Feature Context Mismatch in .txt Files
- Dominant language
- Java
- Stars
- 6.1k
- Forks
- 537
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 4
Description
### ⚠️ This issue respects the following points: ⚠️
- [x] This is a **bug**. Not a [question or feature request](https://github.com/gsantner/markor/issues/new/choose).
- [x] The topic is **not** already reported at [Issues](https://github.com/gsantner/markor/issues?q=#js-issues-search). _(I've searched it)_.
- [x] Markor **is** up to date. See [Releases](https://github.com/gsantner/markor/tags) for the latest version. Updates are available from [F-Droid](https://f-droid.org/en/packages/net.gsantner.markor/) and GitHub.
- [x] The bug is still present in the latest development version (git master). (Please [download](https://nightly.link/gsantner/markor/workflows/build-android-project/master) and try the test version of Markor, named **Marder**. Don't worry; Markor and Marder appear as completely separate applications. You can install both side-by-side, and Markor settings are not touched. In case the issue is resolved there, you don't need to create a bug report. The change will be part of the next Markor update.)
### Description
The "Insert Image" button is available in the toolbar for .txt (plain text) files, but it inserts Markdown syntax that cannot be rendered, misleading users.
https://github.com/user-attachments/assets/d8d6ceb5-0df8-4b5a-90a6-4b99484700ea
### Steps to reproduce
1. Open or create a .txt file.
2. Click the "Insert Image" icon in the toolbar.
3. Select or upload an image.
4. Observe that Markdown code is inserted into the text.
5. Click the "Preview" icon.
### Information
Android version: 14
Device: Honor 70
App Version: 2.16.1
### Source
F-Droid
### Format / File type
todo.txt
### Additional info / Log
```shell
Actual Behavior
The preview mode displays the raw Markdown string instead of the actual image. Since .txt files do not support rich media rendering, the feature is functional but logically broken.
Expected Behavior (Rule Violation)
Context-Aware UI: The "Insert Image" button should be hidden or disabled for .txt files, as they do not support Markdown rendering. This feature should only be active for .md (Markdown) or rich-text supported formats to avoid misleading the user.
Suggested Fix
Logic: Implement a check for file extension upon opening the editor.
Action: If file_extension === '.txt', then hide or disable the "Insert Image" action.
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the issue with a todo.txt file: open the editor, use Insert Image, and check Preview. Trace the toolbar action handling and file-format checks involved in the editor. Done means the image action is unavailable for plain-text files while remaining available for supported rich-text formats, with the existing behavior covered by a relevant test if one exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100