Added eslint and made suggested changes.

This commit is contained in:
NebulousNessie 2025-11-11 14:53:27 +00:00
parent 6090dedf01
commit 1399f4cdba
12 changed files with 159 additions and 180 deletions

View file

@ -1,3 +1,9 @@
node_modules/
dist/
main.js
*.min.js
versions.json
manifest.json
node_modules/
main.js

24
.eslintrc.json Normal file
View file

@ -0,0 +1,24 @@
{
"root": true,
"env": {
"browser": true,
"es2021": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"require-await": "off"
}
}

5
commands.txt Normal file
View file

@ -0,0 +1,5 @@
Run ESLint on all src/ files: npx -y eslint "src/**/*.ts"
Run ESLint on all src/ files and autofix: npx -y eslint "src/**/*.ts" --fix
Type checking: npx -y tsc -p tsconfig.json
Build to main.js: npm run Build

104
package-lock.json generated
View file

@ -21,6 +21,7 @@
"@typescript-eslint/parser": "5.29.0",
"builtin-modules": "3.3.0",
"esbuild": "^0.17.3",
"eslint": "^8.57.1",
"obsidian": "latest",
"obsidian-typings": "^3.12.0",
"tslib": "2.4.0",
@ -757,7 +758,6 @@
"integrity": "sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"eslint-visitor-keys": "^3.4.3"
},
@ -777,7 +777,6 @@
"integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
}
@ -788,7 +787,6 @@
"integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"ajv": "^6.12.4",
"debug": "^4.3.2",
@ -813,7 +811,6 @@
"integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}
@ -867,7 +864,6 @@
"deprecated": "Use @eslint/config-array instead",
"dev": true,
"license": "Apache-2.0",
"peer": true,
"dependencies": {
"@humanwhocodes/object-schema": "^2.0.3",
"debug": "^4.3.1",
@ -883,7 +879,6 @@
"integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==",
"dev": true,
"license": "Apache-2.0",
"peer": true,
"engines": {
"node": ">=12.22"
},
@ -898,8 +893,7 @@
"integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==",
"deprecated": "Use @eslint/object-schema instead",
"dev": true,
"license": "BSD-3-Clause",
"peer": true
"license": "BSD-3-Clause"
},
"node_modules/@iconify/types": {
"version": "2.0.0",
@ -2341,8 +2335,7 @@
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz",
"integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==",
"dev": true,
"license": "ISC",
"peer": true
"license": "ISC"
},
"node_modules/acorn": {
"version": "8.15.0",
@ -2363,7 +2356,6 @@
"integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
"dev": true,
"license": "MIT",
"peer": true,
"peerDependencies": {
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
}
@ -2374,7 +2366,6 @@
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
@ -2392,7 +2383,6 @@
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=8"
}
@ -2403,7 +2393,6 @@
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"color-convert": "^2.0.1"
},
@ -2419,8 +2408,7 @@
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true,
"license": "Python-2.0",
"peer": true
"license": "Python-2.0"
},
"node_modules/array-union": {
"version": "2.1.0",
@ -2597,7 +2585,6 @@
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=6"
}
@ -2608,7 +2595,6 @@
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
@ -2666,7 +2652,6 @@
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"color-name": "~1.1.4"
},
@ -2679,8 +2664,7 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true,
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/colord": {
"version": "2.9.3",
@ -2735,7 +2719,6 @@
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
@ -3328,8 +3311,7 @@
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
"dev": true,
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/defer-to-connect": {
"version": "1.1.3",
@ -3412,7 +3394,6 @@
"integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==",
"dev": true,
"license": "Apache-2.0",
"peer": true,
"dependencies": {
"esutils": "^2.0.2"
},
@ -3618,7 +3599,6 @@
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.6.1",
@ -3731,7 +3711,6 @@
"integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==",
"dev": true,
"license": "BSD-2-Clause",
"peer": true,
"dependencies": {
"esrecurse": "^4.3.0",
"estraverse": "^5.2.0"
@ -3749,7 +3728,6 @@
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
"dev": true,
"license": "BSD-2-Clause",
"peer": true,
"engines": {
"node": ">=4.0"
}
@ -3760,7 +3738,6 @@
"integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==",
"dev": true,
"license": "BSD-2-Clause",
"peer": true,
"dependencies": {
"acorn": "^8.9.0",
"acorn-jsx": "^5.3.2",
@ -3779,7 +3756,6 @@
"integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==",
"dev": true,
"license": "BSD-3-Clause",
"peer": true,
"dependencies": {
"estraverse": "^5.1.0"
},
@ -3793,7 +3769,6 @@
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
"dev": true,
"license": "BSD-2-Clause",
"peer": true,
"engines": {
"node": ">=4.0"
}
@ -3837,7 +3812,6 @@
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
"dev": true,
"license": "BSD-2-Clause",
"peer": true,
"engines": {
"node": ">=0.10.0"
}
@ -3898,8 +3872,7 @@
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"dev": true,
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/fast-glob": {
"version": "3.3.3",
@ -3936,16 +3909,14 @@
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
"dev": true,
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/fast-levenshtein": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
"integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==",
"dev": true,
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/fastq": {
"version": "1.19.1",
@ -3973,7 +3944,6 @@
"integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"flat-cache": "^3.0.4"
},
@ -4000,7 +3970,6 @@
"integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"locate-path": "^6.0.0",
"path-exists": "^4.0.0"
@ -4018,7 +3987,6 @@
"integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"flatted": "^3.2.9",
"keyv": "^4.5.3",
@ -4033,8 +4001,7 @@
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz",
"integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==",
"dev": true,
"license": "ISC",
"peer": true
"license": "ISC"
},
"node_modules/font-awesome-icons": {
"version": "1.6.0",
@ -4166,7 +4133,6 @@
"integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==",
"dev": true,
"license": "ISC",
"peer": true,
"dependencies": {
"is-glob": "^4.0.3"
},
@ -4199,7 +4165,6 @@
"integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"type-fest": "^0.20.2"
},
@ -4296,8 +4261,7 @@
"resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz",
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==",
"dev": true,
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/hachure-fill": {
"version": "0.5.2",
@ -4312,7 +4276,6 @@
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=8"
}
@ -4406,7 +4369,6 @@
"integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"parent-module": "^1.0.0",
"resolve-from": "^4.0.0"
@ -4424,7 +4386,6 @@
"integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=0.8.19"
}
@ -4495,7 +4456,6 @@
"integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=8"
}
@ -4505,8 +4465,7 @@
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
"dev": true,
"license": "ISC",
"peer": true
"license": "ISC"
},
"node_modules/ismobilejs": {
"version": "1.1.1",
@ -4530,7 +4489,6 @@
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"argparse": "^2.0.1"
},
@ -4550,16 +4508,14 @@
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"dev": true,
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/json-stable-stringify-without-jsonify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
"integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==",
"dev": true,
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/json-stringify-safe": {
"version": "5.0.1",
@ -4659,7 +4615,6 @@
"integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"prelude-ls": "^1.2.1",
"type-check": "~0.4.0"
@ -4692,7 +4647,6 @@
"integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"p-locate": "^5.0.0"
},
@ -4715,8 +4669,7 @@
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
"dev": true,
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/lowercase-keys": {
"version": "1.0.1",
@ -4892,8 +4845,7 @@
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
"dev": true,
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/normalize-url": {
"version": "4.5.1",
@ -5109,7 +5061,6 @@
"integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"deep-is": "^0.1.3",
"fast-levenshtein": "^2.0.6",
@ -5137,7 +5088,6 @@
"integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"yocto-queue": "^0.1.0"
},
@ -5154,7 +5104,6 @@
"integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"p-limit": "^3.0.2"
},
@ -5178,7 +5127,6 @@
"integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"callsites": "^3.0.0"
},
@ -5212,7 +5160,6 @@
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=8"
}
@ -5232,7 +5179,6 @@
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=8"
}
@ -5366,7 +5312,6 @@
"integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">= 0.8.0"
}
@ -5406,7 +5351,6 @@
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=6"
}
@ -5504,7 +5448,6 @@
"integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=4"
}
@ -5536,7 +5479,6 @@
"deprecated": "Rimraf versions prior to v4 are no longer supported",
"dev": true,
"license": "ISC",
"peer": true,
"dependencies": {
"glob": "^7.1.3"
},
@ -5689,7 +5631,6 @@
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"shebang-regex": "^3.0.0"
},
@ -5703,7 +5644,6 @@
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=8"
}
@ -5808,7 +5748,6 @@
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"ansi-regex": "^5.0.1"
},
@ -5822,7 +5761,6 @@
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=8"
},
@ -5863,7 +5801,6 @@
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"has-flag": "^4.0.0"
},
@ -5876,8 +5813,7 @@
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
"integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==",
"dev": true,
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/tinyexec": {
"version": "1.0.2",
@ -5957,7 +5893,6 @@
"integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"prelude-ls": "^1.2.1"
},
@ -5971,7 +5906,6 @@
"integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
"dev": true,
"license": "(MIT OR CC0-1.0)",
"peer": true,
"engines": {
"node": ">=10"
},
@ -6023,7 +5957,6 @@
"integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
"dev": true,
"license": "BSD-2-Clause",
"peer": true,
"dependencies": {
"punycode": "^2.1.0"
}
@ -6143,7 +6076,6 @@
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"license": "ISC",
"peer": true,
"dependencies": {
"isexe": "^2.0.0"
},
@ -6160,7 +6092,6 @@
"integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=0.10.0"
}
@ -6217,7 +6148,6 @@
"integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=10"
},

