generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace all local links after local image upload
- Loading branch information
Showing
3 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { App, ButtonComponent, Modal } from 'obsidian' | ||
|
||
export default class InfoModal extends Modal { | ||
constructor(app: App, title: string, message: string) { | ||
super(app) | ||
|
||
this.setTitle(title) | ||
this.contentEl.createEl('p', { text: message }) | ||
|
||
const buttonsDiv = this.modalEl.createDiv('modal-button-container') | ||
new ButtonComponent(buttonsDiv).setButtonText('Ok') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { App, ButtonComponent, Modal } from 'obsidian' | ||
|
||
export default class UpdateLinksConfirmationModal extends Modal { | ||
private updateOnceButton: ButtonComponent | ||
private doNotUpdateButton: ButtonComponent | ||
|
||
constructor(app: App, localFileName: string, stats: { filesCount: number; linksCount: number }) { | ||
super(app) | ||
|
||
this.setTitle('Replace links in vault') | ||
|
||
this.contentEl.createEl('p', { | ||
text: `Do you want to replace internal links that link to original local file (${localFileName}) with remote link?`, | ||
}) | ||
this.contentEl.createEl('p', { | ||
text: `This will affect ${stats.linksCount} links in ${stats.filesCount} files.`, | ||
}) | ||
|
||
const buttonsDiv = this.modalEl.createDiv('modal-button-container') | ||
this.updateOnceButton = new ButtonComponent(buttonsDiv).setButtonText('Yes') | ||
this.doNotUpdateButton = new ButtonComponent(buttonsDiv).setButtonText('Do not update') | ||
} | ||
|
||
onDoUpdateClick(callback: (evt: MouseEvent) => any) { | ||
this.updateOnceButton.onClick(callback) | ||
} | ||
|
||
onDoNotUpdateClick(callback: (evt: MouseEvent) => any) { | ||
this.doNotUpdateButton.onClick(callback) | ||
} | ||
|
||
disableButtons() { | ||
this.updateOnceButton.setDisabled(true) | ||
this.doNotUpdateButton.setDisabled(true) | ||
} | ||
} |