-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local images from file system should resolve to Iris/Images
as the default path to look in
#43
Comments
I quickly tested this Electron protocol, and it seems to work fine. This is apparently a safe way of doing it, since many older methods forcefully disable flags and whatnot in the Electron main process, causing unwanted security issues. Reference: https://www.electronjs.org/docs/latest/api/protocol
import { protocol, net } from 'electron'
//initialize app
//custom protocol to handle local file system absolute paths
app.whenReady().then(() => {
protocol.handle('image', (request) =>
net.fetch('file://' + request.url.slice('image://'.length)))
})
![test](image::///Users/alex/Iris/Images/test.png)
For now, it doesn't have to reside within the main notes folder, but in future releases, there will be an |
The protocol above allows advanced mode users to use the local filesystem as a path for greater flexibility. This will be part of the next update for Iris. Note for Basic Mode users: You can copy an image and paste it directly into the editor. It will transform the pasted image data into base64, creating a hard link. I don't remember what package or lines of code that enables this, so I'll take a look at it when I have time. |
Since this feature doesn't affect the critical parts the core (only changes to Electron main process and Markdown parser), I might create a commit for this in the main branch within the next week or so. If that's the case, the update will be This is a very simple addition to the code and can be easily removed or modified if necessary. |
protocol.handle('image', (request): Promise<Response> => {
return net.fetch('file://' + request.url.slice('image://'.length)).catch((e) => console.error(e)) as Promise<Response>
}) Not 100% necessary but just added types and have it able to throw exceptions if needed. |
Changes are live in v0.2.0-dev-4.3 branch. I won't merge into main branch yet since I want to tweak/add a few things. |
I will submit a PR instead of directly merging into main once v0.2.0-dev-4.3 is ready. The PR makes it easier for tracking and future reference. |
Reference from #90:
Will be closed once v0.3.0-dev.1 releases. This is complete as of now. |
If a user wants to insert a local image from the file system, the default path should resolve to
Iris/Images
.The folder helps keep all images in one place and makes it easy to backup the
Iris
directory. This should avoid path issues for local images at least.Drag and drop images is another feature that would be good to have. However, that will be in a future release at the earliest.
The text was updated successfully, but these errors were encountered: