Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm exec lint-staged
22 changes: 16 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,21 @@
"typecheck:watch": "pnpm --filter marktext typecheck:watch",
"check": "pnpm lint && pnpm typecheck",
"gen-third-party": "tsx scripts/generateThirdPartyLicense.ts",
"validate-licenses": "tsx scripts/validateLicenses.ts"
"validate-licenses": "tsx scripts/validateLicenses.ts",
"prepare": "husky"
},
"pnpm": {
"overrides": {
"postcss": "8.5.15",
"esbuild@>=0.27.0 <0.28.1": "0.28.1"
}
"lint-staged": {
"packages/desktop/src/**/*.{ts,vue}": [
"eslint --fix",
"prettier --write"
],
"packages/desktop/test/**/*.ts": [
"eslint --fix",
"prettier --write"
],
"*.{json,md,yaml}": [
"prettier --write"
]
},
"devDependencies": {
"@babel/eslint-parser": "^7.29.7",
Expand All @@ -51,7 +59,9 @@
"eslint-plugin-i18n-json": "^4.0.1",
"eslint-plugin-jsonc": "^3.2.0",
"eslint-plugin-vue": "^10.9.2",
"husky": "^9.1.7",
"license-checker": "^25.0.1",
"lint-staged": "^17.2.0",
"neostandard": "^0.13.0",
"prettier": "^3.8.4",
"tsx": "^4.22.4",
Expand Down
40 changes: 31 additions & 9 deletions packages/desktop/src/renderer/src/store/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,22 +233,44 @@ export const useProjectStore = defineStore('project', () => {
const { pathname: src } = activeItem.value
clipboard.value = { type: String(type), src }
})
bus.on('SIDEBAR::paste', () => {
bus.on('SIDEBAR::paste', async() => {
const cb = clipboard.value
const { pathname, isDirectory } = activeItem.value
const dirname = isDirectory ? pathname : window.path.dirname(pathname)
if (cb && cb.src) {
cb.dest = dirname + PATH_SEPARATOR + window.path.basename(cb.src)
let dest = dirname + PATH_SEPARATOR + window.path.basename(cb.src)

if (window.path.normalize(cb.src) === window.path.normalize(cb.dest)) {
notice.notify({
title: 'Paste Forbidden',
type: 'warning',
message: 'Source and destination must not be the same.'
})
return
if (window.path.normalize(cb.src) === window.path.normalize(dest)) {
if (cb.type === 'cut') {
notice.notify({
title: 'Paste Forbidden',
type: 'warning',
message: 'Source and destination must not be the same.'
})
return
}
// Copy in same folder: generate unique name (e.g. "file (copy).md", "file (copy 2).md")
const ext = window.path.extname(cb.src)
const base = window.path.basename(cb.src, ext)
let suffix = 1
const MAX_COPIES = 99
dest = dirname + PATH_SEPARATOR + base + ' (copy)' + ext
while (await window.fileUtils.pathExists(dest)) {
suffix++
if (suffix > MAX_COPIES) {
notice.notify({
title: 'Too many copies',
type: 'warning',
message: `Maximum of ${MAX_COPIES} copies reached. Please clean up first.`
})
return
}
dest = dirname + PATH_SEPARATOR + base + ` (copy ${suffix})` + ext
}
}

cb.dest = dest

paste(cb as PasteOptions)
.then(() => {
clipboard.value = null
Expand Down
Loading
Loading