mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-12 04:12:30 +00:00
feat: add option for password protection in askString function
This commit is contained in:
+4
-2
@@ -43,13 +43,15 @@ export class InputStringDialog extends Modal {
|
|||||||
key: string;
|
key: string;
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
isManuallyClosed = false;
|
isManuallyClosed = false;
|
||||||
|
isPassword: boolean = false;
|
||||||
|
|
||||||
constructor(app: App, title: string, key: string, placeholder: string, onSubmit: (result: string | false) => void) {
|
constructor(app: App, title: string, key: string, placeholder: string, isPassword: boolean, onSubmit: (result: string | false) => void) {
|
||||||
super(app);
|
super(app);
|
||||||
this.onSubmit = onSubmit;
|
this.onSubmit = onSubmit;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.placeholder = placeholder;
|
this.placeholder = placeholder;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
this.isPassword = isPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpen() {
|
onOpen() {
|
||||||
@@ -58,7 +60,7 @@ export class InputStringDialog extends Modal {
|
|||||||
contentEl.createEl("h1", { text: this.title });
|
contentEl.createEl("h1", { text: this.title });
|
||||||
// For enter to submit
|
// For enter to submit
|
||||||
const formEl = contentEl.createEl("form");
|
const formEl = contentEl.createEl("form");
|
||||||
new Setting(formEl).setName(this.key).addText((text) =>
|
new Setting(formEl).setName(this.key).setClass(this.isPassword ? "password-input" : "normal-input").addText((text) =>
|
||||||
text.onChange((value) => {
|
text.onChange((value) => {
|
||||||
this.result = value;
|
this.result = value;
|
||||||
})
|
})
|
||||||
|
|||||||
+3
-3
@@ -405,9 +405,9 @@ export const askSelectString = (app: App, message: string, items: string[]): Pro
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const askString = (app: App, title: string, key: string, placeholder: string): Promise<string | false> => {
|
export const askString = (app: App, title: string, key: string, placeholder: string, isPassword?: boolean): Promise<string | false> => {
|
||||||
return new Promise((res) => {
|
return new Promise((res) => {
|
||||||
const dialog = new InputStringDialog(app, title, key, placeholder, (result) => res(result));
|
const dialog = new InputStringDialog(app, title, key, placeholder, isPassword, (result) => res(result));
|
||||||
dialog.open();
|
dialog.open();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -737,4 +737,4 @@ export const remoteDatabaseCleanup = async (plugin: ObsidianLiveSyncPlugin, dryR
|
|||||||
Logger(ex, LOG_LEVEL.VERBOSE);
|
Logger(ex, LOG_LEVEL.VERBOSE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -255,4 +255,8 @@ div.sls-setting-menu-btn {
|
|||||||
|
|
||||||
.sls-setting-hidden {
|
.sls-setting-hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.password-input > .setting-item-control >input {
|
||||||
|
-webkit-text-security: disc;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user