feat: add configuration for imageTool - #366
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Thanks for adding a description — the PR is now marked as Ready for Review. |
| * @param url - image URL pasted by the user | ||
| */ | ||
| uploadByUrl: (url: string): Promise<{ success: 1; file: { url: string } }> => { | ||
| return Promise.resolve({ |
There was a problem hiding this comment.
we need to save file by url first, then substitute our own internal path to the file.url
| if (toolClassAndInfo.tool.name === 'image') { | ||
| const noteId = toValue(options.noteId); | ||
|
|
||
| if (noteId !== null) { |
There was a problem hiding this comment.
what about images in new notes?
There was a problem hiding this comment.
Pull request overview
Adds Editor.js Image Tool configuration to the note editor, integrating image uploads with the existing authorized note-attachment upload flow and exposing attachment URLs for rendering.
Changes:
- Extend
useNoteEditorto acceptnoteIdand configure the Editor.js image tool with customuploadByFile/uploadByUrlhandlers. - Add
uploadImage()inNoteSettingsService, plus repository support for building direct attachment URLs (getFileUrl()). - Expose transport base URL (
getBaseUrl()), and extend tool config typing to allow per-toolconfig.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/presentation/pages/Note.vue | Passes noteId into useNoteEditor so image uploads can be note-scoped. |
| src/presentation/pages/HistoryVersion.vue | Passes noteId into useNoteEditor for history viewer configuration parity. |
| src/infrastructure/transport/fetch.transport.ts | Adds getBaseUrl() accessor used to build absolute attachment URLs. |
| src/infrastructure/noteAttachmentUploader.repository.ts | Adds getFileUrl() to build a direct URL for an uploaded attachment key. |
| src/domain/noteSettings.service.ts | Adds uploadImage() that uploads via attachment repository and returns the image URL. |
| src/domain/noteAttachmentUploader.repository.interface.ts | Extends attachment repository interface with getFileUrl(). |
| src/domain/entities/EditorTool.ts | Extends EditorjsToolsConfig to support optional per-tool config. |
| src/application/services/useNoteEditor.ts | Adds noteId option and configures the Editor.js image tool uploader integration. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (toolClassAndInfo.tool.name === 'image') { | ||
| const noteId = toValue(options.noteId); | ||
|
|
||
| if (noteId !== null) { | ||
| toolConfig.config = { |
Summary
Added Editor.js image tool (https://github.com/editor-js/image) configuration with a custom uploader that integrates with the existing authorized note attachment upload pipeline.
Details
useNoteEditor.ts— Added anoteIdoption to the composable. When the image tool is loaded and anoteIdis available, the tool is configured with a customuploadByFileuploader that callsnoteSettingsService.uploadImage()(which uses the authorizednoteAttachmentRepository), and anuploadByUrlhandler that accepts pasted URLs as-is.noteSettings.service.ts— AddeduploadImage(id, data)method that uploads a image via the attachment repository and returns the file URL.noteAttachmentUploader.repository.ts— ImplementedgetFileUrl(noteId, key)to build a direct URL to a stored attachment.noteAttachmentUploader.repository.interface.ts— AddedgetFileUrlto the repository interface.fetch.transport.ts— AddedgetBaseUrl()method to expose the transport's base URL.EditorTool.ts— ExtendedEditorjsToolsConfigtype to support an optionalconfigfield per tool.Note.vue&HistoryVersion.vue— PassnoteIdto theuseNoteEditorcomposable.Also check other related PR: Disabling authorization for GET image requests