Browse Source

Squashed commit of the following:

commit fac096bad0
Merge: a5b08c5 73f5da6
Author: meld-cp <18450687+meld-cp@users.noreply.github.com>
Date:   Sat Sep 30 11:10:27 2023 +1300

    Merge pull request #125 from meld-cp:dev-enote-quick-edit-shotcut

    Add quick edit toggle command for encrypted notes

commit 73f5da6aff
Author: Liam Swayne <liamtswayne@gmail.com>
Date:   Wed Sep 27 13:49:56 2023 -0400

    grammatical fix

commit a5b08c5040
Merge: c0dadec aad254f
Author: meld-cp <18450687+meld-cp@users.noreply.github.com>
Date:   Thu Sep 28 07:05:49 2023 +1300

    Merge pull request #123 from LiamSwayne/patch-1

    grammatical fix

commit aad254f0c6
Author: Liam Swayne <liamtswayne@gmail.com>
Date:   Wed Sep 27 13:49:56 2023 -0400

    grammatical fix

commit f353639a52
Author: Cleon <18450687+meld-cp@users.noreply.github.com>
Date:   Sun Sep 17 14:00:06 2023 +1200

    update readme

commit c7e25062c9
Author: Cleon <18450687+meld-cp@users.noreply.github.com>
Date:   Sun Sep 17 10:03:15 2023 +1200

    add key bindable command to toggle reading view
pull/126/head
Cleon 2 years ago
parent
commit
3c5f958701
  1. 1
      README.md
  2. 9
      src/features/feature-whole-note-encrypt/EncryptedFileContentView.ts
  3. 17
      src/features/feature-whole-note-encrypt/FeatureWholeNoteEncrypt.ts

1
README.md

@ -26,6 +26,7 @@ You can install the plugin via the Community Plugins tab within Obsidian by sear @@ -26,6 +26,7 @@ You can install the plugin via the Community Plugins tab within Obsidian by sear
> Please report any bugs or feature requests [here](https://github.com/meld-cp/obsidian-encrypt/issues).
### 2.3.2
- add key-bindable command to toggle reading view for encrypted notes ([#116](https://github.com/meld-cp/obsidian-encrypt/issues/116))
- change to using `.mdenc` file extensions for encrypted notes ([#117](https://github.com/meld-cp/obsidian-encrypt/issues/117))
### 2.3.1

9
src/features/feature-whole-note-encrypt/EncryptedFileContentView.ts

@ -52,8 +52,8 @@ export class EncryptedFileContentView extends TextFileView { @@ -52,8 +52,8 @@ export class EncryptedFileContentView extends TextFileView {
this.defaultEditNoteView = ( settings.defaultView as EditViewEnum ) ?? EditViewEnum.source;
this.currentEditNoteMode = this.defaultEditNoteView;
this.elActionEditView = this.addAction( this.iconSourceView, 'Source', () => this.actionToggleEditMode() );
this.elActionReadingView = this.addAction( this.iconReadingView, 'Reading', () => this.actionToggleEditMode() );
this.elActionEditView = this.addAction( this.iconSourceView, 'Source', () => this.toggleReadingView() );
this.elActionReadingView = this.addAction( this.iconReadingView, 'Reading', () => this.toggleReadingView() );
this.elActionIconLockNote = this.addAction( this.iconLockFile, 'Lock', () => this.actionLockFile() );
this.elActionChangePassword = this.addAction( this.iconChangePassword, 'Change Password', () => this.actionChangePassword() );
@ -65,9 +65,10 @@ export class EncryptedFileContentView extends TextFileView { @@ -65,9 +65,10 @@ export class EncryptedFileContentView extends TextFileView {
this.containerEl.classList.add('meld-encrypt-encrypted-note-view');
this.contentEl.classList.add('meld-encrypt-encrypted-note-view-content');
}
private actionToggleEditMode(){
public toggleReadingView(){
if ( this.currentView != EncryptedFileContentViewStateEnum.editNote ){
return;
}
@ -102,7 +103,7 @@ export class EncryptedFileContentView extends TextFileView { @@ -102,7 +103,7 @@ export class EncryptedFileContentView extends TextFileView {
.setSection('action')
.setIcon( this.iconToggleEditView )
.setTitle('Toggle Editing/Reading')
.onClick( () => this.actionToggleEditMode() )
.onClick( () => this.toggleReadingView() )
;
});
menu.addItem( m =>{

17
src/features/feature-whole-note-encrypt/FeatureWholeNoteEncrypt.ts

@ -36,6 +36,13 @@ export default class FeatureWholeNoteEncrypt implements IMeldEncryptPluginFeatur @@ -36,6 +36,13 @@ export default class FeatureWholeNoteEncrypt implements IMeldEncryptPluginFeatur
icon: 'file-lock-2',
callback: () => this.processCreateNewEncryptedNoteCommand(),
});
this.plugin.addCommand({
id: 'meld-encrypt-toggle-reading-view',
name: 'Toggle Reading View',
icon: 'edit',
callback: () => this.processToggleReadingViewCommand(),
});
}
@ -43,7 +50,12 @@ export default class FeatureWholeNoteEncrypt implements IMeldEncryptPluginFeatur @@ -43,7 +50,12 @@ export default class FeatureWholeNoteEncrypt implements IMeldEncryptPluginFeatur
this.plugin.app.workspace.detachLeavesOfType(VIEW_TYPE_ENCRYPTED_FILE_CONTENT);
}
private processCreateNewEncryptedNoteCommand(): boolean{
private processToggleReadingViewCommand() {
const view = this.plugin.app.workspace.getActiveViewOfType( EncryptedFileContentView );
view?.toggleReadingView();
}
private processCreateNewEncryptedNoteCommand() {
try{
const newFilename = moment().format( `[Untitled] YYYYMMDD hhmmss[.${ENCRYPTED_FILE_EXTENSION_DEFAULT}]`);
@ -66,12 +78,9 @@ export default class FeatureWholeNoteEncrypt implements IMeldEncryptPluginFeatur @@ -66,12 +78,9 @@ export default class FeatureWholeNoteEncrypt implements IMeldEncryptPluginFeatur
new Notice(reason, 10000);
});
return true;
}catch(e){
console.error(e);
new Notice(e, 10000);
return false;
}
}

Loading…
Cancel
Save