WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 4e116fd

Browse files
committed
Merge branch 'next'
2 parents d88030c + 11a35a6 commit 4e116fd

File tree

15 files changed

+443
-321
lines changed

15 files changed

+443
-321
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ Thank you for your support 😊
77

88
Report any bugs or feature requests [here](https://github.com/meld-cp/obsidian-encrypt/issues).
99

10+
## v2.4.1
11+
- Fix tab order, [#173](https://github.com/meld-cp/obsidian-encrypt/issues?q=is%3Aissue%20173)
12+
- Fix switching view modes may lose content (feat-whole-note), [#187](https://github.com/meld-cp/obsidian-encrypt/issues/187)
13+
- Fix decrypt not working for large text (feat-in-place), [#188](https://github.com/meld-cp/obsidian-encrypt/issues/188), added new settings to adjust scan range per user requirements.
14+
- Fix missing view actions (feat-whole-note), [#192](https://github.com/meld-cp/obsidian-encrypt/issues/192)
15+
16+
1017
## v2.4.0
1118
- Rewrite the encrypted note editor to be based off the Obsidian note editor. Fixes [#142](https://github.com/meld-cp/obsidian-encrypt/issues/142), [#145](https://github.com/meld-cp/obsidian-encrypt/issues/145), [#148](https://github.com/meld-cp/obsidian-encrypt/issues/148), [#152](https://github.com/meld-cp/obsidian-encrypt/issues/152), [#153](https://github.com/meld-cp/obsidian-encrypt/issues/153), [#154](https://github.com/meld-cp/obsidian-encrypt/issues/154), [#159](https://github.com/meld-cp/obsidian-encrypt/issues/159)
1219
- Build a standalone CLI script (mdenc) to work with encrypted notes independently to Obsidian. See [#105](https://github.com/meld-cp/obsidian-encrypt/issues/105).

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "meld-encrypt",
33
"name": "Meld Encrypt",
4-
"version": "2.4.0",
4+
"version": "2.4.1",
55
"minAppVersion": "1.0.3",
66
"description": "Hide secrets in your vault",
77
"author": "meld-cp",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-sample-plugin",
3-
"version": "2.4.0",
3+
"version": "2.4.1",
44
"description": "Hide secrets in your vault",
55
"main": "main.js",
66
"scripts": {

src/PluginPasswordModal.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import { App, Modal, Setting, TextComponent } from 'obsidian';
22
import { UiHelper } from 'src/services/UiHelper';
3-
import { IPasswordAndHint } from './services/SessionPasswordService';
3+
import { PasswordAndHint } from './services/SessionPasswordService';
44

55
export default class PluginPasswordModal extends Modal {
66

77
// input
88
private title: string;
9-
private defaultPassword: IPasswordAndHint | null;
9+
private defaultPassword: PasswordAndHint | null;
1010
//private defaultHint?: string | null = null;
1111
private confirmPassword: boolean;
1212
private isEncrypting: boolean;
1313

1414
// output
1515
public resultConfirmed = false;
16-
public resultPassword: IPasswordAndHint;
16+
public resultPassword: PasswordAndHint;
1717

1818
constructor(
1919
app: App,
2020
title: string,
2121
isEncrypting:boolean,
2222
confirmPassword: boolean,
23-
defaultPassword: IPasswordAndHint | null,
23+
defaultPassword: PasswordAndHint | null,
2424
) {
2525
super(app);
2626
this.title = title;
@@ -46,6 +46,7 @@ export default class PluginPasswordModal extends Modal {
4646

4747
UiHelper.buildPasswordSetting({
4848
container: contentEl,
49+
tabIndex: 0,
4950
name: 'Password:',
5051
placeholder: this.isEncrypting ? '' : `Hint: ${hint}`,
5152
initialValue: password,
@@ -85,6 +86,7 @@ export default class PluginPasswordModal extends Modal {
8586
const sConfirmPassword = UiHelper.buildPasswordSetting({
8687
container : contentEl,
8788
name: 'Confirm Password:',
89+
tabIndex: 1,
8890
autoFocus: password != '',
8991
onChangeCallback: (value) => {
9092
confirmPass = value;
@@ -119,6 +121,7 @@ export default class PluginPasswordModal extends Modal {
119121
.addText( tc=>{
120122
//tcHint = tc;
121123
tc.inputEl.placeholder = `Password Hint`;
124+
tc.inputEl.tabIndex = 2;
122125
tc.setValue(hint);
123126
tc.onChange( v=> hint = v );
124127
tc.inputEl.on('keypress', '*', (ev, target) => {
@@ -142,6 +145,7 @@ export default class PluginPasswordModal extends Modal {
142145
/* END Hint text row */
143146

144147
new Setting(contentEl).addButton( cb=>{
148+
cb.buttonEl.tabIndex = 99;
145149
cb
146150
.setButtonText('Confirm')
147151
.onClick( evt =>{
@@ -173,8 +177,8 @@ export default class PluginPasswordModal extends Modal {
173177

174178
}
175179

176-
open2Async(): Promise<IPasswordAndHint|null> {
177-
return new Promise<IPasswordAndHint|null>( (resolve, reject) =>{
180+
open2Async(): Promise<PasswordAndHint|null> {
181+
return new Promise<PasswordAndHint|null>( (resolve, reject) =>{
178182

179183
this.onClose = () =>{
180184
if (this.resultConfirmed == true){
@@ -189,8 +193,8 @@ export default class PluginPasswordModal extends Modal {
189193
} );
190194
}
191195

192-
openAsync(): Promise<IPasswordAndHint> {
193-
return new Promise<IPasswordAndHint>( (resolve, reject) =>{
196+
openAsync(): Promise<PasswordAndHint> {
197+
return new Promise<PasswordAndHint>( (resolve, reject) =>{
194198

195199
this.onClose = () =>{
196200
if (this.resultConfirmed == true){

src/features/feature-convert-note/FeatureConvertNote.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { IMeldEncryptPluginSettings } from "src/settings/MeldEncryptPluginSettin
33
import { IMeldEncryptPluginFeature } from "../IMeldEncryptPluginFeature";
44
import { Notice, TFile, TextFileView } from "obsidian";
55
import PluginPasswordModal from "src/PluginPasswordModal";
6-
import { IPasswordAndHint, SessionPasswordService } from "src/services/SessionPasswordService";
6+
import { PasswordAndHint, SessionPasswordService } from "src/services/SessionPasswordService";
77
import { FileDataHelper, JsonFileEncoding } from "src/services/FileDataHelper";
88
import { Utils } from "src/services/Utils";
99
import "src/services/Constants";
@@ -198,7 +198,7 @@ export default class FeatureConvertNote implements IMeldEncryptPluginFeature {
198198
}
199199
}
200200

201-
private async closeUpdateRememberPasswordThenReopen( file:TFile, newFileExtension: string, content: string, pw:IPasswordAndHint ) {
201+
private async closeUpdateRememberPasswordThenReopen( file:TFile, newFileExtension: string, content: string, pw:PasswordAndHint ) {
202202

203203
let didDetach = false;
204204

@@ -225,7 +225,7 @@ export default class FeatureConvertNote implements IMeldEncryptPluginFeature {
225225
}
226226
}
227227

228-
private async encryptFile(file: TFile, passwordAndHint:IPasswordAndHint ) : Promise<string> {
228+
private async encryptFile(file: TFile, passwordAndHint:PasswordAndHint ) : Promise<string> {
229229
const content = await this.plugin.app.vault.read( file );
230230
const encryptedData = await FileDataHelper.encrypt( passwordAndHint.password, passwordAndHint.hint, content );
231231
return JsonFileEncoding.encode( encryptedData );

src/features/feature-inplace-encrypt/FeatureInplaceEncrypt.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import { Decryptable } from "./Decryptable";
1212
import { FeatureInplaceTextAnalysis } from "./featureInplaceTextAnalysis";
1313
import { _HINT, _PREFIXES, _PREFIX_ENCODE_DEFAULT, _PREFIX_ENCODE_DEFAULT_VISIBLE, _SUFFIXES, _SUFFIX_NO_COMMENT, _SUFFIX_WITH_COMMENT } from "./FeatureInplaceConstants";
1414

15-
const MAX_LOOKBACK = 2000;
16-
1715
export default class FeatureInplaceEncrypt implements IMeldEncryptPluginFeature{
1816
plugin:MeldEncrypt;
1917
pluginSettings: IMeldEncryptPluginSettings;
@@ -246,6 +244,25 @@ export default class FeatureInplaceEncrypt implements IMeldEncryptPluginFeature{
246244
})
247245
;
248246

247+
new Setting(containerEl)
248+
.setName('Search limit for markers')
249+
.setDesc('How far to look for markers when encrypting/decrypting.')
250+
.addText( text => {
251+
text
252+
.setValue(this.featureSettings.markerSearchLimit?.toString() ?? '10000' )
253+
.onChange( async value => {
254+
const num = parseInt(value);
255+
if ( !isNaN(num) ){
256+
this.featureSettings.markerSearchLimit = num;
257+
await saveSettingCallback();
258+
}
259+
})
260+
;
261+
text.inputEl.type = 'number';
262+
text.inputEl.min = '1000';
263+
text.inputEl.max = '9999999';
264+
})
265+
249266
new Setting(containerEl)
250267
.setName('By default, show encrypted marker when reading')
251268
.setDesc('When encrypting inline text, should the default be to have a visible marker in Reading view?')
@@ -286,8 +303,8 @@ export default class FeatureInplaceEncrypt implements IMeldEncryptPluginFeature{
286303
if ( !editor.somethingSelected() ){
287304
// nothing selected, first assume user wants to decrypt, expand to start and end markers...
288305
// but if no markers found then prompt to encrypt text
289-
const foundStartPos = this.getClosestPrefixCursorPos( editor, MAX_LOOKBACK );
290-
const foundEndPos = this.getClosestSuffixCursorPos(editor, MAX_LOOKBACK );
306+
const foundStartPos = this.getClosestPrefixCursorPos( editor );
307+
const foundEndPos = this.getClosestSuffixCursorPos( editor );
291308

292309
if (
293310
foundStartPos == null
@@ -391,8 +408,10 @@ export default class FeatureInplaceEncrypt implements IMeldEncryptPluginFeature{
391408
return false;
392409
}
393410

394-
private getClosestPrefixCursorPos(editor: Editor, maxLookback: number ): EditorPosition | null{
411+
private getClosestPrefixCursorPos(editor: Editor ): EditorPosition | null{
395412

413+
const maxLookback = this.featureSettings.markerSearchLimit;
414+
396415
const maxLengthPrefix = _PREFIXES.reduce((prev,cur, i) => {
397416
if (i== 0) return cur;
398417
if ( cur.length > prev.length ) return cur;
@@ -420,7 +439,9 @@ export default class FeatureInplaceEncrypt implements IMeldEncryptPluginFeature{
420439

421440
}
422441

423-
private getClosestSuffixCursorPos(editor: Editor, maxLookForward: number): EditorPosition | null{
442+
private getClosestSuffixCursorPos( editor: Editor ): EditorPosition | null{
443+
const maxLookForward = this.featureSettings.markerSearchLimit;
444+
424445
const maxLengthPrefix = _PREFIXES.reduce((prev,cur, i) => {
425446
if (i== 0) return cur;
426447
if ( cur.length > prev.length ) return cur;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export interface IFeatureInplaceEncryptSettings {
22
expandToWholeLines: boolean;
3+
markerSearchLimit: number;
34
showMarkerWhenReadingDefault: boolean;
45
}

0 commit comments

Comments
 (0)