From dac16e6003cad16de74adea529a0c4da7585115c Mon Sep 17 00:00:00 2001 From: Luca Orio Date: Wed, 1 Jun 2022 14:59:33 -0700 Subject: [PATCH 1/3] removed jsyaml --- package-lock.json | 15 --------------- package.json | 1 - src/img-gallery-renderer.ts | 5 ++--- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index a571eb4..cce2e16 100644 --- a/package-lock.json +++ b/package-lock.json @@ -204,12 +204,6 @@ "eslint-visitor-keys": "^3.3.0" } }, - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, "array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", @@ -536,15 +530,6 @@ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, - "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "requires": { - "argparse": "^2.0.1" - } - }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", diff --git a/package.json b/package.json index 3d88932..23fcf02 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "@typescript-eslint/parser": "^5.2.0", "builtin-modules": "^3.2.0", "esbuild": "0.13.12", - "js-yaml": "^4.1.0", "obsidian": "latest", "tslib": "2.3.1", "typescript": "^4.4.4" diff --git a/src/img-gallery-renderer.ts b/src/img-gallery-renderer.ts index 35a2403..3d68daf 100644 --- a/src/img-gallery-renderer.ts +++ b/src/img-gallery-renderer.ts @@ -1,5 +1,4 @@ -import { App, MarkdownRenderChild, TFolder, TFile, Platform, normalizePath } from 'obsidian' -import * as jsyaml from 'js-yaml' +import { App, MarkdownRenderChild, TFolder, TFile, Platform, normalizePath, parseYaml } from 'obsidian' import ImgGallery from './main' export class imgGalleryRenderer extends MarkdownRenderChild { @@ -34,7 +33,7 @@ export class imgGalleryRenderer extends MarkdownRenderChild { private _getSettings() { // parse the settings from the code block - const settingsObj: any = jsyaml.load(this.src) + const settingsObj: any = parseYaml(this.src) // check for required settings if (settingsObj === undefined) { From 7ea88d20f30e2f8d3aac506ebf373f1b204b2d8e Mon Sep 17 00:00:00 2001 From: Luca Orio Date: Wed, 1 Jun 2022 15:00:16 -0700 Subject: [PATCH 2/3] fixed initialization of array --- src/img-gallery-renderer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/img-gallery-renderer.ts b/src/img-gallery-renderer.ts index 3d68daf..67acd15 100644 --- a/src/img-gallery-renderer.ts +++ b/src/img-gallery-renderer.ts @@ -4,7 +4,7 @@ import ImgGallery from './main' export class imgGalleryRenderer extends MarkdownRenderChild { private _gallery: HTMLElement = null private _settings: {[key: string]: any} = {} - private _imagesList: string[] = null + private _imagesList: string[] = [] constructor( public plugin: ImgGallery, From 692340d10debc2b0e1bfadad548a1da5eef67147 Mon Sep 17 00:00:00 2001 From: Luca Orio Date: Wed, 1 Jun 2022 15:22:17 -0700 Subject: [PATCH 3/3] fixed mixed types of settings --- src/img-gallery-renderer.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/img-gallery-renderer.ts b/src/img-gallery-renderer.ts index 67acd15..43ac354 100644 --- a/src/img-gallery-renderer.ts +++ b/src/img-gallery-renderer.ts @@ -51,19 +51,19 @@ export class imgGalleryRenderer extends MarkdownRenderChild { // store settings, normalize and set sensible defaults this._settings.path = normalizePath(settingsObj.path) - this._settings.type = settingsObj.type || 'horizontal' - this._settings.radius = settingsObj.radius || '0' - this._settings.gutter = settingsObj.gutter || '8' - this._settings.sortby = settingsObj.sortby || 'ctime' - this._settings.sort = settingsObj.sort || 'desc' + this._settings.type = settingsObj.type ?? 'horizontal' + this._settings.radius = settingsObj.radius ?? 0 + this._settings.gutter = settingsObj.gutter ?? 8 + this._settings.sortby = settingsObj.sortby ?? 'ctime' + this._settings.sort = settingsObj.sort ?? 'desc' // settings for vertical mansory only - this._settings.mobile = settingsObj.mobile || '1' - if (Platform.isDesktop) this._settings.columns = settingsObj.columns || '3' + this._settings.mobile = settingsObj.mobile ?? 1 + if (Platform.isDesktop) this._settings.columns = settingsObj.columns ?? 3 else this._settings.columns = this._settings.mobile // settings for horizontal mansory only - this._settings.height = settingsObj.height || '260' + this._settings.height = settingsObj.height ?? 260 } private _getImagesList() {