View file

@ -6,6 +6,7 @@
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"lint": "eslint \"src/**/*.ts\"",
"version": "node version-bump.mjs && git add manifest.json versions.json"
},
"keywords": [],
@ -18,6 +19,7 @@
"@typescript-eslint/parser": "5.29.0",
"builtin-modules": "3.3.0",
"esbuild": "^0.17.3",
"eslint": "^8.57.1",
"obsidian": "latest",
"obsidian-typings": "^3.12.0",
"tslib": "2.4.0",

View file

@ -88,7 +88,7 @@ export function addPinButton(
// Cleanup removes listeners and restores UI
function cleanup() {
img.classList.remove("mocblockRenderer-editing-outline");
img.style.cursor = "";
//img.style.cursor = "";
pinBtn.removeAttribute("disabled");
polyBtn.removeAttribute("disabled");
// Component owns the listeners; no manual removal needed

View file

@ -18,9 +18,9 @@ export function renderPinMarker(
markerFile: any,
source: string,
el: HTMLElement,
refreshMOCBlock: Function,
saveUpdatedMarker: Function,
deleteMarkerFromFile: Function,
refreshMOCBlock: (source: string, el: HTMLElement, ctx: any) => Promise<void> | void,
saveUpdatedMarker: (vault: any, path: string, marker: any) => Promise<void>,
deleteMarkerFromFile: (vault: any, file: any, markerId: string) => Promise<void>,
parentComponent: Component) {
@ -34,7 +34,6 @@ export function renderPinMarker(
// Get SVG styles from style settings. If not defined, use defaults from below.
const styleName = pin.styleName ?? "Default";
const config = settings.styleNames[styleName];
const StyleName = config?.styleName ?? "";
const iconName = config?.icon ?? "map-pin";
const fillColour = config?.fillColour ?? "#705dcf";
const strokeColour = config?.strokeColour ?? "#555454";
@ -127,19 +126,22 @@ export function renderPinMarker(
wasDragged = false;
};
const onDocMouseUp = async () => {
if (isDragging) {
isDragging = false;
const onDocMouseUp = () => {
// Wrap async logic in an IIFE so the registered handler returns void
(async () => {
if (isDragging) {
isDragging = false;
// Save to JSON config file when the marker is dropped
if (wasDragged) {
await saveUpdatedMarker(
app.vault,
`${settings.dataFolder}/${moc_id}.md`,
pin
);
}
}
// Save to JSON config file when the marker is dropped
if (wasDragged) {
await saveUpdatedMarker(
app.vault,
`${settings.dataFolder}/${moc_id}.md`,
pin
);
}
}
})();
};
const onDocMouseMove = (evt: MouseEvent) => {
@ -191,9 +193,9 @@ export function renderPolylineMarker(
markerFile: any,
source: string,
el: HTMLElement,
refreshMOCBlock: Function,
saveUpdatedMarker: Function,
deleteMarkerFromFile: Function,
refreshMOCBlock: (source: string, el: HTMLElement, ctx: any) => Promise<void> | void,
saveUpdatedMarker: (vault: any, path: string, marker: any) => Promise<void>,
deleteMarkerFromFile: (vault: any, file: any, markerId: string) => Promise<void>,
parentComponent: Component) {
// Get style config for this polyline
@ -290,9 +292,9 @@ export function addResizeHandle(
markerFile: any,
source: string,
el: HTMLElement,
refreshMOCBlock: any,
saveUpdatedMarker: any,
deleteMarkerFromFile: any,
refreshMOCBlock: (source: string, el: HTMLElement, ctx: any) => Promise<void> | void,
saveUpdatedMarker: (vault: any, path: string, marker: any) => Promise<void>,
deleteMarkerFromFile: (vault: any, file: any, markerId: string) => Promise<void>,
parentComponent: Component
) {
if (!isEditMode) return;
@ -370,43 +372,46 @@ export function addResizeHandle(
}
};
const onMouseUp = async () => {
if (isResizing) {
isResizing = false;
document.body.classList.remove("mocblockRenderer-userselect-none");
const onMouseUp = () => {
// Wrap async logic in an IIFE so the registered handler returns void
(async () => {
if (isResizing) {
isResizing = false;
document.body.classList.remove("mocblockRenderer-userselect-none");
// --- Save new width to the MOC block YAML ---
const file = app.vault.getFileByPath(ctx.sourcePath);
if (!(file instanceof TFile)) return;
// --- Save new width to the MOC block YAML ---
const file = app.vault.getFileByPath(ctx.sourcePath);
if (!(file instanceof TFile)) return;
const content = await app.vault.read(file);
const section = ctx.getSectionInfo(el);
if (!section) return;
const content = await app.vault.read(file);
const section = ctx.getSectionInfo(el);
if (!section) return;
const lines = content.split("\n");
const blockLines = lines.slice(section.lineStart + 1, section.lineEnd);
const lines = content.split("\n");
const blockLines = lines.slice(section.lineStart + 1, section.lineEnd);
let found = false;
for (let i = 0; i < blockLines.length; i++) {
if (blockLines[i].trim().startsWith("image_width:")) {
blockLines[i] = `image_width: ${img.offsetWidth}`;
found = true;
break;
let found = false;
for (let i = 0; i < blockLines.length; i++) {
if (blockLines[i].trim().startsWith("image_width:")) {
blockLines[i] = `image_width: ${img.offsetWidth}`;
found = true;
break;
}
}
if (!found) {
blockLines.push(`image_width: ${img.offsetWidth}`);
}
}
if (!found) {
blockLines.push(`image_width: ${img.offsetWidth}`);
}
const newBlock = ["```moc", ...blockLines, "```"].join("\n");
const newContent = [
...lines.slice(0, section.lineStart),
newBlock,
...lines.slice(section.lineEnd + 1),
].join("\n");
const newBlock = ["```moc", ...blockLines, "```"].join("\n");
const newContent = [
...lines.slice(0, section.lineStart),
newBlock,
...lines.slice(section.lineEnd + 1),
].join("\n");
await app.vault.process(file, () => newContent);
}
await app.vault.process(file, () => newContent);
}
})();
};
parentComponent.registerDomEvent(window, "mousemove", onMouseMove);

View file

@ -22,6 +22,11 @@ export function getIconSVG(iconName: string): string | null {
const el = getIcon(iconName as any) as HTMLElement | null;
if (el && (el as any).outerHTML) return (el as any).outerHTML;
} catch (e) {
// Log and return null when an icon can't be resolved
// (sometimes getIcon throws for missing ids)
// Keep this non-fatal so callers can fallback.
// eslint-disable-next-line no-console
console.warn("getIconSVG failed for", iconName, e);
}
return null;
}

View file

@ -29,19 +29,19 @@ export default class MOCBlockPlugin extends Plugin {
this.addCommand({
id: "insert-mocblock",
name: "Insert MOC Block",
editorCallback: (editor, view) => {
new NewMocBlockModal(this.app, async (mocblockText) => {
editor.replaceSelection(mocblockText);
name: "Insert moc block",
editorCallback: (editor) => {
new NewMocBlockModal(this.app, (mocblockText) => {
editor.replaceSelection(mocblockText);
}).open();
},
});
this.addRibbonIcon("image", "Insert MOC Block", () => {
this.addRibbonIcon("image", "Insert moc block", () => {
const activeView = this.app.workspace.getActiveViewOfType(MarkdownView);
if (!activeView) return;
new NewMocBlockModal(this.app, async (mocblockText) => {
new NewMocBlockModal(this.app, (mocblockText) => {
activeView.editor.replaceSelection(mocblockText);
}).open();
});
@ -63,7 +63,7 @@ export default class MOCBlockPlugin extends Plugin {
}
} // Fix for getting correct view in multi-pane setup, and if page refreshes without being selected (i.e. file explorer clicked)
const isEditMode: boolean = !!(view && typeof view.getMode === "function" && view.getMode() === "source");
const isEditMode = !!(view && typeof view.getMode === "function" && view.getMode() === "source");
// Parse YAML MOC Block Data
let config: any;
@ -79,7 +79,7 @@ export default class MOCBlockPlugin extends Plugin {
} catch (e) {
console.error("Invalid YAML in moc block", e);
el.createEl("pre", { text: "Invalid YAML in MOC block." });
el.createEl("pre", { text: "Invalid yaml in moc block." });
return;
}
// --------------------------------
@ -119,7 +119,7 @@ export default class MOCBlockPlugin extends Plugin {
// moc_id config defined in check if statement above.
const imageRef = config.image;
const imageWidth = config.image_width;
const isFullscreen = config.fullscreen === true || config.fullscreen === "false";
// fullscreen flag currently unused
// debug log, check yaml parsed correctly.
//console.log("Width:", imageWidth);
@ -130,7 +130,7 @@ export default class MOCBlockPlugin extends Plugin {
// Check for image field. Cannot auto-generate, notify user to add one.
if (!imageRef) {
el.createEl("pre", { text: "Missing 'image' field. Cannot create MOC Block." });
el.createEl("pre", { text: "Missing 'image' field. Cannot create moc block." });
return;
}
// --------------------------------
@ -221,8 +221,8 @@ export default class MOCBlockPlugin extends Plugin {
if (isEditMode) {
const actions = container.createEl("div", { cls: "mocblockRenderer-actions-buttons" });
const pinBtn = actions.createEl("button", { text: "+ Pin" });
const polyBtn = actions.createEl("button", { text: "✎ Area" });
const pinBtn = actions.createEl("button", { text: "+ pin" });
const polyBtn = actions.createEl("button", { text: "✎ area" });
// Prepare marker file path for action buttons
const markerFilePath = `${this.settings.dataFolder}/${moc_id}.md`;
@ -320,7 +320,8 @@ export default class MOCBlockPlugin extends Plugin {
await this.saveData(this.settings);
}
async onunload() {
onunload(): void {
// no-op placeholder; keep method non-empty to satisfy lint rules
void 0;
}
}

View file

@ -1,5 +1,5 @@
import { App, Modal, Setting, setIcon, TFile, SuggestModal, Notice, Component } from "obsidian";
import { PinMarker, PolylineMarker, refreshMOCBlock } from "./helpers";
import { App, Modal, Setting, setIcon, TFile, SuggestModal, Notice } from "obsidian";
import { PinMarker, PolylineMarker } from "./helpers";
import { styleNamesSetting } from "./settings";
import { v4 as uuidv4 } from "uuid";
@ -152,10 +152,10 @@ export class NewPinModal extends Modal {
btn.setButtonText("Add pin")
.setCta()
.onClick(async () => {
if (!selectedstyleName || !linkValue.trim()) {
new Notice("All fields are required.");
return;
}
if (!selectedstyleName || !linkValue.trim()) {
new Notice("All fields are required.");
return;
}
const newMarker: PinMarker = {
markerId: uuidv4(),
x: this.percentX,
@ -179,8 +179,8 @@ export class NewPinModal extends Modal {
export class PinEditModal extends Modal {
marker: PinMarker;
onSave: (updated: PinMarker) => void;
onDelete?: (marker: PinMarker) => void;
onSave: (updated: PinMarker) => void | Promise<void>;
onDelete?: (marker: PinMarker) => void | Promise<void>;
styleNames: Record<string, styleNamesSetting>;
onCloseRefresh?: () => void;
@ -188,8 +188,8 @@ export class PinEditModal extends Modal {
app: App,
marker: PinMarker,
styleNames: Record<string, styleNamesSetting>,
onSave: (updated: PinMarker) => void,
onDelete?: (marker: PinMarker) => void
onSave: (updated: PinMarker) => void | Promise<void>,
onDelete?: (marker: PinMarker) => void | Promise<void>
, onCloseRefresh?: () => void
) {
super(app);
@ -262,7 +262,7 @@ export class PinEditModal extends Modal {
setIcon(btn.extraSettingsEl, "trash-2"); // Obsidian's trash icon
btn.extraSettingsEl.setAttr("aria-label", "Delete marker");
btn.extraSettingsEl.classList.add("mocblock-trash-hover");
btn.extraSettingsEl.addEventListener("click", async () => {
btn.extraSettingsEl.addEventListener("click", () => {
if (this.onDelete) {
this.onDelete?.(this.marker as any);
}
@ -367,8 +367,8 @@ export class NewPolylineModal extends Modal {
export class PolylineEditModal extends Modal {
marker: PolylineMarker;
onSave: (updated: PolylineMarker) => void;
onDelete?: (marker: PolylineMarker) => void;
onSave: (updated: PolylineMarker) => void | Promise<void>;
onDelete?: (marker: PolylineMarker) => void | Promise<void>;
styleNames: Record<string, styleNamesSetting>;
onCloseRefresh?: () => void;
@ -376,8 +376,8 @@ export class PolylineEditModal extends Modal {
app: App,
marker: PolylineMarker,
styleNames: Record<string, styleNamesSetting>,
onSave: (updated: PolylineMarker) => void,
onDelete?: (marker: PolylineMarker) => void
onSave: (updated: PolylineMarker) => void | Promise<void>,
onDelete?: (marker: PolylineMarker) => void | Promise<void>
, onCloseRefresh?: () => void
) {
super(app);
@ -450,7 +450,7 @@ export class PolylineEditModal extends Modal {
setIcon(btn.extraSettingsEl, "trash-2");
btn.extraSettingsEl.setAttr("aria-label", "Delete polyline");
btn.extraSettingsEl.classList.add("mocblock-trash-hover");
btn.extraSettingsEl.addEventListener("click", async () => {
btn.extraSettingsEl.addEventListener("click", () => {
if (this.onDelete) {
this.onDelete?.(this.marker as any);
}
@ -477,10 +477,10 @@ export class NewMocBlockModal extends Modal {
onOpen() {
const { contentEl } = this;
// contentEl.createEl("h2", { text: "New MOC Block" });
new Setting(contentEl).setName('New MOC Block').setHeading();
new Setting(contentEl).setName('New moc block').setHeading();
let imageLink = "";
let moc_id = `moc-${Math.random().toString(36).slice(2, 10)}`;
const moc_id = `moc-${Math.random().toString(36).slice(2, 10)}`;
//const imageInput = contentEl.createEl("input", { type: "text", placeholder: "Image path" });
new Setting(contentEl)

View file

@ -43,24 +43,24 @@ export class MOCBlockSettingTab extends PluginSettingTab {
const { containerEl } = this;
containerEl.empty();
//containerEl.createEl("h2", { text: "Data file settings" });
new Setting(containerEl).setName('Data file settings').setHeading();
//new Setting(containerEl).setName('Data file settings').setHeading();
// Add data folder setting
new Setting(containerEl)
.setName("Data folder")
.setDesc("Folder in your vault where marker data files will be stored.")
.addText(text => {
text.setPlaceholder("e.g. MOCData");
text.setValue(this.plugin.settings.dataFolder || "MOCData");
text.setPlaceholder("e.g. mocdata");
text.setValue(this.plugin.settings.dataFolder || "mocdata");
// Track value but don't save yet: annoying workaround to prevent save on every keystroke.
let pendingValue = this.plugin.settings.dataFolder || "MOCData";
let pendingValue = this.plugin.settings.dataFolder || "mocdata";
text.onChange((value) => {
pendingValue = value.trim();
});
text.inputEl.addEventListener("blur", async () => {
const oldPath = normalizePath(this.plugin.settings.dataFolder);
const newPath = normalizePath(pendingValue || "MOCData");
const newPath = normalizePath(pendingValue || "mocdata");
this.plugin.settings.dataFolder = newPath;
await this.plugin.saveSettings();
await renameDataFolder(this.app, oldPath, newPath);
@ -77,7 +77,7 @@ export class MOCBlockSettingTab extends PluginSettingTab {
// ---------------------------------
// containerEl.createEl("h2", { text: "Style settings" });
new Setting(containerEl).setName('Style settings').setHeading();
new Setting(containerEl).setName('Marker & Polyline Styles').setHeading();
// Toggle for opaque pins
new Setting(containerEl)
@ -106,7 +106,7 @@ export class MOCBlockSettingTab extends PluginSettingTab {
});
// Style name (always visible)
const styleNameEl = row.createEl("span", { text: styleName, cls: "mocblock-settings-style-title" });
//const styleNameEl = row.createEl("span", { text: styleName, cls: "mocblock-settings-style-title" });
// Details div (hidden by default)
const detailsDiv = containerEl.createDiv({ cls: "mocblock-settings-style-details" });
@ -199,7 +199,7 @@ export class MOCBlockSettingTab extends PluginSettingTab {
// Style input
addSetting.addText(text => {
text.setPlaceholder("e.g. Style1");
text.setPlaceholder("e.g. style1");
text.onChange(value => { styleValue = value; });
});

View file

@ -11,6 +11,7 @@
"importHelpers": true,
"isolatedModules": true,
"strictNullChecks": true,
"skipLibCheck": true,
"lib": [
"DOM",
"ES5",