Skip to content

Commit b4a4229

Browse files
authored
fix: patch git exec command (#50)
* update: logseq sdk version * fix: patch for the `#git_execCommand` method not found * fix: incorrectness for the `logseq.UI.queryElementRect`
1 parent 743a4ae commit b4a4229

File tree

5 files changed

+36
-14
lines changed

5 files changed

+36
-14
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
"preview": "vite preview"
1313
},
1414
"dependencies": {
15-
"@logseq/libs": "^0.0.15",
16-
"antd": "^5.7.3",
17-
"react": "^18.2.0",
18-
"react-dom": "^18.2.0"
15+
"@logseq/libs": "^0.0.16",
16+
"antd": "^4.18.9",
17+
"react": "^17.0.2",
18+
"react-dom": "^17.0.2"
1919
},
2020
"devDependencies": {
2121
"@semantic-release/changelog": "^6.0.1",

src/helper/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { SettingSchemaDesc } from "@logseq/libs/dist/LSPlugin.user";
22

33
export const COMMON_STYLE = `
4+
.ui-items-container[data-type=toolbar] > .list-wrap {
5+
overflow: visible;
6+
}
47
#injected-ui-item-git-logseq-git {
58
position: relative;
69
}

src/helper/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const getPluginStyle = () => pluginStyle;
2828

2929
export const showPopup = () => {
3030
const _style = getPluginStyle();
31-
logseq.App.queryElementRect("#logseq-git--git").then((triggerIconRect) => {
31+
logseq.UI.queryElementRect("#logseq-git--git").then((triggerIconRect) => {
3232
console.log("[faiz:] === triggerIconRect", triggerIconRect);
3333
if (!triggerIconRect) return;
3434
const popupWidth = 120 + 10 * 2;

src/main.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,20 @@ import {
2424
} from "./helper/util";
2525
import "./index.css";
2626

27-
const isDevelopment = import.meta.env.DEV;
27+
// TODO: patch logseq Git command for the temporary fix solution
28+
// https://github.com/haydenull/logseq-plugin-git/issues/48
29+
try {
30+
// @ts-ignore
31+
top.logseq.sdk.git.exec_command(['status'])
32+
} catch (e) {
33+
// @ts-ignore
34+
logseq.Git['execCommand'] = async function (args: string[]) {
35+
const ret = await logseq.App.execGitCommand(args)
36+
return {exitCode: ret == undefined ? 1 : 0, stdout: ret}
37+
}
38+
}
39+
40+
const isDevelopment = import.meta.env.DEV
2841

2942
if (isDevelopment) {
3043
renderApp("browser");

yarn.lock

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,13 +392,14 @@
392392
"@jridgewell/resolve-uri" "^3.0.3"
393393
"@jridgewell/sourcemap-codec" "^1.4.10"
394394

395-
"@logseq/libs@^0.0.15":
396-
version "0.0.15"
397-
resolved "https://registry.yarnpkg.com/@logseq/libs/-/libs-0.0.15.tgz#03b8b81a0a1557e3f022d68c978ddcb501cd4421"
398-
integrity sha512-Z4YrYGfu8Y3s9LTqVnPGkxlO+KZtP1YalH/A63zYgxP61cV5QtKlnHWNcjsKxsD5CkaSL4MlSN4mf7wNx/Fm0A==
395+
"@logseq/libs@^0.0.16":
396+
version "0.0.16"
397+
resolved "https://registry.yarnpkg.com/@logseq/libs/-/libs-0.0.16.tgz#52d542fa2ab4f2c6c6961209108962fecf925aba"
398+
integrity sha512-lsiwpBtZd/j6n02hp2ytP+LZZOoZxmqBj0MpULT4CajrH51pnI65Bzcb4+Ne/lJW6IzMbIinYmMm0Zoi3nL65g==
399399
dependencies:
400400
csstype "3.1.0"
401401
debug "4.3.4"
402+
deepmerge "4.3.1"
402403
dompurify "2.3.8"
403404
eventemitter3 "4.0.7"
404405
fast-deep-equal "3.1.3"
@@ -652,10 +653,10 @@
652653
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
653654
integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==
654655

655-
"@types/node@^18.15.12":
656-
version "18.17.0"
657-
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.17.0.tgz#35d44267a33dd46b49ee0f73d31b05fd7407e290"
658-
integrity sha512-GXZxEtOxYGFchyUzxvKI14iff9KZ2DI+A6a37o6EQevtg6uO9t+aUZKcaC1Te5Ng1OnLM7K9NVVj+FbecD9cJg==
656+
"@types/node@^17.0.9":
657+
version "17.0.9"
658+
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.9.tgz#0b7f161afb5b1cc12518d29b2cdc7175d5490628"
659+
integrity sha512-5dNBXu/FOER+EXnyah7rn8xlNrfMOQb/qXnw4NQgLkCygKBKhdmF/CA5oXVOKZLBEahw8s2WP9LxIcN/oDDRgQ==
659660

660661
"@types/normalize-package-data@^2.4.0":
661662
version "2.4.1"
@@ -1334,6 +1335,11 @@ deep-extend@^0.6.0:
13341335
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac"
13351336
integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==
13361337

1338+
deepmerge@4.3.1:
1339+
version "4.3.1"
1340+
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a"
1341+
integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==
1342+
13371343
defaults@^1.0.3:
13381344
version "1.0.3"
13391345
resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d"

0 commit comments

Comments
 (0)