Uploads to same folder
This commit is contained in:
parent
04d6de18e6
commit
fd6f81d500
11
common/path.test.ts
Normal file
11
common/path.test.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { assertEquals } from "../test_deps.ts";
|
||||
import { folderName, resolve } from "./path.ts";
|
||||
|
||||
Deno.test("Path functions", () => {
|
||||
assertEquals(folderName(""), "");
|
||||
assertEquals(folderName("page"), "");
|
||||
assertEquals(folderName("folder/page"), "folder");
|
||||
|
||||
assertEquals(resolve("", "page"), "page");
|
||||
assertEquals(resolve("folder", "page"), "folder/page");
|
||||
});
|
23
common/path.ts
Normal file
23
common/path.ts
Normal file
@ -0,0 +1,23 @@
|
||||
export function folderName(path: string) {
|
||||
return path.split("/").slice(0, -1).join("/");
|
||||
}
|
||||
|
||||
export function resolve(...paths: string[]) {
|
||||
const parts = paths.reduce((acc, path) => {
|
||||
return acc.concat(path.split("/"));
|
||||
}, [] as string[]);
|
||||
const resolvedParts = [];
|
||||
for (const part of parts) {
|
||||
if (part === "..") {
|
||||
resolvedParts.pop();
|
||||
} else if (part !== ".") {
|
||||
resolvedParts.push(part);
|
||||
}
|
||||
}
|
||||
const result = resolvedParts.join("/");
|
||||
if (result[0] === "/") {
|
||||
return result.substring(1);
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
37
deno.jsonc
37
deno.jsonc
@ -31,35 +31,22 @@
|
||||
},
|
||||
"importMap": "import_map.json",
|
||||
"lint": {
|
||||
"files": {
|
||||
"exclude": [
|
||||
"dist",
|
||||
"dist_bundle"
|
||||
]
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
"dist_bundle"
|
||||
],
|
||||
"rules": {
|
||||
"exclude": ["no-explicit-any"]
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"files": {
|
||||
"exclude": ["plugos/forked", "plugos/sqlite/deno-sqlite"]
|
||||
}
|
||||
},
|
||||
"fmt": {
|
||||
"files": {
|
||||
"exclude": [
|
||||
"dist",
|
||||
"dist_bundle",
|
||||
"desktop",
|
||||
"mobile",
|
||||
"pages",
|
||||
"website",
|
||||
"website_build",
|
||||
"test_space",
|
||||
"plugos/environments/worker_bundle.json",
|
||||
"README.md"
|
||||
]
|
||||
}
|
||||
"exclude": [
|
||||
"dist",
|
||||
"dist_bundle",
|
||||
"website",
|
||||
"website_build",
|
||||
"test_space",
|
||||
"README.md"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
VERSION=$1
|
||||
echo "export const version = '$VERSION';" > version.ts
|
||||
echo "export const version = \"$VERSION\";" > version.ts
|
||||
git commit -am $VERSION
|
||||
git tag $VERSION
|
||||
git push && git push --tags
|
||||
|
@ -17,6 +17,8 @@ import {
|
||||
findParentMatching,
|
||||
nodeAtPos,
|
||||
} from "../../plug-api/lib/tree.ts";
|
||||
import { folderName, resolve } from "../../common/path.ts";
|
||||
|
||||
const turndownService = new TurndownService({
|
||||
hr: "---",
|
||||
codeBlockStyle: "fenced",
|
||||
@ -202,6 +204,8 @@ export function attachmentExtension(editor: Editor) {
|
||||
return;
|
||||
}
|
||||
|
||||
suggestedName = resolve(folderName(editor.currentPage!), suggestedName);
|
||||
|
||||
const finalFileName = await editor.prompt(
|
||||
"File name for pasted attachment",
|
||||
suggestedName,
|
||||
|
Loading…
Reference in New Issue
Block a user