mirror of
https://github.com/shadiestgoat/obsidian-simple-password.git
synced 2026-07-22 05:46:29 +00:00
Cleanup
This commit is contained in:
parent
c912a72aa5
commit
975de496c0
10 changed files with 42 additions and 119 deletions
22
LICENSE
22
LICENSE
|
|
@ -1,5 +1,21 @@
|
|||
Copyright (C) 2020-2025 by Dynalist Inc.
|
||||
MIT License
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
|
||||
Copyright (c) 2025 Lucy Dryaeva
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
|
|||
12
README.md
12
README.md
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
Lets you put a simple lock on your [Obsidian](https://obsidian.md) vault
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
|
||||
- Lets you lock your vault so that no one snoops
|
||||
|
|
@ -28,6 +30,16 @@ When the privacy mode is set to close tabs, it will not let tabs open for protec
|
|||
|
||||
When the privacy mode is set to blur, it will only blur the background of the modal.
|
||||
|
||||
### Preview
|
||||
|
||||
#### Blur Mode
|
||||
|
||||

|
||||
|
||||
#### Tab Closer
|
||||
|
||||

|
||||
|
||||
## Ackgnoledgements
|
||||
|
||||
**HEAVILY** inspired by [Qing Li's Password Protection plugin](https://github.com/qing3962/password-protection) - I just wanted to add a few things to their plugin & the codebase didn't allow for my ideas to be easily implemented.
|
||||
|
|
|
|||
|
|
@ -94,7 +94,9 @@ export default ts.config(
|
|||
'svelte/require-event-dispatcher-types': 'warn',
|
||||
'svelte/require-optimized-style-attribute': 'warn',
|
||||
'svelte/prefer-style-directive': 'warn',
|
||||
'svelte/prefer-class-directive': 'warn'
|
||||
'svelte/prefer-class-directive': 'warn',
|
||||
// Breaks svelete >:(
|
||||
'import-x/no-duplicates': 'off'
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
|||
BIN
github/preview-blur.gif
Normal file
BIN
github/preview-blur.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 319 KiB |
BIN
github/preview-close.gif
Normal file
BIN
github/preview-close.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 224 KiB |
BIN
github/preview-main.png
Normal file
BIN
github/preview-main.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 136 KiB |
111
main.ts
111
main.ts
|
|
@ -1,111 +0,0 @@
|
|||
import {
|
||||
App,
|
||||
Editor,
|
||||
MarkdownView,
|
||||
Modal,
|
||||
Notice,
|
||||
Plugin,
|
||||
PluginSettingTab,
|
||||
Setting,
|
||||
TFile
|
||||
} from 'obsidian'
|
||||
|
||||
// Remember to rename these classes and interfaces!
|
||||
|
||||
interface MyPluginSettings {
|
||||
mySetting: string
|
||||
}
|
||||
|
||||
const DEFAULT_SETTINGS: MyPluginSettings = {
|
||||
mySetting: 'default'
|
||||
}
|
||||
|
||||
export default class MyPlugin extends Plugin {
|
||||
settings: MyPluginSettings
|
||||
ribbonIconEl: HTMLElement
|
||||
|
||||
async onload() {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData())
|
||||
|
||||
// This adds a simple command that can be triggered anywhere
|
||||
this.addCommand({
|
||||
id: 'open-sample-modal-simple',
|
||||
name: 'Open sample modal (simple)',
|
||||
callback: () => {
|
||||
new SampleModal(this.app).open()
|
||||
}
|
||||
})
|
||||
|
||||
this.registerEvent(this.app.workspace.on('file-open', (f: TFile | null) => {
|
||||
if (!f) return
|
||||
|
||||
}))
|
||||
|
||||
// This adds a settings tab so the user can configure various aspects of the plugin
|
||||
this.addSettingTab(new SampleSettingTab(this.app, this))
|
||||
|
||||
// When registering intervals, this function will automatically clear the interval when the plugin is disabled.
|
||||
this.registerInterval(window.setInterval(() => console.log('setInterval'), 5 * 60 * 1000))
|
||||
}
|
||||
|
||||
isPathLocked(p: string) {
|
||||
this.settings.
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs all the needed actions to initiate a lock
|
||||
*/
|
||||
async lock() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs everything that needs to be done in order to set ourselfs into an unlock state
|
||||
*/
|
||||
async unlock() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class SampleModal extends Modal {
|
||||
constructor(app: App) {
|
||||
super(app)
|
||||
}
|
||||
|
||||
onOpen() {
|
||||
const { contentEl } = this
|
||||
contentEl.setText('Woah!')
|
||||
}
|
||||
|
||||
onClose() {
|
||||
const { contentEl } = this
|
||||
contentEl.empty()
|
||||
}
|
||||
}
|
||||
|
||||
class SampleSettingTab extends PluginSettingTab {
|
||||
plugin: MyPlugin
|
||||
|
||||
constructor(app: App, plugin: MyPlugin) {
|
||||
super(app, plugin)
|
||||
this.plugin = plugin
|
||||
}
|
||||
|
||||
display(): void {
|
||||
const { containerEl } = this
|
||||
|
||||
containerEl.empty()
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Setting #1')
|
||||
.setDesc("It's a secret")
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder('Enter your secret')
|
||||
.setValue(this.plugin.settings.mySetting)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.mySetting = value
|
||||
await this.plugin.saveSettings()
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -5,9 +5,10 @@
|
|||
correctPassword: string
|
||||
hint: string
|
||||
value?: string
|
||||
placeholder?: string
|
||||
}
|
||||
|
||||
let { correctPassword, hint, value = $bindable('') }: Props = $props()
|
||||
let { correctPassword, hint, value = $bindable(''), placeholder = "Password" }: Props = $props()
|
||||
|
||||
export function submit(shoulClear: boolean): boolean {
|
||||
const correct = value == correctPassword
|
||||
|
|
@ -27,7 +28,9 @@
|
|||
</script>
|
||||
|
||||
<div class="sp-password-input">
|
||||
<input type="password" placeholder="Password" bind:value />
|
||||
<!-- svelte-ignore a11y_autofocus -->
|
||||
<!-- This is only rendered in modals, at which point focus SHOULD jump to the new element -->
|
||||
<input type="password" {placeholder} autofocus bind:value />
|
||||
{#if wrongCount > 0}
|
||||
<p class="sp-wrong">
|
||||
Wrong Password!
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
}}
|
||||
>
|
||||
{#if requireOldPassword}
|
||||
<PasswordInput {correctPassword} {hint} bind:this={passInp} bind:value={oldPassword} />
|
||||
<PasswordInput {correctPassword} {hint} bind:this={passInp} bind:value={oldPassword} placeholder="Old Password" />
|
||||
{/if}
|
||||
|
||||
<input type="password" placeholder="New Password" bind:value={newPassword} />
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ import { AbstractInputSuggest, Notice, PluginSettingTab, Setting } from 'obsidia
|
|||
import type SimplePassword from 'src'
|
||||
import { NewPasswordModal, RequirePasswordModal } from './modals'
|
||||
import SettingsPaths from './components/SettingsPaths.svelte'
|
||||
import { mount, unmount, writable, get } from 'svelte'
|
||||
import { mount, unmount } from 'svelte'
|
||||
import { writable, get } from 'svelte/store'
|
||||
|
||||
export enum PrivacyMode {
|
||||
BLUR = 'blur',
|
||||
|
|
|
|||
Loading…
Reference in a new issue