fix: normalize path of pictures (#53)

Refs: #46
This commit is contained in:
samuele-cozzi 2023-03-08 14:38:50 +01:00 committed by GitHub
parent 053f8a3f3c
commit c362ae56a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 13 additions and 245 deletions

2
.gitignore vendored
View file

@ -22,3 +22,5 @@ data.json
.DS_Store
tests/coverage
vault/.obsidian

View file

@ -10,13 +10,20 @@ export class FilePath {
}
private getRootPath(file: TFile): string {
const basePath = (file.vault.adapter as FileSystemAdapter).getBasePath();
let basePath = (file.vault.adapter as FileSystemAdapter).getBasePath();
if (basePath.startsWith('/')){
basePath = `/${normalizePath(basePath)}`;
}
else
{
basePath = normalizePath(basePath);
}
console.log(`Root Path: ${basePath}`);
return basePath;
}
getCompleteFileBasePath(file: TFile): string{
const basePath = `${this.getRootPath(file)}/${normalizePath(file.parent.path)}/`;
const basePath = `app://local/${this.getRootPath(file)}/${normalizePath(file.parent.path)}/`;
console.log(`Complete File Base Path: ${basePath}`);
return basePath;
}

View file

@ -52,7 +52,7 @@ export class MarpPreviewView extends ItemView {
async displaySlides(view : MarkdownView) {
console.log("Marp Preview Display Slides");
const basePath = `app://local/${(new FilePath(this.settings)).getCompleteFileBasePath(view.file)}/`;
const basePath = (new FilePath(this.settings)).getCompleteFileBasePath(view.file);
const markdownText = view.data;
const container = this.containerEl.children[1];

View file

@ -1,5 +0,0 @@
{
"showUnsupportedFiles": true,
"useMarkdownLinks": true,
"newLinkFormat": "relative"
}

View file

@ -1,3 +0,0 @@
{
"accentColor": ""
}

View file

@ -1,3 +0,0 @@
[
"obsidian-marp-slides"
]

View file

@ -1,29 +0,0 @@
{
"file-explorer": true,
"global-search": true,
"switcher": true,
"graph": true,
"backlink": true,
"canvas": true,
"outgoing-link": true,
"tag-pane": true,
"page-preview": true,
"daily-notes": true,
"templates": true,
"note-composer": true,
"command-palette": true,
"slash-command": false,
"editor-status": true,
"starred": true,
"markdown-importer": false,
"zk-prefixer": false,
"random-note": false,
"outline": true,
"word-count": true,
"slides": false,
"audio-recorder": false,
"workspaces": false,
"file-recovery": true,
"publish": false,
"sync": false
}

View file

@ -1,20 +0,0 @@
[
"file-explorer",
"global-search",
"switcher",
"graph",
"backlink",
"canvas",
"outgoing-link",
"tag-pane",
"page-preview",
"daily-notes",
"templates",
"note-composer",
"command-palette",
"editor-status",
"starred",
"outline",
"word-count",
"file-recovery"
]

View file

@ -1 +0,0 @@
{}

View file

@ -1,180 +0,0 @@
{
"main": {
"id": "90d87bdf81788a37",
"type": "split",
"children": [
{
"id": "12c19632d10a9b10",
"type": "tabs",
"children": [
{
"id": "e52e1420408369eb",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "samples/Sampe 1.md",
"mode": "source",
"source": false
}
}
},
{
"id": "3ec35f35e4219b34",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "samples/Sampe 1.md",
"mode": "source",
"source": false
}
}
}
],
"currentTab": 1
}
],
"direction": "vertical"
},
"left": {
"id": "e8858204eedcf45a",
"type": "split",
"children": [
{
"id": "dc5d3dc908dfe1bb",
"type": "tabs",
"children": [
{
"id": "e031976b5faa0e76",
"type": "leaf",
"state": {
"type": "file-explorer",
"state": {
"sortOrder": "alphabetical"
}
}
},
{
"id": "e0da967959233d0f",
"type": "leaf",
"state": {
"type": "search",
"state": {
"query": "",
"matchingCase": false,
"explainSearch": false,
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical"
}
}
},
{
"id": "a782d991e0b3d63c",
"type": "leaf",
"state": {
"type": "starred",
"state": {}
}
}
]
}
],
"direction": "horizontal",
"width": 300
},
"right": {
"id": "95e6049b8c791436",
"type": "split",
"children": [
{
"id": "9e57d6fe74fb5995",
"type": "tabs",
"children": [
{
"id": "418913b710c907f4",
"type": "leaf",
"state": {
"type": "backlink",
"state": {
"file": "samples/Sampe 1.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
"showSearch": false,
"searchQuery": "",
"backlinkCollapsed": false,
"unlinkedCollapsed": true
}
}
},
{
"id": "4867a1414a42fb4d",
"type": "leaf",
"state": {
"type": "outgoing-link",
"state": {
"file": "samples/Sampe 1.md",
"linksCollapsed": false,
"unlinkedCollapsed": true
}
}
},
{
"id": "ec5cbbfcf6a54a0f",
"type": "leaf",
"state": {
"type": "tag",
"state": {
"sortOrder": "frequency",
"useHierarchy": true
}
}
},
{
"id": "51e00549a4dc43c5",
"type": "leaf",
"state": {
"type": "outline",
"state": {
"file": "samples/Sampe 1.md"
}
}
},
{
"id": "493e5e9efd32c8fa",
"type": "leaf",
"state": {
"type": "marp-preview-view",
"state": {}
}
}
],
"currentTab": 4
}
],
"direction": "horizontal",
"width": 460.5
},
"left-ribbon": {
"hiddenItems": {
"switcher:Open quick switcher": false,
"graph:Open graph view": false,
"canvas:Create new canvas": false,
"daily-notes:Open today's daily note": false,
"templates:Insert template": false,
"command-palette:Open command palette": false,
"obsidian-marp-slides:Show Slide Preview": false
}
},
"active": "493e5e9efd32c8fa",
"lastOpenFiles": [
"themes/theme1.css",
"themes/theme1.md",
"samples/Sampe 1.md",
"samples/Sampe 1.pdf",
"themes",
"samples"
]
}

View file

@ -10,7 +10,7 @@ theme: default
## subtitle
![](../attachments/placeholder-circle.png)
![bg](../attachments/placeholder-circle.png)
---