mirror of
https://github.com/Ellpeck/ObsidianJustSharePlease.git
synced 2024-11-26 12:18:35 +01:00
cleaned up view
This commit is contained in:
parent
0679f3add8
commit
7067957899
2 changed files with 28 additions and 25 deletions
|
@ -205,9 +205,8 @@ export default class JustSharePleasePlugin extends Plugin {
|
||||||
text = text.replace(/^---\s*\n.*?\n---\s*\n(.*)$/s, "$1");
|
text = text.replace(/^---\s*\n.*?\n---\s*\n(.*)$/s, "$1");
|
||||||
|
|
||||||
// include note name
|
// include note name
|
||||||
if (this.settings.includeNoteName) {
|
if (this.settings.includeNoteName)
|
||||||
text = `# ${file.basename}\n\n${text}`;
|
text = `# ${file.basename}\n\n${text}`;
|
||||||
}
|
|
||||||
|
|
||||||
// embed attachments directly
|
// embed attachments directly
|
||||||
let attachments = /!\[(.*)]\((.+)\)|!\[\[(.+)]]/g;
|
let attachments = /!\[(.*)]\((.+)\)|!\[\[(.+)]]/g;
|
||||||
|
|
50
src/view.ts
50
src/view.ts
|
@ -16,34 +16,38 @@ export class JSPView extends ItemView {
|
||||||
public refresh(): void {
|
public refresh(): void {
|
||||||
this.contentEl.empty();
|
this.contentEl.empty();
|
||||||
let content = this.contentEl.createDiv({cls: "just-share-please-view"});
|
let content = this.contentEl.createDiv({cls: "just-share-please-view"});
|
||||||
for (let shared of this.plugin.settings.shared) {
|
if (this.plugin.settings.shared.length > 0) {
|
||||||
let file = this.plugin.app.vault.getAbstractFileByPath(shared.path) as TFile;
|
for (let shared of this.plugin.settings.shared) {
|
||||||
let div = content.createDiv({cls: "just-share-please-shared-item"});
|
let file = this.plugin.app.vault.getAbstractFileByPath(shared.path) as TFile;
|
||||||
div.createSpan({cls: "just-share-please-shared-name", text: basename(shared.path, extname(shared.path))});
|
let div = content.createDiv({cls: "just-share-please-shared-item"});
|
||||||
new ButtonComponent(div)
|
div.createSpan({cls: "just-share-please-shared-name", text: basename(shared.path, extname(shared.path))});
|
||||||
.setClass("clickable-icon")
|
|
||||||
.setTooltip("Copy JSP link")
|
|
||||||
.setIcon("link")
|
|
||||||
.onClick(async () => this.plugin.copyShareLink(shared));
|
|
||||||
if (file) {
|
|
||||||
new ButtonComponent(div)
|
new ButtonComponent(div)
|
||||||
.setClass("clickable-icon")
|
.setClass("clickable-icon")
|
||||||
.setTooltip("Open in Obsidian")
|
.setTooltip("Copy JSP link")
|
||||||
.setIcon("edit")
|
.setIcon("link")
|
||||||
.onClick(async () => {
|
.onClick(async () => this.plugin.copyShareLink(shared));
|
||||||
// TODO open in obsidian
|
if (file) {
|
||||||
});
|
new ButtonComponent(div)
|
||||||
|
.setClass("clickable-icon")
|
||||||
|
.setTooltip("Open in Obsidian")
|
||||||
|
.setIcon("edit")
|
||||||
|
.onClick(async () => {
|
||||||
|
// TODO open in obsidian
|
||||||
|
});
|
||||||
|
new ButtonComponent(div)
|
||||||
|
.setClass("clickable-icon")
|
||||||
|
.setTooltip("Update in JSP")
|
||||||
|
.setIcon("share")
|
||||||
|
.onClick(async () => this.plugin.updateFile(shared, file));
|
||||||
|
}
|
||||||
new ButtonComponent(div)
|
new ButtonComponent(div)
|
||||||
.setClass("clickable-icon")
|
.setClass("clickable-icon")
|
||||||
.setTooltip("Update in JSP")
|
.setTooltip("Delete from JSP")
|
||||||
.setIcon("share")
|
.setIcon("trash")
|
||||||
.onClick(async () => this.plugin.updateFile(shared, file));
|
.onClick(async () => this.plugin.deleteFile(shared));
|
||||||
}
|
}
|
||||||
new ButtonComponent(div)
|
} else {
|
||||||
.setClass("clickable-icon")
|
content.createSpan({text: "You have not shared any items yet."});
|
||||||
.setTooltip("Delete from JSP")
|
|
||||||
.setIcon("trash")
|
|
||||||
.onClick(async () => this.plugin.deleteFile(shared));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue