From 122080a873de2b7c18806c85aef176264a99c93d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yingyi=20/=20=E9=A2=96=E9=80=B8?= <49649786+Zuoqiu-Yingyi@users.noreply.github.com> Date: Fri, 29 May 2026 12:11:19 +0800 Subject: [PATCH 1/5] chore: update TypeScript and related dependencies; add SCSS module declarations --- package.json | 6 +- pnpm-lock.yaml | 158 +++++++++++++++++++----------------------- src/declarations.d.ts | 4 ++ src/index.ts | 36 +++++----- 4 files changed, 98 insertions(+), 106 deletions(-) create mode 100644 src/declarations.d.ts diff --git a/package.json b/package.json index b7f58db..c927dd8 100644 --- a/package.json +++ b/package.json @@ -31,12 +31,12 @@ "mini-css-extract-plugin": "^2.10.2", "npm-run-all": "^4.1.5", "sass": "^1.100.0", - "sass-loader": "^16.0.8", + "sass-loader": "^17.0.0", "siyuan": "1.2.2-alpha.0", "tslib": "^2.8.1", - "typescript": "^4.9.5", + "typescript": "^5.9.3", "webpack": "^5.107.2", - "webpack-cli": "^7.0.2", + "webpack-cli": "^7.0.3", "zip-webpack-plugin": "^4.0.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7bf1944..54b176e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,10 +16,10 @@ importers: version: 10.0.1(eslint@10.4.0) '@typescript-eslint/eslint-plugin': specifier: ^8.60.0 - version: 8.60.0(@typescript-eslint/parser@8.60.0(eslint@10.4.0)(typescript@4.9.5))(eslint@10.4.0)(typescript@4.9.5) + version: 8.60.0(@typescript-eslint/parser@8.60.0(eslint@10.4.0)(typescript@5.9.3))(eslint@10.4.0)(typescript@5.9.3) '@typescript-eslint/parser': specifier: ^8.60.0 - version: 8.60.0(eslint@10.4.0)(typescript@4.9.5) + version: 8.60.0(eslint@10.4.0)(typescript@5.9.3) copy-webpack-plugin: specifier: ^14.0.0 version: 14.0.0(webpack@5.107.2) @@ -48,8 +48,8 @@ importers: specifier: ^1.100.0 version: 1.100.0 sass-loader: - specifier: ^16.0.8 - version: 16.0.8(sass@1.100.0)(webpack@5.107.2) + specifier: ^17.0.0 + version: 17.0.0(sass@1.100.0)(webpack@5.107.2) siyuan: specifier: 1.2.2-alpha.0 version: 1.2.2-alpha.0 @@ -57,14 +57,14 @@ importers: specifier: ^2.8.1 version: 2.8.1 typescript: - specifier: ^4.9.5 - version: 4.9.5 + specifier: ^5.9.3 + version: 5.9.3 webpack: specifier: ^5.107.2 - version: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.2) + version: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.3) webpack-cli: - specifier: ^7.0.2 - version: 7.0.2(webpack@5.107.2) + specifier: ^7.0.3 + version: 7.0.3(webpack@5.107.2) zip-webpack-plugin: specifier: ^4.0.3 version: 4.0.3(webpack-sources@3.5.0)(webpack@5.107.2) @@ -808,8 +808,8 @@ packages: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} - electron-to-chromium@1.5.361: - resolution: {integrity: sha512-Q6Hts7N9FnJc5LeGRINFvLhCI9xZmNtTDe5ZbcVezQz7cU4a8Aua3GH1b8J2XY8Al9PF+OCwYqhgsOOheMdvkA==} + electron-to-chromium@1.5.363: + resolution: {integrity: sha512-VjUKPyWzGnT1fujlkEGC/BvN70Hh70KXtAqcmniXviYlJC/ivcT+BWGPyxWVbJZLfvtKR6dqg1L7T7pgAMBtWA==} emojis-list@3.0.0: resolution: {integrity: sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==} @@ -950,10 +950,6 @@ packages: fast-uri@3.1.2: resolution: {integrity: sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ==} - fastest-levenshtein@1.0.16: - resolution: {integrity: sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==} - engines: {node: '>= 4.9.1'} - fdir@6.5.0: resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} engines: {node: '>=12.0.0'} @@ -1543,20 +1539,17 @@ packages: resolution: {integrity: sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==} engines: {node: '>= 0.4'} - sass-loader@16.0.8: - resolution: {integrity: sha512-hcov4ZwZJIGbEuyNr9EmiTmZueyrxSToE6GOzoZnq5JM7ecRO7ttyvilPn+VmRsqiP16+VYZzVnGZj/hzZgKBA==} - engines: {node: '>= 18.12.0'} + sass-loader@17.0.0: + resolution: {integrity: sha512-0Ybm8ohBQ9LcrycVrFQp/KQBNX5a3Wda9/smS0mE/xLffzEnwvV8nykOzrbiSWNzTE3IB/jiXx8O4QmDPG2+Gw==} + engines: {node: '>= 22.11.0'} peerDependencies: '@rspack/core': 0.x || ^1.0.0 || ^2.0.0-0 - node-sass: ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 sass: ^1.3.0 sass-embedded: '*' webpack: ^5.0.0 peerDependenciesMeta: '@rspack/core': optional: true - node-sass: - optional: true sass: optional: true sass-embedded: @@ -1708,8 +1701,8 @@ packages: resolution: {integrity: sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==} engines: {node: '>=6'} - terser-webpack-plugin@5.6.0: - resolution: {integrity: sha512-Eum+5ajkaOhf5KbM26osvv21kLD7BaGqQ1UA4Ami4arYwylmGUQTgHFpHDdmJod1q4QXa66p0to/FBKID+J1vA==} + terser-webpack-plugin@5.6.1: + resolution: {integrity: sha512-201R5j+sJpK8nFWwKVyNfZot8FaJbLZDq5evriVzbV1wDtSXDjRUDRfJzHpAaxFDMEhsZL1QkeqM61wgsS3KaQ==} engines: {node: '>= 10.13.0'} peerDependencies: '@minify-html/node': '*' @@ -1789,9 +1782,9 @@ packages: resolution: {integrity: sha512-3KS2b+kL7fsuk/eJZ7EQdnEmQoaho/r6KUef7hxvltNA5DR8NAUM+8wJMbJyZ4G9/7i3v5zPBIMN5aybAh2/Jg==} engines: {node: '>= 0.4'} - typescript@4.9.5: - resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} - engines: {node: '>=4.2.0'} + typescript@5.9.3: + resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} + engines: {node: '>=14.17'} hasBin: true unbox-primitive@1.1.0: @@ -1820,8 +1813,8 @@ packages: resolution: {integrity: sha512-Zn5uXdcFNIA1+1Ei5McRd+iRzfhENPCe7LeABkJtNulSxjma+l7ltNx55BWZkRlwRnpOgHqxnjyaDgJnNXnqzg==} engines: {node: '>=10.13.0'} - webpack-cli@7.0.2: - resolution: {integrity: sha512-dB0R4T+C/8YuvM+fabdvil6QE44/ChDXikV5lOOkrUeCkW5hTJv2pGLE3keh+D5hjYw8icBaJkZzpFoaHV4T+g==} + webpack-cli@7.0.3: + resolution: {integrity: sha512-2E2C6A1e2El7791zQgTH7LPIuwLjRliow9OHS/qlJc9pwhZlCoL/uiwqd/1WSlXT83wJfmfDbkcqHXuXoPJZ3g==} engines: {node: '>=20.9.0'} hasBin: true peerDependencies: @@ -1864,8 +1857,8 @@ packages: resolution: {integrity: sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==} engines: {node: '>= 0.4'} - which-typed-array@1.1.20: - resolution: {integrity: sha512-LYfpUkmqwl0h9A2HL09Mms427Q1RZWuOHsukfVcKRq9q95iQxdw0ix1JQrqbcDR9PH1QDwf5Qo8OZb5lksZ8Xg==} + which-typed-array@1.1.21: + resolution: {integrity: sha512-zbRA8cVm6io/d5W8uIe2hblzN76/Wm3v/yiythQvr+dpBWeqhPSWIDNj4zOyHi4zKbMK6DN34Xsr9jPHJERAEw==} engines: {node: '>= 0.4'} which@1.3.1: @@ -2176,40 +2169,40 @@ snapshots: dependencies: undici-types: 7.24.6 - '@typescript-eslint/eslint-plugin@8.60.0(@typescript-eslint/parser@8.60.0(eslint@10.4.0)(typescript@4.9.5))(eslint@10.4.0)(typescript@4.9.5)': + '@typescript-eslint/eslint-plugin@8.60.0(@typescript-eslint/parser@8.60.0(eslint@10.4.0)(typescript@5.9.3))(eslint@10.4.0)(typescript@5.9.3)': dependencies: '@eslint-community/regexpp': 4.12.2 - '@typescript-eslint/parser': 8.60.0(eslint@10.4.0)(typescript@4.9.5) + '@typescript-eslint/parser': 8.60.0(eslint@10.4.0)(typescript@5.9.3) '@typescript-eslint/scope-manager': 8.60.0 - '@typescript-eslint/type-utils': 8.60.0(eslint@10.4.0)(typescript@4.9.5) - '@typescript-eslint/utils': 8.60.0(eslint@10.4.0)(typescript@4.9.5) + '@typescript-eslint/type-utils': 8.60.0(eslint@10.4.0)(typescript@5.9.3) + '@typescript-eslint/utils': 8.60.0(eslint@10.4.0)(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.60.0 eslint: 10.4.0 ignore: 7.0.5 natural-compare: 1.4.0 - ts-api-utils: 2.5.0(typescript@4.9.5) - typescript: 4.9.5 + ts-api-utils: 2.5.0(typescript@5.9.3) + typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.60.0(eslint@10.4.0)(typescript@4.9.5)': + '@typescript-eslint/parser@8.60.0(eslint@10.4.0)(typescript@5.9.3)': dependencies: '@typescript-eslint/scope-manager': 8.60.0 '@typescript-eslint/types': 8.60.0 - '@typescript-eslint/typescript-estree': 8.60.0(typescript@4.9.5) + '@typescript-eslint/typescript-estree': 8.60.0(typescript@5.9.3) '@typescript-eslint/visitor-keys': 8.60.0 debug: 4.4.3 eslint: 10.4.0 - typescript: 4.9.5 + typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/project-service@8.60.0(typescript@4.9.5)': + '@typescript-eslint/project-service@8.60.0(typescript@5.9.3)': dependencies: - '@typescript-eslint/tsconfig-utils': 8.60.0(typescript@4.9.5) + '@typescript-eslint/tsconfig-utils': 8.60.0(typescript@5.9.3) '@typescript-eslint/types': 8.60.0 debug: 4.4.3 - typescript: 4.9.5 + typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -2218,47 +2211,47 @@ snapshots: '@typescript-eslint/types': 8.60.0 '@typescript-eslint/visitor-keys': 8.60.0 - '@typescript-eslint/tsconfig-utils@8.60.0(typescript@4.9.5)': + '@typescript-eslint/tsconfig-utils@8.60.0(typescript@5.9.3)': dependencies: - typescript: 4.9.5 + typescript: 5.9.3 - '@typescript-eslint/type-utils@8.60.0(eslint@10.4.0)(typescript@4.9.5)': + '@typescript-eslint/type-utils@8.60.0(eslint@10.4.0)(typescript@5.9.3)': dependencies: '@typescript-eslint/types': 8.60.0 - '@typescript-eslint/typescript-estree': 8.60.0(typescript@4.9.5) - '@typescript-eslint/utils': 8.60.0(eslint@10.4.0)(typescript@4.9.5) + '@typescript-eslint/typescript-estree': 8.60.0(typescript@5.9.3) + '@typescript-eslint/utils': 8.60.0(eslint@10.4.0)(typescript@5.9.3) debug: 4.4.3 eslint: 10.4.0 - ts-api-utils: 2.5.0(typescript@4.9.5) - typescript: 4.9.5 + ts-api-utils: 2.5.0(typescript@5.9.3) + typescript: 5.9.3 transitivePeerDependencies: - supports-color '@typescript-eslint/types@8.60.0': {} - '@typescript-eslint/typescript-estree@8.60.0(typescript@4.9.5)': + '@typescript-eslint/typescript-estree@8.60.0(typescript@5.9.3)': dependencies: - '@typescript-eslint/project-service': 8.60.0(typescript@4.9.5) - '@typescript-eslint/tsconfig-utils': 8.60.0(typescript@4.9.5) + '@typescript-eslint/project-service': 8.60.0(typescript@5.9.3) + '@typescript-eslint/tsconfig-utils': 8.60.0(typescript@5.9.3) '@typescript-eslint/types': 8.60.0 '@typescript-eslint/visitor-keys': 8.60.0 debug: 4.4.3 minimatch: 10.2.5 semver: 7.8.1 tinyglobby: 0.2.16 - ts-api-utils: 2.5.0(typescript@4.9.5) - typescript: 4.9.5 + ts-api-utils: 2.5.0(typescript@5.9.3) + typescript: 5.9.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.60.0(eslint@10.4.0)(typescript@4.9.5)': + '@typescript-eslint/utils@8.60.0(eslint@10.4.0)(typescript@5.9.3)': dependencies: '@eslint-community/eslint-utils': 4.9.1(eslint@10.4.0) '@typescript-eslint/scope-manager': 8.60.0 '@typescript-eslint/types': 8.60.0 - '@typescript-eslint/typescript-estree': 8.60.0(typescript@4.9.5) + '@typescript-eslint/typescript-estree': 8.60.0(typescript@5.9.3) eslint: 10.4.0 - typescript: 4.9.5 + typescript: 5.9.3 transitivePeerDependencies: - supports-color @@ -2428,7 +2421,7 @@ snapshots: dependencies: baseline-browser-mapping: 2.10.32 caniuse-lite: 1.0.30001793 - electron-to-chromium: 1.5.361 + electron-to-chromium: 1.5.363 node-releases: 2.0.46 update-browserslist-db: 1.2.3(browserslist@4.28.2) @@ -2494,7 +2487,7 @@ snapshots: schema-utils: 4.3.3 serialize-javascript: 7.0.5 tinyglobby: 0.2.16 - webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.2) + webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.3) cross-spawn@6.0.6: dependencies: @@ -2521,7 +2514,7 @@ snapshots: postcss-value-parser: 4.2.0 semver: 7.8.1 optionalDependencies: - webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.2) + webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.3) cssesc@3.0.0: {} @@ -2584,7 +2577,7 @@ snapshots: es-errors: 1.3.0 gopd: 1.2.0 - electron-to-chromium@1.5.361: {} + electron-to-chromium@1.5.363: {} emojis-list@3.0.0: {} @@ -2654,7 +2647,7 @@ snapshots: typed-array-byte-offset: 1.0.4 typed-array-length: 1.0.7 unbox-primitive: 1.1.0 - which-typed-array: 1.1.20 + which-typed-array: 1.1.21 es-define-property@1.0.1: {} @@ -2684,7 +2677,7 @@ snapshots: esbuild: 0.27.7 get-tsconfig: 4.14.0 loader-utils: 2.0.4 - webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.2) + webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.3) webpack-sources: 3.5.0 esbuild@0.27.7: @@ -2811,8 +2804,6 @@ snapshots: fast-uri@3.1.2: {} - fastest-levenshtein@1.0.16: {} - fdir@6.5.0(picomatch@4.0.4): optionalDependencies: picomatch: 4.0.4 @@ -3061,7 +3052,7 @@ snapshots: is-typed-array@1.1.15: dependencies: - which-typed-array: 1.1.20 + which-typed-array: 1.1.21 is-weakmap@2.0.2: {} @@ -3148,7 +3139,7 @@ snapshots: dependencies: schema-utils: 4.3.3 tapable: 2.3.3 - webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.2) + webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.3) minimatch@10.2.5: dependencies: @@ -3383,12 +3374,10 @@ snapshots: es-errors: 1.3.0 is-regex: 1.2.1 - sass-loader@16.0.8(sass@1.100.0)(webpack@5.107.2): - dependencies: - neo-async: 2.6.2 + sass-loader@17.0.0(sass@1.100.0)(webpack@5.107.2): optionalDependencies: sass: 1.100.0 - webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.2) + webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.3) sass@1.100.0: dependencies: @@ -3559,13 +3548,13 @@ snapshots: tapable@2.3.3: {} - terser-webpack-plugin@5.6.0(postcss@8.5.15)(webpack@5.107.2): + terser-webpack-plugin@5.6.1(postcss@8.5.15)(webpack@5.107.2): dependencies: '@jridgewell/trace-mapping': 0.3.31 jest-worker: 27.5.1 schema-utils: 4.3.3 terser: 5.48.0 - webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.2) + webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.3) optionalDependencies: postcss: 8.5.15 @@ -3581,9 +3570,9 @@ snapshots: fdir: 6.5.0(picomatch@4.0.4) picomatch: 4.0.4 - ts-api-utils@2.5.0(typescript@4.9.5): + ts-api-utils@2.5.0(typescript@5.9.3): dependencies: - typescript: 4.9.5 + typescript: 5.9.3 tslib@2.8.1: {} @@ -3624,7 +3613,7 @@ snapshots: possible-typed-array-names: 1.1.0 reflect.getprototypeof: 1.0.10 - typescript@4.9.5: {} + typescript@5.9.3: {} unbox-primitive@1.1.0: dependencies: @@ -3657,17 +3646,16 @@ snapshots: glob-to-regexp: 0.4.1 graceful-fs: 4.2.11 - webpack-cli@7.0.2(webpack@5.107.2): + webpack-cli@7.0.3(webpack@5.107.2): dependencies: '@discoveryjs/json-ext': 1.1.0 commander: 14.0.3 cross-spawn: 7.0.6 envinfo: 7.21.0 - fastest-levenshtein: 1.0.16 import-local: 3.2.0 interpret: 3.1.1 rechoir: 0.8.0 - webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.2) + webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.3) webpack-merge: 6.0.1 webpack-merge@6.0.1: @@ -3678,7 +3666,7 @@ snapshots: webpack-sources@3.5.0: {} - webpack@5.107.2(postcss@8.5.15)(webpack-cli@7.0.2): + webpack@5.107.2(postcss@8.5.15)(webpack-cli@7.0.3): dependencies: '@types/estree': 1.0.9 '@types/json-schema': 7.0.15 @@ -3700,11 +3688,11 @@ snapshots: neo-async: 2.6.2 schema-utils: 4.3.3 tapable: 2.3.3 - terser-webpack-plugin: 5.6.0(postcss@8.5.15)(webpack@5.107.2) + terser-webpack-plugin: 5.6.1(postcss@8.5.15)(webpack@5.107.2) watchpack: 2.5.1 webpack-sources: 3.5.0 optionalDependencies: - webpack-cli: 7.0.2(webpack@5.107.2) + webpack-cli: 7.0.3(webpack@5.107.2) transitivePeerDependencies: - '@minify-html/node' - '@swc/core' @@ -3741,7 +3729,7 @@ snapshots: isarray: 2.0.5 which-boxed-primitive: 1.1.1 which-collection: 1.0.2 - which-typed-array: 1.1.20 + which-typed-array: 1.1.21 which-collection@1.0.2: dependencies: @@ -3750,7 +3738,7 @@ snapshots: is-weakmap: 2.0.2 is-weakset: 2.0.4 - which-typed-array@1.1.20: + which-typed-array@1.1.21: dependencies: available-typed-arrays: 1.0.7 call-bind: 1.0.9 @@ -3780,6 +3768,6 @@ snapshots: zip-webpack-plugin@4.0.3(webpack-sources@3.5.0)(webpack@5.107.2): dependencies: - webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.2) + webpack: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.3) webpack-sources: 3.5.0 yazl: 2.5.1 diff --git a/src/declarations.d.ts b/src/declarations.d.ts new file mode 100644 index 0000000..e0ceb0e --- /dev/null +++ b/src/declarations.d.ts @@ -0,0 +1,4 @@ +declare module "*.scss" { + const content: Record; + export default content; +} diff --git a/src/index.ts b/src/index.ts index 203b778..1071057 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,8 +38,8 @@ const TAB_TYPE = "custom_tab"; const DOCK_TYPE = "dock_tab"; export default class PluginSample extends Plugin { - private custom: () => Custom; - private isMobile: boolean; + private custom!: () => Custom; + private isMobile!: boolean; private blockIconEventBindThis = this.blockIconEvent.bind(this); updateProtyleToolbar(toolbar: Array) { @@ -231,10 +231,10 @@ export default class PluginSample extends Plugin { let rect = topBarElement.getBoundingClientRect(); // 如果被隐藏,则使用更多按钮 if (rect.width === 0) { - rect = document.querySelector("#barMore").getBoundingClientRect(); + rect = document.querySelector("#barMore")!.getBoundingClientRect(); } if (rect.width === 0) { - rect = document.querySelector("#barPlugins").getBoundingClientRect(); + rect = document.querySelector("#barPlugins")!.getBoundingClientRect(); } this.addMenu(rect); } @@ -246,7 +246,7 @@ export default class PluginSample extends Plugin { `; - statusIconTemp.content.firstElementChild.addEventListener("click", () => { + statusIconTemp.content.firstElementChild!.addEventListener("click", () => { confirm("⚠️", this.i18n.confirmRemove.replace("${name}", this.name), () => { this.removeData(STORAGE_NAME).then(() => { this.data[STORAGE_NAME] = {readonlyText: "Readonly"}; @@ -442,11 +442,11 @@ export default class PluginSample extends Plugin { width: this.isMobile ? "92vw" : "560px", height: "540px", }); - new Protyle(this.app, dialog.element.querySelector("#protyle"), { - blockId: this.getEditor().protyle.block.rootID, + new Protyle(this.app, dialog.element.querySelector("#protyle")!, { + blockId: this.getEditor()!.protyle.block.rootID, }); fetchPost("/api/system/currentTime", {}, (response) => { - dialog.element.querySelector("#time").innerHTML = new Date(response.data).toString(); + dialog.element.querySelector("#time")!.innerHTML = new Date(response.data).toString(); }); } @@ -466,8 +466,8 @@ export default class PluginSample extends Plugin { label: "Open Attribute Panel", click: () => { openAttributePanel({ - nodeElement: this.getEditor().protyle.wysiwyg.element.firstElementChild as HTMLElement, - protyle: this.getEditor().protyle, + nodeElement: this.getEditor()!.protyle!.wysiwyg!.element.firstElementChild! as HTMLElement, + protyle: this.getEditor()!.protyle!, focusName: "custom", }); }, @@ -485,8 +485,8 @@ export default class PluginSample extends Plugin { label: "Select Opened Doc(open doc first)", click: () => { (getModelByDockType("file") as Files).selectItem( - this.getEditor().protyle.notebookId, - this.getEditor().protyle.path, + this.getEditor()!.protyle.notebookId!, + this.getEditor()!.protyle.path!, ); }, }); @@ -529,7 +529,7 @@ export default class PluginSample extends Plugin { const tab = await openTab({ app: this.app, doc: { - id: this.getEditor().protyle.block.rootID, + id: this.getEditor()!.protyle.block.rootID!, }, }); console.log(tab); @@ -566,7 +566,7 @@ export default class PluginSample extends Plugin { label: "Open Float Layer(open doc first)", click: () => { this.addFloatLayer({ - refDefs: [{refID: this.getEditor().protyle.block.rootID}], + refDefs: [{refID: this.getEditor()!.protyle.block.rootID!}], x: window.innerWidth - 768 - 120, y: 32, isBacklink: false, @@ -578,7 +578,7 @@ export default class PluginSample extends Plugin { label: "Open Doc Window(open doc first)", click: () => { openWindow({ - doc: {id: this.getEditor().protyle.block.rootID}, + doc: {id: this.getEditor()!.protyle.block.rootID!}, }); }, }); @@ -587,7 +587,7 @@ export default class PluginSample extends Plugin { icon: "iconFile", label: "Open Doc(open doc first)", click: () => { - openMobileFileById(this.app, this.getEditor().protyle.block.rootID); + openMobileFileById(this.app, this.getEditor()!.protyle.block.rootID!); }, }); } @@ -966,8 +966,8 @@ export default class PluginSample extends Plugin { menu.fullscreen(); } else { menu.open({ - x: rect.right, - y: rect.bottom, + x: rect!.right, + y: rect!.bottom, isLeft: true, }); } From 287c882ac88910f68ec55b860e02d78e85b8284a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yingyi=20/=20=E9=A2=96=E9=80=B8?= <49649786+Zuoqiu-Yingyi@users.noreply.github.com> Date: Sat, 30 May 2026 20:00:16 +0800 Subject: [PATCH 2/5] chore: update TypeScript configuration and improve null checks in plugin methods --- package.json | 4 ++++ src/index.ts | 33 +++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index c927dd8..98ea4dc 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,10 @@ "keywords": [], "author": "Vanessa", "license": "MIT", + "packageManager": "pnpm@11.4.0", + "engines": { + "node": ">=24.0.0" + }, "devDependencies": { "@eslint/eslintrc": "^3.3.5", "@eslint/js": "^10.0.1", diff --git a/src/index.ts b/src/index.ts index 1071057..1175d70 100644 --- a/src/index.ts +++ b/src/index.ts @@ -443,10 +443,13 @@ export default class PluginSample extends Plugin { height: "540px", }); new Protyle(this.app, dialog.element.querySelector("#protyle")!, { - blockId: this.getEditor()!.protyle.block.rootID, + blockId: this.getEditor()?.protyle.block.rootID, }); fetchPost("/api/system/currentTime", {}, (response) => { - dialog.element.querySelector("#time")!.innerHTML = new Date(response.data).toString(); + const time = dialog.element.querySelector("#time"); + if (time) { + time.textContent = response.data.currentTime; + } }); } @@ -466,8 +469,8 @@ export default class PluginSample extends Plugin { label: "Open Attribute Panel", click: () => { openAttributePanel({ - nodeElement: this.getEditor()!.protyle!.wysiwyg!.element.firstElementChild! as HTMLElement, - protyle: this.getEditor()!.protyle!, + nodeElement: this.getEditor()?.protyle?.wysiwyg?.element.firstElementChild as HTMLElement, + protyle: this.getEditor()?.protyle, focusName: "custom", }); }, @@ -484,9 +487,11 @@ export default class PluginSample extends Plugin { icon: "iconFocus", label: "Select Opened Doc(open doc first)", click: () => { + const protyle = this.getEditor()?.protyle; + if (protyle?.notebookId == null || protyle?.path == null) return; (getModelByDockType("file") as Files).selectItem( - this.getEditor()!.protyle.notebookId!, - this.getEditor()!.protyle.path!, + protyle.notebookId, + protyle.path!, ); }, }); @@ -526,10 +531,12 @@ export default class PluginSample extends Plugin { icon: "iconFile", label: "Open Doc Tab(open doc first)", click: async () => { + const rootID = this.getEditor()?.protyle.block.rootID; + if (rootID == null) return; const tab = await openTab({ app: this.app, doc: { - id: this.getEditor()!.protyle.block.rootID!, + id: rootID!, }, }); console.log(tab); @@ -565,8 +572,10 @@ export default class PluginSample extends Plugin { icon: "iconLayout", label: "Open Float Layer(open doc first)", click: () => { + const rootID = this.getEditor()?.protyle.block.rootID; + if (rootID == null) return; this.addFloatLayer({ - refDefs: [{refID: this.getEditor()!.protyle.block.rootID!}], + refDefs: [{refID: rootID}], x: window.innerWidth - 768 - 120, y: 32, isBacklink: false, @@ -577,8 +586,10 @@ export default class PluginSample extends Plugin { icon: "iconOpenWindow", label: "Open Doc Window(open doc first)", click: () => { + const rootID = this.getEditor()?.protyle.block.rootID; + if (rootID == null) return; openWindow({ - doc: {id: this.getEditor()!.protyle.block.rootID!}, + doc: {id: rootID}, }); }, }); @@ -587,7 +598,9 @@ export default class PluginSample extends Plugin { icon: "iconFile", label: "Open Doc(open doc first)", click: () => { - openMobileFileById(this.app, this.getEditor()!.protyle.block.rootID!); + const rootID = this.getEditor()?.protyle.block.rootID; + if (rootID == null) return; + openMobileFileById(this.app, rootID); }, }); } From 947ca9d4c8c4cbd6c978e4ad593d2e16801c354c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yingyi=20/=20=E9=A2=96=E9=80=B8?= <49649786+Zuoqiu-Yingyi@users.noreply.github.com> Date: Sat, 30 May 2026 20:02:45 +0800 Subject: [PATCH 3/5] chore: update TypeScript to 6.0.3 and add kernel.js to ESLint ignore list --- eslint.config.mjs | 1 + package.json | 2 +- pnpm-lock.yaml | 124 +++++++++++++++++++++++----------------------- src/kernel.ts | 2 - 4 files changed, 64 insertions(+), 65 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 8841304..e86f80b 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -20,6 +20,7 @@ export default [ "dist", "node_modules", "index.js", + "kernel.js", ], }, ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"), diff --git a/package.json b/package.json index 98ea4dc..4998ebc 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "sass-loader": "^17.0.0", "siyuan": "1.2.2-alpha.0", "tslib": "^2.8.1", - "typescript": "^5.9.3", + "typescript": "^6.0.3", "webpack": "^5.107.2", "webpack-cli": "^7.0.3", "zip-webpack-plugin": "^4.0.3" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 54b176e..f1c44cc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,10 +16,10 @@ importers: version: 10.0.1(eslint@10.4.0) '@typescript-eslint/eslint-plugin': specifier: ^8.60.0 - version: 8.60.0(@typescript-eslint/parser@8.60.0(eslint@10.4.0)(typescript@5.9.3))(eslint@10.4.0)(typescript@5.9.3) + version: 8.60.0(@typescript-eslint/parser@8.60.0(eslint@10.4.0)(typescript@6.0.3))(eslint@10.4.0)(typescript@6.0.3) '@typescript-eslint/parser': specifier: ^8.60.0 - version: 8.60.0(eslint@10.4.0)(typescript@5.9.3) + version: 8.60.0(eslint@10.4.0)(typescript@6.0.3) copy-webpack-plugin: specifier: ^14.0.0 version: 14.0.0(webpack@5.107.2) @@ -57,8 +57,8 @@ importers: specifier: ^2.8.1 version: 2.8.1 typescript: - specifier: ^5.9.3 - version: 5.9.3 + specifier: ^6.0.3 + version: 6.0.3 webpack: specifier: ^5.107.2 version: 5.107.2(postcss@8.5.15)(webpack-cli@7.0.3) @@ -808,15 +808,15 @@ packages: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} - electron-to-chromium@1.5.363: - resolution: {integrity: sha512-VjUKPyWzGnT1fujlkEGC/BvN70Hh70KXtAqcmniXviYlJC/ivcT+BWGPyxWVbJZLfvtKR6dqg1L7T7pgAMBtWA==} + electron-to-chromium@1.5.364: + resolution: {integrity: sha512-G/dYE3+AYhyHwzTwg8UbnXf7zqMERYh7l2jJ3QujhFsH8agSYwtnGAR2aZ7f0AakIKJXd5En/Hre4igIUrdlYw==} emojis-list@3.0.0: resolution: {integrity: sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==} engines: {node: '>= 4'} - enhanced-resolve@5.22.0: - resolution: {integrity: sha512-xYcDWrpELkFzz9SpZ3PlI6Eu6eD93Yf0WLDRxikGhWJ3MAir2SNZTIVCVZqZ/NUyx8AdMc2gT9C0gPiw18kG+A==} + enhanced-resolve@5.22.1: + resolution: {integrity: sha512-6QEuw3zoX1SJQc7b87aBXke/no+mG2bTBgw29gWMQonLmpEkWoCAVkl+M49e48AZlWzxiDzDZzYdp6kobcyLww==} engines: {node: '>=10.13.0'} envinfo@7.21.0: @@ -1068,8 +1068,8 @@ packages: resolution: {integrity: sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==} engines: {node: '>= 0.4'} - hasown@2.0.3: - resolution: {integrity: sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==} + hasown@2.0.4: + resolution: {integrity: sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==} engines: {node: '>= 0.4'} hosted-git-info@2.8.9: @@ -1089,8 +1089,8 @@ packages: resolution: {integrity: sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==} engines: {node: '>= 4'} - immutable@5.1.5: - resolution: {integrity: sha512-t7xcm2siw+hlUM68I+UEOK+z84RzmN59as9DZ7P1l0994DKUWV7UXBMQZVxaoMSRQ+PBZbHCOoBt7a2wxOMt+A==} + immutable@5.1.6: + resolution: {integrity: sha512-q1swsS8K7L8usSHuOqF2TAoCCkonYz0SG38wLAggaa4Wml70zixIvt2ql4coQ2C2B3hTjltJry4r6bULwgAXLQ==} import-fresh@3.3.1: resolution: {integrity: sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==} @@ -1778,12 +1778,12 @@ packages: resolution: {integrity: sha512-bTlAFB/FBYMcuX81gbL4OcpH5PmlFHqlCCpAl8AlEzMz5k53oNDvN8p1PNOWLEmI2x4orp3raOFB51tv9X+MFQ==} engines: {node: '>= 0.4'} - typed-array-length@1.0.7: - resolution: {integrity: sha512-3KS2b+kL7fsuk/eJZ7EQdnEmQoaho/r6KUef7hxvltNA5DR8NAUM+8wJMbJyZ4G9/7i3v5zPBIMN5aybAh2/Jg==} + typed-array-length@1.0.8: + resolution: {integrity: sha512-phPGCwqr2+Qo0fwniCE8e4pKnGu/yFb5nD5Y8bf0EEeiI5GklnACYA9GFy/DrAeRrKHXvHn+1SUsOWgJp6RO+g==} engines: {node: '>= 0.4'} - typescript@5.9.3: - resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} + typescript@6.0.3: + resolution: {integrity: sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==} engines: {node: '>=14.17'} hasBin: true @@ -2169,40 +2169,40 @@ snapshots: dependencies: undici-types: 7.24.6 - '@typescript-eslint/eslint-plugin@8.60.0(@typescript-eslint/parser@8.60.0(eslint@10.4.0)(typescript@5.9.3))(eslint@10.4.0)(typescript@5.9.3)': + '@typescript-eslint/eslint-plugin@8.60.0(@typescript-eslint/parser@8.60.0(eslint@10.4.0)(typescript@6.0.3))(eslint@10.4.0)(typescript@6.0.3)': dependencies: '@eslint-community/regexpp': 4.12.2 - '@typescript-eslint/parser': 8.60.0(eslint@10.4.0)(typescript@5.9.3) + '@typescript-eslint/parser': 8.60.0(eslint@10.4.0)(typescript@6.0.3) '@typescript-eslint/scope-manager': 8.60.0 - '@typescript-eslint/type-utils': 8.60.0(eslint@10.4.0)(typescript@5.9.3) - '@typescript-eslint/utils': 8.60.0(eslint@10.4.0)(typescript@5.9.3) + '@typescript-eslint/type-utils': 8.60.0(eslint@10.4.0)(typescript@6.0.3) + '@typescript-eslint/utils': 8.60.0(eslint@10.4.0)(typescript@6.0.3) '@typescript-eslint/visitor-keys': 8.60.0 eslint: 10.4.0 ignore: 7.0.5 natural-compare: 1.4.0 - ts-api-utils: 2.5.0(typescript@5.9.3) - typescript: 5.9.3 + ts-api-utils: 2.5.0(typescript@6.0.3) + typescript: 6.0.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.60.0(eslint@10.4.0)(typescript@5.9.3)': + '@typescript-eslint/parser@8.60.0(eslint@10.4.0)(typescript@6.0.3)': dependencies: '@typescript-eslint/scope-manager': 8.60.0 '@typescript-eslint/types': 8.60.0 - '@typescript-eslint/typescript-estree': 8.60.0(typescript@5.9.3) + '@typescript-eslint/typescript-estree': 8.60.0(typescript@6.0.3) '@typescript-eslint/visitor-keys': 8.60.0 debug: 4.4.3 eslint: 10.4.0 - typescript: 5.9.3 + typescript: 6.0.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/project-service@8.60.0(typescript@5.9.3)': + '@typescript-eslint/project-service@8.60.0(typescript@6.0.3)': dependencies: - '@typescript-eslint/tsconfig-utils': 8.60.0(typescript@5.9.3) + '@typescript-eslint/tsconfig-utils': 8.60.0(typescript@6.0.3) '@typescript-eslint/types': 8.60.0 debug: 4.4.3 - typescript: 5.9.3 + typescript: 6.0.3 transitivePeerDependencies: - supports-color @@ -2211,47 +2211,47 @@ snapshots: '@typescript-eslint/types': 8.60.0 '@typescript-eslint/visitor-keys': 8.60.0 - '@typescript-eslint/tsconfig-utils@8.60.0(typescript@5.9.3)': + '@typescript-eslint/tsconfig-utils@8.60.0(typescript@6.0.3)': dependencies: - typescript: 5.9.3 + typescript: 6.0.3 - '@typescript-eslint/type-utils@8.60.0(eslint@10.4.0)(typescript@5.9.3)': + '@typescript-eslint/type-utils@8.60.0(eslint@10.4.0)(typescript@6.0.3)': dependencies: '@typescript-eslint/types': 8.60.0 - '@typescript-eslint/typescript-estree': 8.60.0(typescript@5.9.3) - '@typescript-eslint/utils': 8.60.0(eslint@10.4.0)(typescript@5.9.3) + '@typescript-eslint/typescript-estree': 8.60.0(typescript@6.0.3) + '@typescript-eslint/utils': 8.60.0(eslint@10.4.0)(typescript@6.0.3) debug: 4.4.3 eslint: 10.4.0 - ts-api-utils: 2.5.0(typescript@5.9.3) - typescript: 5.9.3 + ts-api-utils: 2.5.0(typescript@6.0.3) + typescript: 6.0.3 transitivePeerDependencies: - supports-color '@typescript-eslint/types@8.60.0': {} - '@typescript-eslint/typescript-estree@8.60.0(typescript@5.9.3)': + '@typescript-eslint/typescript-estree@8.60.0(typescript@6.0.3)': dependencies: - '@typescript-eslint/project-service': 8.60.0(typescript@5.9.3) - '@typescript-eslint/tsconfig-utils': 8.60.0(typescript@5.9.3) + '@typescript-eslint/project-service': 8.60.0(typescript@6.0.3) + '@typescript-eslint/tsconfig-utils': 8.60.0(typescript@6.0.3) '@typescript-eslint/types': 8.60.0 '@typescript-eslint/visitor-keys': 8.60.0 debug: 4.4.3 minimatch: 10.2.5 semver: 7.8.1 tinyglobby: 0.2.16 - ts-api-utils: 2.5.0(typescript@5.9.3) - typescript: 5.9.3 + ts-api-utils: 2.5.0(typescript@6.0.3) + typescript: 6.0.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.60.0(eslint@10.4.0)(typescript@5.9.3)': + '@typescript-eslint/utils@8.60.0(eslint@10.4.0)(typescript@6.0.3)': dependencies: '@eslint-community/eslint-utils': 4.9.1(eslint@10.4.0) '@typescript-eslint/scope-manager': 8.60.0 '@typescript-eslint/types': 8.60.0 - '@typescript-eslint/typescript-estree': 8.60.0(typescript@5.9.3) + '@typescript-eslint/typescript-estree': 8.60.0(typescript@6.0.3) eslint: 10.4.0 - typescript: 5.9.3 + typescript: 6.0.3 transitivePeerDependencies: - supports-color @@ -2421,7 +2421,7 @@ snapshots: dependencies: baseline-browser-mapping: 2.10.32 caniuse-lite: 1.0.30001793 - electron-to-chromium: 1.5.363 + electron-to-chromium: 1.5.364 node-releases: 2.0.46 update-browserslist-db: 1.2.3(browserslist@4.28.2) @@ -2577,11 +2577,11 @@ snapshots: es-errors: 1.3.0 gopd: 1.2.0 - electron-to-chromium@1.5.363: {} + electron-to-chromium@1.5.364: {} emojis-list@3.0.0: {} - enhanced-resolve@5.22.0: + enhanced-resolve@5.22.1: dependencies: graceful-fs: 4.2.11 tapable: 2.3.3 @@ -2616,7 +2616,7 @@ snapshots: has-property-descriptors: 1.0.2 has-proto: 1.2.0 has-symbols: 1.1.0 - hasown: 2.0.3 + hasown: 2.0.4 internal-slot: 1.1.0 is-array-buffer: 3.0.5 is-callable: 1.2.7 @@ -2645,7 +2645,7 @@ snapshots: typed-array-buffer: 1.0.3 typed-array-byte-length: 1.0.3 typed-array-byte-offset: 1.0.4 - typed-array-length: 1.0.7 + typed-array-length: 1.0.8 unbox-primitive: 1.1.0 which-typed-array: 1.1.21 @@ -2664,7 +2664,7 @@ snapshots: es-errors: 1.3.0 get-intrinsic: 1.3.0 has-tostringtag: 1.0.2 - hasown: 2.0.3 + hasown: 2.0.4 es-to-primitive@1.3.0: dependencies: @@ -2843,7 +2843,7 @@ snapshots: call-bound: 1.0.4 define-properties: 1.2.1 functions-have-names: 1.2.3 - hasown: 2.0.3 + hasown: 2.0.4 is-callable: 1.2.7 functions-have-names@1.2.3: {} @@ -2860,7 +2860,7 @@ snapshots: get-proto: 1.0.1 gopd: 1.2.0 has-symbols: 1.1.0 - hasown: 2.0.3 + hasown: 2.0.4 math-intrinsics: 1.1.0 get-proto@1.0.1: @@ -2917,7 +2917,7 @@ snapshots: dependencies: has-symbols: 1.1.0 - hasown@2.0.3: + hasown@2.0.4: dependencies: function-bind: 1.1.2 @@ -2931,7 +2931,7 @@ snapshots: ignore@7.0.5: {} - immutable@5.1.5: {} + immutable@5.1.6: {} import-fresh@3.3.1: dependencies: @@ -2948,7 +2948,7 @@ snapshots: internal-slot@1.1.0: dependencies: es-errors: 1.3.0 - hasown: 2.0.3 + hasown: 2.0.4 side-channel: 1.1.0 interpret@3.1.1: {} @@ -2982,7 +2982,7 @@ snapshots: is-core-module@2.16.2: dependencies: - hasown: 2.0.3 + hasown: 2.0.4 is-data-view@1.0.2: dependencies: @@ -3031,7 +3031,7 @@ snapshots: call-bound: 1.0.4 gopd: 1.2.0 has-tostringtag: 1.0.2 - hasown: 2.0.3 + hasown: 2.0.4 is-set@2.0.3: {} @@ -3382,7 +3382,7 @@ snapshots: sass@1.100.0: dependencies: chokidar: 5.0.0 - immutable: 5.1.5 + immutable: 5.1.6 source-map-js: 1.2.1 optionalDependencies: '@parcel/watcher': 2.5.6 @@ -3570,9 +3570,9 @@ snapshots: fdir: 6.5.0(picomatch@4.0.4) picomatch: 4.0.4 - ts-api-utils@2.5.0(typescript@5.9.3): + ts-api-utils@2.5.0(typescript@6.0.3): dependencies: - typescript: 5.9.3 + typescript: 6.0.3 tslib@2.8.1: {} @@ -3604,7 +3604,7 @@ snapshots: is-typed-array: 1.1.15 reflect.getprototypeof: 1.0.10 - typed-array-length@1.0.7: + typed-array-length@1.0.8: dependencies: call-bind: 1.0.9 for-each: 0.3.5 @@ -3613,7 +3613,7 @@ snapshots: possible-typed-array-names: 1.1.0 reflect.getprototypeof: 1.0.10 - typescript@5.9.3: {} + typescript@6.0.3: {} unbox-primitive@1.1.0: dependencies: @@ -3677,7 +3677,7 @@ snapshots: acorn-import-phases: 1.0.4(acorn@8.16.0) browserslist: 4.28.2 chrome-trace-event: 1.0.4 - enhanced-resolve: 5.22.0 + enhanced-resolve: 5.22.1 es-module-lexer: 2.1.0 eslint-scope: 5.1.1 events: 3.3.0 diff --git a/src/kernel.ts b/src/kernel.ts index 07be83f..9aeaff3 100644 --- a/src/kernel.ts +++ b/src/kernel.ts @@ -1,5 +1,3 @@ -/// - import type * as kernel from "siyuan/kernel"; /** From 168204eb56282c361c0f205d1f6568ee0ea9eed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yingyi=20/=20=E9=A2=96=E9=80=B8?= <49649786+Zuoqiu-Yingyi@users.noreply.github.com> Date: Sat, 30 May 2026 21:28:04 +0800 Subject: [PATCH 4/5] chore: improve null checks for Protyle initialization and attribute panel opening --- src/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1175d70..0d1c2c5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -442,7 +442,9 @@ export default class PluginSample extends Plugin { width: this.isMobile ? "92vw" : "560px", height: "540px", }); - new Protyle(this.app, dialog.element.querySelector("#protyle")!, { + const protyle = dialog.element.querySelector("#protyle"); + if (protyle == null) return; + new Protyle(this.app, protyle, { blockId: this.getEditor()?.protyle.block.rootID, }); fetchPost("/api/system/currentTime", {}, (response) => { @@ -469,7 +471,9 @@ export default class PluginSample extends Plugin { label: "Open Attribute Panel", click: () => { openAttributePanel({ - nodeElement: this.getEditor()?.protyle?.wysiwyg?.element.firstElementChild as HTMLElement, + nodeElement: this.getEditor()?.protyle?.wysiwyg?.element.firstElementChild as + | HTMLElement + | undefined, protyle: this.getEditor()?.protyle, focusName: "custom", }); From c93818e13d6a89370217ebc110a2b9dac6d55e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yingyi=20/=20=E9=A2=96=E9=80=B8?= <49649786+Zuoqiu-Yingyi@users.noreply.github.com> Date: Sun, 31 May 2026 00:32:03 +0800 Subject: [PATCH 5/5] chore: improve null checks for element rect retrieval in addMenu method --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 0d1c2c5..2b7a462 100644 --- a/src/index.ts +++ b/src/index.ts @@ -231,10 +231,10 @@ export default class PluginSample extends Plugin { let rect = topBarElement.getBoundingClientRect(); // 如果被隐藏,则使用更多按钮 if (rect.width === 0) { - rect = document.querySelector("#barMore")!.getBoundingClientRect(); + rect = document.querySelector("#barMore")?.getBoundingClientRect() ?? rect; } if (rect.width === 0) { - rect = document.querySelector("#barPlugins")!.getBoundingClientRect(); + rect = document.querySelector("#barPlugins")?.getBoundingClientRect() ?? rect; } this.addMenu(rect); }