Skip to content

multiple path choices for pasted image - #389

Open
hamidb80 wants to merge 22 commits into
suchnsuch:mainfrom
hamidb80:pasted-image-local-wildcard
Open

multiple path choices for pasted image#389
hamidb80 wants to merge 22 commits into
suchnsuch:mainfrom
hamidb80:pasted-image-local-wildcard

Conversation

@hamidb80

Copy link
Copy Markdown
Contributor

addresses #370

@hamidb80 hamidb80 changed the title allow local wildcard for pasted image allow local wildcard for pasted images Jun 19, 2026
@hamidb80
hamidb80 marked this pull request as draft June 19, 2026 06:53

@taylorhadden taylorhadden left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a pretty useful feature. We should also update the documentation and the description of the wildcard in the Attachments settings.

Comment thread apps/tangent-electron/src/main/Workspace.ts Outdated
Comment thread apps/tangent-electron/src/main/Workspace.ts Outdated
Comment thread apps/tangent-electron/src/main/Workspace.ts Outdated
Comment thread apps/tangent-electron/src/main/Workspace.ts Outdated
@hamidb80
hamidb80 requested a review from taylorhadden June 19, 2026 15:16
@hamidb80
hamidb80 marked this pull request as ready for review June 19, 2026 15:26
@hamidb80 hamidb80 changed the title allow local wildcard for pasted images allow local (closest) wildcard for pasted images Jun 19, 2026
@hamidb80

hamidb80 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Notes

  • error handling for path errors, etc should be added in the UI
  • someone may want to have comma , in the directory's name for that we should allow "dir,name" inside " but maybe that's overthinking...

@taylorhadden taylorhadden left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After looking at this some more, I'm no longer thinking that a flat array of strings is the way to tackle this.

...getSettings().defaultPasteLocation.value.split(',').map(s => s.trim()), // paths are separated by comma (,)
'' // default fallback to root path
]
const closestWildCardPrefix = "./**/"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A key problem with this approach is that this actually normally has an inverted meaning. This should technically be "any file that is a sibling or lower" by standard globstar syntax.

There are many options that we might want for finding & creating attachment folders, and they are not something easily encoded into a string. I think it would be better to have each option be an object, similar to how the Creation Rules are defined. That way we can define things like "find nearest ancestor" or "create if not found" in each option.

This comment was marked as outdated.

This comment was marked as outdated.

@hamidb80 hamidb80 Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly I had a weird feeling about this pattern too

image

something like that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely the right direction. I think following a pattern similar to Creation Rules (a list that opens an individual editor) would be even better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works!!!

image image

Comment thread apps/tangent-electron/src/main/files.ts
@hamidb80
hamidb80 marked this pull request as draft June 24, 2026 01:56
@hamidb80

hamidb80 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Taylor do you think how many modes do we need? ( in settings )

  1. Default (detects based on ./ or /), upward
  2. Absolute, local, upward

@hamidb80

hamidb80 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

why are there 2 places for settings?

	settings: Settings
	workspaceSettings = new WritableStore<WorkspaceSettings>(null)

the first one is available in getSettings() but it's a little tricky to get workspaceSettings

@hamidb80

hamidb80 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

it now works but the UI it's a little messy

Taylor please checkout and give me feedback. do you agree with the direction?

@hamidb80
hamidb80 marked this pull request as ready for review July 5, 2026 10:20
@hamidb80 hamidb80 changed the title allow local (closest) wildcard for pasted images support multiple path choices for pasted image Jul 5, 2026
@hamidb80 hamidb80 changed the title support multiple path choices for pasted image multiple path choices for pasted image Jul 5, 2026

@taylorhadden taylorhadden left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks mostly like the right direction. You shouldn't need to hand over the attachment rules across the renderer/main divide though. We should make those settings accessible.

That could be something that I do separately if you prefer.

getAllFonts(): Promise<string[]>
getAllLanguages(): Promise<string[]>
saveImageFromClipboard(contextPath: string): Promise<string>
saveImageFromClipboard(contextPath: string, attachmentRules: AttachmentRuleDefinition[]): Promise<string>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to route the rules through here. The workspace settings should theoretically be accessible from the main process.

As I check, I can see I have a TODO about this in the main/Workspace.ts file. It uses the same DataFile concept as the renderer process, so it should be relatively straightforward.


const attachmentModeDefinition: SettingDefinition<ResolveMode> = {
name: 'Creation Mode',
description: 'Determines how the new note is created.',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The descriptions here haven't been updated.

patchBlockList: ['id']
}

export default class AttachmentRule extends ObjectStore {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the attachment rule also define how the pasted attachment is named? Is the current naming scheme sufficient?

Having to redefine the naming template might be a pain though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants