impl. Kroki, compile path, and code-editor feature
This commit is contained in:
1 parent
c1bc8f0c03
commit
94d56f9a8f
49 files changed
+40652
-389
No files matched your search
@@ -1,3 +1,4 @@
|
||||
data/
|
||||
.tmp/
|
||||
*.sh
|
||||
assets/editor/node_modules/
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
FROM golang:1.22-alpine
|
||||
FROM golang:1.25-alpine
|
||||
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { build } from "esbuild";
|
||||
|
||||
await build({
|
||||
entryPoints: ["src/editor.js"],
|
||||
bundle: true,
|
||||
minify: false,
|
||||
sourcemap: true,
|
||||
outfile: "../../static/vendor/codemirror/editor.bundle.js",
|
||||
});
|
||||
Generated
+677
@@ -0,0 +1,677 @@
|
||||
{
|
||||
"name": "editor",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "editor",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.20.3",
|
||||
"@codemirror/commands": "^6.10.3",
|
||||
"@codemirror/lang-html": "^6.4.11",
|
||||
"@codemirror/lang-markdown": "^6.5.0",
|
||||
"@codemirror/language": "^6.12.3",
|
||||
"@codemirror/state": "^6.6.0",
|
||||
"@codemirror/view": "^6.43.0",
|
||||
"@replit/codemirror-vim": "^6.3.0",
|
||||
"esbuild": "^0.28.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/autocomplete": {
|
||||
"version": "6.20.3",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.3.tgz",
|
||||
"integrity": "sha512-tlosUqb+3BbxCxZdu4tKeRghPFC+QM7q4X5YhKV2eCmPG+1r2F3f4AaSz5sCrFqUtX4Jh20VFTKecl16MgiV9g==",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.17.0",
|
||||
"@lezer/common": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/commands": {
|
||||
"version": "6.10.3",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.10.3.tgz",
|
||||
"integrity": "sha512-JFRiqhKu+bvSkDLI+rUhJwSxQxYb759W5GBezE8Uc8mHLqC9aV/9aTC7yJSqCtB3F00pylrLCwnyS91Ap5ej4Q==",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.6.0",
|
||||
"@codemirror/view": "^6.27.0",
|
||||
"@lezer/common": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lang-css": {
|
||||
"version": "6.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.3.1.tgz",
|
||||
"integrity": "sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.0.0",
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@lezer/common": "^1.0.2",
|
||||
"@lezer/css": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lang-html": {
|
||||
"version": "6.4.11",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-html/-/lang-html-6.4.11.tgz",
|
||||
"integrity": "sha512-9NsXp7Nwp891pQchI7gPdTwBuSuT3K65NGTHWHNJ55HjYcHLllr0rbIZNdOzas9ztc1EUVBlHou85FFZS4BNnw==",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.0.0",
|
||||
"@codemirror/lang-css": "^6.0.0",
|
||||
"@codemirror/lang-javascript": "^6.0.0",
|
||||
"@codemirror/language": "^6.4.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.17.0",
|
||||
"@lezer/common": "^1.0.0",
|
||||
"@lezer/css": "^1.1.0",
|
||||
"@lezer/html": "^1.3.12"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lang-javascript": {
|
||||
"version": "6.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.2.5.tgz",
|
||||
"integrity": "sha512-zD4e5mS+50htS7F+TYjBPsiIFGanfVqg4HyUz6WNFikgOPf2BgKlx+TQedI1w6n/IqRBVBbBWmGFdLB/7uxO4A==",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.0.0",
|
||||
"@codemirror/language": "^6.6.0",
|
||||
"@codemirror/lint": "^6.0.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.17.0",
|
||||
"@lezer/common": "^1.0.0",
|
||||
"@lezer/javascript": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lang-markdown": {
|
||||
"version": "6.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-markdown/-/lang-markdown-6.5.0.tgz",
|
||||
"integrity": "sha512-0K40bZ35jpHya6FriukbgaleaqzBLZfOh7HuzqbMxBXkbYMJDxfF39c23xOgxFezR+3G+tR2/Mup+Xk865OMvw==",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.7.1",
|
||||
"@codemirror/lang-html": "^6.0.0",
|
||||
"@codemirror/language": "^6.3.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.0.0",
|
||||
"@lezer/common": "^1.2.1",
|
||||
"@lezer/markdown": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/language": {
|
||||
"version": "6.12.3",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.3.tgz",
|
||||
"integrity": "sha512-QwCZW6Tt1siP37Jet9Tb02Zs81TQt6qQrZR2H+eGMcFsL1zMrk2/b9CLC7/9ieP1fjIUMgviLWMmgiHoJrj+ZA==",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.23.0",
|
||||
"@lezer/common": "^1.5.0",
|
||||
"@lezer/highlight": "^1.0.0",
|
||||
"@lezer/lr": "^1.0.0",
|
||||
"style-mod": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lint": {
|
||||
"version": "6.9.6",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.6.tgz",
|
||||
"integrity": "sha512-6Kp7r6XfCi/D/5sdXieMfg9pJU1bUEx96WITuLU6ESaKizCz0QHFMjY/TaFSbigDdEAIgi93itLBIUETP4oK+A==",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.42.0",
|
||||
"crelt": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/search": {
|
||||
"version": "6.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.7.0.tgz",
|
||||
"integrity": "sha512-ZvGm99wc/s2cITtMT15LFdn8aH/aS+V+DqyGq/N5ZlV5vWtH+nILvC2nw0zX7ByNoHHDZ2IxxdW38O0tc5nVHg==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.37.0",
|
||||
"crelt": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/state": {
|
||||
"version": "6.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.6.0.tgz",
|
||||
"integrity": "sha512-4nbvra5R5EtiCzr9BTHiTLc+MLXK2QGiAVYMyi8PkQd3SR+6ixar/Q/01Fa21TBIDOZXgeWV4WppsQolSreAPQ==",
|
||||
"dependencies": {
|
||||
"@marijn/find-cluster-break": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/view": {
|
||||
"version": "6.43.0",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.0.tgz",
|
||||
"integrity": "sha512-V7ZCLQO3Jus9hzh2jVCCPW3mO4IBMr43O37PqSUYautJSnnJF41YlgLw21x0fLJTYvJ+Vkm6Gp+qKGH9pltgXA==",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.6.0",
|
||||
"crelt": "^1.0.6",
|
||||
"style-mod": "^4.1.0",
|
||||
"w3c-keyname": "^2.2.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/aix-ppc64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.0.tgz",
|
||||
"integrity": "sha512-lhRUCeuOyJQURhTxl4WkpFTjIsbDayJHih5kZC1giwE+MhIzAb7mEsQMqMf18rHLsrb5qI1tafG20mLxEWcWlA==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"aix"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.0.tgz",
|
||||
"integrity": "sha512-wqh0ByljabXLKHeWXYLqoJ5jKC4XBaw6Hk08OfMrCRd2nP2ZQ5eleDZC41XHyCNgktBGYMbqnrJKq/K/lzPMSQ==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-+WzIXQOSaGs33tLEgYPYe/yQHf0WTU0X42Jca3y8NWMbUVhp7rUnw+vAsRC/QiDrdD31IszMrZy+qwPOPjd+rw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-+VJggoaKhk2VNNqVL7f6S189UzShHC/mR9EE8rDdSkdpN0KflSwWY/gWjDrNxxisg8Fp1ZCD9jLMo4m0OUfeUA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-0T+A9WZm+bZ84nZBtk1ckYsOvyA3x7e2Acj1KdVfV4/2tdG4fzUp91YHx+GArWLtwqp77pBXVCPn2We7Letr0Q==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-fyzLm/DLDl/84OCfp2f/XQ4flmORsjU7VKt8HLjvIXChJoFFOIL6pLJPH4Yhd1n1gGFF9mPwtlN5Wf82DZs+LQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/freebsd-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-l9GeW5UZBT9k9brBYI+0WDffcRxgHQD8ShN2Ur4xWq/NFzUKm3k5lsH4PdaRgb2w7mI9u61nr2gI2mLI27Nh3Q==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/freebsd-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-BXoQai/A0wPO6Es3yFJ7APCiKGc1tdAEOgeTNy3SsB491S3aHn4S4r3e976eUnPdU+NbdtmBuLncYir2tMU9Nw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-arm": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.0.tgz",
|
||||
"integrity": "sha512-CjaaREJagqJp7iTaNQjjidaNbCKYcd4IDkzbwwxtSvjI7NZm79qiHc8HqciMddQ6CKvJT6aBd8lO9kN/ZudLlw==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-RVyzfb3FWsGA55n6WY0MEIEPURL1FcbhFE6BffZEMEekfCzCIMtB5yyDcFnVbTnwk+CLAgTujmV/Lgvih56W+A==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-ia32": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.0.tgz",
|
||||
"integrity": "sha512-KBnSTt1kxl9x70q+ydterVdl+Cn0H18ngRMRCEQfrbqdUuntQQ0LoMZv47uB97NljZFzY6HcfqEZ2SAyIUTQBQ==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-loong64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.0.tgz",
|
||||
"integrity": "sha512-zpSlUce1mnxzgBADvxKXX5sl8aYQHo2ezvMNI8I0lbblJtp8V4odlm3Yzlj7gPyt3T8ReksE6bK+pT3WD+aJRg==",
|
||||
"cpu": [
|
||||
"loong64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-mips64el": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.0.tgz",
|
||||
"integrity": "sha512-2jIfP6mmjkdmeTlsX/9vmdmhBmKADrWqN7zcdtHIeNSCH1SqIoNI63cYsjQR8J+wGa4Y5izRcSHSm8K3QWmk3w==",
|
||||
"cpu": [
|
||||
"mips64el"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-ppc64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.0.tgz",
|
||||
"integrity": "sha512-bc0FE9wWeC0WBm49IQMPSPILRocGTQt3j5KPCA8os6VprfuJ7KD+5PzESSrJ6GmPIPJK965ZJHTUlSA6GNYEhg==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-riscv64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.0.tgz",
|
||||
"integrity": "sha512-SQPZOwoTTT/HXFXQJG/vBX8sOFagGqvZyXcgLA3NhIqcBv1BJU1d46c0rGcrij2B56Z2rNiSLaZOYW5cUk7yLQ==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-s390x": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.0.tgz",
|
||||
"integrity": "sha512-SCfR0HN8CEEjnYnySJTd2cw0k9OHB/YFzt5zgJEwa+wL/T/raGWYMBqwDNAC6dqFKmJYZoQBRfHjgwLHGSrn3Q==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-us0dSb9iFxIi8srnpl931Nvs65it/Jd2a2K3qs7fz2WfGPHqzfzZTfec7oxZJRNPXPnNYZtanmRc4AL/JwVzHQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/netbsd-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-CR/RYotgtCKwtftMwJlUU7xCVNg3lMYZ0RzTmAHSfLCXw3NtZtNpswLEj/Kkf6kEL3Gw+BpOekRX0BYCtklhUw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"netbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/netbsd-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-nU1yhmYutL+fQ71Kxnhg8uEOdC0pwEW9entHykTgEbna2pw2dkbFSMeqjjyHZoCmt8SBkOSvV+yNmm94aUrrqw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"netbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openbsd-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-cXb5vApOsRsxsEl4mcZ1XY3D4DzcoMxR/nnc4IyqYs0rTI8ZKmW6kyyg+11Z8yvgMfAEldKzP7AdP64HnSC/6g==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openbsd-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-8wZM2qqtv9UP3mzy7HiGYNH/zjTA355mpeuA+859TyR+e+Tc08IHYpLJuMsfpDJwoLo1ikIJI8jC3GFjnRClzA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openharmony-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-FLGfyizszcef5C3YtoyQDACyg95+dndv79i2EekILBofh5wpCa1KuBqOWKrEHZg3zrL3t5ouE5jgr94vA+Wb2w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openharmony"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/sunos-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-1ZgjUoEdHZZl/YlV76TSCz9Hqj9h9YmMGAgAPYd+q4SicWNX3G5GCyx9uhQWSLcbvPW8Ni7lj4gDa1T40akdlw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"sunos"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-arm64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.0.tgz",
|
||||
"integrity": "sha512-Q9StnDmQ/enxnpxCCLSg0oo4+34B9TdXpuyPeTedN/6+iXBJ4J+zwfQI28u/Jl40nOYAxGoNi7mFP40RUtkmUA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-ia32": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.0.tgz",
|
||||
"integrity": "sha512-zF3ag/gfiCe6U2iczcRzSYJKH1DCI+ByzSENHlM2FcDbEeo5Zd2C86Aq0tKUYAJJ1obRP84ymxIAksZUcdztHA==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-x64": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.0.tgz",
|
||||
"integrity": "sha512-pEl1bO9mfAmIC+tW5btTmrKaujg3zGtUmWNdCw/xs70FBjwAL3o9OEKNHvNmnyylD6ubxUERiEhdsL0xBQ9efw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/common": {
|
||||
"version": "1.5.2",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.2.tgz",
|
||||
"integrity": "sha512-sxQE460fPZyU3sdc8lafxiPwJHBzZRy/udNFynGQky1SePYBdhkBl1kOagA9uT3pxR8K09bOrmTUqA9wb/PjSQ=="
|
||||
},
|
||||
"node_modules/@lezer/css": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.3.3.tgz",
|
||||
"integrity": "sha512-RzBo8r+/6QJeow7aPHIpGVIH59xTcJXp399820gZoMo9noQDRVpJLheIBUicYwKcsbOYoBRoLZlf2720dG/4Tg==",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.2.0",
|
||||
"@lezer/highlight": "^1.0.0",
|
||||
"@lezer/lr": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/highlight": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.3.tgz",
|
||||
"integrity": "sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g==",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/html": {
|
||||
"version": "1.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/html/-/html-1.3.13.tgz",
|
||||
"integrity": "sha512-oI7n6NJml729m7pjm9lvLvmXbdoMoi2f+1pwSDJkl9d68zGr7a9Btz8NdHTGQZtW2DA25ybeuv/SyDb9D5tseg==",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.2.0",
|
||||
"@lezer/highlight": "^1.0.0",
|
||||
"@lezer/lr": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/javascript": {
|
||||
"version": "1.5.4",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.4.tgz",
|
||||
"integrity": "sha512-vvYx3MhWqeZtGPwDStM2dwgljd5smolYD2lR2UyFcHfxbBQebqx8yjmFmxtJ/E6nN6u1D9srOiVWm3Rb4tmcUA==",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.2.0",
|
||||
"@lezer/highlight": "^1.1.3",
|
||||
"@lezer/lr": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/lr": {
|
||||
"version": "1.4.10",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.10.tgz",
|
||||
"integrity": "sha512-rnCpTIBafOx4mRp43xOxDJbFipJm/c0cia/V5TiGlhmMa+wsSdoGmUN3w5Bqrks/09Q/D4tNAmWaT8p6NRi77A==",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/markdown": {
|
||||
"version": "1.6.4",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.6.4.tgz",
|
||||
"integrity": "sha512-N0SxazMj4k65DBfaf1azqtMZd6u7MqluP84/NZnB/io8Td9aleFmAhz9hcbvSfsxT5tdYlJ5qgv5aMJGY4zEtA==",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.5.0",
|
||||
"@lezer/highlight": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@marijn/find-cluster-break": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.2.tgz",
|
||||
"integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g=="
|
||||
},
|
||||
"node_modules/@replit/codemirror-vim": {
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@replit/codemirror-vim/-/codemirror-vim-6.3.0.tgz",
|
||||
"integrity": "sha512-aTx931ULAMuJx6xLf7KQDOL7CxD+Sa05FktTDrtLaSy53uj01ll3Zf17JdKsriER248oS55GBzg0CfCTjEneAQ==",
|
||||
"peerDependencies": {
|
||||
"@codemirror/commands": "6.x.x",
|
||||
"@codemirror/language": "6.x.x",
|
||||
"@codemirror/search": "6.x.x",
|
||||
"@codemirror/state": "6.x.x",
|
||||
"@codemirror/view": "6.x.x"
|
||||
}
|
||||
},
|
||||
"node_modules/crelt": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz",
|
||||
"integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g=="
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.28.0",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.0.tgz",
|
||||
"integrity": "sha512-sNR9MHpXSUV/XB4zmsFKN+QgVG82Cc7+/aaxJ8Adi8hyOac+EXptIp45QBPaVyX3N70664wRbTcLTOemCAnyqw==",
|
||||
"hasInstallScript": true,
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/aix-ppc64": "0.28.0",
|
||||
"@esbuild/android-arm": "0.28.0",
|
||||
"@esbuild/android-arm64": "0.28.0",
|
||||
"@esbuild/android-x64": "0.28.0",
|
||||
"@esbuild/darwin-arm64": "0.28.0",
|
||||
"@esbuild/darwin-x64": "0.28.0",
|
||||
"@esbuild/freebsd-arm64": "0.28.0",
|
||||
"@esbuild/freebsd-x64": "0.28.0",
|
||||
"@esbuild/linux-arm": "0.28.0",
|
||||
"@esbuild/linux-arm64": "0.28.0",
|
||||
"@esbuild/linux-ia32": "0.28.0",
|
||||
"@esbuild/linux-loong64": "0.28.0",
|
||||
"@esbuild/linux-mips64el": "0.28.0",
|
||||
"@esbuild/linux-ppc64": "0.28.0",
|
||||
"@esbuild/linux-riscv64": "0.28.0",
|
||||
"@esbuild/linux-s390x": "0.28.0",
|
||||
"@esbuild/linux-x64": "0.28.0",
|
||||
"@esbuild/netbsd-arm64": "0.28.0",
|
||||
"@esbuild/netbsd-x64": "0.28.0",
|
||||
"@esbuild/openbsd-arm64": "0.28.0",
|
||||
"@esbuild/openbsd-x64": "0.28.0",
|
||||
"@esbuild/openharmony-arm64": "0.28.0",
|
||||
"@esbuild/sunos-x64": "0.28.0",
|
||||
"@esbuild/win32-arm64": "0.28.0",
|
||||
"@esbuild/win32-ia32": "0.28.0",
|
||||
"@esbuild/win32-x64": "0.28.0"
|
||||
}
|
||||
},
|
||||
"node_modules/style-mod": {
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz",
|
||||
"integrity": "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ=="
|
||||
},
|
||||
"node_modules/w3c-keyname": {
|
||||
"version": "2.2.8",
|
||||
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
|
||||
"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ=="
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "editor",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.20.3",
|
||||
"@codemirror/commands": "^6.10.3",
|
||||
"@codemirror/lang-html": "^6.4.11",
|
||||
"@codemirror/lang-markdown": "^6.5.0",
|
||||
"@codemirror/language": "^6.12.3",
|
||||
"@codemirror/state": "^6.6.0",
|
||||
"@codemirror/view": "^6.43.0",
|
||||
"@replit/codemirror-vim": "^6.3.0",
|
||||
"esbuild": "^0.28.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,373 @@
|
||||
import { EditorView, keymap, lineNumbers } from "@codemirror/view";
|
||||
import { EditorState } from "@codemirror/state";
|
||||
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
|
||||
import {
|
||||
bracketMatching,
|
||||
defaultHighlightStyle,
|
||||
syntaxHighlighting,
|
||||
} from "@codemirror/language";
|
||||
import {
|
||||
autocompletion,
|
||||
completionKeymap,
|
||||
closeBrackets,
|
||||
closeBracketsKeymap,
|
||||
} from "@codemirror/autocomplete";
|
||||
|
||||
import { html } from "@codemirror/lang-html";
|
||||
import { markdown } from "@codemirror/lang-markdown";
|
||||
import { vim, Vim } from "@replit/codemirror-vim";
|
||||
|
||||
const pagesWikiTheme = EditorView.theme({
|
||||
".cm-selectionBackground": {
|
||||
backgroundColor: "rgba(255, 216, 102, 0.48) !important",
|
||||
},
|
||||
"&.cm-focused .cm-selectionBackground": {
|
||||
backgroundColor: "rgba(255, 216, 102, 0.58) !important",
|
||||
},
|
||||
".cm-selectionLayer .cm-selectionBackground": {
|
||||
backgroundColor: "rgba(255, 216, 102, 0.58) !important",
|
||||
},
|
||||
".cm-content ::selection": {
|
||||
backgroundColor: "rgba(255, 216, 102, 0.48) !important",
|
||||
color: "#ffffff !important",
|
||||
},
|
||||
});
|
||||
|
||||
let vimMode = "INSERT";
|
||||
|
||||
function setEditorMode(mode) {
|
||||
vimMode = mode;
|
||||
|
||||
const el =
|
||||
document.getElementById("editor-vim-mode");
|
||||
|
||||
if (!el) {
|
||||
return;
|
||||
}
|
||||
|
||||
const cls =
|
||||
"mode-" + mode.toLowerCase();
|
||||
|
||||
el.innerHTML =
|
||||
"<strong class=\"" + cls + "\">" + mode + "</strong>";
|
||||
}
|
||||
|
||||
function markdownCompletions(context) {
|
||||
const word =
|
||||
context.matchBefore(/[A-Za-z#`\-\[\]\{\}:\/]*/);
|
||||
|
||||
if (!word || (word.from === word.to && !context.explicit)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
from: word.from,
|
||||
options: [
|
||||
{ label: "# ", type: "keyword", apply: "# " },
|
||||
{ label: "## ", type: "keyword", apply: "## " },
|
||||
{ label: "### ", type: "keyword", apply: "### " },
|
||||
{ label: "- ", type: "keyword", apply: "- " },
|
||||
{ label: "```text", type: "snippet", apply: "```text\n\n```" },
|
||||
{ label: "```go", type: "snippet", apply: "```go\n\n```" },
|
||||
{ label: "```bash", type: "snippet", apply: "```bash\n\n```" },
|
||||
{ label: "[link](url)", type: "snippet", apply: "[text](url)" },
|
||||
{ label: "{{children}}", type: "function", apply: "{{children}}" },
|
||||
{ label: "{{children:/}}", type: "function", apply: "{{children:/}}" },
|
||||
{ label: "{{children:/ exclude=/draft}}", type: "function", apply: "{{children:/ exclude=/draft}}" },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
function installVimCommands() {
|
||||
if (!Vim || !Vim.defineEx || window.PagesWikiVimCommandsInstalled) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.PagesWikiVimCommandsInstalled = true;
|
||||
|
||||
const save =
|
||||
() => {
|
||||
if (window.PagesEditor && window.PagesEditor.saveNow) {
|
||||
window.PagesEditor.saveNow();
|
||||
}
|
||||
};
|
||||
|
||||
const quit =
|
||||
() => {
|
||||
location.href =
|
||||
window.PagesWikiCurrentPath || "/";
|
||||
};
|
||||
|
||||
const saveQuit =
|
||||
() => {
|
||||
save();
|
||||
setTimeout(quit, 120);
|
||||
};
|
||||
|
||||
// Register both canonical and short names.
|
||||
Vim.defineEx("write", "w", save);
|
||||
Vim.defineEx("w", "w", save);
|
||||
|
||||
Vim.defineEx("quit", "q", quit);
|
||||
Vim.defineEx("q", "q", quit);
|
||||
|
||||
Vim.defineEx("wq", "wq", saveQuit);
|
||||
Vim.defineEx("x", "x", saveQuit);
|
||||
}
|
||||
|
||||
function attachVimModeTracking(view) {
|
||||
view.dom.addEventListener(
|
||||
"keydown",
|
||||
(ev) => {
|
||||
if (ev.key === "Escape" || (ev.ctrlKey && ev.key === "[")) {
|
||||
setEditorMode("NORMAL");
|
||||
return;
|
||||
}
|
||||
|
||||
if (vimMode === "NORMAL") {
|
||||
if (ev.key === "i" || ev.key === "a" || ev.key === "o" || ev.key === "O") {
|
||||
setEditorMode("INSERT");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev.key === "R") {
|
||||
setEditorMode("REPLACE");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev.key === "v" || ev.key === "V") {
|
||||
setEditorMode("VISUAL");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (vimMode === "VISUAL" && ev.key === "Escape") {
|
||||
setEditorMode("NORMAL");
|
||||
}
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
view.dom.addEventListener(
|
||||
"focusin",
|
||||
() => {
|
||||
if (!vimMode) {
|
||||
setEditorMode("INSERT");
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function attachStatusBar(view) {
|
||||
const cursorEl =
|
||||
document.getElementById("editor-cursor");
|
||||
|
||||
function updateCursor() {
|
||||
if (!cursorEl) {
|
||||
return;
|
||||
}
|
||||
|
||||
const head =
|
||||
view.state.selection.main.head;
|
||||
|
||||
const line =
|
||||
view.state.doc.lineAt(head);
|
||||
|
||||
cursorEl.textContent =
|
||||
"Ln " +
|
||||
line.number +
|
||||
", Col " +
|
||||
String(head - line.from + 1);
|
||||
}
|
||||
|
||||
updateCursor();
|
||||
setEditorMode(vimMode || "INSERT");
|
||||
|
||||
view.dom.addEventListener("keyup", updateCursor);
|
||||
view.dom.addEventListener("mouseup", updateCursor);
|
||||
view.dom.addEventListener("focusin", updateCursor);
|
||||
}
|
||||
|
||||
window.PagesWikiEditor = {
|
||||
create(target, initialText, mode, options = {}) {
|
||||
const keymapName =
|
||||
String(options.keymap || "default").toLowerCase();
|
||||
|
||||
const extensions = [
|
||||
lineNumbers(),
|
||||
history(),
|
||||
bracketMatching(),
|
||||
closeBrackets(),
|
||||
pagesWikiTheme,
|
||||
EditorView.lineWrapping,
|
||||
EditorView.updateListener.of((update) => {
|
||||
if (update.docChanged) {
|
||||
schedulePagesWikiPreview(update.view);
|
||||
}
|
||||
}),
|
||||
];
|
||||
|
||||
if (keymapName === "vim") {
|
||||
installVimCommands();
|
||||
extensions.push(vim());
|
||||
setEditorMode("NORMAL");
|
||||
} else {
|
||||
setEditorMode("INSERT");
|
||||
}
|
||||
|
||||
extensions.push(
|
||||
keymap.of([
|
||||
...defaultKeymap,
|
||||
...historyKeymap,
|
||||
...completionKeymap,
|
||||
...closeBracketsKeymap,
|
||||
])
|
||||
);
|
||||
|
||||
if (options.syntax !== false) {
|
||||
extensions.push(syntaxHighlighting(defaultHighlightStyle));
|
||||
}
|
||||
|
||||
if (options.autocomplete !== false) {
|
||||
extensions.push(
|
||||
autocompletion({
|
||||
activateOnTyping: true,
|
||||
override: mode === "markdown"
|
||||
? [markdownCompletions]
|
||||
: undefined,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (mode === "markdown") {
|
||||
extensions.push(markdown());
|
||||
} else {
|
||||
extensions.push(html());
|
||||
}
|
||||
|
||||
const view =
|
||||
new EditorView({
|
||||
state: EditorState.create({
|
||||
doc: initialText,
|
||||
extensions,
|
||||
}),
|
||||
parent: target,
|
||||
});
|
||||
|
||||
attachStatusBar(view);
|
||||
|
||||
if (keymapName === "vim") {
|
||||
attachVimModeTracking(view);
|
||||
attachPagesWikiExFallback(view);
|
||||
}
|
||||
|
||||
return view;
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
function attachPagesWikiExFallback(view) {
|
||||
let active = false;
|
||||
let buffer = "";
|
||||
|
||||
function save() {
|
||||
if (window.PagesEditor && window.PagesEditor.saveNow) {
|
||||
window.PagesEditor.saveNow();
|
||||
}
|
||||
}
|
||||
|
||||
function quit() {
|
||||
location.href =
|
||||
window.PagesWikiCurrentPath || "/";
|
||||
}
|
||||
|
||||
view.dom.addEventListener(
|
||||
"keydown",
|
||||
(ev) => {
|
||||
if (!active && vimMode === "NORMAL" && ev.key === ":") {
|
||||
active = true;
|
||||
buffer = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev.key === "Escape" || (ev.ctrlKey && ev.key === "[")) {
|
||||
active = false;
|
||||
buffer = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev.key === "Enter") {
|
||||
const cmd =
|
||||
buffer.trim();
|
||||
|
||||
active = false;
|
||||
buffer = "";
|
||||
|
||||
if (cmd === "w") {
|
||||
ev.preventDefault();
|
||||
save();
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd === "q") {
|
||||
ev.preventDefault();
|
||||
quit();
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd === "wq" || cmd === "x") {
|
||||
ev.preventDefault();
|
||||
save();
|
||||
setTimeout(quit, 120);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev.key.length === 1) {
|
||||
buffer += ev.key;
|
||||
}
|
||||
|
||||
if (ev.key === "Backspace") {
|
||||
buffer =
|
||||
buffer.slice(0, -1);
|
||||
}
|
||||
},
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
let pagesWikiPreviewTimer = null;
|
||||
|
||||
function schedulePagesWikiPreview(view) {
|
||||
const textarea =
|
||||
document.getElementById("editor");
|
||||
|
||||
if (textarea) {
|
||||
textarea.value =
|
||||
view.state.doc.toString();
|
||||
}
|
||||
|
||||
if (pagesWikiPreviewTimer) {
|
||||
clearTimeout(pagesWikiPreviewTimer);
|
||||
}
|
||||
|
||||
pagesWikiPreviewTimer =
|
||||
setTimeout(
|
||||
() => {
|
||||
if (
|
||||
window.PagesEditor &&
|
||||
window.PagesEditor.renderPreview
|
||||
) {
|
||||
window.PagesEditor.renderPreview();
|
||||
}
|
||||
},
|
||||
350
|
||||
);
|
||||
}
|
||||
@@ -17,4 +17,20 @@ services:
|
||||
- ./data:/data
|
||||
environment:
|
||||
PAGESWIKI_DATA_DIR: /data
|
||||
KROKI_URL: http://kroki:8000
|
||||
restart: unless-stopped
|
||||
kroki:
|
||||
image: yuzutech/kroki
|
||||
environment:
|
||||
KROKI_MERMAID_HOST: kroki-mermaid
|
||||
KROKI_MERMAID_PORT: 8002
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- kroki-mermaid
|
||||
|
||||
|
||||
kroki-mermaid:
|
||||
image: yuzutech/kroki-mermaid
|
||||
restart: unless-stopped
|
||||
expose:
|
||||
- "8002"
|
||||
@@ -1,8 +1,9 @@
|
||||
module pageswiki
|
||||
|
||||
go 1.22.12
|
||||
go 1.25
|
||||
|
||||
require (
|
||||
github.com/JohannesKaufmann/html-to-markdown/v2 v2.3.0
|
||||
github.com/gomarkdown/markdown v0.0.0-20260417124207-7d523f7318df
|
||||
github.com/google/uuid v1.6.0
|
||||
golang.org/x/text v0.22.0
|
||||
@@ -10,12 +11,14 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/JohannesKaufmann/dom v0.2.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-isatty v0.0.22 // indirect
|
||||
github.com/ncruces/go-strftime v0.1.9 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
golang.org/x/net v0.35.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
|
||||
modernc.org/libc v1.55.3 // indirect
|
||||
modernc.org/mathutil v1.6.0 // indirect
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
github.com/JohannesKaufmann/dom v0.2.0 h1:1bragmEb19K8lHAqgFgqCpiPCFEZMTXzOIEjuxkUfLQ=
|
||||
github.com/JohannesKaufmann/dom v0.2.0/go.mod h1:57iSUl5RKric4bUkgos4zu6Xt5LMHUnw3TF1l5CbGZo=
|
||||
github.com/JohannesKaufmann/html-to-markdown/v2 v2.3.0 h1:e+ZfpzWc28HIrpIwT+J0wvlK6zkb0ffXHDH9I4QF4lU=
|
||||
github.com/JohannesKaufmann/html-to-markdown/v2 v2.3.0/go.mod h1:CD7yrhaD1dBDORPdjkpBrvnrzVIs9kZM6SRteYYUqdA=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/gomarkdown/markdown v0.0.0-20260417124207-7d523f7318df h1:Mwihr/o+v4L5h56rwHLOE20+hh7Okhwno5BHz3zDuao=
|
||||
@@ -8,21 +12,28 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
|
||||
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
|
||||
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
|
||||
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/sebdah/goldie/v2 v2.5.5 h1:rx1mwF95RxZ3/83sdS4Yp7t2C5TCokvWP4TBRbAyEWY=
|
||||
github.com/sebdah/goldie/v2 v2.5.5/go.mod h1:oZ9fp0+se1eapSRjfYbsV/0Hqhbuu3bJVvKI/NNtssI=
|
||||
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
||||
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
||||
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
|
||||
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
||||
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
||||
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
|
||||
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
|
||||
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package compiler
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
func DiagramHash(
|
||||
diagramType string,
|
||||
source string,
|
||||
format string,
|
||||
) string {
|
||||
|
||||
sum :=
|
||||
sha256.Sum256(
|
||||
[]byte(
|
||||
diagramType + "\x00" + format + "\x00" + source,
|
||||
),
|
||||
)
|
||||
|
||||
return hex.EncodeToString(
|
||||
sum[:],
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package compiler
|
||||
|
||||
import (
|
||||
htmltomarkdown "github.com/JohannesKaufmann/html-to-markdown/v2"
|
||||
)
|
||||
|
||||
func HTMLToMarkdown(
|
||||
html string,
|
||||
) (string, error) {
|
||||
|
||||
return htmltomarkdown.ConvertString(
|
||||
html,
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (s *Server) handleBrowser(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
) {
|
||||
|
||||
currentPath :=
|
||||
strings.TrimPrefix(
|
||||
r.URL.Path,
|
||||
"/v/browser",
|
||||
)
|
||||
|
||||
if currentPath == "" || currentPath == "/" {
|
||||
currentPath = "/"
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(currentPath, "/") {
|
||||
currentPath = "/" + currentPath
|
||||
}
|
||||
|
||||
entries, err :=
|
||||
s.store.ListBrowserEntries(
|
||||
currentPath,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
s.render(
|
||||
w,
|
||||
"browser.gohtml",
|
||||
map[string]any{
|
||||
"NavItems": resolveNavItems(
|
||||
s.getSystemNavItems(),
|
||||
NavContext{
|
||||
Path: currentPath,
|
||||
},
|
||||
),
|
||||
"Path": currentPath,
|
||||
"Breadcrumbs": buildBreadcrumbs(currentPath),
|
||||
"Entries": entries,
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"pageswiki/internal/compiler"
|
||||
)
|
||||
|
||||
func (s *Server) compileMarkdownFromPath(
|
||||
path string,
|
||||
) (string, error) {
|
||||
|
||||
objectUUID, err :=
|
||||
s.store.ResolvePath(
|
||||
path,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
latest, err :=
|
||||
s.store.GetLatestRevision(
|
||||
objectUUID,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
html :=
|
||||
s.expandMacros(
|
||||
latest.Body,
|
||||
path,
|
||||
)
|
||||
|
||||
return compiler.HTMLToMarkdown(
|
||||
html,
|
||||
)
|
||||
}
|
||||
|
||||
func (s *Server) handleCompileMarkdown(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
) {
|
||||
|
||||
path :=
|
||||
strings.TrimPrefix(
|
||||
r.URL.Path,
|
||||
"/:/compile/markdown",
|
||||
)
|
||||
|
||||
if path == "" {
|
||||
path = "/"
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(path, "/") {
|
||||
path = "/" + path
|
||||
}
|
||||
|
||||
out, err :=
|
||||
s.compileMarkdownFromPath(
|
||||
path,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set(
|
||||
"Content-Type",
|
||||
"text/markdown; charset=utf-8",
|
||||
)
|
||||
|
||||
_, _ = w.Write(
|
||||
[]byte(out),
|
||||
)
|
||||
}
|
||||
@@ -166,10 +166,9 @@ func (s *Server) handleConfig(
|
||||
s.getTheme()
|
||||
|
||||
if v := strings.TrimSpace(r.FormValue("theme")); v != "" {
|
||||
switch v {
|
||||
case "dark", "light", "monokai", "solarized-dark", "solarized-light", "terminal-green", "amber-crt", "lain-dark", "nanoha-dark":
|
||||
if isAllowedTheme(v) {
|
||||
theme = v
|
||||
default:
|
||||
} else {
|
||||
http.Error(w, "invalid theme", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
@@ -239,6 +238,51 @@ func (s *Server) handleConfig(
|
||||
return
|
||||
}
|
||||
|
||||
case "editor":
|
||||
|
||||
keymap :=
|
||||
strings.TrimSpace(
|
||||
r.FormValue("editor_keymap"),
|
||||
)
|
||||
|
||||
if keymap != "vim" {
|
||||
keymap = "default"
|
||||
}
|
||||
|
||||
err = s.store.SetConfig(
|
||||
"editor_keymap",
|
||||
keymap,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
err = s.store.SetConfig(
|
||||
"editor_syntax_highlight",
|
||||
boolFormValue(
|
||||
r.FormValue("editor_syntax_highlight"),
|
||||
),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
err = s.store.SetConfig(
|
||||
"editor_autocomplete",
|
||||
boolFormValue(
|
||||
r.FormValue("editor_autocomplete"),
|
||||
),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
case "zombie-purge":
|
||||
|
||||
_, err = s.store.PurgeZombieObjects(
|
||||
@@ -338,6 +382,10 @@ func (s *Server) handleConfig(
|
||||
"Locale": s.getLocale(),
|
||||
"Timezone": s.getTimezoneName(),
|
||||
"Theme": s.getTheme(),
|
||||
"ThemeOptions": themeOptions(),
|
||||
"EditorKeymap": s.getEditorKeymap(),
|
||||
"EditorSyntax": s.getEditorSyntaxHighlight(),
|
||||
"EditorAutocomplete": s.getEditorAutocomplete(),
|
||||
"ZombieGraceHours": zombieGraceHours,
|
||||
"Objects": recent,
|
||||
"ZombieObjects": zombies,
|
||||
@@ -346,3 +394,16 @@ func (s *Server) handleConfig(
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func boolFormValue(
|
||||
v string,
|
||||
) string {
|
||||
|
||||
if v == "on" ||
|
||||
v == "true" ||
|
||||
v == "1" {
|
||||
return "true"
|
||||
}
|
||||
|
||||
return "false"
|
||||
}
|
||||
@@ -0,0 +1,402 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var diagramSourceCache = map[string]diagramCacheEntry{}
|
||||
|
||||
type diagramCacheEntry struct {
|
||||
Type string
|
||||
Source string
|
||||
At time.Time
|
||||
}
|
||||
|
||||
func diagramHash(
|
||||
diagramType string,
|
||||
source string,
|
||||
format string,
|
||||
) string {
|
||||
|
||||
sum :=
|
||||
sha256.Sum256(
|
||||
[]byte(
|
||||
diagramType + "\x00" + format + "\x00" + source,
|
||||
),
|
||||
)
|
||||
|
||||
return hex.EncodeToString(
|
||||
sum[:],
|
||||
)
|
||||
}
|
||||
|
||||
func allowedDiagramType(
|
||||
t string,
|
||||
) bool {
|
||||
|
||||
switch t {
|
||||
case "mermaid", "plantuml", "graphviz", "dot", "d2":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeDiagramType(
|
||||
t string,
|
||||
) string {
|
||||
|
||||
switch t {
|
||||
case "dot":
|
||||
return "graphviz"
|
||||
default:
|
||||
return t
|
||||
}
|
||||
}
|
||||
|
||||
func krokiURL() string {
|
||||
|
||||
v :=
|
||||
strings.TrimSpace(
|
||||
os.Getenv("KROKI_URL"),
|
||||
)
|
||||
|
||||
if v == "" {
|
||||
return "http://kroki:8000"
|
||||
}
|
||||
|
||||
return strings.TrimRight(
|
||||
v,
|
||||
"/",
|
||||
)
|
||||
}
|
||||
|
||||
func (s *Server) renderDiagramsInHTML(
|
||||
html string,
|
||||
) string {
|
||||
|
||||
re :=
|
||||
regexp.MustCompile(`(?s)<pre><code class="language-(mermaid|plantuml|graphviz|dot|d2)">(.+?)</code></pre>`)
|
||||
|
||||
return re.ReplaceAllStringFunc(
|
||||
html,
|
||||
func(block string) string {
|
||||
|
||||
m :=
|
||||
re.FindStringSubmatch(
|
||||
block,
|
||||
)
|
||||
|
||||
if len(m) != 3 {
|
||||
return block
|
||||
}
|
||||
|
||||
diagramType :=
|
||||
normalizeDiagramType(
|
||||
m[1],
|
||||
)
|
||||
|
||||
source :=
|
||||
htmlUnescapeString(
|
||||
m[2],
|
||||
)
|
||||
|
||||
hash :=
|
||||
diagramHash(
|
||||
diagramType,
|
||||
source,
|
||||
"svg",
|
||||
)
|
||||
|
||||
diagramSourceCache[hash] =
|
||||
diagramCacheEntry{
|
||||
Type: diagramType,
|
||||
Source: source,
|
||||
At: time.Now(),
|
||||
}
|
||||
|
||||
return `<figure class="diagram diagram-` + diagramType + `">` +
|
||||
`<img src="/:/compile/diagram/` + diagramType + `/` + hash + `.svg" loading="lazy" alt="` + diagramType + ` diagram">` +
|
||||
`</figure>`
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func htmlUnescapeString(
|
||||
s string,
|
||||
) string {
|
||||
|
||||
r :=
|
||||
strings.NewReplacer(
|
||||
"<", "<",
|
||||
">", ">",
|
||||
"&", "&",
|
||||
""", `"`,
|
||||
"'", "'",
|
||||
)
|
||||
|
||||
return r.Replace(
|
||||
s,
|
||||
)
|
||||
}
|
||||
|
||||
func (s *Server) handleCompileDiagram(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
) {
|
||||
|
||||
if r.Method == http.MethodPost {
|
||||
s.handleCompileDiagramPost(
|
||||
w,
|
||||
r,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
rest :=
|
||||
strings.TrimPrefix(
|
||||
r.URL.Path,
|
||||
"/:/compile/diagram/",
|
||||
)
|
||||
|
||||
parts :=
|
||||
strings.Split(
|
||||
rest,
|
||||
"/",
|
||||
)
|
||||
|
||||
if len(parts) != 2 {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
diagramType :=
|
||||
normalizeDiagramType(
|
||||
parts[0],
|
||||
)
|
||||
|
||||
if !allowedDiagramType(diagramType) {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
hashFile :=
|
||||
parts[1]
|
||||
|
||||
if !strings.HasSuffix(hashFile, ".svg") {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
hash :=
|
||||
strings.TrimSuffix(
|
||||
hashFile,
|
||||
".svg",
|
||||
)
|
||||
|
||||
if !regexp.MustCompile(`^[a-f0-9]{64}$`).MatchString(hash) {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
cachePath :=
|
||||
filepath.Join(
|
||||
"/data/cache/diagram",
|
||||
diagramType,
|
||||
hash+".svg",
|
||||
)
|
||||
|
||||
if b, err := os.ReadFile(cachePath); err == nil {
|
||||
|
||||
w.Header().Set(
|
||||
"Content-Type",
|
||||
"image/svg+xml; charset=utf-8",
|
||||
)
|
||||
|
||||
_, _ = w.Write(b)
|
||||
return
|
||||
}
|
||||
|
||||
entry, ok :=
|
||||
diagramSourceCache[hash]
|
||||
|
||||
if !ok || entry.Type != diagramType {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
s.renderDiagramSVG(
|
||||
w,
|
||||
diagramType,
|
||||
entry.Source,
|
||||
cachePath,
|
||||
)
|
||||
}
|
||||
|
||||
func (s *Server) handleCompileDiagramPost(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
) {
|
||||
|
||||
rest :=
|
||||
strings.TrimPrefix(
|
||||
r.URL.Path,
|
||||
"/:/compile/diagram/",
|
||||
)
|
||||
|
||||
diagramType :=
|
||||
normalizeDiagramType(
|
||||
strings.Trim(rest, "/"),
|
||||
)
|
||||
|
||||
if !allowedDiagramType(diagramType) {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
defer r.Body.Close()
|
||||
|
||||
sourceBytes, err :=
|
||||
io.ReadAll(
|
||||
io.LimitReader(
|
||||
r.Body,
|
||||
1024*1024,
|
||||
),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
source :=
|
||||
string(sourceBytes)
|
||||
|
||||
hash :=
|
||||
diagramHash(
|
||||
diagramType,
|
||||
source,
|
||||
"svg",
|
||||
)
|
||||
|
||||
cachePath :=
|
||||
filepath.Join(
|
||||
"/data/cache/diagram",
|
||||
diagramType,
|
||||
hash+".svg",
|
||||
)
|
||||
|
||||
if b, err := os.ReadFile(cachePath); err == nil {
|
||||
|
||||
w.Header().Set(
|
||||
"Content-Type",
|
||||
"image/svg+xml; charset=utf-8",
|
||||
)
|
||||
|
||||
_, _ = w.Write(b)
|
||||
return
|
||||
}
|
||||
|
||||
s.renderDiagramSVG(
|
||||
w,
|
||||
diagramType,
|
||||
source,
|
||||
cachePath,
|
||||
)
|
||||
}
|
||||
|
||||
func (s *Server) renderDiagramSVG(
|
||||
w http.ResponseWriter,
|
||||
diagramType string,
|
||||
source string,
|
||||
cachePath string,
|
||||
) {
|
||||
|
||||
req, err :=
|
||||
http.NewRequest(
|
||||
http.MethodPost,
|
||||
krokiURL()+"/"+diagramType+"/svg",
|
||||
bytes.NewBufferString(source),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
req.Header.Set(
|
||||
"Content-Type",
|
||||
"text/plain; charset=utf-8",
|
||||
)
|
||||
|
||||
client :=
|
||||
http.Client{
|
||||
Timeout: 15 * time.Second,
|
||||
}
|
||||
|
||||
resp, err :=
|
||||
client.Do(
|
||||
req,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 502)
|
||||
return
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode < 200 ||
|
||||
resp.StatusCode >= 300 {
|
||||
|
||||
http.Error(w, "diagram renderer failed", 502)
|
||||
return
|
||||
}
|
||||
|
||||
b, err :=
|
||||
io.ReadAll(
|
||||
resp.Body,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
_ =
|
||||
os.MkdirAll(
|
||||
filepath.Dir(cachePath),
|
||||
0755,
|
||||
)
|
||||
|
||||
_ =
|
||||
os.WriteFile(
|
||||
cachePath,
|
||||
b,
|
||||
0644,
|
||||
)
|
||||
|
||||
w.Header().Set(
|
||||
"Content-Type",
|
||||
"image/svg+xml; charset=utf-8",
|
||||
)
|
||||
|
||||
w.Header().Set(
|
||||
"Content-Security-Policy",
|
||||
"default-src 'none'; style-src 'unsafe-inline'; img-src data:",
|
||||
)
|
||||
|
||||
_, _ =
|
||||
w.Write(
|
||||
b,
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package server
|
||||
|
||||
func (s *Server) getEditorKeymap() string {
|
||||
|
||||
v, err :=
|
||||
s.store.GetConfig(
|
||||
"editor_keymap",
|
||||
)
|
||||
|
||||
if err != nil || v == "" {
|
||||
return "default"
|
||||
}
|
||||
|
||||
switch v {
|
||||
case "default", "vim":
|
||||
return v
|
||||
default:
|
||||
return "default"
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) getEditorSyntaxHighlight() bool {
|
||||
|
||||
v, err :=
|
||||
s.store.GetConfig(
|
||||
"editor_syntax_highlight",
|
||||
)
|
||||
|
||||
if err != nil || v == "" {
|
||||
return true
|
||||
}
|
||||
|
||||
return v != "false"
|
||||
}
|
||||
|
||||
func (s *Server) getEditorAutocomplete() bool {
|
||||
|
||||
v, err :=
|
||||
s.store.GetConfig(
|
||||
"editor_autocomplete",
|
||||
)
|
||||
|
||||
if err != nil || v == "" {
|
||||
return true
|
||||
}
|
||||
|
||||
return v != "false"
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (s *Server) handleEditorRoute(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
) {
|
||||
|
||||
if strings.HasPrefix(r.URL.Path, "/e/-/") {
|
||||
s.handleSemanticEditor(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
// Known future editor adapters.
|
||||
for _, prefix := range []string{
|
||||
"/e/plain/",
|
||||
"/e/hex/",
|
||||
"/e/pdf/",
|
||||
"/e/office/",
|
||||
} {
|
||||
if strings.HasPrefix(r.URL.Path, prefix) {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Backward compatibility:
|
||||
// /e/foo/bar -> /e/-/foo/bar
|
||||
oldPath :=
|
||||
strings.TrimPrefix(
|
||||
r.URL.Path,
|
||||
"/e",
|
||||
)
|
||||
|
||||
if oldPath == "" {
|
||||
oldPath = "/"
|
||||
}
|
||||
|
||||
http.Redirect(
|
||||
w,
|
||||
r,
|
||||
"/e/-"+oldPath,
|
||||
http.StatusFound,
|
||||
)
|
||||
}
|
||||
@@ -11,6 +11,11 @@ func (s *Server) handleHome(
|
||||
r *http.Request,
|
||||
) {
|
||||
|
||||
if r.URL.Path != "/" {
|
||||
s.handleSemanticRoute(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
homePath, err :=
|
||||
s.store.GetConfig(
|
||||
"home_path",
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type MarkdownLine struct {
|
||||
Number int
|
||||
Text string
|
||||
}
|
||||
|
||||
func splitMarkdownLines(
|
||||
body string,
|
||||
) []MarkdownLine {
|
||||
|
||||
body =
|
||||
strings.ReplaceAll(
|
||||
body,
|
||||
"\r\n",
|
||||
"\n",
|
||||
)
|
||||
|
||||
lines :=
|
||||
strings.Split(
|
||||
body,
|
||||
"\n",
|
||||
)
|
||||
|
||||
out :=
|
||||
make(
|
||||
[]MarkdownLine,
|
||||
0,
|
||||
len(lines),
|
||||
)
|
||||
|
||||
for i, line := range lines {
|
||||
|
||||
out = append(
|
||||
out,
|
||||
MarkdownLine{
|
||||
Number: i + 1,
|
||||
Text: line,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func (s *Server) handleMarkdownView(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
) {
|
||||
|
||||
path :=
|
||||
strings.TrimPrefix(
|
||||
r.URL.Path,
|
||||
"/v/markdown",
|
||||
)
|
||||
|
||||
if path == "" {
|
||||
path = "/"
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(path, "/") {
|
||||
path = "/" + path
|
||||
}
|
||||
|
||||
objectUUID, err :=
|
||||
s.store.ResolvePath(
|
||||
path,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
markdown, err :=
|
||||
s.compileMarkdownFromPath(
|
||||
path,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
s.render(
|
||||
w,
|
||||
"markdown_view.gohtml",
|
||||
map[string]any{
|
||||
"NavItems": resolveNavItems(
|
||||
s.getSystemNavItems(),
|
||||
NavContext{
|
||||
Path: path,
|
||||
ObjectUUID: objectUUID,
|
||||
ObjectURI: "uuid:" + objectUUID,
|
||||
},
|
||||
),
|
||||
"Path": path,
|
||||
"ObjectUUID": objectUUID,
|
||||
"ObjectURI": "uuid:" + objectUUID,
|
||||
"Lines": splitMarkdownLines(markdown),
|
||||
"MarkdownRaw": markdown,
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (s *Server) handlePlainView(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
) {
|
||||
|
||||
path :=
|
||||
strings.TrimPrefix(
|
||||
r.URL.Path,
|
||||
"/v/plain",
|
||||
)
|
||||
|
||||
if path == "" {
|
||||
path = "/"
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(path, "/") {
|
||||
path = "/" + path
|
||||
}
|
||||
|
||||
objectUUID, err :=
|
||||
s.store.ResolvePath(
|
||||
path,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
latest, err :=
|
||||
s.store.GetLatestRevision(
|
||||
objectUUID,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set(
|
||||
"Content-Type",
|
||||
"text/plain; charset=utf-8",
|
||||
)
|
||||
|
||||
_, _ = w.Write(
|
||||
[]byte(latest.Body),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (s *Server) handlePreview(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
) {
|
||||
|
||||
path :=
|
||||
strings.TrimPrefix(
|
||||
r.URL.Path,
|
||||
"/v/preview",
|
||||
)
|
||||
|
||||
if path == "" {
|
||||
path = "/"
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(path, "/") {
|
||||
path = "/" + path
|
||||
}
|
||||
|
||||
objectUUID, err :=
|
||||
s.store.ResolvePath(
|
||||
path,
|
||||
)
|
||||
|
||||
if err == nil {
|
||||
|
||||
latest, err :=
|
||||
s.store.GetLatestRevision(
|
||||
objectUUID,
|
||||
)
|
||||
|
||||
if err == nil &&
|
||||
strings.TrimSpace(latest.Body) != "" {
|
||||
|
||||
rendered :=
|
||||
s.renderDiagramsInHTML(
|
||||
s.expandMacros(
|
||||
latest.Body,
|
||||
path,
|
||||
),
|
||||
)
|
||||
|
||||
s.render(
|
||||
w,
|
||||
"preview.gohtml",
|
||||
map[string]any{
|
||||
"Path": path,
|
||||
"RenderedHTML": template.HTML(
|
||||
rendered,
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
entries, err :=
|
||||
s.store.ListBrowserEntries(
|
||||
path,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
s.render(
|
||||
w,
|
||||
"preview.gohtml",
|
||||
map[string]any{
|
||||
"Path": path,
|
||||
"IsListing": true,
|
||||
"Entries": entries,
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -8,11 +8,13 @@ func mergeTemplateData(
|
||||
data any,
|
||||
wikiName string,
|
||||
theme string,
|
||||
sThemeCSS string,
|
||||
) map[string]any {
|
||||
|
||||
out := map[string]any{
|
||||
"WikiName": wikiName,
|
||||
"Theme": theme,
|
||||
"ThemeCSS": sThemeCSS,
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
@@ -46,6 +48,7 @@ func (s *Server) render(
|
||||
data,
|
||||
s.getWikiName(),
|
||||
s.getTheme(),
|
||||
s.getThemeCSS(),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
+47
-102
@@ -3,15 +3,31 @@ package routes
|
||||
import "net/http"
|
||||
|
||||
type UIHandlers struct {
|
||||
Home http.HandlerFunc
|
||||
NewPage http.HandlerFunc
|
||||
SemanticEditor http.HandlerFunc
|
||||
SemanticPage http.HandlerFunc
|
||||
RawView http.HandlerFunc
|
||||
LinkManager http.HandlerFunc
|
||||
Health http.HandlerFunc
|
||||
Tree http.HandlerFunc
|
||||
Config http.HandlerFunc
|
||||
Home http.HandlerFunc
|
||||
NewPage http.HandlerFunc
|
||||
SemanticEditor http.HandlerFunc
|
||||
SemanticPage http.HandlerFunc
|
||||
RawView http.HandlerFunc
|
||||
LinkManager http.HandlerFunc
|
||||
Health http.HandlerFunc
|
||||
Tree http.HandlerFunc
|
||||
Browser http.HandlerFunc
|
||||
Preview http.HandlerFunc
|
||||
PlainView http.HandlerFunc
|
||||
MarkdownView http.HandlerFunc
|
||||
CompileMarkdown http.HandlerFunc
|
||||
CompileDiagram http.HandlerFunc
|
||||
Config http.HandlerFunc
|
||||
}
|
||||
|
||||
func handleIfNotNil(
|
||||
mux *http.ServeMux,
|
||||
pattern string,
|
||||
h http.HandlerFunc,
|
||||
) {
|
||||
if h != nil {
|
||||
mux.HandleFunc(pattern, h)
|
||||
}
|
||||
}
|
||||
|
||||
func RegisterUIRoutes(
|
||||
@@ -19,103 +35,32 @@ func RegisterUIRoutes(
|
||||
h UIHandlers,
|
||||
) {
|
||||
|
||||
mux.HandleFunc(
|
||||
"/healthz",
|
||||
h.Health,
|
||||
)
|
||||
handleIfNotNil(mux, "/", h.Home)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/v/tree",
|
||||
h.Tree,
|
||||
)
|
||||
handleIfNotNil(mux, "/:/new", h.NewPage)
|
||||
handleIfNotNil(mux, "/new", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/:/new", http.StatusFound)
|
||||
})
|
||||
handleIfNotNil(mux, "/e/", h.SemanticEditor)
|
||||
handleIfNotNil(mux, "/r/", h.RawView)
|
||||
handleIfNotNil(mux, "/l/", h.LinkManager)
|
||||
handleIfNotNil(mux, "/health", h.Health)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/-/sys/config",
|
||||
h.Config,
|
||||
)
|
||||
handleIfNotNil(mux, "/v/tree", h.Tree)
|
||||
handleIfNotNil(mux, "/v/browser", h.Browser)
|
||||
handleIfNotNil(mux, "/v/browser/", h.Browser)
|
||||
handleIfNotNil(mux, "/v/preview", h.Preview)
|
||||
handleIfNotNil(mux, "/v/preview/", h.Preview)
|
||||
handleIfNotNil(mux, "/v/plain", h.PlainView)
|
||||
handleIfNotNil(mux, "/v/plain/", h.PlainView)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/new",
|
||||
h.NewPage,
|
||||
)
|
||||
handleIfNotNil(mux, "/v/markdown", h.MarkdownView)
|
||||
handleIfNotNil(mux, "/v/markdown/", h.MarkdownView)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/e",
|
||||
h.SemanticEditor,
|
||||
)
|
||||
handleIfNotNil(mux, "/:/compile/markdown", h.CompileMarkdown)
|
||||
handleIfNotNil(mux, "/:/compile/markdown/", h.CompileMarkdown)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/e/",
|
||||
h.SemanticEditor,
|
||||
)
|
||||
handleIfNotNil(mux, "/:/compile/diagram/", h.CompileDiagram)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/raw",
|
||||
h.RawView,
|
||||
)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/raw/",
|
||||
h.RawView,
|
||||
)
|
||||
mux.HandleFunc(
|
||||
"/l/",
|
||||
h.LinkManager,
|
||||
)
|
||||
|
||||
mux.HandleFunc(
|
||||
"/",
|
||||
func(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
) {
|
||||
|
||||
if r.URL.Path == "/" {
|
||||
|
||||
h.Home(
|
||||
w,
|
||||
r,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
switch r.URL.Path {
|
||||
|
||||
case "/v/tree":
|
||||
|
||||
h.Tree(
|
||||
w,
|
||||
r,
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
case "/new":
|
||||
|
||||
h.NewPage(
|
||||
w,
|
||||
r,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if r.URL.Path == "/e" ||
|
||||
r.URL.Path == "/raw" {
|
||||
|
||||
http.NotFound(
|
||||
w,
|
||||
r,
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
h.SemanticPage(
|
||||
w,
|
||||
r,
|
||||
)
|
||||
},
|
||||
)
|
||||
handleIfNotNil(mux, "/-/sys/config", h.Config)
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package server
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@@ -41,12 +40,13 @@ func (s *Server) handleSemanticRoute(
|
||||
}
|
||||
|
||||
bs := buildBreadcrumbs(path)
|
||||
log.Printf("breadcrumb debug path=%s bs=%#v", path, bs)
|
||||
|
||||
rendered :=
|
||||
s.expandMacros(
|
||||
latest.Body,
|
||||
path,
|
||||
s.renderDiagramsInHTML(
|
||||
s.expandMacros(
|
||||
latest.Body,
|
||||
path,
|
||||
),
|
||||
)
|
||||
|
||||
s.render(
|
||||
@@ -55,7 +55,7 @@ func (s *Server) handleSemanticRoute(
|
||||
map[string]any{
|
||||
"Title": path,
|
||||
"Path": path,
|
||||
"Breadcrumbs": buildBreadcrumbs(path),
|
||||
"Breadcrumbs": bs,
|
||||
"ObjectUUID": objectUUID,
|
||||
"NavItems": resolveNavItems(
|
||||
s.getSystemNavItems(),
|
||||
@@ -79,7 +79,7 @@ func (s *Server) handleSemanticEditor(
|
||||
|
||||
path := strings.TrimPrefix(
|
||||
r.URL.Path,
|
||||
"/e",
|
||||
"/e/-",
|
||||
)
|
||||
|
||||
if path == "" {
|
||||
@@ -128,12 +128,26 @@ func (s *Server) handleSemanticEditor(
|
||||
|
||||
if editType == "markdown" {
|
||||
|
||||
body =
|
||||
htmlToMarkdown(
|
||||
body,
|
||||
compiled, err :=
|
||||
s.compileMarkdownFromPath(
|
||||
path,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
http.Error(
|
||||
w,
|
||||
err.Error(),
|
||||
500,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
body = compiled
|
||||
}
|
||||
|
||||
renderedBody :=
|
||||
body
|
||||
|
||||
s.render(
|
||||
w,
|
||||
"editor.gohtml",
|
||||
@@ -144,56 +158,14 @@ func (s *Server) handleSemanticEditor(
|
||||
"Body": body,
|
||||
"RenderedHTML": template.HTML(
|
||||
s.expandMacros(
|
||||
body,
|
||||
renderedBody,
|
||||
path,
|
||||
),
|
||||
),
|
||||
"EditType": editType,
|
||||
"EditType": editType,
|
||||
"EditorKeymap": s.getEditorKeymap(),
|
||||
"EditorSyntax": s.getEditorSyntaxHighlight(),
|
||||
"EditorAutocomplete": s.getEditorAutocomplete(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func htmlToMarkdown(
|
||||
in string,
|
||||
) string {
|
||||
|
||||
out := in
|
||||
|
||||
out = strings.ReplaceAll(
|
||||
out,
|
||||
"<h1>",
|
||||
"# ",
|
||||
)
|
||||
|
||||
out = strings.ReplaceAll(
|
||||
out,
|
||||
"</h1>",
|
||||
"",
|
||||
)
|
||||
|
||||
out = strings.ReplaceAll(
|
||||
out,
|
||||
"<ul>",
|
||||
"",
|
||||
)
|
||||
|
||||
out = strings.ReplaceAll(
|
||||
out,
|
||||
"</ul>",
|
||||
"",
|
||||
)
|
||||
|
||||
out = strings.ReplaceAll(
|
||||
out,
|
||||
"<li>",
|
||||
"- ",
|
||||
)
|
||||
|
||||
out = strings.ReplaceAll(
|
||||
out,
|
||||
"</li>",
|
||||
"",
|
||||
)
|
||||
|
||||
return out
|
||||
}
|
||||
@@ -91,6 +91,18 @@ func (s *Server) registerStaticRoutes() {
|
||||
staticFS,
|
||||
),
|
||||
)
|
||||
|
||||
themeFS := http.FileServer(
|
||||
http.Dir("/data/themes"),
|
||||
)
|
||||
|
||||
s.mux.Handle(
|
||||
"/-/theme/",
|
||||
http.StripPrefix(
|
||||
"/-/theme/",
|
||||
themeFS,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func (s *Server) mustLoadTemplates() {
|
||||
@@ -164,15 +176,21 @@ func (s *Server) registerRoutes() {
|
||||
routespkg.RegisterUIRoutes(
|
||||
s.mux,
|
||||
routespkg.UIHandlers{
|
||||
Home: s.handleHome,
|
||||
NewPage: s.handleNewPage,
|
||||
SemanticEditor: s.handleSemanticEditor,
|
||||
SemanticPage: s.handleSemanticRoute,
|
||||
RawView: s.handleRawView,
|
||||
LinkManager: s.handleLinkManager,
|
||||
Health: s.handleHealth,
|
||||
Tree: s.handleTree,
|
||||
Config: s.handleConfig,
|
||||
Home: s.handleHome,
|
||||
NewPage: s.handleNewPage,
|
||||
SemanticEditor: s.handleEditorRoute,
|
||||
SemanticPage: s.handleSemanticRoute,
|
||||
RawView: s.handleRawView,
|
||||
LinkManager: s.handleLinkManager,
|
||||
Health: s.handleHealth,
|
||||
Tree: s.handleTree,
|
||||
Browser: s.handleBrowser,
|
||||
Preview: s.handlePreview,
|
||||
PlainView: s.handlePlainView,
|
||||
MarkdownView: s.handleMarkdownView,
|
||||
CompileMarkdown: s.handleCompileMarkdown,
|
||||
CompileDiagram: s.handleCompileDiagram,
|
||||
Config: s.handleConfig,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
+98
-10
@@ -1,20 +1,108 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ThemeOption struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
CSS string `json:"css"`
|
||||
}
|
||||
|
||||
func builtinThemeOptions() []ThemeOption {
|
||||
return []ThemeOption{
|
||||
{ID: "dark", Label: "Dark", CSS: "/static/css/theme/dark.css"},
|
||||
{ID: "light", Label: "Light", CSS: "/static/css/theme/light.css"},
|
||||
{ID: "monokai", Label: "Monokai", CSS: "/static/css/theme/monokai.css"},
|
||||
{ID: "solarized-dark", Label: "Solarized Dark", CSS: "/static/css/theme/solarized-dark.css"},
|
||||
{ID: "solarized-light", Label: "Solarized Light", CSS: "/static/css/theme/solarized-light.css"},
|
||||
{ID: "terminal-green", Label: "Terminal Green", CSS: "/static/css/theme/terminal-green.css"},
|
||||
{ID: "amber-crt", Label: "Amber CRT", CSS: "/static/css/theme/amber-crt.css"},
|
||||
{ID: "lain-dark", Label: "Lain Dark", CSS: "/static/css/theme/lain-dark.css"},
|
||||
{ID: "nanoha-dark", Label: "Nanoha Dark", CSS: "/static/css/theme/nanoha-dark.css"},
|
||||
}
|
||||
}
|
||||
|
||||
func externalThemeOptions() []ThemeOption {
|
||||
path := "/data/themes/themes.json"
|
||||
|
||||
b, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var items []ThemeOption
|
||||
if err := json.Unmarshal(b, &items); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var out []ThemeOption
|
||||
|
||||
for _, item := range items {
|
||||
item.ID = strings.TrimSpace(item.ID)
|
||||
item.Label = strings.TrimSpace(item.Label)
|
||||
item.CSS = strings.TrimSpace(item.CSS)
|
||||
|
||||
if item.ID == "" || item.Label == "" || item.CSS == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.Contains(item.ID, "/") || strings.Contains(item.ID, "..") {
|
||||
continue
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(item.CSS, "/") {
|
||||
item.CSS = "/-/theme/" + filepath.Base(item.CSS)
|
||||
}
|
||||
|
||||
out = append(out, item)
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func themeOptions() []ThemeOption {
|
||||
items := builtinThemeOptions()
|
||||
items = append(items, externalThemeOptions()...)
|
||||
return items
|
||||
}
|
||||
|
||||
func findTheme(id string) (ThemeOption, bool) {
|
||||
for _, opt := range themeOptions() {
|
||||
if opt.ID == id {
|
||||
return opt, true
|
||||
}
|
||||
}
|
||||
return ThemeOption{}, false
|
||||
}
|
||||
|
||||
func isAllowedTheme(theme string) bool {
|
||||
_, ok := findTheme(theme)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (s *Server) getTheme() string {
|
||||
|
||||
theme, err :=
|
||||
s.store.GetConfig(
|
||||
"theme",
|
||||
)
|
||||
|
||||
theme, err := s.store.GetConfig("theme")
|
||||
if err != nil || theme == "" {
|
||||
return "dark"
|
||||
}
|
||||
|
||||
switch theme {
|
||||
case "dark", "light", "monokai", "solarized-dark", "solarized-light", "terminal-green", "amber-crt", "lain-dark", "nanoha-dark":
|
||||
return theme
|
||||
default:
|
||||
if !isAllowedTheme(theme) {
|
||||
return "dark"
|
||||
}
|
||||
|
||||
return theme
|
||||
}
|
||||
|
||||
func (s *Server) getThemeCSS() string {
|
||||
opt, ok := findTheme(s.getTheme())
|
||||
if !ok {
|
||||
return "/static/css/theme/dark.css"
|
||||
}
|
||||
|
||||
return opt.CSS
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"path"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type BrowserEntry struct {
|
||||
Name string
|
||||
Path string
|
||||
ObjectUUID string
|
||||
IsDir bool
|
||||
Size int
|
||||
UpdatedAt int64
|
||||
ChildCount int
|
||||
}
|
||||
|
||||
func normalizeBrowserPath(p string) string {
|
||||
p = strings.TrimSpace(p)
|
||||
|
||||
if p == "" {
|
||||
return "/"
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(p, "/") {
|
||||
p = "/" + p
|
||||
}
|
||||
|
||||
if p != "/" {
|
||||
p = strings.TrimRight(p, "/")
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *Store) ListBrowserEntries(
|
||||
parent string,
|
||||
) ([]BrowserEntry, error) {
|
||||
|
||||
parent = normalizeBrowserPath(parent)
|
||||
|
||||
rows, err := s.DB.Query(`
|
||||
WITH latest AS (
|
||||
SELECT
|
||||
r.object_uuid,
|
||||
r.body,
|
||||
r.created_at,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY r.object_uuid
|
||||
ORDER BY r.created_at DESC
|
||||
) AS rn
|
||||
FROM revisions r
|
||||
)
|
||||
SELECT
|
||||
p.path,
|
||||
p.object_uuid,
|
||||
COALESCE(LENGTH(latest.body), 0),
|
||||
COALESCE(latest.created_at, 0)
|
||||
FROM paths p
|
||||
LEFT JOIN latest
|
||||
ON latest.object_uuid = p.object_uuid
|
||||
AND latest.rn = 1
|
||||
WHERE p.path = ?
|
||||
OR p.path LIKE ?
|
||||
ORDER BY p.path ASC
|
||||
`,
|
||||
parent,
|
||||
func() string {
|
||||
if parent == "/" {
|
||||
return "/%"
|
||||
}
|
||||
return parent + "/%"
|
||||
}(),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer rows.Close()
|
||||
|
||||
dirMap := map[string]*BrowserEntry{}
|
||||
var files []BrowserEntry
|
||||
|
||||
prefix := parent
|
||||
if prefix != "/" {
|
||||
prefix += "/"
|
||||
}
|
||||
|
||||
for rows.Next() {
|
||||
|
||||
var fullPath string
|
||||
var objectUUID string
|
||||
var size int
|
||||
var updatedAt int64
|
||||
|
||||
err := rows.Scan(
|
||||
&fullPath,
|
||||
&objectUUID,
|
||||
&size,
|
||||
&updatedAt,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if fullPath == parent {
|
||||
continue
|
||||
}
|
||||
|
||||
rel := ""
|
||||
|
||||
if parent == "/" {
|
||||
rel = strings.TrimPrefix(fullPath, "/")
|
||||
} else {
|
||||
rel = strings.TrimPrefix(fullPath, prefix)
|
||||
}
|
||||
|
||||
rel = strings.Trim(rel, "/")
|
||||
|
||||
if rel == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
parts := strings.Split(rel, "/")
|
||||
|
||||
if len(parts) > 1 {
|
||||
|
||||
name := parts[0]
|
||||
dirPath := path.Join(parent, name)
|
||||
|
||||
if !strings.HasPrefix(dirPath, "/") {
|
||||
dirPath = "/" + dirPath
|
||||
}
|
||||
|
||||
if dirPath == "." {
|
||||
dirPath = "/"
|
||||
}
|
||||
|
||||
ent, ok := dirMap[dirPath]
|
||||
|
||||
if !ok {
|
||||
ent = &BrowserEntry{
|
||||
Name: name,
|
||||
Path: dirPath,
|
||||
IsDir: true,
|
||||
}
|
||||
dirMap[dirPath] = ent
|
||||
}
|
||||
|
||||
ent.ChildCount++
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
files = append(
|
||||
files,
|
||||
BrowserEntry{
|
||||
Name: parts[0],
|
||||
Path: fullPath,
|
||||
ObjectUUID: objectUUID,
|
||||
IsDir: false,
|
||||
Size: size,
|
||||
UpdatedAt: updatedAt,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
var out []BrowserEntry
|
||||
|
||||
for _, d := range dirMap {
|
||||
out = append(out, *d)
|
||||
}
|
||||
|
||||
out = append(out, files...)
|
||||
|
||||
sort.SliceStable(
|
||||
out,
|
||||
func(i, j int) bool {
|
||||
if out[i].IsDir != out[j].IsDir {
|
||||
return out[i].IsDir
|
||||
}
|
||||
|
||||
return out[i].Name < out[j].Name
|
||||
},
|
||||
)
|
||||
|
||||
return out, nil
|
||||
}
|
||||
+30
-6
@@ -2,6 +2,7 @@ package store
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -29,15 +30,17 @@ func (s *Store) ResolvePath(
|
||||
path string,
|
||||
) (string, error) {
|
||||
|
||||
row := s.DB.QueryRow(`
|
||||
SELECT object_uuid
|
||||
FROM paths
|
||||
WHERE path = ?
|
||||
`, path)
|
||||
path = normalizePath(path)
|
||||
|
||||
var objectUUID string
|
||||
|
||||
err := row.Scan(&objectUUID)
|
||||
err := s.DB.QueryRow(`
|
||||
SELECT object_uuid
|
||||
FROM paths
|
||||
WHERE path = ?
|
||||
LIMIT 1
|
||||
`, path).Scan(&objectUUID)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -45,6 +48,27 @@ func (s *Store) ResolvePath(
|
||||
return objectUUID, nil
|
||||
}
|
||||
|
||||
func normalizePath(
|
||||
path string,
|
||||
) string {
|
||||
|
||||
path = strings.TrimSpace(path)
|
||||
|
||||
if path == "" {
|
||||
return "/"
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(path, "/") {
|
||||
path = "/" + path
|
||||
}
|
||||
|
||||
if path != "/" {
|
||||
path = strings.TrimRight(path, "/")
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
|
||||
func (s *Store) ListChildren(
|
||||
prefix string,
|
||||
) ([]string, error) {
|
||||
|
||||
@@ -95,3 +95,70 @@ th {
|
||||
.muted {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
/* config hardening */
|
||||
body:has(.config-sidebar) main,
|
||||
body:has(.config-sidebar) .config-layout,
|
||||
body:has(.config-sidebar) .container {
|
||||
display: grid;
|
||||
grid-template-columns: 16rem minmax(0, 1fr);
|
||||
gap: 1.5rem;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
body:has(.config-sidebar) .config-sidebar {
|
||||
grid-column: 1;
|
||||
position: sticky;
|
||||
top: 4rem;
|
||||
}
|
||||
|
||||
body:has(.config-sidebar) .config-panel,
|
||||
body:has(.config-sidebar) .config-section {
|
||||
grid-column: 2;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
body:has(.config-sidebar) .config-panel {
|
||||
display: none;
|
||||
}
|
||||
|
||||
body:has(.config-sidebar) .config-panel.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* disable previous experimental config hardening */
|
||||
body:has(.config-sidebar) main,
|
||||
body:has(.config-sidebar) .config-layout,
|
||||
body:has(.config-sidebar) .container {
|
||||
display: initial;
|
||||
grid-template-columns: initial;
|
||||
gap: initial;
|
||||
align-items: initial;
|
||||
}
|
||||
|
||||
|
||||
.diagram {
|
||||
margin: 1rem 0;
|
||||
padding: 0.75rem;
|
||||
border: 1px solid var(--border-soft);
|
||||
background: var(--panel);
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.diagram img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.diagram img {
|
||||
background: #fff;
|
||||
padding: 0.75rem;
|
||||
border-radius: 0.35rem;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.diagram img {
|
||||
filter: brightness(0.92) contrast(1.08);
|
||||
}
|
||||
}
|
||||
@@ -313,3 +313,289 @@ document.addEventListener(
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
async function renderPagesWikiDiagramsInPreview(root) {
|
||||
|
||||
if (!root) {
|
||||
return
|
||||
}
|
||||
|
||||
const blocks =
|
||||
root.querySelectorAll(
|
||||
"pre code.language-mermaid, pre code.language-plantuml, pre code.language-graphviz, pre code.language-dot, pre code.language-d2"
|
||||
)
|
||||
|
||||
for (const code of blocks) {
|
||||
|
||||
const pre =
|
||||
code.closest("pre")
|
||||
|
||||
if (!pre) {
|
||||
continue
|
||||
}
|
||||
|
||||
let diagramType =
|
||||
Array.from(code.classList)
|
||||
.find(c => c.startsWith("language-"))
|
||||
?.replace("language-", "")
|
||||
|
||||
if (!diagramType) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (diagramType === "dot") {
|
||||
diagramType = "graphviz"
|
||||
}
|
||||
|
||||
const source =
|
||||
code.textContent || ""
|
||||
|
||||
const figure =
|
||||
document.createElement("figure")
|
||||
|
||||
figure.className =
|
||||
"diagram diagram-" + diagramType
|
||||
|
||||
figure.textContent =
|
||||
"Rendering " + diagramType + "..."
|
||||
|
||||
pre.replaceWith(figure)
|
||||
|
||||
try {
|
||||
|
||||
const res =
|
||||
await fetch(
|
||||
"/:/compile/diagram/" + encodeURIComponent(diagramType),
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "text/plain; charset=utf-8",
|
||||
},
|
||||
body: source,
|
||||
},
|
||||
)
|
||||
|
||||
if (!res.ok) {
|
||||
figure.textContent =
|
||||
"Diagram render failed: " + res.status
|
||||
continue
|
||||
}
|
||||
|
||||
const svg =
|
||||
await res.text()
|
||||
|
||||
const blob =
|
||||
new Blob(
|
||||
[svg],
|
||||
{
|
||||
type: "image/svg+xml",
|
||||
},
|
||||
)
|
||||
|
||||
const url =
|
||||
URL.createObjectURL(blob)
|
||||
|
||||
const img =
|
||||
document.createElement("img")
|
||||
|
||||
img.src =
|
||||
url
|
||||
|
||||
img.alt =
|
||||
diagramType + " diagram"
|
||||
|
||||
img.onload =
|
||||
() => {
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
figure.textContent =
|
||||
""
|
||||
|
||||
figure.appendChild(img)
|
||||
|
||||
} catch (err) {
|
||||
|
||||
figure.textContent =
|
||||
"Diagram render failed"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const PagesWikiOldRenderPreview =
|
||||
window.PagesEditor &&
|
||||
window.PagesEditor.renderPreview
|
||||
|
||||
if (PagesWikiOldRenderPreview) {
|
||||
|
||||
window.PagesEditor.renderPreview =
|
||||
async function() {
|
||||
|
||||
const ret =
|
||||
PagesWikiOldRenderPreview.apply(
|
||||
window.PagesEditor,
|
||||
arguments,
|
||||
)
|
||||
|
||||
await Promise.resolve(ret)
|
||||
|
||||
await renderPagesWikiDiagramsInPreview(
|
||||
document.getElementById("preview"),
|
||||
)
|
||||
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
async function renderPagesWikiDiagramsInPreview(root) {
|
||||
|
||||
if (!root) {
|
||||
return
|
||||
}
|
||||
|
||||
const blocks =
|
||||
root.querySelectorAll(
|
||||
"pre code.language-mermaid, pre code.language-plantuml, pre code.language-graphviz, pre code.language-dot, pre code.language-d2"
|
||||
)
|
||||
|
||||
for (const code of blocks) {
|
||||
|
||||
const pre =
|
||||
code.closest("pre")
|
||||
|
||||
if (!pre) {
|
||||
continue
|
||||
}
|
||||
|
||||
let diagramType =
|
||||
Array.from(code.classList)
|
||||
.find(c => c.startsWith("language-"))
|
||||
?.replace("language-", "")
|
||||
|
||||
if (!diagramType) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (diagramType === "dot") {
|
||||
diagramType = "graphviz"
|
||||
}
|
||||
|
||||
const source =
|
||||
code.textContent || ""
|
||||
|
||||
const figure =
|
||||
document.createElement("figure")
|
||||
|
||||
figure.className =
|
||||
"diagram diagram-" + diagramType
|
||||
|
||||
figure.textContent =
|
||||
"Rendering " + diagramType + "..."
|
||||
|
||||
pre.replaceWith(figure)
|
||||
|
||||
const res =
|
||||
await fetch(
|
||||
"/:/compile/diagram/" + encodeURIComponent(diagramType),
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "text/plain; charset=utf-8",
|
||||
},
|
||||
body: source,
|
||||
},
|
||||
)
|
||||
|
||||
if (!res.ok) {
|
||||
figure.textContent =
|
||||
"Diagram render failed: " + res.status
|
||||
continue
|
||||
}
|
||||
|
||||
const svg =
|
||||
await res.text()
|
||||
|
||||
const blob =
|
||||
new Blob(
|
||||
[svg],
|
||||
{
|
||||
type: "image/svg+xml",
|
||||
},
|
||||
)
|
||||
|
||||
const url =
|
||||
URL.createObjectURL(blob)
|
||||
|
||||
const img =
|
||||
document.createElement("img")
|
||||
|
||||
img.src =
|
||||
url
|
||||
|
||||
img.alt =
|
||||
diagramType + " diagram"
|
||||
|
||||
img.onload =
|
||||
() => URL.revokeObjectURL(url)
|
||||
|
||||
figure.textContent =
|
||||
""
|
||||
|
||||
figure.appendChild(img)
|
||||
}
|
||||
}
|
||||
|
||||
function installPagesWikiDiagramPreviewHook() {
|
||||
|
||||
if (
|
||||
!window.PagesEditor ||
|
||||
!window.PagesEditor.renderPreview ||
|
||||
window.PagesEditorDiagramPreviewHookInstalled
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
window.PagesEditorDiagramPreviewHookInstalled = true
|
||||
|
||||
const original =
|
||||
window.PagesEditor.renderPreview
|
||||
|
||||
window.PagesEditor.renderPreview =
|
||||
async function() {
|
||||
|
||||
const ret =
|
||||
original.apply(
|
||||
window.PagesEditor,
|
||||
arguments,
|
||||
)
|
||||
|
||||
await Promise.resolve(ret)
|
||||
|
||||
await renderPagesWikiDiagramsInPreview(
|
||||
document.getElementById("preview"),
|
||||
)
|
||||
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener(
|
||||
"DOMContentLoaded",
|
||||
() => {
|
||||
installPagesWikiDiagramPreviewHook()
|
||||
|
||||
setTimeout(
|
||||
() => {
|
||||
installPagesWikiDiagramPreviewHook()
|
||||
|
||||
if (
|
||||
window.PagesEditor &&
|
||||
window.PagesEditor.renderPreview
|
||||
) {
|
||||
window.PagesEditor.renderPreview()
|
||||
}
|
||||
},
|
||||
100,
|
||||
)
|
||||
},
|
||||
)
|
||||
+35585
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../../assets/editor/node_modules/@marijn/find-cluster-break/src/index.js", "../../../assets/editor/node_modules/@codemirror/state/dist/index.js", "../../../assets/editor/node_modules/style-mod/src/style-mod.js", "../../../assets/editor/node_modules/w3c-keyname/index.js", "../../../assets/editor/node_modules/@codemirror/view/dist/index.js", "../../../assets/editor/node_modules/@lezer/common/dist/index.js", "../../../assets/editor/node_modules/@lezer/highlight/dist/index.js", "../../../assets/editor/node_modules/@codemirror/language/dist/index.js", "../../../assets/editor/node_modules/@codemirror/commands/dist/index.js", "../../../assets/editor/node_modules/@codemirror/autocomplete/dist/index.js", "../../../assets/editor/node_modules/@lezer/lr/dist/index.js", "../../../assets/editor/node_modules/@lezer/html/dist/index.js", "../../../assets/editor/node_modules/@lezer/css/dist/index.js", "../../../assets/editor/node_modules/@codemirror/lang-css/dist/index.js", "../../../assets/editor/node_modules/@lezer/javascript/dist/index.js", "../../../assets/editor/node_modules/@codemirror/lang-javascript/dist/index.js", "../../../assets/editor/node_modules/@codemirror/lang-html/dist/index.js", "../../../assets/editor/node_modules/@lezer/markdown/dist/index.js", "../../../assets/editor/node_modules/@codemirror/lang-markdown/dist/index.js", "../../../assets/editor/node_modules/@codemirror/search/dist/index.js", "../../../assets/editor/node_modules/@replit/codemirror-vim/dist/index.js", "../../../assets/editor/src/editor.js"],
|
||||
"sourcesContent": ["// These are filled with ranges (rangeFrom[i] up to but not including\n// rangeTo[i]) of code points that count as extending characters.\nlet rangeFrom = [], rangeTo = []\n\n;(() => {\n // Compressed representation of the Grapheme_Cluster_Break=Extend\n // information from\n // http://www.unicode.org/Public/16.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.\n // Each pair of elements represents a range, as an offet from the\n // previous range and a length. Numbers are in base-36, with the empty\n // string being a shorthand for 1.\n let numbers = \"lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o\".split(\",\").map(s => s ? parseInt(s, 36) : 1)\n for (let i = 0, n = 0; i < numbers.length; i++)\n (i % 2 ? rangeTo : rangeFrom).push(n = n + numbers[i])\n})()\n\nexport function isExtendingChar(code) {\n if (code < 768) return false\n for (let from = 0, to = rangeFrom.length;;) {\n let mid = (from + to) >> 1\n if (code < rangeFrom[mid]) to = mid\n else if (code >= rangeTo[mid]) from = mid + 1\n else return true\n if (from == to) return false\n }\n}\n\nfunction isRegionalIndicator(code) {\n return code >= 0x1F1E6 && code <= 0x1F1FF\n}\n\nfunction check(code) {\n for (let i = 0; i < rangeFrom.length; i++) {\n if (rangeTo[i] > code) return rangeFrom[i] <= code\n }\n return false\n}\n\nconst ZWJ = 0x200d\n\nexport function findClusterBreak(str, pos, forward = true, includeExtending = true) {\n return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending)\n}\n\nfunction nextClusterBreak(str, pos, includeExtending) {\n if (pos == str.length) return pos\n // If pos is in the middle of a surrogate pair, move to its start\n if (pos && surrogateLow(str.charCodeAt(pos)) && surrogateHigh(str.charCodeAt(pos - 1))) pos--\n let prev = codePointAt(str, pos)\n pos += codePointSize(prev)\n while (pos < str.length) {\n let next = codePointAt(str, pos)\n if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {\n pos += codePointSize(next)\n prev = next\n } else if (isRegionalIndicator(next)) {\n let countBefore = 0, i = pos - 2\n while (i >= 0 && isRegionalIndicator(codePointAt(str, i))) { countBefore++; i -= 2 }\n if (countBefore % 2 == 0) break\n else pos += 2\n } else {\n break\n }\n }\n return pos\n}\n\nfunction prevClusterBreak(str, pos, includeExtending) {\n while (pos > 0) {\n let found = nextClusterBreak(str, pos - 2, includeExtending)\n if (found < pos) return found\n pos--\n }\n return 0\n}\n\nfunction codePointAt(str, pos) {\n let code0 = str.charCodeAt(pos)\n if (!surrogateHigh(code0) || pos + 1 == str.length) return code0\n let code1 = str.charCodeAt(pos + 1)\n if (!surrogateLow(code1)) return code0\n return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000\n}\n\nfunction surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000 }\nfunction surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00 }\nfunction codePointSize(code) { return code < 0x10000 ? 1 : 2 }\n", "import { findClusterBreak as findClusterBreak$1 } from '@marijn/find-cluster-break';\n\n/**\nThe data structure for documents. @nonabstract\n*/\nclass Text {\n /**\n Get the line description around the given position.\n */\n lineAt(pos) {\n if (pos < 0 || pos > this.length)\n throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);\n return this.lineInner(pos, false, 1, 0);\n }\n /**\n Get the description for the given (1-based) line number.\n */\n line(n) {\n if (n < 1 || n > this.lines)\n throw new RangeError(`Invalid line number ${n}Line truncated
|
||||
"mappings": ";;AAEA,MAAI,YAAY,CAAC;AAAjB,MAAoB,UAAU,CAAC;AAE9B,GAAC,MAAM;AAON,QAAI,UAAU,izCAAizC,MAAM,GAAG,EAAE,IAAI,OAAK,IAAI,SAAS,GAAG,EAAE,IAAI,CAAC;AAC12C,aAAS,IAAI,GAAG,IAAI,GAAG,IAAI,QAAQ,QAAQ;AACzC,OAAC,IAAI,IAAI,UAAU,WAAW,KAAK,IAAI,IAAI,QAAQ,CAAC,CAAC;AAAA,EACzD,GAAG;AAEI,WAAS,gBAAgB,MAAM;AACpC,QAAI,OAAO,IAAK,QAAO;AACvB,aAAS,OAAO,GAAG,KAAK,UAAU,YAAU;AAC1C,UAAI,MAAO,OAAO,MAAO;AACzB,UAAI,OAAO,UAAU,GAAG,EAAG,MAAK;AAAA,eACvB,QAAQ,QAAQ,GAAG,EAAG,QAAO,MAAM;AAAA,UACvC,QAAO;AACZ,UAAI,QAAQ,GAAI,QAAO;AAAA,IACzB;AAAA,EACF;AAEA,WAAS,oBAAoB,MAAM;AACjC,WAAO,QAAQ,UAAW,QAAQ;AAAA,EACpC;AASA,MAAM,MAAM;AAEL,WAAS,iBAAiB,KAAK,KAAK,UAAU,MAAM,mBAAmB,MAAM;AAClF,YAAQ,UAAU,mBAAmB,kBAAkB,KAAK,KAAK,gBAAgB;AAAA,EACnF;AAEA,WAAS,iBAAiB,KAAK,KAAK,kBAAkB;AACpD,QAAI,OAAO,IAAI,OAAQ,QAAO;AAE9B,QAAI,OAAO,aAAa,IAAI,WAAW,GAAG,CAAC,KAAK,cAAc,IAAI,WAAW,MAAM,CAAC,CAAC,EAAG;AACxF,QAAI,OAAO,YAAY,KAAK,GAAG;AAC/B,WAAO,cAAc,IAAI;AACzB,WAAO,MAAM,IAAI,QAAQ;AACvB,UAAI,OAAO,YAAY,KAAK,GAAG;AAC/B,UAAI,QAAQ,OAAO,QAAQ,OAAO,oBAAoB,gBAAgB,IAAI,GAAG;AAC3E,eAAO,cAAc,IAAI;AACzB,eAAO;AAAA,MACT,WAAW,oBAAoB,IAAI,GAAG;AACpC,YAAI,cAAc,GAAG,IAAI,MAAM;AAC/B,eAAO,KAAK,KAAK,oBAAoB,YAAY,KAAK,CAAC,CAAC,GAAG;AAAE;AAAe,eAAK;AAAA,QAAE;AACnF,YAAI,cAAc,KAAK,EAAG;AAAA,YACrB,QAAO;AAAA,MACd,OAAO;AACL;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,WAAS,iBAAiB,KAAK,KAAK,kBAAkB;AACpD,WAAO,MAAM,GAAG;AACd,UAAI,QAAQ,iBAAiB,KAAK,MAAM,GAAG,gBAAgB;AAC3D,UAAI,QAAQ,IAAK,QAAO;AACxB;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,WAAS,YAAY,KAAK,KAAK;AAC7B,QAAI,QAAQ,IAAI,WAAW,GAAG;AAC9B,QAAI,CAAC,cAAc,KAAK,KAAK,MAAM,KAAK,IAAI,OAAQ,QAAO;AAC3D,QAAI,QAAQ,IAAI,WAAW,MAAM,CAAC;AAClC,QAAI,CAAC,aAAa,KAAK,EAAG,QAAO;AACjC,YAAS,QAAQ,SAAW,OAAO,QAAQ,SAAU;AAAA,EACvD;AAEA,WAAS,aAAa,IAAI;AAAE,WAAO,MAAM,SAAU,KAAK;AAAA,EAAO;AAC/D,WAAS,cAAc,IAAI;AAAE,WAAO,MAAM,SAAU,KAAK;AAAA,EAAO;AAChE,WAAS,cAAc,MAAM;AAAE,WAAO,OAAO,QAAU,IAAI;AAAA,EAAE;;;ACjF7D,MAAMA,QAAN,MAAM,MAAK;AAAA;AAAA;AAAA;AAAA,IAIP,OAAO,KAAK;AACR,UAAI,MAAM,KAAK,MAAM,KAAK;AACtB,cAAM,IAAI,WAAW,oBAAoB,GAAG,0BAA0B,KAAK,MAAM,EAAE;AACvF,aAAO,KAAK,UAAU,KAAK,OAAO,GAAG,CAAC;AAAA,IAC1C;AAAA;AAAA;AAAA;AAAA,IAIA,KAAK,GAAG;AACJ,UAAI,IAAI,KAAK,IAAI,KAAK;AAClB,cAAM,IAAI,WAAW,uBAAuB,CAAC,OAAO,KAAK,KAAK,gBAAgB;AAClF,aAAO,KAAK,UAAU,GAAG,MAAM,GAAG,CAAC;AAAA,IACvC;AAAA;AAAA;AAAA;AAAA,IAIA,QAAQ,MAAM,IAAI,MAAM;AACpB,OAAC,MAAM,EAAE,IAAI,KAAK,MAAM,MAAM,EAAE;AAChC,UAAI,QAAQ,CAAC;AACb,WAAK;AAAA,QAAU;AAAA,QAAG;AAAA,QAAM;AAAA,QAAO;AAAA;AAAA,MAAe;AAC9C,UAAI,KAAK;AACL,aAAK;AAAA,UAAU;AAAA,UAAG,KAAK;AAAA,UAAQ;AAAA,UAAO,IAAoB;AAAA;AAAA,QAAe;AAC7E,WAAK;AAAA,QAAU;AAAA,QAAI,KAAK;AAAA,QAAQ;AAAA,QAAO;AAAA;AAAA,MAAiB;AACxD,aAAO,SAAS,KAAK,OAAO,KAAK,UAAU,KAAK,QAAQ,KAAK,MAAM;AAAA,IACvE;AAAA;AAAA;AAAA;AAAA,IAIA,OAAO,OAAO;AACV,aAAO,KAAK,QAAQ,KAAK,QAAQ,KAAK,QAAQ,KAAK;AAAA,IACvD;AAAA;AAAA;AAAA;AAAA,IAIA,MAAM,MAAM,KAAK,KAAK,QAAQ;AAC1B,OAAC,MAAM,EAAE,IAAI,KAAK,MAAM,MAAM,EAAE;AAChC,UAAI,QAAQ,CAAC;AACb,WAAK,UAAU,MAAM,IAAI,OAAO,CAAC;AACjC,aAAO,SAAS,KAAK,OAAO,KAAK,IAAI;AAAA,IACzC;AAAA;AAAA;AAAA;AAAA,IAIA,GAAG,OAAO;AACN,UAAI,SAAS;AACT,eAAO;AACX,UAAI,MAAM,UAAU,KAAK,UAAU,MAAM,SAAS,KAAK;AACnD,eAAO;AACX,UAAI,QAAQ,KAAK,cAAc,OAAO,CAAC,GAAG,MAAM,KAAK,SAAS,KAAK,cAAc,OAAO,EAAE;AAC1F,UAAI,IAAI,IAAI,cAAc,IAAI,GAAG,IAAI,IAAI,cAAc,KAAK;AAC5D,eAAS,OAAO,OAAO,MAAM,WAAS;AAClC,UAAE,KAAK,IAAI;AACX,UAAE,KAAK,IAAI;AACX,eAAO;AACP,YAAI,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE;AAC/D,iBAAO;AACX,eAAO,EAAE,MAAM;AACf,YAAI,EAAE,QAAQ,OAAO;AACjB,iBAAO;AAAA,MACf;AAAA,IACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,KAAK,MAAM,GAAG;AAAE,aAAO,IAAI,cAAc,MAAM,GAAG;AAAA,IAAG;AAAA;AAAA;AAAA;AAAA;AAAA,IAKrD,UAAU,MAAM,KAAK,KAAK,QAAQ;AAAE,aAAO,IAAI,kBAAkB,MAAM,MAAM,EAAE;AAAA,IAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQlF,UAAU,MAAM,IAAI;AAChB,UAAI;AACJ,UAAI,QAAQ,MAAM;AACd,gBAAQ,KAAK,KAAK;AAAA,MACtB,OACK;AACD,YAAI,MAAM;AACN,eAAK,KAAK,QAAQ;AACtB,YAAI,QAAQ,KAAK,KAAK,IAAI,EAAE;AAC5B,gBAAQ,KAAK,UAAU,OAAO,KAAK,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,SAAS,MAAM,IAAI,IAAI,KAAK,KAAK,KAAK,CAAC,EAAE,EAAE,CAAC;AAAA,MAC1H;AACA,aAAO,IAAI,WAAW,KAAK;AAAA,IAC/B;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,WAAW;AAAE,aAAO,KAAK,YAAY,CAAC;AAAA,IAAG;AAAA;AAAA;AAAA;AAAA;AAAA,IAKzC,SAAS;AACL,UAAI,QAAQ,CAAC;AACb,WAAK,QAAQ,KAAK;AAClB,aAAO;AAAA,IACX;AAAA;AAAA;AAAA;AAAA,IAIA,cAAc;AAAA,IAAE;AAAA;AAAA;AAAA;AAAA,IAIhB,OAAO,GAAG,MAAM;AACZ,UAAI,KAAK,UAAU;AACf,cAAM,IAAI,WAAW,wCAAwC;AACjE,UAAI,KAAK,UAAU,KAAK,CAAC,KAAK,CAAC;AAC3B,eAAO,MAAK;AAChB,aAAO,KAAK,UAAU,KAAuB,IAAI,SAAS,IAAI,IAAI,SAAS,KAAK,SAAS,MAAM,MAAM,CAAC,CAAC,CAAC;AAAA,IAC5G;AAAA,EACJ;AAIA,MAAM,WAAN,MAAM,kBAAiBA,MAAK;AAAA,IACxB,YAAY,MAAM,SAAS,WAAW,IAAI,GAAG;AACzC,YAAM;AACN,WAAK,OAAO;AACZ,WAAK,SAAS;AAAA,IAClB;AAAA,IACA,IAAI,QAAQ;AAAE,aAAO,KAAK,KAAK;AAAA,IAAQ;AAAA,IACvC,IAAI,WAAW;AAAE,aAAO;AAAA,IAAM;AAAA,IAC9B,UAAU,QAAQ,QAAQ,MAAM,QAAQ;AACpC,eAAS,IAAI,KAAI,KAAK;AAClB,YAAIC,UAAS,KAAK,KAAK,CAAC,GAAG,MAAM,SAASA,QAAO;AACjD,aAAK,SAAS,OAAO,QAAQ;AACzB,iBAAO,IAAI,KAAK,QAAQ,KAAK,MAAMA,OAAM;AAC7C,iBAAS,MAAM;AACf;AAAA,MACJ;AAAA,IACJ;AAAA,IACA,UAAU,MAAM,IAAI,QAAQ,MAAM;AAC9B,UAAI,OAAO,QAAQ,KAAK,MAAM,KAAK,SAAS,OACtC,IAAI,UAAS,UAAU,KAAK,MAAM,MAAM,EAAE,GAAG,KAAK,Line truncated
|
||||
"names": ["Text", "string", "top", "number", "findClusterBreak", "surrogateLow", "surrogateHigh", "codePointAt", "codePointSize", "MapMode", "doc", "process", "insert", "i", "values", "compare", "config", "_a", "id", "prec", "content", "base", "scrollIntoView", "CharCategory", "require", "name", "defaults", "cur", "spec", "id", "doc", "name", "ie", "name", "BlockType", "off", "elt", "doc", "cur", "top", "rect", "Direction", "replace", "type", "_a", "findClusterBreak", "values", "t", "id", "pos", "flatten", "Text", "dist", "cache", "blockWrappers", "marks", "tile", "decorations", "from", "to", "offset", "textHeight", "i", "content", "child", "scrollIntoView", "base", "handlers", "observers", "insert", "event", "data", "QueryType", "DecorationComparator", "gap", "key", "view", "config", "shift", "meta", "command", "codePointAt", "codePointSize", "cmd", "t", "_a", "i", "values", "_a", "config", "t", "space", "top", "elt", "top", "values", "config", "gutter", "cur", "gutters", "asArray", "marker", "elt", "event", "number", "Range", "config", "parser", "name", "id", "types", "IterMode", "data", "_a", "mounted", "cur", "cache", "children", "positions", "node", "buffer", "contextHash", "length", "lookAhead", "base", "pair", "nodeSize", "nodeStart", "from", "to", "off", "string", "done", "inner", "r", "pos", "name", "base", "t", "sameArray", "config", "tags", "cur", "hasChild", "rangeFrom", "rangeTo", "name", "values", "data", "parser", "name", "top", "base", "_a", "doc", "parser", "_a", "language", "name", "values", "cur", "base", "lineEnd", "space", "closing", "cur", "lineEnd", "_a", "from", "to", "values", "config", "baseTheme$1", "baseTheme$1", "values", "from", "to", "baseTheme", "decorations", "config", "cur", "matching", "bracket", "pos", "string", "indentUnit", "_a", "name", "name", "t", "config", "data", "comment", "empty", "isAdjacent", "config", "command", "_a", "none", "isAdjacent", "t", "config", "bracket", "space", "matching", "cur", "findClusterBreak", "findClusterBreak", "nextChar", "lineEnd", "Text", "findClusterBreak", "dist", "insert", "Text", "changes", "cur", "space", "types", "score", "_a", "codePointAt", "codePointSize", "space", "config", "content", "off", "applyCompletion", "options", "id", "scrollIntoView", "name", "compare", "cur", "none", "noAttrs", "baseTheme", "pos", "m", "snippet", "Text", "inputHandler", "insert", "codePointSize", "codePointAt", "bracket", "doc", "config", "content", "baseTheme", "score", "_a", "parser", "base", "count", "top", "off", "i", "Type", "data", "id", "FragmentCursor", "insert", "name", "config", "t", "prec", "values", "name", "getAttrs", "tags", "id", "attrs", "dash", "id", "callee", "parser", "name", "tags", "identifier", "doc", "_a", "callee", "cur", "node", "parser", "newline", "space", "slash", "question", "bracketL", "spec_identifier", "parser", "id", "doc", "top", "node", "name", "parser", "_a", "name", "config", "doc", "android", "base", "empty", "insert", "elementName", "doc", "name", "identifier", "elt", "_a", "base", "config", "cur", "autoCloseTags", "selfClosers", "to", "insert", "hash", "Type", "content", "Line", "elt", "space", "count", "marks", "base", "empty", "off", "parser", "FragmentCursor", "none", "top", "rangeEnd", "t", "config", "nodeTypes", "name", "id", "rm", "spec", "conc", "Element", "comment", "cur", "node", "m", "next", "parser", "heading", "doc", "number", "cur", "node", "content", "space", "config", "insert", "changes", "empty", "_a", "codePointAt", "codePointSize", "off", "doc", "_a", "config", "QueryType", "doc", "findClusterBreak", "Pos", "defaultKeymap", "vim", "name", "find", "InputState", "keyName", "command", "keys", "prompt", "value", "keymap", "semicolon", "operator", "macroModeState", "onChange", "query", "e", "cur", "content", "top", "spaces", "base", "number", "tags", "i", "dir", "nextChar", "cm", "options", "searchState", "commandMatch", "noremap", "marks", "lineEnd", "numberRegex", "cmd", "count", "replace", "repeat", "doc", "_a", "handlers", "wordChar", "config", "scrollIntoView", "on", "space", "line", "max", "getDrawSelectionConfig", "defaultConfig", "elt", "from", "to", "vimPlugin", "cmd"]
|
||||
}
|
||||
Vendored
+655
@@ -0,0 +1,655 @@
|
||||
.cm-editor {
|
||||
min-height: 70vh;
|
||||
background: #0b0f14;
|
||||
color: #d7dde8;
|
||||
border: 1px solid #263241;
|
||||
border-radius: 0.35rem;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.cm-scroller {
|
||||
font-family:
|
||||
"JetBrains Mono",
|
||||
"Hack Nerd Font",
|
||||
monospace;
|
||||
}
|
||||
|
||||
.cm-content {
|
||||
min-height: 70vh;
|
||||
caret-color: #ffd866;
|
||||
}
|
||||
|
||||
.cm-gutters {
|
||||
background: #080c10;
|
||||
color: #596678;
|
||||
border-right: 1px solid #263241;
|
||||
}
|
||||
|
||||
.cm-activeLine {
|
||||
background: rgba(255,255,255,0.035);
|
||||
}
|
||||
|
||||
.cm-activeLineGutter {
|
||||
background: rgba(255,255,255,0.045);
|
||||
color: #ffd866;
|
||||
}
|
||||
|
||||
.cm-cursor {
|
||||
border-left-color: #ffd866;
|
||||
}
|
||||
|
||||
.cm-selectionBackground,
|
||||
.cm-content ::selection {
|
||||
background: rgba(120,160,255,0.35) !important;
|
||||
}
|
||||
|
||||
.cm-line {
|
||||
padding: 0 0.25rem;
|
||||
}
|
||||
|
||||
.cm-focused {
|
||||
outline: none;
|
||||
box-shadow:
|
||||
0 0 0 1px rgba(255,216,102,0.28),
|
||||
0 0 1.2rem rgba(255,216,102,0.08);
|
||||
}
|
||||
|
||||
.editor-shell {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.editor-toolbar {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
margin-bottom: 0.75rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.editor-toolbar button,
|
||||
.editor-toolbar a {
|
||||
background: #111821;
|
||||
color: #d7dde8;
|
||||
border: 1px solid #263241;
|
||||
border-radius: 0.25rem;
|
||||
padding: 0.38rem 0.7rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.editor-toolbar button:hover,
|
||||
.editor-toolbar a:hover {
|
||||
background: #1a2430;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.editor-meta {
|
||||
color: #8190a5;
|
||||
font-family:
|
||||
"JetBrains Mono",
|
||||
monospace;
|
||||
font-size: 0.86rem;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.cm-tooltip {
|
||||
background: #111821;
|
||||
color: #d7dde8;
|
||||
border: 1px solid #44506a;
|
||||
border-radius: 0.25rem;
|
||||
box-shadow: 0 0.4rem 1.2rem rgba(0,0,0,0.45);
|
||||
z-index: 2000;
|
||||
}
|
||||
|
||||
.cm-tooltip-autocomplete ul {
|
||||
max-height: 18rem;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.cm-tooltip-autocomplete ul li[aria-selected] {
|
||||
background: #26324a;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.cm-vim-panel {
|
||||
background: #080c10;
|
||||
color: #ffd866;
|
||||
border-top: 1px solid #263241;
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
padding: 0.25rem 0.5rem;
|
||||
}
|
||||
|
||||
.cm-vim-panel input {
|
||||
background: #111821;
|
||||
color: #ffd866;
|
||||
border: 1px solid #44506a;
|
||||
}
|
||||
|
||||
.cm-editor.cm-focused {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* autocomplete popup */
|
||||
|
||||
.cm-tooltip {
|
||||
background: #101624 !important;
|
||||
color: #e6eaff !important;
|
||||
border: 1px solid #5d6f9f !important;
|
||||
border-radius: 0.25rem;
|
||||
box-shadow: 0 0.45rem 1.2rem rgba(0,0,0,0.55);
|
||||
z-index: 3000;
|
||||
}
|
||||
|
||||
.cm-tooltip-autocomplete {
|
||||
font-family:
|
||||
"JetBrains Mono",
|
||||
monospace;
|
||||
}
|
||||
|
||||
.cm-tooltip-autocomplete ul {
|
||||
max-height: 18rem;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.cm-tooltip-autocomplete ul li {
|
||||
color: #e6eaff !important;
|
||||
background: #101624 !important;
|
||||
padding: 0.25rem 0.5rem;
|
||||
}
|
||||
|
||||
.cm-tooltip-autocomplete ul li[aria-selected] {
|
||||
background: #314a7a !important;
|
||||
color: #ffffff !important;
|
||||
}
|
||||
|
||||
.cm-completionLabel {
|
||||
color: #ffffff !important;
|
||||
}
|
||||
|
||||
.cm-completionDetail {
|
||||
color: #ffd86f !important;
|
||||
}
|
||||
|
||||
.cm-completionInfo {
|
||||
background: #101624 !important;
|
||||
color: #e6eaff !important;
|
||||
border: 1px solid #5d6f9f !important;
|
||||
}
|
||||
|
||||
/* editor layout */
|
||||
|
||||
.editor-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
gap: 1rem;
|
||||
height: auto;
|
||||
min-height: 30rem;
|
||||
}
|
||||
|
||||
#editor-mount {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
#editor-mount .cm-editor {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#editor-mount .cm-scroller {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.preview {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* status bar */
|
||||
|
||||
.editor-statusbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
height: 1.8rem;
|
||||
padding: 0 0.65rem;
|
||||
border: 1px solid #263241;
|
||||
border-top: none;
|
||||
background: #080c10;
|
||||
color: #9fa9c2;
|
||||
font-family:
|
||||
"JetBrains Mono",
|
||||
monospace;
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
.editor-statusbar strong {
|
||||
color: #ffd86f;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.editor-status-left,
|
||||
.editor-status-right {
|
||||
display: flex;
|
||||
gap: 0.8rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* viewport-contained editor */
|
||||
|
||||
body.mode-editor {
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
body.mode-editor .topbar {
|
||||
height: 48px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body.mode-editor .container {
|
||||
height: calc(100vh - 48px);
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
body.mode-editor .card {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
body.mode-editor .editor-grid {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
height: auto;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
body.mode-editor .editor-pane {
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
body.mode-editor #editor-mount {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
body.mode-editor #editor-mount .cm-editor {
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
body.mode-editor #editor-mount .cm-scroller {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
body.mode-editor #preview {
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* cursor visibility */
|
||||
|
||||
.cm-cursor,
|
||||
.cm-dropCursor {
|
||||
border-left: 2px solid #ffd86f !important;
|
||||
}
|
||||
|
||||
.cm-focused .cm-cursor {
|
||||
border-left-color: #ffef9a !important;
|
||||
box-shadow: 0 0 0.35rem rgba(255,216,102,0.65);
|
||||
}
|
||||
|
||||
.cm-selectionMatch {
|
||||
background: rgba(255,216,102,0.18);
|
||||
}
|
||||
|
||||
/* reduce native-looking scrollbar noise */
|
||||
|
||||
body.mode-editor {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
body.mode-editor::-webkit-scrollbar {
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* editor scrollbars */
|
||||
|
||||
body.mode-editor .cm-scroller,
|
||||
body.mode-editor #preview,
|
||||
body.mode-editor .preview,
|
||||
body.mode-editor .cm-tooltip-autocomplete ul {
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: #5d6f9f #080c10;
|
||||
}
|
||||
|
||||
body.mode-editor .cm-scroller::-webkit-scrollbar,
|
||||
body.mode-editor #preview::-webkit-scrollbar,
|
||||
body.mode-editor .preview::-webkit-scrollbar,
|
||||
body.mode-editor .cm-tooltip-autocomplete ul::-webkit-scrollbar {
|
||||
width: 0.55rem;
|
||||
height: 0.55rem;
|
||||
}
|
||||
|
||||
body.mode-editor .cm-scroller::-webkit-scrollbar-track,
|
||||
body.mode-editor #preview::-webkit-scrollbar-track,
|
||||
body.mode-editor .preview::-webkit-scrollbar-track,
|
||||
body.mode-editor .cm-tooltip-autocomplete ul::-webkit-scrollbar-track {
|
||||
background: #080c10;
|
||||
}
|
||||
|
||||
body.mode-editor .cm-scroller::-webkit-scrollbar-thumb,
|
||||
body.mode-editor #preview::-webkit-scrollbar-thumb,
|
||||
body.mode-editor .preview::-webkit-scrollbar-thumb,
|
||||
body.mode-editor .cm-tooltip-autocomplete ul::-webkit-scrollbar-thumb {
|
||||
background: #5d6f9f;
|
||||
border-radius: 999px;
|
||||
border: 2px solid #080c10;
|
||||
}
|
||||
|
||||
body.mode-editor .cm-scroller::-webkit-scrollbar-thumb:hover,
|
||||
body.mode-editor #preview::-webkit-scrollbar-thumb:hover,
|
||||
body.mode-editor .preview::-webkit-scrollbar-thumb:hover,
|
||||
body.mode-editor .cm-tooltip-autocomplete ul::-webkit-scrollbar-thumb:hover {
|
||||
background: #ffd86f;
|
||||
}
|
||||
|
||||
/* autocomplete popup width/scroll cleanup */
|
||||
|
||||
.cm-tooltip-autocomplete {
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
.cm-tooltip-autocomplete ul {
|
||||
background: #101624 !important;
|
||||
padding: 0.15rem 0 !important;
|
||||
}
|
||||
|
||||
.cm-tooltip-autocomplete ul::-webkit-scrollbar-corner {
|
||||
background: #080c10;
|
||||
}
|
||||
|
||||
/* line numbers */
|
||||
|
||||
.cm-lineNumbers .cm-gutterElement {
|
||||
color: #7f8ca8;
|
||||
padding: 0 0.65rem 0 0.45rem;
|
||||
}
|
||||
|
||||
.cm-gutters {
|
||||
background: #070c12 !important;
|
||||
border-right: 1px solid #263241 !important;
|
||||
}
|
||||
|
||||
.cm-activeLineGutter {
|
||||
background: #172033 !important;
|
||||
color: #ffd86f !important;
|
||||
}
|
||||
|
||||
.cm-lineNumbers .cm-gutterElement:hover {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
/* editor compact command menu */
|
||||
|
||||
.editor-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
margin-bottom: 0.6rem;
|
||||
}
|
||||
|
||||
.editor-head-left {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.editor-head-path {
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
color: #aab5ce;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.editor-head-right {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
}
|
||||
|
||||
.editor-format-button,
|
||||
.editor-menu-button {
|
||||
height: 2rem;
|
||||
min-width: 2rem;
|
||||
padding: 0 0.65rem;
|
||||
border: 1px solid #344158;
|
||||
background: #101624;
|
||||
color: #d7dde8;
|
||||
border-radius: 0.25rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.editor-menu-button {
|
||||
font-size: 1.25rem;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.editor-format-button:hover,
|
||||
.editor-menu-button:hover {
|
||||
background: #1b2640;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.editor-menu {
|
||||
position: absolute;
|
||||
top: 2.35rem;
|
||||
right: 0;
|
||||
display: none;
|
||||
min-width: 12rem;
|
||||
background: #101624;
|
||||
border: 1px solid #44506a;
|
||||
border-radius: 0.3rem;
|
||||
box-shadow: 0 0.5rem 1.4rem rgba(0,0,0,0.55);
|
||||
z-index: 2500;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.editor-menu.open {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.editor-menu button,
|
||||
.editor-menu a {
|
||||
display: block;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 0.55rem 0.75rem;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-bottom: 1px solid rgba(255,255,255,0.06);
|
||||
color: #d7dde8;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.editor-menu button:hover,
|
||||
.editor-menu a:hover {
|
||||
background: #26324a;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.editor-menu .danger {
|
||||
color: #ff8ca8;
|
||||
}
|
||||
|
||||
.editor-format-dialog {
|
||||
border: 1px solid #44506a;
|
||||
border-radius: 0.35rem;
|
||||
background: #101624;
|
||||
color: #d7dde8;
|
||||
padding: 1rem;
|
||||
min-width: 20rem;
|
||||
}
|
||||
|
||||
.editor-format-dialog::backdrop {
|
||||
background: rgba(0,0,0,0.55);
|
||||
}
|
||||
|
||||
.editor-format-dialog h3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.editor-format-choice {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.editor-format-choice button {
|
||||
text-align: left;
|
||||
padding: 0.65rem 0.75rem;
|
||||
}
|
||||
|
||||
/* CodeMirror syntax colors: dark theme tuning */
|
||||
|
||||
.cm-editor {
|
||||
background: #070b10 !important;
|
||||
color: #d8e2f2 !important;
|
||||
}
|
||||
|
||||
.cm-content {
|
||||
color: #d8e2f2 !important;
|
||||
}
|
||||
|
||||
.cm-line {
|
||||
color: #d8e2f2;
|
||||
}
|
||||
|
||||
/* headings / markdown markers */
|
||||
.cm-heading,
|
||||
.cm-header,
|
||||
.cm-line .ͼc,
|
||||
.cm-line .ͼd,
|
||||
.cm-line .ͼe,
|
||||
.cm-line .ͼf {
|
||||
color: #ffd86f !important;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/* links */
|
||||
.cm-link,
|
||||
.cm-url,
|
||||
.cm-line .ͼa {
|
||||
color: #8bd5ff !important;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* emphasis */
|
||||
.cm-emphasis {
|
||||
color: #f7b7d8 !important;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.cm-strong {
|
||||
color: #ffffff !important;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/* code / fenced block */
|
||||
.cm-monospace,
|
||||
.cm-inlineCode,
|
||||
.cm-line .ͼb {
|
||||
color: #aee7ff !important;
|
||||
background: rgba(174,231,255,0.08);
|
||||
}
|
||||
|
||||
/* punctuation / markdown syntax */
|
||||
.cm-punctuation,
|
||||
.cm-line .ͼ13,
|
||||
.cm-line .ͼ14 {
|
||||
color: #7f8ca8 !important;
|
||||
}
|
||||
|
||||
/* keywords / tags */
|
||||
.cm-keyword {
|
||||
color: #ff9ecb !important;
|
||||
}
|
||||
|
||||
.cm-tagName {
|
||||
color: #8bd5ff !important;
|
||||
}
|
||||
|
||||
.cm-attributeName {
|
||||
color: #ffd86f !important;
|
||||
}
|
||||
|
||||
.cm-string {
|
||||
color: #b7f7c1 !important;
|
||||
}
|
||||
|
||||
.cm-comment {
|
||||
color: #7f8ca8 !important;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* fallback for generated lezer highlight classes */
|
||||
.cm-line [class^="ͼ"],
|
||||
.cm-line [class*=" ͼ"] {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
/* selection should not destroy contrast */
|
||||
.cm-selectionBackground,
|
||||
.cm-content ::selection {
|
||||
background: rgba(255,216,102,0.26) !important;
|
||||
color: #ffffff !important;
|
||||
}
|
||||
|
||||
/* last-resort visual selection override */
|
||||
.cm-editor .cm-selectionLayer > div,
|
||||
.cm-editor.cm-focused .cm-selectionLayer > div {
|
||||
background-color: rgba(255, 216, 102, 0.55) !important;
|
||||
}
|
||||
|
||||
.cm-editor.pageswiki-vim-visual .cm-selectionLayer > div {
|
||||
background-color: rgba(183, 247, 193, 0.58) !important;
|
||||
}
|
||||
|
||||
.preview .diagram,
|
||||
#preview .diagram {
|
||||
margin: 1rem 0;
|
||||
padding: 0.75rem;
|
||||
border: 1px solid #263241;
|
||||
background: #ffffff;
|
||||
border-radius: 0.35rem;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.preview .diagram img,
|
||||
#preview .diagram img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
@@ -31,7 +31,7 @@
|
||||
View
|
||||
</a>
|
||||
|
||||
<a href="/e{{ .Path }}">
|
||||
<a href="/e/-{{ .Path }}">
|
||||
Edit
|
||||
</a>
|
||||
|
||||
|
||||
@@ -0,0 +1,831 @@
|
||||
{{ define "browser.gohtml" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Browser</title>
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/jetbrains-mono@5.0.20/index.css">
|
||||
<link rel="stylesheet" href="/o/path:/system/static/css/main.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: "Hack Nerd Font";
|
||||
src: url("https://cdn.jsdelivr.net/gh/ryanoasis/nerd-fonts@master/patched-fonts/Hack/Regular/HackNerdFont-Regular.ttf") format("truetype");
|
||||
}
|
||||
|
||||
.browser-layout {
|
||||
display: grid;
|
||||
grid-template-columns: var(--browser-sidebar-width, 14rem) 6px 1fr 6px var(--browser-preview-width, 22rem);
|
||||
min-height: calc(100vh - 48px);
|
||||
}
|
||||
|
||||
.browser-sidebar,
|
||||
.browser-preview {
|
||||
border-color: var(--border-soft);
|
||||
padding: 0.75rem;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.browser-sidebar {
|
||||
border-right: 1px solid var(--border-soft);
|
||||
}
|
||||
|
||||
.browser-preview {
|
||||
border-left: 1px solid var(--border-soft);
|
||||
}
|
||||
|
||||
.browser-layout.no-sidebar .browser-sidebar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.browser-layout.no-preview .browser-preview {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.browser-layout.no-sidebar {
|
||||
grid-template-columns: 1fr 6px var(--browser-preview-width, 22rem);
|
||||
}
|
||||
|
||||
.browser-layout.no-preview {
|
||||
grid-template-columns: var(--browser-sidebar-width, 14rem) 6px 1fr;
|
||||
}
|
||||
|
||||
.browser-layout.no-sidebar.no-preview {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.browser-main {
|
||||
padding: 1rem;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.browser-toolbar {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
margin-bottom: 0.75rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.icon-button {
|
||||
min-width: 2.25rem;
|
||||
height: 2.25rem;
|
||||
padding: 0;
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
}
|
||||
|
||||
.segmented {
|
||||
display: inline-flex;
|
||||
border: 1px solid var(--button-border);
|
||||
border-radius: 0.25rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.segmented button {
|
||||
border: none;
|
||||
border-right: 1px solid var(--button-border);
|
||||
border-radius: 0;
|
||||
background: var(--button-bg);
|
||||
}
|
||||
|
||||
.segmented button:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.segmented button.active {
|
||||
background: var(--row-hover);
|
||||
color: var(--link-hover);
|
||||
}
|
||||
|
||||
.sidebar-link {
|
||||
display: block;
|
||||
margin: 0.25rem 0;
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.pane-close {
|
||||
min-width: 2rem;
|
||||
height: 2rem;
|
||||
padding: 0;
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.browser-path {
|
||||
padding: 0.35rem 0;
|
||||
border-bottom: 1px solid var(--border-soft);
|
||||
}
|
||||
|
||||
.browser-path {
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
color: var(--muted);
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.browser-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
|
||||
gap: 0.55rem;
|
||||
}
|
||||
|
||||
.browser-grid.details {
|
||||
display: table;
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.browser-row {
|
||||
border: 1px solid var(--border-soft);
|
||||
padding: 0.55rem;
|
||||
cursor: default;
|
||||
user-select: none;
|
||||
background: var(--panel);
|
||||
}
|
||||
|
||||
.browser-row:hover,
|
||||
.browser-row.selected {
|
||||
background: var(--row-hover);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.browser-grid.details .browser-row {
|
||||
display: table-row;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.browser-grid.details .browser-cell {
|
||||
display: table-cell;
|
||||
padding: 0.42rem;
|
||||
border-bottom: 1px solid var(--border-soft);
|
||||
}
|
||||
|
||||
.browser-icon {
|
||||
font-family: "Hack Nerd Font";
|
||||
font-size: 1.35rem;
|
||||
color: var(--link);
|
||||
}
|
||||
|
||||
.browser-icon.dir {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.browser-name {
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.browser-meta {
|
||||
color: var(--muted);
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
.context-menu {
|
||||
position: fixed;
|
||||
z-index: 1000;
|
||||
min-width: 12rem;
|
||||
display: none;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
box-shadow: 0 0.4rem 1.4rem rgba(0,0,0,0.35);
|
||||
}
|
||||
|
||||
.context-menu button {
|
||||
display: block;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--border-soft);
|
||||
background: transparent;
|
||||
color: var(--fg);
|
||||
padding: 0.5rem 0.75rem;
|
||||
}
|
||||
|
||||
.context-menu button:hover {
|
||||
background: var(--row-hover);
|
||||
}
|
||||
|
||||
.preview-frame {
|
||||
width: 100%;
|
||||
height: 70vh;
|
||||
border: 1px solid var(--border-soft);
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
|
||||
.resize-handle {
|
||||
background: var(--border-soft);
|
||||
cursor: col-resize;
|
||||
min-width: 6px;
|
||||
}
|
||||
|
||||
.resize-handle:hover,
|
||||
.resize-handle.dragging {
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
.browser-layout.no-sidebar #sidebar-resizer,
|
||||
.browser-layout.no-preview #preview-resizer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<header class="topbar">
|
||||
<div class="brand">
|
||||
<a href="/">{{ .WikiName }}</a>
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
{{ range .NavItems }}
|
||||
<a href="{{ .ResolvedHref }}">{{ .Label }}</a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main id="browser-layout" class="browser-layout">
|
||||
|
||||
<aside id="browser-sidebar" class="browser-sidebar">
|
||||
<button
|
||||
type="button"
|
||||
class="pane-close"
|
||||
title="Hide sidebar"
|
||||
onclick="toggleSidebar()"
|
||||
>
|
||||
‹
|
||||
</button>
|
||||
|
||||
<h3>Navigator</h3>
|
||||
<a class="sidebar-link" href="/v/browser/">Root</a>
|
||||
<a class="sidebar-link" href="/v/browser/pageswiki-design">pageswiki-design</a>
|
||||
<a class="sidebar-link" href="/v/tree">Tree View</a>
|
||||
<a class="sidebar-link" href="/-/sys/config">Config</a>
|
||||
</aside>
|
||||
|
||||
<div
|
||||
id="sidebar-resizer"
|
||||
class="resize-handle"
|
||||
onmousedown="startResize(event, 'sidebar')"
|
||||
></div>
|
||||
|
||||
<section class="browser-main">
|
||||
|
||||
<div class="browser-toolbar">
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="icon-button"
|
||||
title="Toggle sidebar"
|
||||
onclick="toggleSidebar()"
|
||||
>
|
||||
☰
|
||||
</button>
|
||||
|
||||
<div class="segmented" role="group" aria-label="View mode">
|
||||
|
||||
<button
|
||||
id="view-icons"
|
||||
type="button"
|
||||
title="Icon view"
|
||||
onclick="setViewMode('icons')"
|
||||
>
|
||||
▦
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="view-details"
|
||||
type="button"
|
||||
title="Detail view"
|
||||
onclick="setViewMode('details')"
|
||||
>
|
||||
☷
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
<button
|
||||
id="preview-toggle"
|
||||
type="button"
|
||||
class="icon-button"
|
||||
title="Toggle preview"
|
||||
onclick="togglePreview()"
|
||||
>
|
||||
◧
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="browser-path">
|
||||
{{ .Path }}
|
||||
</div>
|
||||
|
||||
<div id="browser-grid" class="browser-grid">
|
||||
|
||||
{{ range .Entries }}
|
||||
|
||||
<div
|
||||
class="browser-row"
|
||||
draggable="true"
|
||||
data-path="{{ .Path }}"
|
||||
data-name="{{ .Name }}"
|
||||
data-is-dir="{{ .IsDir }}"
|
||||
data-object-uuid="{{ .ObjectUUID }}"
|
||||
oncontextmenu="openContextMenu(event, this)"
|
||||
onclick="selectEntry(this)"
|
||||
ondblclick="openEntry(this)"
|
||||
ondragstart="dragStart(event, this)"
|
||||
ondragover="dragOver(event, this)"
|
||||
ondrop="dropEntry(event, this)"
|
||||
>
|
||||
|
||||
<div class="browser-cell browser-icon {{ if .IsDir }}dir{{ end }}">
|
||||
{{ if .IsDir }}{{ else }}{{ end }}
|
||||
</div>
|
||||
|
||||
<div class="browser-cell browser-name">
|
||||
{{ .Name }}
|
||||
</div>
|
||||
|
||||
<div class="browser-cell browser-meta">
|
||||
{{ if .IsDir }}
|
||||
{{ .ChildCount }} items
|
||||
{{ else }}
|
||||
{{ formatBytes .Size }}
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
<div class="browser-cell browser-meta">
|
||||
{{ if not .IsDir }}
|
||||
{{ formatUnix .UpdatedAt }}
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
<div
|
||||
id="preview-resizer"
|
||||
class="resize-handle"
|
||||
onmousedown="startResize(event, 'preview')"
|
||||
></div>
|
||||
|
||||
<aside id="browser-preview" class="browser-preview">
|
||||
<button
|
||||
type="button"
|
||||
class="pane-close"
|
||||
title="Hide preview"
|
||||
onclick="togglePreview()"
|
||||
>
|
||||
›
|
||||
</button>
|
||||
|
||||
<iframe
|
||||
id="preview-frame"
|
||||
class="preview-frame"
|
||||
src="about:blank"
|
||||
></iframe>
|
||||
</aside>
|
||||
|
||||
</main>
|
||||
|
||||
<div id="context-menu" class="context-menu">
|
||||
<button type="button" onclick="ctxOpen()">Open</button>
|
||||
<button type="button" onclick="ctxEdit()">Edit</button>
|
||||
<button type="button" onclick="ctxRename()">Rename</button>
|
||||
<button type="button" onclick="ctxCopyPath()">Copy path</button>
|
||||
<button type="button" onclick="ctxLink()">Path links</button>
|
||||
<button type="button" onclick="ctxMeta()">Metadata</button>
|
||||
<button type="button" onclick="ctxExternal()">Open with external handler</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let selectedEntry = null
|
||||
let draggedPath = ""
|
||||
|
||||
function setViewMode(mode) {
|
||||
const grid =
|
||||
document.getElementById("browser-grid")
|
||||
|
||||
if (mode === "details") {
|
||||
grid.classList.add("details")
|
||||
} else {
|
||||
grid.classList.remove("details")
|
||||
}
|
||||
|
||||
const icons =
|
||||
document.getElementById("view-icons")
|
||||
|
||||
const details =
|
||||
document.getElementById("view-details")
|
||||
|
||||
if (icons && details) {
|
||||
icons.classList.toggle("active", mode === "icons")
|
||||
details.classList.toggle("active", mode === "details")
|
||||
}
|
||||
|
||||
localStorage.setItem("browser.viewMode", mode)
|
||||
}
|
||||
|
||||
function restoreViewMode() {
|
||||
setViewMode(
|
||||
localStorage.getItem("browser.viewMode") || "icons"
|
||||
)
|
||||
}
|
||||
|
||||
function toggleSidebar() {
|
||||
const layout =
|
||||
document.getElementById("browser-layout")
|
||||
|
||||
layout.classList.toggle("no-sidebar")
|
||||
|
||||
localStorage.setItem(
|
||||
"browser.sidebar",
|
||||
layout.classList.contains("no-sidebar") ? "hide" : "show"
|
||||
)
|
||||
}
|
||||
|
||||
function togglePreview() {
|
||||
const layout =
|
||||
document.getElementById("browser-layout")
|
||||
|
||||
layout.classList.toggle("no-preview")
|
||||
|
||||
localStorage.setItem(
|
||||
"browser.preview",
|
||||
layout.classList.contains("no-preview") ? "hide" : "show"
|
||||
)
|
||||
|
||||
updatePaneButtons()
|
||||
}
|
||||
|
||||
function updatePaneButtons() {
|
||||
const layout =
|
||||
document.getElementById("browser-layout")
|
||||
|
||||
const previewBtn =
|
||||
document.getElementById("preview-toggle")
|
||||
|
||||
if (previewBtn) {
|
||||
const hidden =
|
||||
layout.classList.contains("no-preview")
|
||||
|
||||
previewBtn.textContent =
|
||||
hidden ? "◨" : "◧"
|
||||
|
||||
previewBtn.title =
|
||||
hidden ? "Show preview" : "Hide preview"
|
||||
|
||||
previewBtn.classList.toggle(
|
||||
"active",
|
||||
!hidden
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function restorePanes() {
|
||||
const layout =
|
||||
document.getElementById("browser-layout")
|
||||
|
||||
const sidebarWidth =
|
||||
localStorage.getItem("browser.sidebarWidth")
|
||||
|
||||
const previewWidth =
|
||||
localStorage.getItem("browser.previewWidth")
|
||||
|
||||
if (sidebarWidth) {
|
||||
layout.style.setProperty(
|
||||
"--browser-sidebar-width",
|
||||
sidebarWidth
|
||||
)
|
||||
}
|
||||
|
||||
if (previewWidth) {
|
||||
layout.style.setProperty(
|
||||
"--browser-preview-width",
|
||||
previewWidth
|
||||
)
|
||||
}
|
||||
|
||||
if (localStorage.getItem("browser.sidebar") === "hide") {
|
||||
layout.classList.add("no-sidebar")
|
||||
}
|
||||
|
||||
if (localStorage.getItem("browser.preview") === "hide") {
|
||||
layout.classList.add("no-preview")
|
||||
}
|
||||
|
||||
updatePaneButtons()
|
||||
}
|
||||
|
||||
function startResize(ev, pane) {
|
||||
ev.preventDefault()
|
||||
|
||||
const layout =
|
||||
document.getElementById("browser-layout")
|
||||
|
||||
const startX =
|
||||
ev.clientX
|
||||
|
||||
const rect =
|
||||
layout.getBoundingClientRect()
|
||||
|
||||
const sidebarStart =
|
||||
parseFloat(
|
||||
getComputedStyle(layout)
|
||||
.getPropertyValue("--browser-sidebar-width")
|
||||
) || 224
|
||||
|
||||
const previewStart =
|
||||
parseFloat(
|
||||
getComputedStyle(layout)
|
||||
.getPropertyValue("--browser-preview-width")
|
||||
) || 352
|
||||
|
||||
const handle =
|
||||
ev.currentTarget
|
||||
|
||||
handle.classList.add("dragging")
|
||||
|
||||
function onMove(e) {
|
||||
if (pane === "sidebar") {
|
||||
const width =
|
||||
Math.max(
|
||||
120,
|
||||
Math.min(
|
||||
520,
|
||||
sidebarStart + (e.clientX - startX)
|
||||
)
|
||||
)
|
||||
|
||||
layout.style.setProperty(
|
||||
"--browser-sidebar-width",
|
||||
width + "px"
|
||||
)
|
||||
}
|
||||
|
||||
if (pane === "preview") {
|
||||
const width =
|
||||
Math.max(
|
||||
180,
|
||||
Math.min(
|
||||
rect.width - 260,
|
||||
previewStart - (e.clientX - startX)
|
||||
)
|
||||
)
|
||||
|
||||
layout.style.setProperty(
|
||||
"--browser-preview-width",
|
||||
width + "px"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function onUp() {
|
||||
handle.classList.remove("dragging")
|
||||
|
||||
localStorage.setItem(
|
||||
"browser.sidebarWidth",
|
||||
getComputedStyle(layout)
|
||||
.getPropertyValue("--browser-sidebar-width")
|
||||
.trim()
|
||||
)
|
||||
|
||||
localStorage.setItem(
|
||||
"browser.previewWidth",
|
||||
getComputedStyle(layout)
|
||||
.getPropertyValue("--browser-preview-width")
|
||||
.trim()
|
||||
)
|
||||
|
||||
document.removeEventListener("mousemove", onMove)
|
||||
document.removeEventListener("mouseup", onUp)
|
||||
}
|
||||
|
||||
document.addEventListener("mousemove", onMove)
|
||||
document.addEventListener("mouseup", onUp)
|
||||
}
|
||||
|
||||
function selectEntry(el) {
|
||||
for (const row of document.querySelectorAll(".browser-row")) {
|
||||
row.classList.remove("selected")
|
||||
}
|
||||
|
||||
el.classList.add("selected")
|
||||
selectedEntry = el
|
||||
|
||||
updatePreview(el)
|
||||
}
|
||||
|
||||
function openEntry(el) {
|
||||
const p = el.dataset.path
|
||||
|
||||
if (el.dataset.isDir === "true") {
|
||||
location.href = "/v/browser" + p
|
||||
return
|
||||
}
|
||||
|
||||
location.href = p
|
||||
}
|
||||
|
||||
function updatePreview(el) {
|
||||
const p = el.dataset.path
|
||||
const uuid = el.dataset.objectUuid
|
||||
|
||||
const frame =
|
||||
document.getElementById("preview-frame")
|
||||
|
||||
frame.src = "/v/preview" + p
|
||||
}
|
||||
|
||||
function openContextMenu(ev, el) {
|
||||
ev.preventDefault()
|
||||
selectEntry(el)
|
||||
|
||||
const menu =
|
||||
document.getElementById("context-menu")
|
||||
|
||||
menu.style.left =
|
||||
ev.clientX + "px"
|
||||
|
||||
menu.style.top =
|
||||
ev.clientY + "px"
|
||||
|
||||
menu.style.display =
|
||||
"block"
|
||||
}
|
||||
|
||||
document.addEventListener(
|
||||
"click",
|
||||
() => {
|
||||
document.getElementById("context-menu").style.display = "none"
|
||||
}
|
||||
)
|
||||
|
||||
function ctxOpen() {
|
||||
if (selectedEntry) {
|
||||
openEntry(selectedEntry)
|
||||
}
|
||||
}
|
||||
|
||||
function ctxEdit() {
|
||||
if (!selectedEntry) {
|
||||
return
|
||||
}
|
||||
|
||||
location.href =
|
||||
"/e" + selectedEntry.dataset.path
|
||||
}
|
||||
|
||||
async function ctxRename() {
|
||||
if (!selectedEntry) {
|
||||
return
|
||||
}
|
||||
|
||||
const oldPath =
|
||||
selectedEntry.dataset.path
|
||||
|
||||
const newPath =
|
||||
prompt("Rename path:", oldPath)
|
||||
|
||||
if (!newPath || newPath === oldPath) {
|
||||
return
|
||||
}
|
||||
|
||||
await renamePath(oldPath, newPath)
|
||||
location.reload()
|
||||
}
|
||||
|
||||
function ctxCopyPath() {
|
||||
if (!selectedEntry) {
|
||||
return
|
||||
}
|
||||
|
||||
navigator.clipboard.writeText(
|
||||
selectedEntry.dataset.path
|
||||
)
|
||||
}
|
||||
|
||||
function ctxLink() {
|
||||
if (!selectedEntry) {
|
||||
return
|
||||
}
|
||||
|
||||
const uuid =
|
||||
selectedEntry.dataset.objectUuid
|
||||
|
||||
if (!uuid) {
|
||||
alert("directory has no object uuid")
|
||||
return
|
||||
}
|
||||
|
||||
location.href =
|
||||
"/l/uuid:" + uuid
|
||||
}
|
||||
|
||||
function ctxMeta() {
|
||||
if (!selectedEntry) {
|
||||
return
|
||||
}
|
||||
|
||||
alert(
|
||||
"Path: " + selectedEntry.dataset.path +
|
||||
"\\nObject UUID: " + selectedEntry.dataset.objectUuid +
|
||||
"\\nDirectory: " + selectedEntry.dataset.isDir
|
||||
)
|
||||
}
|
||||
|
||||
function ctxExternal() {
|
||||
alert("external handler is not implemented yet")
|
||||
}
|
||||
|
||||
function dragStart(ev, el) {
|
||||
draggedPath =
|
||||
el.dataset.path
|
||||
|
||||
ev.dataTransfer.setData(
|
||||
"text/plain",
|
||||
draggedPath
|
||||
)
|
||||
}
|
||||
|
||||
function dragOver(ev, el) {
|
||||
if (el.dataset.isDir === "true") {
|
||||
ev.preventDefault()
|
||||
}
|
||||
}
|
||||
|
||||
async function dropEntry(ev, el) {
|
||||
ev.preventDefault()
|
||||
|
||||
if (el.dataset.isDir !== "true") {
|
||||
return
|
||||
}
|
||||
|
||||
const targetDir =
|
||||
el.dataset.path
|
||||
|
||||
const oldPath =
|
||||
ev.dataTransfer.getData("text/plain") || draggedPath
|
||||
|
||||
if (!oldPath || oldPath === targetDir) {
|
||||
return
|
||||
}
|
||||
|
||||
const base =
|
||||
oldPath.split("/").filter(Boolean).pop()
|
||||
|
||||
const newPath =
|
||||
targetDir.replace(/\/$/, "") + "/" + base
|
||||
|
||||
if (!confirm(oldPath + "\\n↓\\n" + newPath)) {
|
||||
return
|
||||
}
|
||||
|
||||
await renamePath(oldPath, newPath)
|
||||
location.reload()
|
||||
}
|
||||
|
||||
async function renamePath(oldPath, newPath) {
|
||||
const res =
|
||||
await fetch(
|
||||
"/_/api/v1/path/rename",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
old_path: oldPath,
|
||||
new_path: newPath,
|
||||
}),
|
||||
}
|
||||
)
|
||||
|
||||
if (!res.ok) {
|
||||
alert("rename failed")
|
||||
throw new Error("rename failed")
|
||||
}
|
||||
}
|
||||
|
||||
restoreViewMode()
|
||||
restorePanes()
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
+148
-152
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="/o/path:/system/static/css/modes.css">
|
||||
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
</head>
|
||||
|
||||
<body class="mode-config">
|
||||
@@ -27,7 +27,9 @@
|
||||
|
||||
</header>
|
||||
|
||||
<main class="config-layout">
|
||||
<main class="config-main">
|
||||
|
||||
<div class="config-layout">
|
||||
|
||||
<aside
|
||||
id="config-sidebar"
|
||||
@@ -48,6 +50,10 @@
|
||||
{{ T "config.home" }}
|
||||
</a>
|
||||
|
||||
<a href="#" data-panel="editor" onclick="showConfigPanel('editor'); return false;">
|
||||
Editor
|
||||
</a>
|
||||
|
||||
<a href="#" data-panel="objects" onclick="showConfigPanel('objects'); return false;">
|
||||
{{ T "config.objects" }}
|
||||
</a>
|
||||
@@ -64,7 +70,7 @@
|
||||
|
||||
</aside>
|
||||
|
||||
<section class="config-main">
|
||||
<section class="config-content">
|
||||
|
||||
<section
|
||||
id="panel-home"
|
||||
@@ -141,15 +147,11 @@ English
|
||||
<select
|
||||
name="theme"
|
||||
>
|
||||
<option value="dark" {{ if eq .Theme "dark" }}selected{{ end }}>Dark</option>
|
||||
<option value="light" {{ if eq .Theme "light" }}selected{{ end }}>Light</option>
|
||||
<option value="monokai" {{ if eq .Theme "monokai" }}selected{{ end }}>Monokai</option>
|
||||
<option value="solarized-dark" {{ if eq .Theme "solarized-dark" }}selected{{ end }}>Solarized Dark</option>
|
||||
<option value="solarized-light" {{ if eq .Theme "solarized-light" }}selected{{ end }}>Solarized Light</option>
|
||||
<option value="terminal-green" {{ if eq .Theme "terminal-green" }}selected{{ end }}>Terminal Green</option>
|
||||
<option value="amber-crt" {{ if eq .Theme "amber-crt" }}selected{{ end }}>Amber CRT</option>
|
||||
<option value="lain-dark" {{ if eq .Theme "lain-dark" }}selected{{ end }}>Lain Dark</option>
|
||||
<option value="nanoha-dark" {{ if eq .Theme "nanoha-dark" }}selected{{ end }}>Nanoha Dark</option>
|
||||
{{ range .ThemeOptions }}
|
||||
<option value="{{ .ID }}" {{ if eq $.Theme .ID }}selected{{ end }}>
|
||||
{{ .Label }}
|
||||
</option>
|
||||
{{ end }}
|
||||
</select>
|
||||
|
||||
<br>
|
||||
@@ -306,7 +308,6 @@ Purge Zombies
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
<section
|
||||
id="panel-nav-home"
|
||||
class="config-section config-panel"
|
||||
@@ -491,9 +492,76 @@ Purge Zombies
|
||||
|
||||
</section>
|
||||
|
||||
<section
|
||||
id="panel-editor"
|
||||
class="config-section config-panel"
|
||||
>
|
||||
|
||||
<h2>Editor</h2>
|
||||
|
||||
<form
|
||||
method="post"
|
||||
action="/-/sys/config"
|
||||
>
|
||||
|
||||
<input
|
||||
type="hidden"
|
||||
name="section"
|
||||
value="editor"
|
||||
>
|
||||
|
||||
<label>
|
||||
Keymap
|
||||
</label>
|
||||
|
||||
<select name="editor_keymap">
|
||||
<option value="default" {{ if eq .EditorKeymap "default" }}selected{{ end }}>
|
||||
Default
|
||||
</option>
|
||||
<option value="vim" {{ if eq .EditorKeymap "vim" }}selected{{ end }}>
|
||||
Vim
|
||||
</option>
|
||||
</select>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="editor_syntax_highlight"
|
||||
{{ if .EditorSyntax }}checked{{ end }}
|
||||
>
|
||||
Syntax highlighting
|
||||
</label>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="editor_autocomplete"
|
||||
{{ if .EditorAutocomplete }}checked{{ end }}
|
||||
>
|
||||
Autocomplete
|
||||
</label>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<button type="submit">
|
||||
Save
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
@@ -577,82 +645,10 @@ document.addEventListener(
|
||||
},
|
||||
)
|
||||
|
||||
function moveNavRow(button, direction) {
|
||||
|
||||
const row =
|
||||
button.closest(
|
||||
"tr"
|
||||
)
|
||||
|
||||
const tbody =
|
||||
row.parentElement
|
||||
|
||||
if (direction < 0) {
|
||||
|
||||
const prev =
|
||||
row.previousElementSibling
|
||||
|
||||
if (prev) {
|
||||
|
||||
tbody.insertBefore(
|
||||
row,
|
||||
prev
|
||||
)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
const next =
|
||||
row.nextElementSibling
|
||||
|
||||
if (next) {
|
||||
|
||||
tbody.insertBefore(
|
||||
next,
|
||||
row
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function moveNavRow(button, direction) {
|
||||
|
||||
const row =
|
||||
button.closest(
|
||||
"tr"
|
||||
)
|
||||
|
||||
const tbody =
|
||||
row.parentElement
|
||||
|
||||
if (direction < 0) {
|
||||
|
||||
const prev =
|
||||
row.previousElementSibling
|
||||
|
||||
if (prev) {
|
||||
|
||||
tbody.insertBefore(
|
||||
row,
|
||||
prev
|
||||
)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
const next =
|
||||
row.nextElementSibling
|
||||
|
||||
if (next) {
|
||||
|
||||
tbody.insertBefore(
|
||||
next,
|
||||
row
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function moveNavRow(button, direction) {
|
||||
@@ -697,109 +693,109 @@ function moveNavRow(button, direction) {
|
||||
|
||||
<style>
|
||||
|
||||
.config-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 14rem 1fr;
|
||||
min-height: calc(100vh - 48px);
|
||||
body.mode-config .config-main {
|
||||
padding: 1.25rem;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.config-sidebar {
|
||||
border-right: 1px solid rgba(255,255,255,0.06);
|
||||
body.mode-config .config-layout {
|
||||
display: grid !important;
|
||||
grid-template-columns: 16rem minmax(0, 1fr) !important;
|
||||
gap: 1.5rem !important;
|
||||
align-items: start !important;
|
||||
}
|
||||
|
||||
body.mode-config .config-sidebar {
|
||||
grid-column: 1;
|
||||
position: sticky;
|
||||
top: 4rem;
|
||||
align-self: start;
|
||||
border-right: 1px solid var(--border-soft);
|
||||
padding: 0.75rem;
|
||||
transition: width 0.12s linear;
|
||||
min-height: calc(100vh - 6rem);
|
||||
}
|
||||
|
||||
.config-sidebar.collapsed {
|
||||
body.mode-config .config-sidebar.collapsed {
|
||||
width: 2.5rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar-toggle {
|
||||
background: transparent;
|
||||
color: #aaa;
|
||||
border: 1px solid rgba(255,255,255,0.08);
|
||||
padding: 0.25rem 0.5rem;
|
||||
cursor: pointer;
|
||||
body.mode-config .config-sidebar.collapsed .sidebar-nav {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sidebar-nav {
|
||||
body.mode-config .config-content {
|
||||
grid-column: 2;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
body.mode-config .config-panel {
|
||||
display: none;
|
||||
}
|
||||
|
||||
body.mode-config .config-panel.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
body.mode-config .sidebar-nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-top: 1rem;
|
||||
gap: 0.5rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.sidebar-nav a {
|
||||
body.mode-config .sidebar-nav a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.config-main {
|
||||
padding: 1.25rem;
|
||||
body.mode-config .sidebar-nav a.active {
|
||||
color: var(--link-hover);
|
||||
}
|
||||
|
||||
.config-section {
|
||||
body.mode-config .config-section {
|
||||
margin-bottom: 2rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.config-section input[type="text"] {
|
||||
width: 100%;
|
||||
body.mode-config .config-section input[type="text"],
|
||||
body.mode-config .config-section input[type="number"],
|
||||
body.mode-config .config-section select {
|
||||
max-width: 42rem;
|
||||
background: var(--input-bg);
|
||||
color: var(--fg);
|
||||
border: 1px solid var(--input-border);
|
||||
}
|
||||
|
||||
body.mode-config .config-section input[type="text"] {
|
||||
width: 100%;
|
||||
padding: 0.6rem;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.recent-table {
|
||||
body.mode-config .recent-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.recent-table th {
|
||||
body.mode-config .recent-table th,
|
||||
body.mode-config .recent-table td {
|
||||
border-bottom: 1px solid var(--border-soft);
|
||||
padding: 0.4rem;
|
||||
}
|
||||
|
||||
body.mode-config .recent-table th {
|
||||
text-align: left;
|
||||
color: var(--muted);
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
body.mode-config .recent-table tr:hover {
|
||||
background: var(--row-hover);
|
||||
}
|
||||
|
||||
body.mode-config .mono {
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
}
|
||||
|
||||
body.mode-config .muted {
|
||||
color: var(--muted);
|
||||
border-bottom: 1px solid rgba(255,255,255,0.08);
|
||||
padding: 0.45rem 0.35rem;
|
||||
}
|
||||
|
||||
.recent-table td {
|
||||
border-bottom: 1px solid rgba(255,255,255,0.035);
|
||||
padding: 0.38rem 0.35rem;
|
||||
}
|
||||
|
||||
.recent-table tr:hover {
|
||||
background: rgba(255,255,255,0.025);
|
||||
}
|
||||
|
||||
.mono {
|
||||
font-family:
|
||||
"JetBrains Mono",
|
||||
monospace;
|
||||
}
|
||||
|
||||
.muted {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
|
||||
.config-panel {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.config-panel.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.sidebar-nav a.active {
|
||||
color: var(--link-hover);
|
||||
text-shadow:
|
||||
0 0 0.45rem rgba(180,120,255,0.35);
|
||||
}
|
||||
|
||||
.config-sidebar.collapsed .sidebar-nav {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
+227
-29
@@ -20,7 +20,20 @@
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
|
||||
|
||||
<script
|
||||
type="module"
|
||||
src="/o/path:/system/static/vendor/codemirror/editor.bundle.js"
|
||||
></script>
|
||||
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="/o/path:/system/static/vendor/codemirror/editor.css"
|
||||
>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="mode-editor">
|
||||
@@ -59,57 +72,67 @@ Links
|
||||
|
||||
<section class="card">
|
||||
|
||||
<div class="path-label">
|
||||
<div class="editor-head">
|
||||
|
||||
<div class="editor-head-left">
|
||||
<div class="editor-head-path">
|
||||
{{ .Path }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="editor-toolbar">
|
||||
<div class="editor-head-right">
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="PagesEditor.saveNow()"
|
||||
class="editor-format-button"
|
||||
onclick="openFormatDialog()"
|
||||
>
|
||||
{{ .EditType }}
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="editor-menu-button"
|
||||
onclick="toggleEditorMenu(event)"
|
||||
aria-label="Editor menu"
|
||||
>
|
||||
⋯
|
||||
</button>
|
||||
|
||||
<div
|
||||
id="editor-menu"
|
||||
class="editor-menu"
|
||||
>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="PagesEditor.saveNow(); closeEditorMenu();"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="PagesPathActions.renameCurrentPath()"
|
||||
onclick="PagesPathActions.renameCurrentPath(); closeEditorMenu();"
|
||||
>
|
||||
Rename
|
||||
</button>
|
||||
|
||||
<a href="/r/history/{{ .ObjectUUID }}">
|
||||
History
|
||||
</a>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="PagesPathActions.removeCurrentPath()"
|
||||
class="danger"
|
||||
onclick="PagesPathActions.removeCurrentPath(); closeEditorMenu();"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
|
||||
<a
|
||||
class="button"
|
||||
href="/r/history/{{ .ObjectUUID }}"
|
||||
>
|
||||
History
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<select id="editor-type">
|
||||
|
||||
<option
|
||||
value="html"
|
||||
{{ if eq .EditType "html" }}selected{{ end }}
|
||||
>
|
||||
HTML
|
||||
</option>
|
||||
|
||||
<option
|
||||
value="markdown"
|
||||
{{ if eq .EditType "markdown" }}selected{{ end }}
|
||||
>
|
||||
Markdown
|
||||
</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -118,8 +141,40 @@ Markdown
|
||||
<textarea
|
||||
id="editor"
|
||||
class="editor"
|
||||
hidden
|
||||
>{{ .Body }}</textarea>
|
||||
|
||||
<div class="editor-pane">
|
||||
|
||||
<div
|
||||
id="editor-mount"
|
||||
data-keymap="{{ .EditorKeymap }}"
|
||||
data-syntax="{{ .EditorSyntax }}"
|
||||
data-autocomplete="{{ .EditorAutocomplete }}"
|
||||
></div>
|
||||
|
||||
<div
|
||||
id="editor-statusbar"
|
||||
class="editor-statusbar"
|
||||
>
|
||||
<div class="editor-status-left">
|
||||
<span id="editor-vim-mode">
|
||||
MODE
|
||||
</span>
|
||||
<span>
|
||||
{{ .EditType }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="editor-status-right">
|
||||
<span id="editor-cursor">
|
||||
Ln 1, Col 1
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<article
|
||||
id="preview"
|
||||
class="preview"
|
||||
@@ -141,11 +196,154 @@ Markdown
|
||||
|
||||
</section>
|
||||
|
||||
<dialog
|
||||
id="editor-format-dialog"
|
||||
class="editor-format-dialog"
|
||||
>
|
||||
|
||||
<h3>Select Document Format</h3>
|
||||
|
||||
<div class="editor-format-choice">
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="switchEditorFormat('html')"
|
||||
>
|
||||
HTML
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="switchEditorFormat('markdown')"
|
||||
>
|
||||
Markdown
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="closeFormatDialog()"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
|
||||
</dialog>
|
||||
|
||||
</main>
|
||||
|
||||
<script src="/o/path:/system/static/js/editor.js"></script>
|
||||
<script src="/o/path:/system/static/js/path-actions.js"></script>
|
||||
|
||||
|
||||
<script>
|
||||
window.PagesWikiCurrentPath = "{{ .Path }}";
|
||||
|
||||
window.addEventListener(
|
||||
"DOMContentLoaded",
|
||||
() => {
|
||||
const textarea =
|
||||
document.getElementById("editor")
|
||||
|
||||
const mount =
|
||||
document.getElementById("editor-mount")
|
||||
|
||||
if (!textarea || !mount || !window.PagesWikiEditor) {
|
||||
return
|
||||
}
|
||||
|
||||
const cm =
|
||||
window.PagesWikiEditor.create(
|
||||
mount,
|
||||
textarea.value,
|
||||
"{{ .EditType }}",
|
||||
{
|
||||
keymap: mount.dataset.keymap,
|
||||
syntax: mount.dataset.syntax === "true",
|
||||
autocomplete: mount.dataset.autocomplete === "true",
|
||||
}
|
||||
)
|
||||
|
||||
window.PagesWikiCodeMirror =
|
||||
cm
|
||||
|
||||
window.PagesWikiGetEditorText =
|
||||
() => cm.state.doc.toString()
|
||||
|
||||
const syncTextarea =
|
||||
() => {
|
||||
textarea.value =
|
||||
cm.state.doc.toString()
|
||||
}
|
||||
|
||||
const oldSaveNow =
|
||||
window.PagesEditor && window.PagesEditor.saveNow
|
||||
|
||||
if (oldSaveNow) {
|
||||
window.PagesEditor.saveNow =
|
||||
function() {
|
||||
syncTextarea()
|
||||
return oldSaveNow.apply(
|
||||
window.PagesEditor,
|
||||
arguments
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
function toggleEditorMenu(ev) {
|
||||
ev.stopPropagation()
|
||||
|
||||
document
|
||||
.getElementById("editor-menu")
|
||||
.classList
|
||||
.toggle("open")
|
||||
}
|
||||
|
||||
function closeEditorMenu() {
|
||||
const menu =
|
||||
document.getElementById("editor-menu")
|
||||
|
||||
if (menu) {
|
||||
menu.classList.remove("open")
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener(
|
||||
"click",
|
||||
closeEditorMenu
|
||||
)
|
||||
|
||||
function openFormatDialog() {
|
||||
document
|
||||
.getElementById("editor-format-dialog")
|
||||
.showModal()
|
||||
}
|
||||
|
||||
function closeFormatDialog() {
|
||||
document
|
||||
.getElementById("editor-format-dialog")
|
||||
.close()
|
||||
}
|
||||
|
||||
function switchEditorFormat(format) {
|
||||
const url =
|
||||
new URL(location.href)
|
||||
|
||||
url.searchParams.set(
|
||||
"edittype",
|
||||
format
|
||||
)
|
||||
|
||||
location.href =
|
||||
url.toString()
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="/o/path:/system/static/css/modes.css">
|
||||
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
</head>
|
||||
|
||||
<body class="mode-home">
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="/o/path:/system/static/css/modes.css">
|
||||
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
</head>
|
||||
|
||||
<body class="mode-links">
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
{{ define "markdown_view.gohtml" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Markdown - {{ .Path }}</title>
|
||||
|
||||
<link rel="stylesheet" href="/o/path:/system/static/css/main.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-tomorrow.min.css"
|
||||
>
|
||||
|
||||
<style>
|
||||
.markdown-view {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.markdown-toolbar {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
margin-bottom: 0.75rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.markdown-path {
|
||||
color: var(--muted);
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.markdown-source {
|
||||
border: 1px solid var(--border-soft);
|
||||
background: var(--input-bg);
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.markdown-line {
|
||||
display: grid;
|
||||
grid-template-columns: 4.5rem 1fr;
|
||||
min-height: 1.35rem;
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.markdown-line-no {
|
||||
color: var(--muted);
|
||||
text-align: right;
|
||||
padding: 0.1rem 0.75rem;
|
||||
border-right: 1px solid var(--border-soft);
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.markdown-line-code {
|
||||
white-space: pre;
|
||||
padding: 0.1rem 0.75rem;
|
||||
}
|
||||
|
||||
.markdown-line:hover {
|
||||
background: var(--row-hover);
|
||||
}
|
||||
|
||||
.markdown-hidden-source {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<header class="topbar">
|
||||
<div class="brand">
|
||||
<a href="/">{{ .WikiName }}</a>
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
{{ range .NavItems }}
|
||||
<a href="{{ .ResolvedHref }}">{{ .Label }}</a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="markdown-view">
|
||||
|
||||
<div class="markdown-toolbar">
|
||||
|
||||
<a href="{{ .Path }}">
|
||||
Rendered
|
||||
</a>
|
||||
|
||||
<a href="/e/-{{ .Path }}">
|
||||
Edit
|
||||
</a>
|
||||
|
||||
<a href="/v/plain{{ .Path }}">
|
||||
Plain
|
||||
</a>
|
||||
|
||||
<a href="/:/compile/markdown{{ .Path }}">
|
||||
Compile
|
||||
</a>
|
||||
|
||||
<button type="button" onclick="copyMarkdown()">
|
||||
Copy
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="markdown-path">
|
||||
{{ .Path }}
|
||||
</div>
|
||||
|
||||
<pre class="markdown-hidden-source"><code id="markdown-raw" class="language-markdown">{{ .MarkdownRaw }}</code></pre>
|
||||
|
||||
<div class="markdown-source">
|
||||
|
||||
{{ range .Lines }}
|
||||
|
||||
<div class="markdown-line">
|
||||
<div class="markdown-line-no">
|
||||
{{ .Number }}
|
||||
</div>
|
||||
|
||||
<code class="markdown-line-code language-markdown">
|
||||
{{ .Text }}
|
||||
</code>
|
||||
</div>
|
||||
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-markdown.min.js"></script>
|
||||
|
||||
<script>
|
||||
function copyMarkdown() {
|
||||
const raw =
|
||||
document.getElementById(
|
||||
"markdown-raw"
|
||||
).textContent
|
||||
|
||||
navigator.clipboard.writeText(
|
||||
raw
|
||||
)
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="/o/path:/system/static/css/modes.css">
|
||||
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
</head>
|
||||
|
||||
<body class="mode-editor">
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="/o/path:/system/static/css/modes.css">
|
||||
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<link rel="stylesheet" href="/o/path:/system/static/css/modes.css">
|
||||
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
</head>
|
||||
|
||||
<body class="mode-page {{ if .IsHome }}is-home-page{{ end }}">
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
{{ define "preview.gohtml" }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Preview</title>
|
||||
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: var(--bg);
|
||||
color: var(--fg);
|
||||
}
|
||||
|
||||
.preview-body {
|
||||
padding: 1rem;
|
||||
font-size: 0.95rem;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.preview-path {
|
||||
margin-bottom: 0.75rem;
|
||||
color: var(--muted);
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
.preview-content {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.preview-content img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.preview-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.preview-entry {
|
||||
display: grid;
|
||||
grid-template-columns: 1.4rem 1fr auto;
|
||||
gap: 0.45rem;
|
||||
align-items: center;
|
||||
padding: 0.28rem 0.15rem;
|
||||
border-bottom: 1px solid var(--border-soft);
|
||||
text-decoration: none;
|
||||
color: var(--fg);
|
||||
}
|
||||
|
||||
.preview-entry:hover {
|
||||
background: var(--row-hover);
|
||||
}
|
||||
|
||||
.preview-icon {
|
||||
color: var(--link);
|
||||
}
|
||||
|
||||
.preview-icon.dir {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.preview-name {
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.preview-meta {
|
||||
color: var(--muted);
|
||||
font-size: 0.82rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<main class="preview-body">
|
||||
|
||||
<div class="preview-path">
|
||||
{{ .Path }}
|
||||
</div>
|
||||
|
||||
{{ if .IsListing }}
|
||||
|
||||
<h3>Index</h3>
|
||||
|
||||
<div class="preview-list">
|
||||
|
||||
{{ range .Entries }}
|
||||
|
||||
<a
|
||||
class="preview-entry"
|
||||
href="{{ if .IsDir }}/v/browser{{ .Path }}{{ else }}{{ .Path }}{{ end }}"
|
||||
target="_top"
|
||||
>
|
||||
|
||||
<span class="preview-icon {{ if .IsDir }}dir{{ end }}">
|
||||
{{ if .IsDir }}📁{{ else }}📄{{ end }}
|
||||
</span>
|
||||
|
||||
<span class="preview-name">
|
||||
{{ .Name }}
|
||||
</span>
|
||||
|
||||
<span class="preview-meta">
|
||||
{{ if .IsDir }}
|
||||
{{ .ChildCount }} items
|
||||
{{ else }}
|
||||
{{ formatBytes .Size }}
|
||||
{{ end }}
|
||||
</span>
|
||||
|
||||
</a>
|
||||
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
|
||||
{{ else }}
|
||||
|
||||
<article class="preview-content">
|
||||
{{ .RenderedHTML }}
|
||||
</article>
|
||||
|
||||
{{ end }}
|
||||
|
||||
</main>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
</head>
|
||||
|
||||
<body class="mode-revision-view">
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
</head>
|
||||
|
||||
<body class="mode-revisions">
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/jetbrains-mono@5.0.20/index.css">
|
||||
<link rel="stylesheet" href="/o/path:/system/static/css/main.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="/static/css/theme/{{ .Theme }}.css">
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
|
||||
<style>
|
||||
@font-face {
|
||||
@@ -283,7 +283,7 @@ body {
|
||||
|
||||
<div class="tree-actions">
|
||||
|
||||
<a href="/e{{ .Path }}" class="tree-btn edit">
|
||||
<a href="/e/-{{ .Path }}" class="tree-btn edit">
|
||||
✎ edit
|
||||
</a>
|
||||
|
||||
|
||||
Reference in new issue
Block a user