Skip to content

Commit

Permalink
Update version to 0.0.36 with improvements and cleanup
Browse files Browse the repository at this point in the history
- Incremented plugin version to 0.0.36 across project files for new release.
- Enhanced TextareaComponent to handle `Enter` keypress, inserting a newline without losing focus.
- Deprecated custom file cache getter in favor of native Obsidian API call `app.vault.getFiles()` for performance and maintainability.
- Introduced HTML detection utility function to the Helper class.
- Refactored StaticDocumentModel to use native Obsidian API call directly, aligning with deprecation of the custom cache getter.
- Updated styles to ensure correct text presentation in contenteditable text areas with proper white-space handling.
  • Loading branch information
PxaMMaxP committed Jan 17, 2024
1 parent e5fa401 commit b238b01
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "prj",
"name": "Prj Plugin",
"version": "0.0.35",
"version": "0.0.36",
"minAppVersion": "0.15.0",
"description": "Prj Plugin - Project, Document, and Task Management",
"author": "M. Passarello",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-sample-plugin",
"version": "0.0.35",
"version": "0.0.36",
"description": "Prj Plugin - Project, Document, and Task Management",
"main": "main.js",
"scripts": {
Expand Down
9 changes: 9 additions & 0 deletions src/libs/EditableDataView/Components/TextareaComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ export default class TextareaComponent extends BaseComponent {
this.component.registerDomEvent(this.presentationSpan, 'keydown', (event: KeyboardEvent) => {
if (event.key === 'Escape') {
this.disableEditMode();
} else if (event.key === 'Enter') {
event.preventDefault();
const selection = window.getSelection();
if (selection && selection.rangeCount > 0) {
const range = selection.getRangeAt(0);
range.deleteContents();
range.insertNode(document.createTextNode('\n'));
range.collapse(false);
}
}
});
}
Expand Down
9 changes: 2 additions & 7 deletions src/libs/FileCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,10 @@ export default class FileCache {
}

/**
* @depraecated Use directly the Obsidian API.
* @deprecated Use `app.vault.getFiles()` instead
*/
public get Cache(): TFile[] {
if (this.fileCacheReady && this.fileCache) {
return Array.from(this.fileCache.values()).filter(file => file !== null) as TFile[];
} else {
this.logger.error("File cache not initialized");
return [];
}
return this.app.vault.getFiles();
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ export default class Helper {
return regexMarkdownSymbols.test(text);
}

static containsHTML(text: string) {
const htmlRegex = /<[^>]*>/;
return htmlRegex.test(text);
}

/**
* Checks if any of the tags in `tagsToCheck` is a substring of any tag in `tagsToBeChecked`
* @param tagsToCheck The tags to check as substrings
Expand Down
2 changes: 1 addition & 1 deletion src/models/StaticHelper/StaticDocumentModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class StaticDocumentModel {
*/
public static getAllPDFsWithoutMetadata(): TFile[] {
const metadataCache = Global.getInstance().metadataCache.cache;
const fileCache = Global.getInstance().fileCache.Cache;
const fileCache = Global.getInstance().app.vault.getFiles();
const setOfPDFsWithMetadata = new Set(metadataCache
.filter(file => file.metadata?.frontmatter?.type === "Metadata" && file.metadata?.frontmatter?.file)
.map(file => new DocumentModel(file.file).getLinkedFile())
Expand Down
5 changes: 5 additions & 0 deletions src/styles/partials/_editableDataView.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@
font-family: inherit;
}

.editable-data-view.textarea-presentation[contenteditable="true"] {
white-space: pre-wrap;
display: inline-block;
}

.editable-data-view.textarea-input-sizer {
display: flex;
position: relative;
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
"0.0.32": "0.15.0",
"0.0.33": "0.15.0",
"0.0.34": "0.15.0",
"0.0.35": "0.15.0"
"0.0.35": "0.15.0",
"0.0.36": "0.15.0"
}

0 comments on commit b238b01

Please sign in to comment.