filecat 7.9.0 → 7.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +173 -182
- package/build/dist/{4967.3fd3bd40a2b5a3b52428.js → 1060.198d91e2dfc174317c3a.js} +1 -1
- package/build/dist/1075.05eed88707339ca32044.js +1 -0
- package/build/dist/{1142.121454b1de53689b7367.js → 1142.bc43fae2e5e38d9359df.js} +1 -1
- package/build/dist/1384.edbad9c24d883a59724d.js +1 -0
- package/build/dist/1417.d390b18dd58ff5c28160.js +1 -0
- package/build/dist/1448.4db495e1389c0c8445b3.js +1 -0
- package/build/dist/{3324.22efcb1c431177b1cf5f.js → 1455.26a021eb94e5bdd5bec2.js} +1 -1
- package/build/dist/{1636.b6a17252dfd0d22f09a7.js → 1636.b80b1883358e132d3424.js} +1 -1
- package/build/dist/{1832.8ea5c3e8288df0b7fd5c.js → 1832.a01933ba5df99576ecc2.js} +1 -1
- package/build/dist/2300.c99b1dd4e752cdfd5e32.js +2 -0
- package/build/dist/{2300.9e1baa1c0368abe53d96.js.LICENSE.txt → 2300.c99b1dd4e752cdfd5e32.js.LICENSE.txt} +1 -1
- package/build/dist/239.f570f06d4b9c020f1013.js +1 -0
- package/build/dist/{2479.dcc88b3370f0f1d66e02.js → 2479.294792ef5d360ad64abc.js} +1 -1
- package/build/dist/2542.26cb302b60de23166227.js +1 -0
- package/build/dist/{259.81bb9e049e5ef587a96f.js → 259.3c0eb22e9b43ffb63c9c.js} +1 -1
- package/build/dist/2626.3bcfe1f26d9cb796a925.js +1 -0
- package/build/dist/2674.d1bf937289c51ddeceac.js +1 -0
- package/build/dist/3233.43bdd7c12ca829d56116.js +1 -0
- package/build/dist/3299.de79d172b41af93a8716.js +1 -0
- package/build/dist/{6992.f6a07311a638794c24f7.js → 3471.ef3b5dcfe37963034187.js} +1 -1
- package/build/dist/{3528.56eeefab6fca5884e2a6.js → 3528.0f8f34028d92fa87c518.js} +1 -1
- package/build/dist/{3659.8a31495bb8f38c0ffa7c.js → 3659.dd03dc2ac52a3ff19105.js} +1 -1
- package/build/dist/4004.f4c06b50348214eb2962.js +1 -0
- package/build/dist/{4560.8ef2e4b60cc86d019dd6.js → 4560.fd9f8cf2d6022b1d3a94.js} +1 -1
- package/build/dist/{4903.b5451ed0802b3f7c07b2.js → 4903.070aaa53a243baf05133.js} +1 -1
- package/build/dist/{4946.c95d4f426146e0180172.js → 4946.d578f6ba367a742d80bf.js} +2 -2
- package/build/dist/4986.f244efce9cf6be21f846.js +1 -0
- package/build/dist/5272.1f0dfac07ba202e7d323.js +1 -0
- package/build/dist/{5308.052f45c15785487b3766.js → 5308.d1e5ccb49396fc1b026d.js} +1 -1
- package/build/dist/{5516.645e4a900df9bdc1806c.js → 5516.88521f3a3c7101c46df3.js} +1 -1
- package/build/dist/5614.43bdd7c12ca829d56116.js +1 -0
- package/build/dist/{5139.adf9574d9b54a216e041.js → 5709.81f43e3c021fafdfe36f.js} +1 -1
- package/build/dist/{5744.e9f1efb88a617b05b709.js → 5744.0f8a0432b73b2eb0a7ff.js} +1 -1
- package/build/dist/{5877.ca081c4798194230243c.js → 5877.98d0475aaf4058b9a715.js} +1 -1
- package/build/dist/{6247.917e3fbef5dc5fbaf937.js → 6247.525b0b68872036ac2fa6.js} +1 -1
- package/build/dist/{7520.fbb0bc2a05cf94e15418.js → 6322.552511b5cb12cd0c821c.js} +1 -1
- package/build/dist/6492.17ecd8515fa512ce9306.js +1 -0
- package/build/dist/{676.a75318a8b598d8daadf0.js → 676.356039ef6f28f96b8c8b.js} +1 -1
- package/build/dist/{6805.bf0c964ab84f0fcc78be.js → 6805.373ac0e7d6555e4a6459.js} +1 -1
- package/build/dist/{6919.8cf13c01184b7148b28e.js → 6919.c7cc8617b658198d4924.js} +1 -1
- package/build/dist/{7038.4e4fc8e405c56d3080e2.js → 7038.166f915547d27e4dc5e4.js} +1 -1
- package/build/dist/{7759.0b68912ff9ef10869f59.js → 7759.7cd3fe8e5d37df25804c.js} +1 -1
- package/build/dist/7873.e3098bc6f510e5bea55f.js +1 -0
- package/build/dist/7923.d44556578af4d3d7cea3.js +2 -0
- package/build/dist/{7943.19d2de387eeb7f513d8e.js → 7943.acf25a5e98dd13290985.js} +1 -1
- package/build/dist/8090.8977224618a14ae42159.js +2 -0
- package/build/dist/8302.ce97557b7cf7c8387942.js +1 -0
- package/build/dist/8319.6a6b9651c87a1bb4cbb9.js +1 -0
- package/build/dist/{8603.4142ce42c1635f493eca.js → 8603.f1cbcfd64cde885f9809.js} +1 -1
- package/build/dist/8649.d6055ad75975b803bbc1.js +1 -0
- package/build/dist/{8727.3628c746061aed7a4077.js → 8727.8658835acb7e0b6e5acc.js} +1 -1
- package/build/dist/{8765.a5633d054abb67142fc3.js → 8765.8758c290a6b132f2ce7f.js} +1 -1
- package/build/dist/8772.2c35012c25ac9eb5f74d.js +2 -0
- package/build/dist/{8772.e8f9731c1c061f1cdf56.js.LICENSE.txt → 8772.2c35012c25ac9eb5f74d.js.LICENSE.txt} +1 -1
- package/build/dist/8781.6bd14487d172e004e3d3.js +1 -0
- package/build/dist/9299.76095cb6629c36ca3343.js +1 -0
- package/build/dist/9334.a25983aafdcbde63ae5e.js +1 -0
- package/build/dist/{9546.e7206c968e92371ae2b1.js → 9546.2cecad04cf676a6616cd.js} +1 -1
- package/build/dist/dark.css +839 -839
- package/build/dist/filerobot-image-editor.min.js +42445 -42445
- package/build/dist/google-dark.css +2032 -2032
- package/build/dist/google.css +1719 -1719
- package/build/dist/index.html +1 -1
- package/build/dist/main.26c2c54f6ab534513ebd.js +2 -0
- package/build/dist/{main.3a12152528aff6ae213a.js.LICENSE.txt → main.26c2c54f6ab534513ebd.js.LICENSE.txt} +1 -1
- package/build/dist/rle.js +17867 -17867
- package/build/main.js +1 -1
- package/build/plugin/core.type.d.ts +62 -0
- package/build/threads.work.filecat.js +1 -1
- package/env +26 -26
- package/package.json +211 -211
- package/shell/build.js +161 -161
- package/shell/config/.babelrc +14 -14
- package/shell/config/base.webpack.config.js +78 -78
- package/shell/config/common-bin.config.js +44 -44
- package/shell/config/env.js +10 -10
- package/shell/config/prebuild-file-path.js +17 -17
- package/shell/config/webpack.exe.config.js +36 -36
- package/shell/config/webpack.npm.config.js +44 -44
- package/shell/config/webpack.web.config.js +152 -152
- package/shell/dev.js +51 -51
- package/shell/docker-build.sh +2 -2
- package/shell/filecat +1 -1
- package/shell/filecat-watch +1 -1
- package/shell/install.js +48 -48
- package/shell/net-agent/git-clone.bat +23 -23
- package/shell/net-agent/git-pull.bat +17 -17
- package/shell/net-agent/git-push.bat +17 -17
- package/shell/pkg.ts +50 -50
- package/shell/postinstall-optional.js +29 -29
- package/shell/start/filecat-install.sh +22 -22
- package/shell/start/filecat-run.sh +2 -2
- package/shell/start/windows-install.js +178 -178
- package/shell/start/windows-uninstall.js +131 -131
- package/shell/util/file.js +46 -46
- package/build/dist/1075.40103ec059c6b23b056e.js +0 -1
- package/build/dist/1384.0d0fc5faa899c9eddcbe.js +0 -1
- package/build/dist/1417.7e511043474084a2a65b.js +0 -1
- package/build/dist/1448.0710f04bed1c52e6a5db.js +0 -1
- package/build/dist/2300.9e1baa1c0368abe53d96.js +0 -2
- package/build/dist/2542.23fb13b1623c9f7c3fc1.js +0 -1
- package/build/dist/2626.05d1faa293e0a3318b9b.js +0 -1
- package/build/dist/2674.7fd28dae86ccdb247851.js +0 -1
- package/build/dist/2851.2195b5906b2c224c7bf7.js +0 -1
- package/build/dist/3140.794a212da633caf38b3a.js +0 -2
- package/build/dist/3233.fb6bffd5e097e4ac9423.js +0 -1
- package/build/dist/3299.f37767d30b6999df4014.js +0 -1
- package/build/dist/4004.5d68418ad5c2321cb11f.js +0 -1
- package/build/dist/4986.78047106f3a0d2d71199.js +0 -1
- package/build/dist/5272.0b70ee8ec5f083fb9f5b.js +0 -1
- package/build/dist/5614.fb6bffd5e097e4ac9423.js +0 -1
- package/build/dist/6492.3ee4060598de873d8e8f.js +0 -1
- package/build/dist/7756.2f851693ba030c42dde8.js +0 -1
- package/build/dist/7873.11d04b741d2b499d9cb9.js +0 -1
- package/build/dist/7923.861345fd55941e8089a1.js +0 -2
- package/build/dist/8014.28b5cf8c3787dc829aa4.js +0 -1
- package/build/dist/8302.5ae5bfe8baa0084204bb.js +0 -1
- package/build/dist/8319.c15a3674ec7abc493595.js +0 -1
- package/build/dist/8772.e8f9731c1c061f1cdf56.js +0 -2
- package/build/dist/8781.58f0c51870d3dd2689d7.js +0 -1
- package/build/dist/9299.6c06dad1abe098b61766.js +0 -1
- package/build/dist/main.3a12152528aff6ae213a.js +0 -2
- /package/build/dist/{4946.c95d4f426146e0180172.js.LICENSE.txt → 4946.d578f6ba367a742d80bf.js.LICENSE.txt} +0 -0
- /package/build/dist/{7923.861345fd55941e8089a1.js.LICENSE.txt → 7923.d44556578af4d3d7cea3.js.LICENSE.txt} +0 -0
- /package/build/dist/{3140.794a212da633caf38b3a.js.LICENSE.txt → 8090.8977224618a14ae42159.js.LICENSE.txt} +0 -0
package/README.md
CHANGED
|
@@ -1,182 +1,173 @@
|
|
|
1
|
-
|
|
2
|
-
<p align="center">
|
|
3
|
-
<img src="./src/web/meta/resources/img/logo-70.png" alt="FileCat Logo" width="70" height="70">
|
|
4
|
-
</p>
|
|
5
|
-
|
|
6
|
-
<h1 align="center">FileCat</h1>
|
|
7
|
-
|
|
8
|
-
<p align="center">
|
|
9
|
-
<i>A self-hosted Web file server and lightweight server management tool</i>
|
|
10
|
-
</p>
|
|
11
|
-
|
|
12
|
-
<p align="center">
|
|
13
|
-
<a href="https://www.npmjs.com/package/filecat">
|
|
14
|
-
<img src="https://img.shields.io/npm/dm/filecat.svg" alt="npm downloads">
|
|
15
|
-
</a>
|
|
16
|
-
<a href="https://www.npmjs.com/package/filecat">
|
|
17
|
-
<img src="https://img.shields.io/npm/v/filecat.svg" alt="npm version">
|
|
18
|
-
</a>
|
|
19
|
-
<a href="https://github.com/xiaobaidadada/filecat">
|
|
20
|
-
<img src="https://img.shields.io/github/stars/xiaobaidadada/filecat.svg" alt="stars">
|
|
21
|
-
</a>
|
|
22
|
-
<a href="https://ghcr.io/xiaobaidadada/filecat">
|
|
23
|
-
<img src="https://img.shields.io/badge/docker-ghcr.io-blue.svg" alt="docker">
|
|
24
|
-
</a>
|
|
25
|
-
<a href="https://github.com/xiaobaidadada/filecat/blob/main/LICENSE">
|
|
26
|
-
<img src="https://img.shields.io/github/license/xiaobaidadada/filecat.svg" alt="license">
|
|
27
|
-
</a>
|
|
28
|
-
</p>
|
|
29
|
-
|
|
30
|
-
<p align="center">
|
|
31
|
-
<a href="#features">Features</a> •
|
|
32
|
-
<a href="#screenshots">Screenshots</a> •
|
|
33
|
-
<a href="#installation">Installation</a> •
|
|
34
|
-
<a href="#quick-start">Quick Start</a>
|
|
35
|
-
</p>
|
|
36
|
-
|
|
37
|
-
<p align="center">
|
|
38
|
-
<a href="./doc/CH_README.md">中文</a>
|
|
39
|
-
</p>
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
FileCat is a self-hosted Web file server and a **lightweight server management tool**. Once deployed, you can manage files on your server anytime and anywhere through a browser, while also enjoying a wide range of server management and operations features.
|
|
44
|
-
|
|
45
|
-
FileCat
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
npm run
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
* Docker: Pull the latest image again
|
|
175
|
-
* Binary: Download and replace the latest package
|
|
176
|
-
2. **Automatic Upgrade** (v5.33.0+): Run the `filecat-upgrade` command to automatically upgrade according to the installation environment. Docker and binary installations also support custom download URL parameters.
|
|
177
|
-
|
|
178
|
-
---
|
|
179
|
-
|
|
180
|
-
## Community
|
|
181
|
-
|
|
182
|
-
Join the QQ group **824838674** for discussion, feedback, and support.
|
|
1
|
+
|
|
2
|
+
<p align="center">
|
|
3
|
+
<img src="./src/web/meta/resources/img/logo-70.png" alt="FileCat Logo" width="70" height="70">
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
<h1 align="center">FileCat</h1>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<i>A self-hosted Web file server and lightweight server management tool</i>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/filecat">
|
|
14
|
+
<img src="https://img.shields.io/npm/dm/filecat.svg" alt="npm downloads">
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/filecat">
|
|
17
|
+
<img src="https://img.shields.io/npm/v/filecat.svg" alt="npm version">
|
|
18
|
+
</a>
|
|
19
|
+
<a href="https://github.com/xiaobaidadada/filecat">
|
|
20
|
+
<img src="https://img.shields.io/github/stars/xiaobaidadada/filecat.svg" alt="stars">
|
|
21
|
+
</a>
|
|
22
|
+
<a href="https://ghcr.io/xiaobaidadada/filecat">
|
|
23
|
+
<img src="https://img.shields.io/badge/docker-ghcr.io-blue.svg" alt="docker">
|
|
24
|
+
</a>
|
|
25
|
+
<a href="https://github.com/xiaobaidadada/filecat/blob/main/LICENSE">
|
|
26
|
+
<img src="https://img.shields.io/github/license/xiaobaidadada/filecat.svg" alt="license">
|
|
27
|
+
</a>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<a href="#features">Features</a> •
|
|
32
|
+
<a href="#screenshots">Screenshots</a> •
|
|
33
|
+
<a href="#installation">Installation</a> •
|
|
34
|
+
<a href="#quick-start">Quick Start</a>
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
<p align="center">
|
|
38
|
+
<a href="./doc/CH_README.md">中文</a>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
FileCat is a self-hosted Web file server and a **lightweight server management tool**. Once deployed, you can manage files on your server anytime and anywhere through a browser, while also enjoying a wide range of server management and operations features.
|
|
44
|
+
|
|
45
|
+
FileCat 是一个自己部署使用的轻量级web文件与工具服务器,UI设计支持移动设备访问,此项目在文件服务器的基础上,提供了很多为开发者使用的功能(内网穿透、CI/CD、大文件日志查看、系统信息查看、安全的SSH终端等),文件访问支持多种格式的预览和编辑,并支持markdown(.md)的所见即所得编辑体验。
|
|
46
|
+
|
|
47
|
+
FileCat uses the UI of [filebrowser](https://github.com/filebrowser/filebrowser).
|
|
48
|
+
|
|
49
|
+
> **Core philosophy**: Centered around file management, FileCat integrates AI Agent, remote desktop, intranet tunneling, system monitoring, and other capabilities to make server management simpler.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Features
|
|
54
|
+
|
|
55
|
+
| Category | Features |
|
|
56
|
+
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
57
|
+
| File Management | Browse, upload, download, edit, and preview files online (images, videos, Markdown, drawings, etc.) |
|
|
58
|
+
| Markdown WYSIWYG Editor | Typora-like Markdown editing — what you see is what you get |
|
|
59
|
+
| Cloud Storage Mount | Mount Baidu Netdisk / SSH(SFTP) / S3 / WebDAV / SMB as local folders, managed with the same file operations |
|
|
60
|
+
| AI Agent | Integrates large language models to assist with server management and file processing (API configuration required). Supports QQ, WeCom, Feishu, DingTalk, and other third-party platform bots |
|
|
61
|
+
| Intranet Tunneling | Expose services on an internal network to the public internet, or enable communication between multiple internal networks |
|
|
62
|
+
| SSH Terminal | Built-in Web terminal for connecting to servers anytime through a browser |
|
|
63
|
+
| Windows Remote Desktop | Directly operate remote Windows desktops (RDP) through a browser |
|
|
64
|
+
| System Information Dashboard | Real-time monitoring of CPU, memory, disk, network, and other system information |
|
|
65
|
+
| CI/CD Workflow | Create custom command pipelines for continuous integration and deployment |
|
|
66
|
+
| Large Log Viewer | Instantly open text log files of any size and efficiently locate problems |
|
|
67
|
+
| Excalidraw Drawing | Built-in whiteboard drawing tool |
|
|
68
|
+
| Multi-user Management | Comprehensive permission management system |
|
|
69
|
+
| Shareable Links | Generate file sharing links for convenient downloads |
|
|
70
|
+
| Multiple Path Mounts | Support mounting multiple filesystem paths |
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Screenshots
|
|
75
|
+
|
|
76
|
+
<table>
|
|
77
|
+
<tr>
|
|
78
|
+
<td align="center"><b>File List</b></td>
|
|
79
|
+
<td align="center"><b>AI Agent</b></td>
|
|
80
|
+
</tr>
|
|
81
|
+
<tr>
|
|
82
|
+
<td><img src="./doc/文件列表.png" alt="File List"/></td>
|
|
83
|
+
<td><img src="./doc/AI能力.png" alt="AI Agent"/></td>
|
|
84
|
+
</tr>
|
|
85
|
+
<tr>
|
|
86
|
+
<td align="center"><b>Intranet Tunneling</b></td>
|
|
87
|
+
<td align="center"><b>System Information Dashboard</b></td>
|
|
88
|
+
</tr>
|
|
89
|
+
<tr>
|
|
90
|
+
<td><img src="./doc/内网穿透.png" alt="Intranet Tunneling"/></td>
|
|
91
|
+
<td><img src="./doc/系统信息看板.png" alt="System Information Dashboard"/></td>
|
|
92
|
+
</tr>
|
|
93
|
+
</table>
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Demo
|
|
98
|
+
|
|
99
|
+
Online demo: **[http://demo.filecat.xiaobaidadada.fun/](http://demo.filecat.xiaobaidadada.fun/)**
|
|
100
|
+
|
|
101
|
+
Username and password: `demo`/`demo` or `test`/`test`
|
|
102
|
+
|
|
103
|
+
> The demo server is sponsored by [Yecaoyun](https://my.yecaoyun.com/aff.php?aff=7185).
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Installation
|
|
108
|
+
|
|
109
|
+
> Minor bug fixes and feature updates are released and synchronized on npm in real time.
|
|
110
|
+
|
|
111
|
+
### 1. NPM Installation (Recommended)
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npm install -g filecat
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
On Linux, after installation, you can use `pm2` to keep the process running, or register FileCat as a systemd service for process management.
|
|
118
|
+
|
|
119
|
+
### 2. One-click Linux Installation Script
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
curl -o install.sh https://filecat.xiaobaidadada.fun/files/linux-install.sh && bash install.sh
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The script automatically downloads the binary package and performs the installation. Simply follow the prompts to enter the required parameters.
|
|
126
|
+
|
|
127
|
+
### 3. Binary Package
|
|
128
|
+
|
|
129
|
+
Download the latest version for your operating system from [Releases](https://github.com/xiaobaidadada/filecat/releases).
|
|
130
|
+
|
|
131
|
+
### 4. Docker
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
docker run -d --name filecat --restart=always --net=host \
|
|
135
|
+
-v /home:/home \
|
|
136
|
+
ghcr.io/xiaobaidadada/filecat:latest \
|
|
137
|
+
--port 5567 --base_folder /home
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 5. Build from Source
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
git clone https://github.com/xiaobaidadada/filecat.git
|
|
144
|
+
cd filecat
|
|
145
|
+
npm install
|
|
146
|
+
npm run dev # Development mode
|
|
147
|
+
# or
|
|
148
|
+
npm run build && node build/main.js # Production mode
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Quick Start
|
|
154
|
+
|
|
155
|
+
**Method 1**: After installing via NPM:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
filecat --port 5567
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Method 2**: After extracting the binary package, run the `filecat-run.sh` script (Linux/Mac) or `filecat-run.cmd` script (Windows) included in the directory.
|
|
162
|
+
|
|
163
|
+
**Default username/password**: `admin` / `admin`
|
|
164
|
+
|
|
165
|
+
> For more options, run `filecat --help`.
|
|
166
|
+
|
|
167
|
+
> **Permission Notice**: By default, FileCat can only access the installation directory after installation. Configure the directories and execution permissions accessible to each user in the settings.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Community
|
|
172
|
+
|
|
173
|
+
Join the QQ group **824838674** for discussion, feedback, and support.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[1060],{51060(e,t,c){c.r(t),c.d(t,{default:()=>a});var a=async(e=[{}])=>(Array.isArray(e)||(e=[e]),new Promise((t,c)=>{const a=document.createElement("input");a.type="file";const i=[...e.map(e=>e.mimeTypes||[]),...e.map(e=>e.extensions||[])].join();a.multiple=e[0].multiple||!1,a.accept=i||"";const l=e=>{"function"==typeof n&&n(),t(e)},n=e[0].legacySetup&&e[0].legacySetup(l,()=>n(c),a);a.addEventListener("change",()=>{l(a.multiple?Array.from(a.files):a.files[0])}),a.click()}))}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[1075,4877],{69918(t,e,n){n.d(e,{Ce:()=>i,FG:()=>r.FG,fy:()=>c,gC:()=>a});var r=n(18840),o=n(14284),s=n(53459);async function a(){try{const t=await o.XO.get("md_editor_setting/get");return{...r.FG,...t?.data??{}}}catch(t){return{...r.FG}}}async function c(t){const e=await o.XO.post("md_editor_setting/save",t);return e?.code!==s.m.Success?null:{...r.FG,...e.data??t}}function i(t,e){t&&(t.style.setProperty("--md-editor-max-width",e.content_max_width),t.style.setProperty("--md-editor-padding",e.content_padding),t.style.setProperty("--md-editor-font-size",e.font_size),t.style.setProperty("--md-editor-line-height",e.line_height))}},64877(t,e,n){n.r(e),n.d(e,{default:()=>a});var r=n(96540),o=n(22022),s=n(74848);function a(t){const{t:e}=(0,o.Bd)(),[n,a]=(0,r.useState)(new Set),c=(0,r.useMemo)(()=>function(t){const e=[],n=[];for(const r of t){const t={...r,children:[]};for(;n.length>0&&n[n.length-1].level>=t.level;)n.pop();0===n.length?e.push(t):n[n.length-1].children.push(t),n.push(t)}return e}(t.items),[t.items]),i=(r,o)=>r.map(r=>{const c=r.children.length>0,l=n.has(r.pos),d=r.pos===t.active_pos;return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:`md-outline-item md-outline-item--h${r.level}${d?" md-outline-item--active":""}`,style:{paddingLeft:.4+.75*o+"em"},title:r.text,onClick:()=>t.on_click(r),children:[(0,s.jsx)("i",{className:"material-icons md-outline-arrow"+(c?"":" md-outline-arrow--empty"),onClick:c?t=>{return e=r.pos,t.stopPropagation(),void a(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});var e}:void 0,children:c?l?"arrow_right":"arrow_drop_down":""}),(0,s.jsx)("span",{className:"md-outline-text",children:r.text||e("未命名标题")})]}),c&&!l&&i(r.children,o+1)]},r.pos)});return 0===t.items.length?(0,s.jsx)("div",{className:"md-outline md-outline--empty",children:(0,s.jsx)("div",{className:"md-outline-tip",children:e("no_head")})}):(0,s.jsx)("div",{className:"md-outline",children:(0,s.jsx)("div",{className:"md-outline-list",children:i(c,0)})})}},76118(t,e,n){n.d(e,{A:()=>dt});var r=n(96540),o=n(22022),s=n(34843),a=n(82893),c=n(42845),i=n(1575),l=n(58903),d=n(89781),u=n(61396),h=n(46762),m=n(73337),p=n(89552),f=n(86059),g=n(5091),_=n(23802),b=n(41105),k=n(89334);const v=new _.A({html:!0,linkify:!0,breaks:!1,typographer:!1});v.renderer.rules.html_block=(t,e)=>`<div data-html-block="${(0,b.pC)(t[e].content)}"></div>`,v.renderer.rules.html_inline=(t,e)=>`<span data-html-inline="${(0,b.pC)(t[e].content)}"></span>`,v.inline.ruler.before("escape","math_inline",function(t,e){const n=t.pos,r=t.src,o=[{open:"\\(",close:"\\)"},{open:"$",close:"$"}];if(r.startsWith("$$",n))return!1;for(const s of o){if(!r.startsWith(s.open,n))continue;const o=n+s.open.length,a=r.indexOf(s.close,o);if(a<0)continue;const c=r.slice(o,a);if(c.trim()){if("$"===s.open){const t=r[a+1];if(void 0!==t&&/\d/.test(t))continue}if(!e){const e=t.push("math_inline","span",0);e.content=c,e.markup=s.open,e.meta={raw:r.slice(n,a+s.close.length)}}return t.pos=a+s.close.length,!0}}return!1}),v.block.ruler.before("fence","math_block",function(t,e,n,r){const o=t.bMarks[e]+t.tShift[e],s=t.eMarks[e],a=t.src.slice(o,s).trim(),c=[{open:"\\[",close:"\\]"},{open:"$$",close:"$$"}];for(const s of c){if(!a.startsWith(s.open))continue;if(a.endsWith(s.close)&&a.length>s.open.length+s.close.length){if(r)return!0;const n=a.slice(s.open.length,a.length-s.close.length),o=t.push("math_block","div",0);return o.content=n,o.markup=s.open,o.meta={raw:a},o.map=[e,e+1],t.line=e+1,!0}const c=a.slice(s.open.length);for(let a=e+1;a<n;a++){const n=t.bMarks[a]+t.tShift[a],i=t.eMarks[a],l=t.src.slice(n,i);if(!l.trimEnd().endsWith(s.close))continue;if(r)return!0;const d=[c,...t.getLines(e+1,a,t.tShift[e],!1).split("\n")].filter((t,e)=>!(0===e&&!t.trim())),u=l.trimEnd().slice(0,-s.close.length);d.push(u);const h=t.push("math_block","div",0);return h.content=d.join("\n").trim(),h.markup=s.open,h.map=[e,a+1],h.meta={raw:t.src.slice(o,t.eMarks[a]).trimEnd()},t.line=a+1,!0}}return!1},{alt:["paragraph","reference","blockquote","list"]}),v.renderer.rules.math_inline=(t,e)=>`<span data-math-inline="${(0,b.pC)(t[e].meta.raw)}"></span>`,v.renderer.rules.math_block=(t,e)=>`<div data-math-block="${(0,b.pC)(t[e].meta.raw)}"></div>`;const y=v.renderer.rules.fence;function w(t){const e=v.render(t??""),n=(new DOMParser).parseFromString(e,"text/html");return l.S4.fromSchema(g.Y).parse(n.body)}function M(t){let e="";return t.forEach(t=>{if(t.isText){let n=t.marks.some(t=>"code"===t.type.name)?t.text??"":function(t){return t.replace(/([\\`*_[\]<>])/g,"\\$1")}(t.text??"");for(const e of t.marks)switch(e.type.name){case"code":n=`\`${t.text??""}\``;break;case"strong":n=`**${n}**`;break;case"em":n=`*${n}*`;break;case"strike":n=`~~${n}~~`;break;case"link":n=`[${n}](${e.attrs.href}${e.attrs.title?` "${e.attrs.title}"`:""})`}e+=n}else if("image"===t.type.name){const{src:n,alt:r,title:o}=t.attrs;e+=``}else"hard_break"===t.type.name?e+=" \n":"html_inline"===t.type.name?e+=t.attrs.value:"math_inline"===t.type.name&&(e+=t.attrs.raw)}),e}function $(t){const e=[];if(t.forEach(t=>{const n=[],r=[];t.forEach(t=>{var e;n.push((e=t.textContent,e.replace(/\|/g,"\\|").replace(/\n/g," ")).trim()),r.push("table_header"===t.type.name)}),e.push({cells:n,header_flags:r})}),0===e.length)return"";const n=Math.max(...e.map(t=>t.cells.length)),r=e[0].header_flags.some(t=>t),o=Array.from({length:n},(t,n)=>Math.max(3,...e.map(t=>x(t.cells[n]??"")))),s=t=>`| ${Array.from({length:n},(e,n)=>{return r=t[n]??"",s=o[n],r+" ".repeat(Math.max(0,s-x(r)));var r,s}).join(" | ")} |`,a=[];if(r){a.push(s(e[0].cells)),a.push(`| ${o.map(t=>"-".repeat(t)).join(" | ")} |`);for(let t=1;t<e.length;t++)a.push(s(e[t].cells))}else{a.push(s(new Array(n).fill(""))),a.push(`| ${o.map(t=>"-".repeat(t)).join(" | ")} |`);for(const t of e)a.push(s(t.cells))}return a.join("\n")}function x(t){let e=0;for(const n of t){const t=n.codePointAt(0)??0;e+=t>=4352&&t<=4447||t>=11904&&t<=42191||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65072&&t<=65135||t>=65280&&t<=65376||t>=65504&&t<=65510?2:1}return e}function A(t,e=""){switch(t.type.name){case"paragraph":default:return e+M(t);case"heading":return`${e}${"#".repeat(t.attrs.level)} ${M(t)}`;case"blockquote":return O(t,"").split("\n").map(t=>`${e}> ${t}`).join("\n");case"code_block":{const n=t.attrs.language??"",r=t.textContent;let o=3;for(const t of r.match(/`+/g)??[])o=Math.max(o,t.length+1);const s="`".repeat(o),a=r.split("\n").map(t=>e+t).join("\n");return`${e}${s}${n}\n${a}\n${e}${s}`}case"horizontal_rule":return`${e}---`;case"html_block":return t.attrs.value.replace(/\n+$/,"").split("\n").map(t=>e+t).join("\n");case"math_block":return t.attrs.raw.replace(/\n+$/,"").split("\n").map(t=>e+t).join("\n");case"bullet_list":{const n=[];return t.forEach((t,r,o)=>{n.push(E(t,e,`${e}- `,`${e} `,o))}),n.join("\n")}case"ordered_list":{const n=[],r=t.attrs.order??1;return t.forEach((t,o,s)=>{n.push(E(t,e,`${e}${r+s}. `,`${e} `,s))}),n.join("\n")}case"table":return $(t).split("\n").map(t=>e+t).join("\n")}}function E(t,e,n,r,o){const s=t.attrs.checked,a=null===s?"":s?"[x] ":"[ ] ",c=[];t.forEach((t,e,n)=>{c.push(A(t,0===n?"":r))});const i=c.join("\n").split("\n");return n+a+i[0]+(i.length>1?"\n"+i.slice(1).join("\n"):"")}function O(t,e=""){const n=[];return t.forEach(t=>{n.push(A(t,e))}),n.join("\n\n")}function S(t){return O(t).trim()+"\n"}v.renderer.rules.fence=(t,e,n,r,o)=>{const s=t[e],a=s.info.trim().toLowerCase();return(0,k.lG)(a)?`<div data-math-block="${(0,b.pC)(`$$\n${s.content.trim()}\n$$`)}"></div>`:y(t,e,n,r,o)};n(64877);var D=n(19878);const C=new c.hs("md_source_highlight");function N(t,e,n){let r=e;for(const e of t){if("string"==typeof e){r+=e.length;continue}const t=r;Array.isArray(e.children)&&(r=N(e.children,r,n)),e.scope&&n.push({from:t,to:r,cls:`hljs-${e.scope}`})}return r}function L(t,e){const n=t.textContent;if(!n)return[];const r=t.attrs.language??"";if(!r||!D.A.getLanguage(r))return[];let o;try{o=D.A.highlight(n,{language:r,ignoreIllegals:!0})}catch{return[]}const s=[],a=o._emitter?.rootNode;a?.children&&N(a.children,0,s);const c=e+1,l=[];for(const t of s){const e=Math.min(t.from,n.length),r=Math.min(t.to,n.length);e>=r||l.push(i.NZ.inline(c+e,c+r,{class:t.cls}))}return l}function z(){return new c.k_({key:C,props:{decorations(t){const e=function(t){const e=[];return t.descendants((t,n)=>"code_block"!==t.type.name||(e.push(...L(t,n)),!1)),i.zF.create(t,e)}(t.doc);return e.find().length?e:null}}})}var j=n(89117),T=n(86063),R=n(52388);const P=new c.hs("md-graph"),V=new Map,G=new Map,I=new Map,F=new Map;function W(t,e){return`${t}\0${e}`}function q(t,e,n){return(r,o)=>{const s=W(r,o),a=t.get(s);if(a)return Promise.resolve(a);let c=e.get(s);return c||(c=n(r,o).then(n=>(t.set(s,n),e.delete(s),n)),e.set(s,c)),c}}const H=q(V,G,(t,e)=>(0,j.U6)(t,e)),B=q(I,F,(t,e)=>(0,T.Hn)(e));function K(t,e){const n=document.createElement("button");return n.className="md-graph__edit",n.type="button",n.textContent=R.A.t("clk_edt"),n.addEventListener("click",n=>{n.stopPropagation(),function(t,e){if(!t)return;const n=Math.min(e+1,t.state.doc.content.size);t.dispatch(t.state.tr.setSelection(c.U3.near(t.state.doc.resolve(n),1))),t.focus()}(t(),e)}),n}function U(t,e){if(e.error)return t.className="md-graph__body",void(t.textContent=e.error);t.className="md-graph__body",t.innerHTML=e.svg}function J(t,e,n,r){const o=document.createElement("div");o.className="md-graph",o.setAttribute("contenteditable","false");const s=document.createElement("div");s.className="md-graph__body",s.addEventListener("click",()=>{const n=V.get(W(e,t));n&&!n.error&&n.svg&&function(t){const e=document.createElement("div");e.className="md-graph-zoom";const n=document.createElement("div");let r;n.className="md-graph-zoom__body";const o=document.createElement("button");o.className="md-graph-zoom__close",o.type="button",o.title=R.A.t("取消"),o.innerHTML='<i class="material-icons">close</i>';const s=t=>{"Escape"===t.key&&a()};function a(){"function"==typeof r&&r(),document.removeEventListener("keydown",s),e.remove()}e.addEventListener("click",t=>{t.target===e&&a()}),o.addEventListener("click",a),document.addEventListener("keydown",s),e.append(n,o),document.body.appendChild(e),r=t(n)}(t=>{t.innerHTML=n.svg})}),o.append(s,K(r,n));const a=V.get(W(e,t));return a?(a.error&&o.classList.add("md-graph--error"),U(s,a),o):(o.classList.add("md-graph--loading"),s.textContent=R.A.t("rendering"),H(e,t).then(t=>{o.isConnected&&(o.classList.remove("md-graph--loading"),t.error&&o.classList.add("md-graph--error"),U(s,t))}),o)}function X(t,e,n){const r=[],{from:o,to:s}=t.selection;return t.doc.descendants((t,a)=>{if("code_block"!==t.type.name)return;const c=t.attrs.language,l=(0,j.Hm)(c),d=(0,T.hj)(c);if(!l&&!d)return;const u=a,h=a+t.nodeSize;if(function(t,e,n,r){return t<=r&&e>=n}(o,s,u,h))return;const m=t.textContent;if(!m.trim())return;r.push(i.NZ.node(u,h,{class:"md-graph-hidden"}));const p=`graph-${c}-${u}-${m}`;d?r.push(i.NZ.widget(h,()=>function(t,e,n,r,o){const s=document.createElement("div");s.className="md-graph md-graph--mind",s.setAttribute("contenteditable","false"),s.textContent=R.A.t("rendering");const a=K(r,n);let c=null;return s.__unmount=()=>{c?.destroy(),c=null},B(e,t).then(t=>{s.isConnected&&(s.textContent="",s.append(a),t.mount(s).then(t=>{s.isConnected?c=t:t.destroy()}).catch(t=>{console.error("[mind] mount failed",t)}))}),s.addEventListener("click",()=>{o?.(t,e=>function(t,e,n,r){if(!t||r===n)return;const o=t.state.doc;let s=null;const a=o.nodeAt(e);if(a&&"code_block"===a.type.name&&a.textContent===n?s={from:e+1,to:e+a.nodeSize-1}:o.descendants((t,e)=>!(s||"code_block"===t.type.name&&"smm-mind"===t.attrs.language&&t.textContent===n&&(s={from:e+1,to:e+t.nodeSize-1},1))),!s)return;const c=t.state.tr.replaceWith(s.from,s.to,t.state.schema.text(r));t.dispatch(c)}(r(),n,t,e))}),s}(m,c,u,e,n),{side:-1,ignoreSelection:!0,key:p,destroy:t=>t.__unmount?.()})):r.push(i.NZ.widget(h,()=>J(m,c,u,e),{side:-1,ignoreSelection:!0,key:p}))}),i.zF.create(t.doc,r)}function Y(t){let e=null;return new c.k_({key:P,props:{decorations(n){const r=X(n,()=>e,t);return r.find().length?r:null}},view:t=>(e=t,{destroy(){e=null}})})}const Z=new Map;class Q{dom;node;view;get_pos;render_box;source_input;editing=!1;draft=null;painted_raw="";constructor(t,e,n){this.node=t,this.view=e,this.get_pos=n;const r="math_block"===t.type.name;this.dom=document.createElement(r?"div":"span"),this.dom.className=r?"md-math md-math--block":"md-math md-math--inline",this.dom.setAttribute("contenteditable","false"),this.render_box=document.createElement("span"),this.render_box.className="md-math__render",this.source_input=document.createElement("textarea"),this.source_input.className="md-math__source",this.source_input.setAttribute("spellcheck","false"),this.source_input.setAttribute("wrap","off"),this.source_input.setAttribute("rows","1"),this.dom.append(this.render_box,this.source_input),function(t,e){Z.set(t,e)}(n(),this),this.source_input.addEventListener("input",()=>{this.draft=this.source_input.value,this.auto_size()}),this.source_input.addEventListener("blur",()=>this.commit()),this.source_input.addEventListener("keydown",t=>{t.stopPropagation(),"Escape"===t.key&&(t.preventDefault(),this.draft=null,this.set_editing(!1))});for(const t of["beforeinput","paste","input","keyup","keypress"])this.source_input.addEventListener(t,t=>t.stopPropagation());this.render_box.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),this.focus_source()}),this.paint(t)}paint(t){const e=t.attrs.raw;if(this.editing)return this.dom.setAttribute("data-mode","source"),null===this.draft&&(this.source_input.value=e),void this.auto_size();if(this.dom.setAttribute("data-mode","preview"),this.painted_raw===e)return;this.painted_raw=e;const n=this.render_box;n.classList.add("md-math--loading"),n.textContent="",n.textContent=e,(0,k.z$)(n,t.attrs.tex,"math_block"===t.type.name?"block":"inline",e)}auto_size(){const t=this.source_input;t.style.height="0px",t.style.height=`${t.scrollHeight}px`}focus_source(){this.editing||(this.set_editing(!0),this.source_input.focus(),this.source_input.setSelectionRange(this.source_input.value.length,this.source_input.value.length))}set_editing(t){this.editing!==t&&(this.editing=t,this.paint(this.node))}set_selected(t){t?this.focus_source():this.editing&&(this.commit(),this.set_editing(!1))}commit(){if(null===this.draft)return;const t=this.draft;if(this.draft=null,t===this.node.attrs.raw)return;const e=this.get_pos(),n=this.view.state.doc.nodeAt(e);if(!n)return;const r=(0,k.V)(t),o=r?.tex??t;this.view.dispatch(this.view.state.tr.setNodeMarkup(e,void 0,{...n.attrs,raw:t,tex:o})),this.painted_raw=""}update(t){if(t.type!==this.node.type)return!1;const e=t.attrs.raw!==this.node.attrs.raw;return this.node=t,e&&(this.draft=null,this.painted_raw=""),this.paint(t),!0}stopEvent(t){return this.dom.contains(t.target)}ignoreMutation(){return!0}destroy(){this.draft=null,function(t){for(const[e,n]of Z)if(n===t)return void Z.delete(e)}(this)}}function tt(t){const e=t.state.selection,n=e.from,r=e.to;for(const[t,e]of Z){const o=r>t&&n<=t+1;e.set_selected(o)}}var et=n(67951),nt=(n(41631),n(50576),n(70432),n(74848));function rt(t){return 0===t?(0,et.uf)("paragraph"):(0,et.uf)("heading",{level:t})}function ot(t){return!(!t.ctrlKey&&!t.metaKey)}function st(t,e){let n=null;try{const r=t.domAtPos(e).node,o=1===r.nodeType?r:r.parentElement;n=o?o.closest(".md-filecat-content > *")??o:null}catch{}if(!n)return;const r=n.closest(".md-editor-scroll");if(!r)return;const o=parseFloat(getComputedStyle(n).scrollMarginTop)||0,s=r.scrollTop+n.getBoundingClientRect().top-r.getBoundingClientRect().top-o,a=r.scrollHeight-r.clientHeight;!function(t,e){const n=t.scrollTop,r=e-n;if(Math.abs(r)<1)return;const o=performance.now(),s=e=>{const a=Math.min(1,(e-o)/500);t.scrollTop=n+r*(1-Math.pow(1-a,3)),a<1&&requestAnimationFrame(s)};requestAnimationFrame(s)}(r,Math.max(0,Math.min(s,a)))}function at(t,e){return(0,f.D8)(1)(t,e)}const ct=r.forwardRef(function(t,e){const{t:n}=(0,o.Bd)(),_=(0,r.useRef)(null),k=(0,r.useRef)(null),[,v]=(0,s.fp)(a.AG.mind_editor),y=(0,r.useRef)(t.on_change),M=(0,r.useRef)(t.on_save),$=(0,r.useRef)(t.on_selection_change),x=(0,r.useRef)(t.on_source_mode_change),A=(0,r.useRef)();return A.current=(t,e)=>{v({name:n("思维导图"),code_source:t,on_save_code:t=>e(t)})},(0,r.useEffect)(()=>{y.current=t.on_change,M.current=t.on_save,$.current=t.on_selection_change,x.current=t.on_source_mode_change}),(0,r.useEffect)(()=>{if(!_.current)return;g.Y;(0,b.sL)(t.doc_path?t.doc_path.replace(/[^/]*$/,""):"");const n=c.$t.create({doc:w(t.value??""),plugins:[(0,d.b6)(),z(),Y((t,e)=>A.current?.(t,e)),new c.k_({view:t=>(tt(t),{update:(t,e)=>{t.state.selection===e.selection&&t.state.doc===e.doc||tt(t)}})}),(0,et.k5)(),(0,u.w)({"Mod-a":et.Rx,"Mod-z":d.tN,"Mod-y":d.ZS,"Mod-Shift-z":d.ZS,"Mod-b":(0,et.NH)("strong"),"Mod-i":(0,et.NH)("em"),"Mod-Shift-x":(0,et.NH)("strike"),"Mod-`":(0,et.NH)("code"),"Mod-1":(t,e)=>rt(1)(t,e),"Mod-2":(t,e)=>rt(2)(t,e),"Mod-3":(t,e)=>rt(3)(t,e),"Mod-0":(t,e)=>rt(0)(t,e),"Mod-Shift-8":et.fK,"Mod-Shift-9":et.oB,"Mod-Shift-.":et.Vu,Tab:et.G8.sink,"Shift-Tab":et.G8.lift,"Mod-Enter":at,"Mod-s":()=>(M.current?.(),!0)}),(0,f.LF)({allowTableNodeSelection:!0}),(0,f.AL)(),(0,m.A)({color:"var(--primary, #1a73e8)",width:2}),(0,p.z)(),(0,u.w)({Enter:(0,h.st)(et.x0,h.pC,et.G8.split,h.Z1,h.iz,h.aw),"Shift-Enter":(t,e)=>{const{hard_break:n}=t.schema.nodes;return e&&e(t.tr.replaceSelectionWith(n.create()).scrollIntoView()),!0},"Mod-Enter":h.I$}),(0,u.w)(h.RV)]}),r=t=>t.setAttribute("data-img-error",""),o=t=>"IMG"===t.tagName&&!t.classList.contains("ProseMirror-separator"),s=t=>{const e=t.target;"IMG"===e?.tagName&&o(e)&&r(e)},a=t=>{const e=t.target;"IMG"===e?.tagName&&o(e)&&(t=>{t.removeAttribute("data-img-error")})(e)},v=_.current;v.addEventListener("error",s,!0),v.addEventListener("load",a,!0);const E=()=>{v.querySelectorAll("img").forEach(t=>{if(!o(t))return;const e=t;e.dataset.imgSeen||(e.dataset.imgSeen="1",e.complete?0===e.naturalWidth&&r(e):r(e))})},D=new MutationObserver(()=>{requestAnimationFrame(E)});D.observe(v,{childList:!0,subtree:!0}),E();let C=null;if(C=new i.Lz(_.current,{state:n,editable:()=>!1!==t.editable,nodeViews:{...(0,b.op)(),math_block:(t,e,n)=>new Q(t,e,n),math_inline:(t,e,n)=>new Q(t,e,n)},handleClickOn(t,e,n,r,o){if(!ot(o))return!1;const s=function(t){if(!(t instanceof Element))return null;const e=t.closest("a[href]"),n=e?.getAttribute("href");return n||null}(o.target)??function(t,e){const n=t.doc.content.size,r=Math.max(0,Math.min(e,n));let o;try{o=t.doc.resolve(r)}catch{return null}for(const e of[1,-1]){const o=1===e?r:r-1;if(!(o<0||o>=n))try{const e=t.doc.resolve(o).marks().find(t=>"link"===t.type.name);if(e?.attrs?.href)return e.attrs.href}catch{}}try{const t=o.parent.marks.find(t=>"link"===t.type.name);if(t?.attrs?.href)return t.attrs.href}catch{}return null}(t.state,e);return!!s&&(window.open(s,"_blank","noopener,noreferrer"),!0)},clipboardTextSerializer:t=>function(t){const e=[];return t.content.forEach(t=>e.push(t)),1===e.length&&"code_block"===e[0].type.name&&"markdown"===e[0].attrs.language?e[0].textContent.replace(/\n*$/,"")+"\n":O(t.content).trim()+"\n"}(t),handlePaste(t,e){const n=e.clipboardData?.getData("text/plain");if(!n)return!1;const{from:r,to:o}=t.state.selection;if(lt(t.state.doc,r)&<(t.state.doc,o))return t.dispatch(t.state.tr.insertText(n.replace(/\r\n?/g,"\n"),r,o).scrollIntoView()),!0;const s=e.clipboardData?.getData("text/html");if(s&&function(t){if(!t)return!1;try{const e=(new DOMParser).parseFromString(t,"text/html"),n=Array.from(e.body.children);return 1===n.length&&"PRE"===n[0].tagName}catch{return!1}}(s)){const e=w(n);return t.dispatch(t.state.tr.replaceSelection(new l.Ji(e.content,0,0)).scrollIntoView()),!0}return!1},handleDOMEvents:{keydown:(t,e)=>{if(ot(e)&&t.dom.classList.add("md-ctrl-down"),it(t.state.doc)&&"Enter"===e.key&&!e.ctrlKey&&!e.metaKey&&!e.altKey){e.preventDefault();const{from:n,to:r}=t.state.selection;return t.dispatch(t.state.tr.insertText("\n",n,r).scrollIntoView()),!0}return!1},keyup:(t,e)=>(ot(e)||t.dom.classList.remove("md-ctrl-down"),!1),blur:t=>(t.dom.classList.remove("md-ctrl-down"),!1),beforeinput:(t,e)=>{if(!it(t.state.doc))return!1;const n=e;if("insertText"!==n.inputType)return!1;const r=n.data;if(null==r)return!1;n.preventDefault();const{from:o,to:s}=t.state.selection;return t.dispatch(t.state.tr.insertText(r.replace(/\r\n?/g,"\n"),o,s).scrollIntoView()),!0}},dispatchTransaction(t){const e=C.state.apply(t);C.updateState(e);const n=it(e.doc);n?C.dom.classList.add("md-source-mode"):C.dom.classList.remove("md-source-mode"),n!==it(t.before)&&x.current?.(n),t.docChanged&&y.current?.(n?e.doc.textContent:S(e.doc)),(t.selectionSet||t.docChanged)&&$.current?.()},attributes:{class:"md-filecat-content",spellcheck:"false"}}),k.current=C,t.initial_source_mode&&!it(C.state.doc)){const t=S(C.state.doc),e=C.state.schema.nodes.code_block.create({language:"markdown"},t?C.state.schema.text(t):null),n=C.state.tr;n.replaceWith(0,C.state.doc.content.size,e),n.setMeta("addToHistory",!1),C.dispatch(n)}const N={get_markdown:()=>it(C.state.doc)?C.state.doc.textContent:S(C.state.doc),set_markdown:t=>{const e=w(t);C.dispatch(C.state.tr.replaceWith(0,C.state.doc.content.size,e.content))},focus:()=>C.focus(),get_view:()=>k.current,in_table:()=>function(t){const{$from:e}=t.selection;for(let t=e.depth;t>0;t--){if("table"===e.node(t).type.name)return!0}return!1}(C.state),active_marks:()=>(C.state.storedMarks??C.state.selection.$from.marks()).map(t=>t.type.name),active_block:()=>{const{$from:t}=C.state.selection;for(let e=t.depth;e>0;e--){const n=t.node(e);if("heading"===n.type.name)return{name:"heading",level:n.attrs.level};if("paragraph"===n.type.name)return{name:"paragraph"}}return{name:"paragraph"}},insert_table:(t=3,e=3)=>{const n=function(t,e,n){const r=(0,f.e)(t),o=r.table,s=r.row,a=r.cell,c=r.header_cell??r.cell;if(!o||!s||!a)return null;const i=t=>s.create(null,Array.from({length:e},()=>t.createAndFill())),l=i(c),d=Array.from({length:n},()=>i(a));return o.create(null,[l,...d])}(C.state.schema,t,e);if(!n)return;const{from:r}=C.state.selection,o=C.state.doc.resolve(r);let s=r;for(let t=o.depth;t>0;t--)if("table"===o.node(t).type.name){s=o.after(t);break}const a=C.state.tr;s===r?a.replaceSelectionWith(n):a.insert(s,n),C.dispatch(a.scrollIntoView());const c=C.state.doc.resolve(Math.min(s+3,C.state.doc.content.size));try{C.dispatch(C.state.tr.setSelection(C.state.selection.constructor.near(c)))}catch{}},get_headings:()=>function(t){const e=[];return t.doc.descendants((t,n)=>("heading"!==t.type.name||e.push({level:t.attrs.level,text:t.textContent,pos:n}),!0)),e}(C.state),scroll_to_pos:t=>{const e=C.state.doc.content.size,n=Math.max(0,Math.min(t,e)),r=C.state.doc.nodeAt(n);let o;try{o=r?c.U3.near(C.state.doc.resolve(n+1),1):c.U3.near(C.state.doc.resolve(n),1)}catch{o=c.U3.near(C.state.doc.resolve(0),1)}C.dispatch(C.state.tr.setSelection(o)),st(C,o.from),C.focus()},is_source_mode:()=>it(C.state.doc),enter_source_mode:()=>{if(it(C.state.doc))return;const t=S(C.state.doc),e=C.state.schema.nodes.code_block.create({language:"markdown"},t?C.state.schema.text(t):null),n=C.state.tr;n.replaceWith(0,C.state.doc.content.size,e),C.dispatch(n),C.dom.classList.add("md-source-mode")},exit_source_mode:()=>{if(!it(C.state.doc))return;const t=w(C.state.doc.textContent),e=C.state.tr;e.replaceWith(0,C.state.doc.content.size,t.content),C.dispatch(e),C.dom.classList.remove("md-source-mode")}};return"function"==typeof e?e(N):e&&(e.current=N),t.on_ready?.(N),()=>{D.disconnect(),v.removeEventListener("error",s,!0),v.removeEventListener("load",a,!0),C.destroy(),k.current=null}},[]),(0,nt.jsx)("div",{className:"md-filecat",ref:_})});function it(t){if(1!==t.childCount)return!1;const e=t.firstChild;return!!e&&"code_block"===e.type.name&&"markdown"===e.attrs.language}function lt(t,e){const n=t.resolve(e);for(let t=n.depth;t>0;t--)if("code_block"===n.node(t).type.name)return!0;return!1}const dt=ct},67951(t,e,n){n.d(e,{NH:()=>d,k5:()=>l,uf:()=>u});var r=n(38341),o=n(5091),s=n(42845),a=n(46762),c=n(3772);function i(t,e){return new r.fV(t,(t,n,r,o)=>{const s=t.schema.marks[e],a=n[1];if(!s||!a)return null;const c=n[0].indexOf(a);if(c<0)return null;const i=r+c,l=i+a.length,d=t.tr;return d.delete(l,o),d.delete(r,i),d.addMark(r,r+a.length,s.create()),d.removeStoredMark(s),d})}function l(){const t=o.Y;return(0,r.sM)({rules:[(0,r.JJ)(/^(#{1,6})\s$/,t.nodes.heading,t=>({level:t[1].length})),(0,r.JJ)(/^#([1-6])\s$/,t.nodes.heading,t=>({level:Number(t[1])})),(0,r.JJ)(/^```([\w-]*)\s$/,t.nodes.code_block,t=>({language:t[1]??""})),(0,r.tG)(/^\s*>\s$/,t.nodes.blockquote),(0,r.tG)(/^\s*([-+*])\s$/,t.nodes.bullet_list),(0,r.tG)(/^(\d+)\.\s$/,t.nodes.ordered_list,t=>({order:Number(t[1])})),i(/(?:\*\*)([^*]+)(?:\*\*)$/,"strong"),i(/(?:__)([^_]+)(?:__)$/,"strong"),i(/(?<![*])\*([^*]+)\*$/,"em"),i(/(?<![_])_([^_]+)_$/,"em"),i(/(?:~~)([^~]+)(?:~~)$/,"strike"),i(/(?:`)([^`]+)(?:`)$/,"code"),...r.Fr,r.gO]})}function d(t){return(e,n)=>{const r=e.schema.marks[t];return!!r&&(0,a.wh)(r)(e,n)}}function u(t,e={}){return(n,r)=>{const o=n.schema.nodes[t];if(!o)return!1;const{$from:s,$to:a}=n.selection,c=s.blockRange(a);if(!c)return!1;const i=s.parent,l=i.type===o&&Object.entries(e).every(([t,e])=>i.attrs[t]===e),d=l?n.schema.nodes.paragraph:o,u=l?{}:e;return r&&r(n.tr.setBlockType(c.start,c.end,d,u)),!0}}const h=(t,e)=>(0,c.Sd)(t.schema.nodes.bullet_list)(t,e),m=(t,e)=>(0,c.Sd)(t.schema.nodes.ordered_list)(t,e),p={sink:(0,c.$B)(o.Y.nodes.list_item),lift:(0,c.T2)(o.Y.nodes.list_item),split:(0,c.wn)(o.Y.nodes.list_item),wrap_bullet:h,wrap_ordered:m};n.d(e,["G8",0,p,"Rx",0,(t,e)=>{const{$from:n}=t.selection;return"code_block"===n.parent.type.name&&(e&&e(t.tr.setSelection(s.U3.create(t.doc,n.start(),n.end())).scrollIntoView()),!0)},"Vu",0,(t,e)=>{const{blockquote:n}=t.schema.nodes,{$from:r,$to:o}=t.selection,s=r.blockRange(o);if(!s)return!1;if(s.parent.type===n&&s.depth>0){const n=r.before(s.depth),o=t.tr.doc.nodeAt(n);if(o&&1===o.childCount)return e&&e(t.tr.replaceWith(n,n+o.nodeSize,o.child(0)).scrollIntoView()),!0;if(e){const n=t.tr,o=r.parent,a=r.after(s.depth);n.delete(s.start,s.end),n.insert(a,o),e(n.scrollIntoView())}return!0}return e&&e(t.tr.wrap(s,[{type:n}]).scrollIntoView()),!0},"fK",0,h,"oB",0,m,"x0",0,(t,e)=>{const{$from:n,empty:r}=t.selection;if(!r||"paragraph"!==n.parent.type.name)return!1;const o=n.parent.textContent;if(!o.trim())return!1;const a=function(t){const e=t.trim(),n=/^#([1-6])$/.exec(e);if(n)return{type:"heading",attrs:{level:Number(n[1])}};const r=/^(#{1,6})$/.exec(e);if(r)return{type:"heading",attrs:{level:r[1].length}};const o=/^```([\w-]*)$/.exec(e);return o?{type:"code_block",attrs:{language:o[1]??""}}:/^(?:-{3,}|\*{3,}|_{3,})$/.test(e.replace(/\s+/g,""))?{type:"horizontal_rule"}:/^>\s*$/.test(e)?{type:"blockquote"}:/^[-+*]\s*$/.test(e)?{type:"bullet_list"}:/^\d+[.)]$/.test(e)?{type:"ordered_list"}:null}(o);if(!a)return!1;if("blockquote"===a.type&&n.depth>1)return!1;const c=t.schema.nodes[a.type];if(!c)return!1;const i=n.before(n.depth),l=n.after(n.depth);if(e){const n=t.tr,r=c.createAndFill(a.attrs)??c.create(a.attrs);n.replaceWith(i,l,r);const o=Math.min(i+1,n.doc.content.size);try{n.setSelection(s.U3.near(n.doc.resolve(o),1))}catch{}n.scrollIntoView(),e(n)}return!0}])},96763(t,e,n){n.d(e,{Kz:()=>a,P7:()=>l,_8:()=>h,_D:()=>u,bN:()=>s,sO:()=>d});var r=n(14284),o=n(53459);function s(t,e){const n="md-theme-style-"+t,r=document.getElementById(n);if(!e)return void r?.remove();let o=r;o||(o=document.createElement("style"),o.id=n,document.head.appendChild(o)),o.textContent=e}async function a(){try{const t=await r.XO.get("md_theme/list");return t?.code===o.m.Success?t.data??[]:[]}catch(t){return[]}}const c="md-theme-change";function i(){window.dispatchEvent(new Event(c))}async function l(t){try{const e=await r.XO.get(`md_theme/get?id=${encodeURIComponent(t)}`);return e?.code===o.m.Success?e.data??"":""}catch(t){return""}}async function d(){try{const t=await r.XO.get("md_theme/active");return t?.code===o.m.Success?t.data??"":""}catch(t){return""}}async function u(t){const e=await r.XO.post("md_theme/save",t);return e?.code!==o.m.Success?null:(i(),e.data)}async function h(t){const e=await r.XO.post("md_theme/del",{id:t});return e?.code===o.m.Success&&(i(),!0)}n.d(e,["o3",0,c])},5091(t,e,n){var r=n(58903),o=n(86059),s=n(41105),a=n(89334);const c=(0,o.of)({tableGroup:"block",cellContent:"block+",cellAttributes:{}}),i={align:{default:null}},l={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",attrs:i,parseDOM:[{tag:"p"}],toDOM:t=>["p",t.attrs.align?{style:`text-align:${t.attrs.align}`}:{},0]},heading:{content:"inline*",group:"block",attrs:{level:{default:1},...i},defining:!0,parseDOM:[1,2,3,4,5,6].map(t=>({tag:`h${t}`,attrs:{level:t}})),toDOM(t){const e=t.attrs.align?{style:`text-align:${t.attrs.align}`}:{};return[`h${t.attrs.level}`,e,0]}},bullet_list:{group:"block",content:"list_item+",parseDOM:[{tag:"ul"}],toDOM:()=>["ul",0]},ordered_list:{group:"block",content:"list_item+",attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs:t=>({order:Number(t.getAttribute("start")??1)})}],toDOM:t=>1===t.attrs.order?["ol",0]:["ol",{start:t.attrs.order},0]},list_item:{content:"paragraph block*",defining:!0,attrs:{checked:{default:null}},parseDOM:[{tag:"li",getAttrs:t=>{const e=t,n=e.querySelector("input[type=checkbox]");if(n)return{checked:n.checked};const r=e.getAttribute("data-checked");return{checked:null===r?null:"true"===r}}}],toDOM:t=>null!==t.attrs.checked?["li",{"data-checked":String(t.attrs.checked)},0]:["li",0]},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]},code_block:{content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>{const e=t.querySelector("code"),n=/language-([\w-]+)/.exec(e?.className??"");return{language:n?n[1]:""}}}],toDOM:t=>["pre",{"data-language":t.attrs.language},["code",0]]},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>["hr"]},html_block:{group:"block",atom:!0,code:!0,attrs:{value:{default:""}},parseDOM:[{tag:"div[data-html-block]",getAttrs:t=>({value:(0,s.Ne)(t.getAttribute("data-html-block")??"")})}],toDOM:t=>["div",{"data-html-block":t.attrs.value}]},html_inline:{inline:!0,group:"inline",atom:!0,code:!0,attrs:{value:{default:""}},parseDOM:[{tag:"span[data-html-inline]",getAttrs:t=>({value:(0,s.Ne)(t.getAttribute("data-html-inline")??"")})}],toDOM:t=>["span",{"data-html-inline":t.attrs.value}]},math_inline:{inline:!0,group:"inline",atom:!0,attrs:{raw:{default:""},tex:{default:""}},parseDOM:[{tag:"span[data-math-inline]",getAttrs:t=>{const e=t,n=(0,s.Ne)(e.getAttribute("data-math-inline")??"");return{raw:n,tex:(0,a.V)(n)?.tex??""}}}],toDOM:t=>["span",{"data-math-inline":t.attrs.raw}]},math_block:{group:"block",atom:!0,code:!0,attrs:{raw:{default:""},tex:{default:""}},parseDOM:[{tag:"div[data-math-block]",getAttrs:t=>{const e=t,n=(0,s.Ne)(e.getAttribute("data-math-block")??"");return{raw:n,tex:(0,a.V)(n)?.tex??""}}}],toDOM:t=>["div",{"data-math-block":t.attrs.raw}]},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]},image:{inline:!0,group:"inline",draggable:!0,attrs:{src:{},alt:{default:null},title:{default:null}},parseDOM:[{tag:"img[src]",getAttrs:t=>{const e=t;return{src:e.getAttribute("src"),alt:e.getAttribute("alt"),title:e.getAttribute("title")}}}],toDOM(t){const{src:e,alt:n,title:r}=t.attrs,o={src:(0,s.KR)(e)};return n&&(o.alt=n),r&&(o.title=r),["img",o]}},text:{group:"inline"},...c},d={strong:{parseDOM:[{tag:"strong"},{tag:"b"},{style:"font-weight=bold"}],toDOM:()=>["strong",0]},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:()=>["em",0]},strike:{parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"}],toDOM:()=>["s",0]},code:{parseDOM:[{tag:"code",getAttrs:t=>"PRE"!==t.parentElement?.tagName&&null}],toDOM:()=>["code",0]},link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:t=>{const e=t;return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM(t){const{href:e,title:n}=t.attrs;return["a",{href:e,title:n,rel:"noopener noreferrer",target:"_blank"},0]}}},u=new r.Sj({nodes:l,marks:d});n.d(e,["Y",0,u])}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[1142],{71142(e,t,r){r.r(t),r.d(t,{default:()=>ue});var n=r(96540),s=r(7523),o=r(34843),c=r(82893),i=r(78247),u=r(23430),a=r(85997),l=r(57952),d=r(62042),m=r(53459),f=r(14284),v=r(57889),_=r(23496),h=r(22022),p=r(76118),g=r(67951),w=r(74848);function x(e){const{t}=(0,h.Bd)(),r=(0,n.useRef)(null),[s,o]=(0,n.useState)({marks:[],block:{name:"paragraph"}}),[c,i]=(0,n.useState)(null),u=(0,n.useCallback)(()=>{const t=e.get_view();if(!t)return;const r=t.state.selection,n=t.state.storedMarks??r.$from.marks();if(o({marks:n.map(e=>e.type.name),block:y(r.$from)}),r.empty)return void i(null);const s=t.coordsAtPos(r.from),c=t.coordsAtPos(r.to),u=(Math.min(s.left,c.left)+Math.max(s.right,c.right))/2,a=Math.min(s.top,c.top),l=Math.max(s.bottom,c.bottom);i({top:a,bottom:l,left:u})},[e.get_view]);(0,n.useEffect)(()=>{u();const t=e.get_view();if(!t)return;const r=()=>u();t.dom.addEventListener("keyup",r),t.dom.addEventListener("mouseup",r),document.addEventListener("selectionchange",r);const n=t.dom.closest(".md-editor-context");return n?.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),()=>{t.dom.removeEventListener("keyup",r),t.dom.removeEventListener("mouseup",r),document.removeEventListener("selectionchange",r),n?.removeEventListener("scroll",r),window.removeEventListener("resize",r)}},[u,e.get_view,e.refresh_key]);const a=t=>{const r=e.get_view();r&&(t(r.state,r.dispatch),r.focus(),u())},l=e=>s.marks.includes(e),d=e=>"heading"===s.block.name&&s.block.level===e,[m,f]=(0,n.useState)({w:0,h:36});if((0,n.useLayoutEffect)(()=>{if(!c||!r.current)return;const e=r.current.offsetWidth,t=r.current.offsetHeight;f(r=>r.w===e&&r.h===t?r:{w:e,h:t})},[c,e.refresh_key]),!c)return null;const v=(e,r,n,s,o=!1)=>(0,w.jsx)("button",{className:"mdtb__btn"+(o?" mdtb__btn--on":""),title:t(n),onMouseDown:e=>e.preventDefault(),onClick:s,children:r},e),_=m.w/2,p=_+4,x=Math.max(p,window.innerWidth-_-4),k=document.querySelector(".header")?.getBoundingClientRect().bottom??0,b=c.top-m.h-8,E=b<k+4,j={top:E?Math.min(c.bottom+8,window.innerHeight-m.h-4):b,left:Math.min(x,Math.max(p,c.left))};return(0,w.jsxs)("div",{className:"mdtb mdtb--floating"+(E?" mdtb--below":""),ref:r,style:j,children:[v("h1","H1","一级标题",()=>a((0,g.uf)("heading",{level:1})),d(1)),v("h2","H2","二级标题",()=>a((0,g.uf)("heading",{level:2})),d(2)),v("h3","H3","三级标题",()=>a((0,g.uf)("heading",{level:3})),d(3)),(0,w.jsx)("span",{className:"mdtb__sep"}),v("b","B","加粗",()=>a((0,g.NH)("strong")),l("strong")),v("i","I","斜体",()=>a((0,g.NH)("em")),l("em")),v("s","S","删除线",()=>a((0,g.NH)("strike")),l("strike")),v("code","</>","行内代码",()=>a((0,g.NH)("code")),l("code")),(0,w.jsx)("span",{className:"mdtb__sep"}),v("ul","≔","无序列表",()=>a(g.fK)),v("ol","1.","有序列表",()=>a(g.oB)),v("quote","❝","引用",()=>a(g.Vu))]})}function y(e){for(let t=e.depth;t>0;t--){const r=e.node(t).type.name;if("heading"===r)return{name:"heading",level:e.node(t).attrs.level};if("paragraph"===r)return{name:"paragraph"}}return{name:"paragraph"}}var k=r(75725),b=r(86059);const E="cut",j="copy",S="paste",C="strong",N="em",L="strike",A="code",R="h1",H="h2",M="h3",G="paragraph",z="bullet",B="ordered",P="quote",$="code_block",F="clean",D="row_before",K="row_after",I="row_delete",T="col_before",U="col_after",W="col_delete",Y="header_toggle",X="cell_merge",q="cell_split",V="table_delete",J="table_insert",O="select_all";function Z(e){const{t}=(0,h.Bd)(),[r,s]=(0,n.useState)(null),o=(0,n.useRef)(e.get_view);o.current=e.get_view,(0,n.useEffect)(()=>{const e=e=>{const t=o.current();if(!t)return;const r=e.target;if(!r||!r.closest(".md-filecat-content"))return;e.preventDefault();const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(n){const e=t.state.selection;if(n.pos<e.from||n.pos>e.to){const{TextSelection:e}=t.state.selection.constructor;try{t.dispatch(t.state.tr.setSelection(e.near(t.state.doc.resolve(n.pos))))}catch{}}}const c=!!r.closest("td, th");s({x:e.clientX,y:e.clientY,in_table:c||(0,b.aH)(t.state)})};return document.addEventListener("contextmenu",e,!0),()=>document.removeEventListener("contextmenu",e,!0)},[]);const c=()=>s(null),i=(0,n.useCallback)(e=>{const t=o.current();t&&(e(t.state,t.dispatch),t.focus(),c())},[]),u=e=>{const t=o.current();t?.focus(),document.execCommand(e),c()};if(!r)return null;const a=r.in_table?[{r:t("上方插入行"),v:D},{r:t("下方插入行"),v:K},{r:t("左侧插入列"),v:T},{r:t("右侧插入列"),v:U},{r:t("删除行"),v:I},{r:t("删除列"),v:W},{r:t("切换表头行"),v:Y},{r:t("合并单元格"),v:X},{r:t("拆分单元格"),v:q},{r:t("删除表格"),v:V}]:[],l=[{r:t("剪切"),v:E},{r:t("复制"),v:j},{r:t("粘贴"),v:S},{r:t("格式"),v:"format",items:[{r:t("加粗"),v:C},{r:t("斜体"),v:N},{r:t("删除线"),v:L},{r:t("行内代码"),v:A}]},{r:t("段落"),v:"block",items:[{r:t("一级标题"),v:R},{r:t("二级标题"),v:H},{r:t("三级标题"),v:M},{r:t("正文"),v:G}]},{r:t("插入"),v:"insert",items:[{r:t("无序列表"),v:z},{r:t("有序列表"),v:B},{r:t("引用"),v:P},{r:t("代码块"),v:$},{r:t("插入表格"),v:J}]},...a.length?[{r:t("表格"),v:"table",items:a}]:[],{r:t("清除格式"),v:F},{r:t("全选"),v:O}];return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(k.rY,{click:c}),(0,w.jsx)(k.Pu,{x:r.x,y:r.y,items:l,click:t=>{switch(t){case E:return u("cut");case j:return u("copy");case S:return u("paste");case C:return i((0,g.NH)("strong"));case N:return i((0,g.NH)("em"));case L:return i((0,g.NH)("strike"));case A:return i((0,g.NH)("code"));case R:return i((0,g.uf)("heading",{level:1}));case H:return i((0,g.uf)("heading",{level:2}));case M:return i((0,g.uf)("heading",{level:3}));case G:return i((0,g.uf)("paragraph"));case z:return i(g.fK);case B:return i(g.oB);case P:return i(g.Vu);case $:return i((0,g.uf)("code_block"));case J:return c(),void e.on_insert_table?.();case D:return i(b.JD);case K:return i(b.gC);case T:return i(b.RC);case U:return i(b.GU);case I:return i(b.aR);case W:return i(b.gR);case Y:return i(b.uC);case X:return i(b.w7);case q:return i(b.L0);case V:return i(b.kG);case F:return i((e,t)=>{const{from:r,to:n}=e.selection;let s=e.tr;return e.doc.nodesBetween(r,n,(e,t)=>{if(e.isText)for(const r of e.marks)s=s.removeMark(t,t+e.nodeSize,r.type)}),t?.(s),!0});case O:return i((e,t)=>{const{TextSelection:r}=e.selection.constructor;return t?.(e.tr.setSelection(r.create(e.doc,0,e.doc.content.size))),!0})}}})]})}var Q=r(64877);function ee(e){const t=[];if(!e)return t;const r=e.split(/(\n)/);let n=null,s=0;for(let e=0;e<r.length;e+=2){const o=r[e],c=s;s+=o.length+(r[e+1]?.length??0);const i=o.endsWith("\r")?o.slice(0,-1):o,u=i.trimStart(),a=/^(`{3,}|~{3,})/.exec(u);if(a){const e=a[1][0];null===n?n=e:n===e&&(n=null);continue}if(null!==n)continue;const l=/^ {0,3}(#{1,6})\s+(.*)$/.exec(i);if(!l)continue;const d=l[1].length,m=l[2].replace(/\s+#+\s*$/,"").trim();t.push({level:d,text:m,pos:c})}return t}var te=r(69918),re=r(96763),ne=r(40505);function se(e){const{t}=(0,h.Bd)(),[r,s]=(0,n.useState)(!1),[i,u]=(0,n.useState)({x:0,y:0}),[l,d]=(0,n.useState)([]),[m]=(0,o.fp)(c.AG.user_base_info);(0,n.useEffect)(()=>{if(!r)return;let e=!1;return(0,re.Kz)().then(t=>{e||d(t)}),()=>{e=!0}},[r]);const f=(e,t)=>(0,w.jsx)("div",{style:{...(0,ne.ok)(t===m?.user_data?.md_editor_theme)},children:e});return(0,w.jsxs)(n.Fragment,{children:[(0,w.jsx)(a.rA,{icon:"palette",title:t("主题"),onClick:e=>{u({x:e.clientX,y:e.clientY}),s(!0)}}),r&&(0,w.jsx)(k.rY,{click:()=>s(!1),children:(0,w.jsx)(k.Pu,{x:i.x,y:i.y,items:[{r:f(t("follow_sys"),""),v:""},...l.map(e=>({r:f(e.id,e.id),v:e.id}))],click:t=>{s(!1),e.on_change(t)}})})]})}var oe=r(2543),ce=r(52671),ie=r(87361);function ue(e){const t=e.pane,{t:r}=(0,h.Bd)(),g=(0,ce.Zp)(),{check_user_auth:y}=(0,i.MH)(),k=y(u.oV.md_editor_setting),[b,E]=(0,o.fp)(c.AG.md_editor),j=t??b,S=(0,o.fp)(c.AG.md_editor_last_context)[1],C=(0,n.useRef)(null),[N,L]=(0,n.useState)(null),[A,R]=(0,n.useState)(!1),[H,M]=(0,n.useState)(!1),[G,z]=(0,n.useState)(0),B=(0,n.useRef)(null),[P,$]=(0,n.useState)([]),[F,D]=(0,n.useState)(-1),[K,I]=(0,n.useState)(15),[T,U]=(0,n.useState)(!1),W=(0,n.useRef)(null),Y=(0,n.useRef)(null),[X,q]=(0,o.fp)(c.AG.md_editor_show_outline),[V,J]=(0,o.fp)(c.AG.md_editor_mode),O=(0,n.useCallback)(()=>{const e="wysiwyg"===V?"source":"wysiwyg",t=B.current;t&&("source"===e?t.enter_source_mode():t.exit_source_mode(),J(e))},[V]),[ne]=(0,o.fp)(c.AG.md_editor_setting),[ue,ae]=(0,o.fp)(c.AG.md_theme_css),[le]=(0,o.fp)(c.AG.user_base_info),{initUserInfo:de}=(0,n.useContext)(s.F),me=(0,n.useRef)(null),fe=(0,n.useRef)(null);(0,n.useEffect)(()=>{fe.current},[le]),(0,n.useEffect)(()=>{(0,te.Ce)(W.current,ne)},[ne]);(0,n.useEffect)(()=>{(0,re.bN)("editor",ue)},[ue]),(0,n.useEffect)(()=>{const e=()=>{(0,re.sO)().then(ae)};return window.addEventListener(re.o3,e),()=>window.removeEventListener(re.o3,e)},[]);const ve=(0,n.useRef)([]),_e=(0,n.useCallback)(()=>{const e=B.current;if(!e)return;const t=e.is_source_mode()?ee(e.get_markdown()):e.get_headings();ve.current=t,$(t)},[]);(0,n.useEffect)(()=>{t?.on_outline?.(P,F)},[P,F]);const he=(0,n.useCallback)(()=>{const e=B.current,t=e?.get_view();if(!e||!t)return;const r=e.is_source_mode()?t.state.selection.from-1:t.state.selection.from;let n=-1;for(const e of ve.current){if(!(e.pos<=r))break;n=e.pos}D(n)},[]);(0,n.useEffect)(()=>{let e=!1;if(j?.url)return M(!1),R(!0),v.l.get(j.url).then(t=>{if(e)return;L(t??"")}).catch(()=>{e||((0,d.zN)(r("打开失败")),L(""))}).finally(()=>{e||R(!1)}),()=>{e=!0};L(null)},[j?.url]),(0,n.useEffect)(()=>{const e=()=>z(e=>e+1);return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[]);const pe=(0,n.useRef)(O);pe.current=O,(0,n.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"/"===e.key&&(e.preventDefault(),e.stopPropagation(),pe.current())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,n.useEffect)(()=>{_e(),he()},[G,V,_e,he]);const ge=(0,n.useCallback)(oe.throttle(e=>{if(!W.current||!Y.current)return;const t=parseFloat(getComputedStyle(W.current).fontSize),r=e.clientX/t,n=window.innerWidth/t-4,s=2.25+Y.current.offsetWidth/t;r<=n&&r>=s&&I(parseFloat(r.toFixed(2)))},32),[]),we=()=>{U(!1),W.current?.removeEventListener("pointermove",ge)},xe=e=>{const t=B.current;t&&(t.scroll_to_pos(t.is_source_mode()?e.pos+1:e.pos),D(e.pos))},ye=async(e=!1)=>{if(!j?.name||!j?.path)return;const t=B.current?.get_markdown();if(void 0===t)return;const n=j.path.slice(0,j.path.length-j.name.length),s=`${encodeURIComponent(n)}${j.name}`;(await f.$M.post(`save/${s}`,{context:t})).code===m.m.Success?(M(!1),e||(0,d.SK)(r("保存成功"))):(0,d.zN)(r("保存失败"))},ke=(0,n.useRef)(ye);ke.current=ye;const be=(0,n.useRef)(H);be.current=H;const Ee=ne?.auto_save_interval??0;(0,n.useEffect)(()=>{if(j.readonly||Ee<=0)return;const e=setInterval(()=>{be.current&&ke.current(!0)},1e3*Ee);return()=>clearInterval(e)},[Ee,j.readonly]);const je=()=>{window.print()},Se=(0,n.useRef)(V);Se.current=V;const Ce=(0,n.useRef)(xe);Ce.current=xe;const Ne=(0,n.useRef)(je);Ne.current=je,(0,n.useEffect)(()=>{t?.on_dirty?.(H)},[H]),(0,n.useEffect)(()=>{t?.register?.({save:e=>ke.current(e),export_pdf:()=>Ne.current(),toggle_mode:()=>pe.current(),mode:()=>Se.current,goto_heading:e=>Ce.current(e),dirty:()=>be.current})},[]);const Le=()=>{E({}),M(!1),L(null),B.current=null,b?.close?.()},Ae=(0,n.useMemo)(()=>j?.url??"md_editor",[j?.url]);if(!j?.name)return null;const Re=!!t,He=(0,w.jsxs)("div",{className:"md-editor-context",ref:W,children:[A&&(0,w.jsxs)("div",{className:"common-box common-box-center",children:[r("加载中"),"..."]}),!A&&null!==N&&(0,w.jsxs)(n.Fragment,{children:[!Re&&X&&(0,w.jsx)("div",{className:"md-outline-panel",style:{width:`${K}em`},children:(0,w.jsx)(Q.default,{items:P,active_pos:F,on_click:xe})}),!Re&&X&&(0,w.jsx)("div",{className:"md-editor-divider",ref:Y,onPointerDown:()=>{U(!0),W.current?.addEventListener("pointermove",ge)},onPointerUp:we}),!Re&&T&&(0,w.jsx)("div",{className:"md-editor-drag-overlay",onPointerUp:we}),(0,w.jsx)("div",{className:"md-editor-scroll",children:(0,w.jsxs)("div",{className:"md-editor-sheet",children:["wysiwyg"===V&&(0,w.jsx)(x,{get_view:()=>B.current?.get_view()??null,refresh_key:G}),(0,w.jsx)(p.A,{value:N,ref:B,initial_source_mode:"source"===V,doc_path:j?.path,on_ready:e=>{const t=e.is_source_mode()?ee(e.get_markdown()):e.get_headings();ve.current=t,$(t),D(-1)},on_change:()=>{H||M(!0),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{const e=B.current?.get_markdown()??"";e&&S(e)},800)},on_save:()=>ke.current(),on_selection_change:()=>z(e=>e+1),on_source_mode_change:e=>{J(e?"source":"wysiwyg"),z(e=>e+1)}},Ae),"wysiwyg"===V&&(0,w.jsx)(Z,{get_view:()=>B.current?.get_view()??null,on_insert_table:()=>{B.current?.insert_table(3,3),M(!0)}})]})})]})]});return Re?He:(0,w.jsxs)("div",{id:"md-editor-container",ref:me,children:[(0,w.jsx)(l.A,{ignore_tags:!0,left_children:[(0,w.jsx)(a.rA,{title:r("关闭"),icon:"close",onClick:Le},1),(0,w.jsx)("div",{className:"md-editor-title",children:j.name},3),...H&&!j.readonly?[(0,w.jsx)(a.rA,{title:r("保存"),icon:"save",onClick:ye},2)]:[],(0,w.jsx)(a.rA,{title:r("大纲"),icon:"list",onClick:()=>q(e=>!e),selected:X},4),...j.readonly?[]:[(0,w.jsx)(a.rA,{title:r("wysiwyg"===V?"源码模式":"实时编辑模式"),icon:"wysiwyg"===V?"code":"edit",onClick:O},5)],...j.readonly?[]:[(0,w.jsx)(se,{on_change:async e=>{const t=await f.wm.post(_.s.user_save_private_attr,{is_md_theme:!0,md_editor_theme:e});t?.code===m.m.Success?(fe.current=e,await de(),(0,d.SK)(r("保存成功"))):(0,d.zN)(r("保存失败"))}},8)],(0,w.jsx)(a.rA,{title:r("导出PDF"),icon:"print",onClick:je},7),...k&&!j.readonly?[(0,w.jsx)(a.rA,{title:r("编辑器设置"),icon:"settings",onClick:()=>{Le(),g(ie.o.md_editor_setting_page)}},6)]:[]]}),He]})}}}]);
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[1142],{71142(e,t,r){r.r(t),r.d(t,{default:()=>ue});var n=r(96540),s=r(7523),o=r(34843),c=r(82893),i=r(78247),u=r(23430),a=r(85997),l=r(57952),d=r(62042),m=r(53459),f=r(14284),v=r(57889),_=r(23496),h=r(22022),p=r(76118),g=r(67951),w=r(74848);function x(e){const{t}=(0,h.Bd)(),r=(0,n.useRef)(null),[s,o]=(0,n.useState)({marks:[],block:{name:"paragraph"}}),[c,i]=(0,n.useState)(null),u=(0,n.useCallback)(()=>{const t=e.get_view();if(!t)return;const r=t.state.selection,n=t.state.storedMarks??r.$from.marks();if(o({marks:n.map(e=>e.type.name),block:y(r.$from)}),r.empty)return void i(null);const s=t.coordsAtPos(r.from),c=t.coordsAtPos(r.to),u=(Math.min(s.left,c.left)+Math.max(s.right,c.right))/2,a=Math.min(s.top,c.top),l=Math.max(s.bottom,c.bottom);i({top:a,bottom:l,left:u})},[e.get_view]);(0,n.useEffect)(()=>{u();const t=e.get_view();if(!t)return;const r=()=>u();t.dom.addEventListener("keyup",r),t.dom.addEventListener("mouseup",r),document.addEventListener("selectionchange",r);const n=t.dom.closest(".md-editor-context");return n?.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),()=>{t.dom.removeEventListener("keyup",r),t.dom.removeEventListener("mouseup",r),document.removeEventListener("selectionchange",r),n?.removeEventListener("scroll",r),window.removeEventListener("resize",r)}},[u,e.get_view,e.refresh_key]);const a=t=>{const r=e.get_view();r&&(t(r.state,r.dispatch),r.focus(),u())},l=e=>s.marks.includes(e),d=e=>"heading"===s.block.name&&s.block.level===e,[m,f]=(0,n.useState)({w:0,h:36});if((0,n.useLayoutEffect)(()=>{if(!c||!r.current)return;const e=r.current.offsetWidth,t=r.current.offsetHeight;f(r=>r.w===e&&r.h===t?r:{w:e,h:t})},[c,e.refresh_key]),!c)return null;const v=(e,r,n,s,o=!1)=>(0,w.jsx)("button",{className:"mdtb__btn"+(o?" mdtb__btn--on":""),title:t(n),onMouseDown:e=>e.preventDefault(),onClick:s,children:r},e),_=m.w/2,p=_+4,x=Math.max(p,window.innerWidth-_-4),k=document.querySelector(".header")?.getBoundingClientRect().bottom??0,b=c.top-m.h-8,E=b<k+4,j={top:E?Math.min(c.bottom+8,window.innerHeight-m.h-4):b,left:Math.min(x,Math.max(p,c.left))};return(0,w.jsxs)("div",{className:"mdtb mdtb--floating"+(E?" mdtb--below":""),ref:r,style:j,children:[v("h1","H1","一级标题",()=>a((0,g.uf)("heading",{level:1})),d(1)),v("h2","H2","二级标题",()=>a((0,g.uf)("heading",{level:2})),d(2)),v("h3","H3","三级标题",()=>a((0,g.uf)("heading",{level:3})),d(3)),(0,w.jsx)("span",{className:"mdtb__sep"}),v("b","B","加粗",()=>a((0,g.NH)("strong")),l("strong")),v("i","I","斜体",()=>a((0,g.NH)("em")),l("em")),v("s","S","删除线",()=>a((0,g.NH)("strike")),l("strike")),v("code","</>","行内代码",()=>a((0,g.NH)("code")),l("code")),(0,w.jsx)("span",{className:"mdtb__sep"}),v("ul","≔","无序列表",()=>a(g.fK)),v("ol","1.","有序列表",()=>a(g.oB)),v("quote","❝","引用",()=>a(g.Vu))]})}function y(e){for(let t=e.depth;t>0;t--){const r=e.node(t).type.name;if("heading"===r)return{name:"heading",level:e.node(t).attrs.level};if("paragraph"===r)return{name:"paragraph"}}return{name:"paragraph"}}var k=r(75725),b=r(86059);const E="cut",j="copy",S="paste",C="strong",N="em",L="strike",A="code",R="h1",H="h2",M="h3",G="paragraph",z="bullet",B="ordered",P="quote",$="code_block",F="clean",D="row_before",K="row_after",I="row_delete",T="col_before",U="col_after",W="col_delete",Y="header_toggle",X="cell_merge",q="cell_split",V="table_delete",J="table_insert",O="select_all";function Z(e){const{t}=(0,h.Bd)(),[r,s]=(0,n.useState)(null),o=(0,n.useRef)(e.get_view);o.current=e.get_view,(0,n.useEffect)(()=>{const e=e=>{const t=o.current();if(!t)return;const r=e.target;if(!r||!r.closest(".md-filecat-content"))return;e.preventDefault();const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(n){const e=t.state.selection;if(n.pos<e.from||n.pos>e.to){const{TextSelection:e}=t.state.selection.constructor;try{t.dispatch(t.state.tr.setSelection(e.near(t.state.doc.resolve(n.pos))))}catch{}}}const c=!!r.closest("td, th");s({x:e.clientX,y:e.clientY,in_table:c||(0,b.aH)(t.state)})};return document.addEventListener("contextmenu",e,!0),()=>document.removeEventListener("contextmenu",e,!0)},[]);const c=()=>s(null),i=(0,n.useCallback)(e=>{const t=o.current();t&&(e(t.state,t.dispatch),t.focus(),c())},[]),u=e=>{const t=o.current();t?.focus(),document.execCommand(e),c()};if(!r)return null;const a=r.in_table?[{r:t("上方插入行"),v:D},{r:t("下方插入行"),v:K},{r:t("左侧插入列"),v:T},{r:t("右侧插入列"),v:U},{r:t("删除行"),v:I},{r:t("删除列"),v:W},{r:t("切换表头行"),v:Y},{r:t("合并单元格"),v:X},{r:t("拆分单元格"),v:q},{r:t("删除表格"),v:V}]:[],l=[{r:t("剪切"),v:E},{r:t("复制"),v:j},{r:t("粘贴"),v:S},{r:t("格式"),v:"format",items:[{r:t("加粗"),v:C},{r:t("斜体"),v:N},{r:t("删除线"),v:L},{r:t("行内代码"),v:A}]},{r:t("段落"),v:"block",items:[{r:t("一级标题"),v:R},{r:t("二级标题"),v:H},{r:t("三级标题"),v:M},{r:t("正文"),v:G}]},{r:t("插入"),v:"insert",items:[{r:t("无序列表"),v:z},{r:t("有序列表"),v:B},{r:t("引用"),v:P},{r:t("代码块"),v:$},{r:t("插入表格"),v:J}]},...a.length?[{r:t("表格"),v:"table",items:a}]:[],{r:t("清除格式"),v:F},{r:t("全选"),v:O}];return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(k.rY,{click:c}),(0,w.jsx)(k.Pu,{x:r.x,y:r.y,items:l,click:t=>{switch(t){case E:return u("cut");case j:return u("copy");case S:return u("paste");case C:return i((0,g.NH)("strong"));case N:return i((0,g.NH)("em"));case L:return i((0,g.NH)("strike"));case A:return i((0,g.NH)("code"));case R:return i((0,g.uf)("heading",{level:1}));case H:return i((0,g.uf)("heading",{level:2}));case M:return i((0,g.uf)("heading",{level:3}));case G:return i((0,g.uf)("paragraph"));case z:return i(g.fK);case B:return i(g.oB);case P:return i(g.Vu);case $:return i((0,g.uf)("code_block"));case J:return c(),void e.on_insert_table?.();case D:return i(b.JD);case K:return i(b.gC);case T:return i(b.RC);case U:return i(b.GU);case I:return i(b.aR);case W:return i(b.gR);case Y:return i(b.uC);case X:return i(b.w7);case q:return i(b.L0);case V:return i(b.kG);case F:return i((e,t)=>{const{from:r,to:n}=e.selection;let s=e.tr;return e.doc.nodesBetween(r,n,(e,t)=>{if(e.isText)for(const r of e.marks)s=s.removeMark(t,t+e.nodeSize,r.type)}),t?.(s),!0});case O:return i((e,t)=>{const{TextSelection:r}=e.selection.constructor;return t?.(e.tr.setSelection(r.create(e.doc,0,e.doc.content.size))),!0})}}})]})}var Q=r(64877);function ee(e){const t=[];if(!e)return t;const r=e.split(/(\n)/);let n=null,s=0;for(let e=0;e<r.length;e+=2){const o=r[e],c=s;s+=o.length+(r[e+1]?.length??0);const i=o.endsWith("\r")?o.slice(0,-1):o,u=i.trimStart(),a=/^(`{3,}|~{3,})/.exec(u);if(a){const e=a[1][0];null===n?n=e:n===e&&(n=null);continue}if(null!==n)continue;const l=/^ {0,3}(#{1,6})\s+(.*)$/.exec(i);if(!l)continue;const d=l[1].length,m=l[2].replace(/\s+#+\s*$/,"").trim();t.push({level:d,text:m,pos:c})}return t}var te=r(69918),re=r(96763),ne=r(40505);function se(e){const{t}=(0,h.Bd)(),[r,s]=(0,n.useState)(!1),[i,u]=(0,n.useState)({x:0,y:0}),[l,d]=(0,n.useState)([]),[m]=(0,o.fp)(c.AG.user_base_info);(0,n.useEffect)(()=>{if(!r)return;let e=!1;return(0,re.Kz)().then(t=>{e||d(t)}),()=>{e=!0}},[r]);const f=(e,t)=>(0,w.jsx)("div",{style:{...(0,ne.ok)(t===m?.user_data?.md_editor_theme)},children:e});return(0,w.jsxs)(n.Fragment,{children:[(0,w.jsx)(a.rA,{icon:"palette",title:t("主题"),onClick:e=>{u({x:e.clientX,y:e.clientY}),s(!0)}}),r&&(0,w.jsx)(k.rY,{click:()=>s(!1),children:(0,w.jsx)(k.Pu,{x:i.x,y:i.y,items:[{r:f(t("follow_sys"),""),v:""},...l.map(e=>({r:f(e.id,e.id),v:e.id}))],click:t=>{s(!1),e.on_change(t)}})})]})}var oe=r(2543),ce=r(61973),ie=r(87361);function ue(e){const t=e.pane,{t:r}=(0,h.Bd)(),g=(0,ce.Zp)(),{check_user_auth:y}=(0,i.MH)(),k=y(u.oV.md_editor_setting),[b,E]=(0,o.fp)(c.AG.md_editor),j=t??b,S=(0,o.fp)(c.AG.md_editor_last_context)[1],C=(0,n.useRef)(null),[N,L]=(0,n.useState)(null),[A,R]=(0,n.useState)(!1),[H,M]=(0,n.useState)(!1),[G,z]=(0,n.useState)(0),B=(0,n.useRef)(null),[P,$]=(0,n.useState)([]),[F,D]=(0,n.useState)(-1),[K,I]=(0,n.useState)(15),[T,U]=(0,n.useState)(!1),W=(0,n.useRef)(null),Y=(0,n.useRef)(null),[X,q]=(0,o.fp)(c.AG.md_editor_show_outline),[V,J]=(0,o.fp)(c.AG.md_editor_mode),O=(0,n.useCallback)(()=>{const e="wysiwyg"===V?"source":"wysiwyg",t=B.current;t&&("source"===e?t.enter_source_mode():t.exit_source_mode(),J(e))},[V]),[ne]=(0,o.fp)(c.AG.md_editor_setting),[ue,ae]=(0,o.fp)(c.AG.md_theme_css),[le]=(0,o.fp)(c.AG.user_base_info),{initUserInfo:de}=(0,n.useContext)(s.F),me=(0,n.useRef)(null),fe=(0,n.useRef)(null);(0,n.useEffect)(()=>{fe.current},[le]),(0,n.useEffect)(()=>{(0,te.Ce)(W.current,ne)},[ne]);(0,n.useEffect)(()=>{(0,re.bN)("editor",ue)},[ue]),(0,n.useEffect)(()=>{const e=()=>{(0,re.sO)().then(ae)};return window.addEventListener(re.o3,e),()=>window.removeEventListener(re.o3,e)},[]);const ve=(0,n.useRef)([]),_e=(0,n.useCallback)(()=>{const e=B.current;if(!e)return;const t=e.is_source_mode()?ee(e.get_markdown()):e.get_headings();ve.current=t,$(t)},[]);(0,n.useEffect)(()=>{t?.on_outline?.(P,F)},[P,F]);const he=(0,n.useCallback)(()=>{const e=B.current,t=e?.get_view();if(!e||!t)return;const r=e.is_source_mode()?t.state.selection.from-1:t.state.selection.from;let n=-1;for(const e of ve.current){if(!(e.pos<=r))break;n=e.pos}D(n)},[]);(0,n.useEffect)(()=>{let e=!1;if(j?.url)return M(!1),R(!0),v.l.get(j.url).then(t=>{if(e)return;L(t??"")}).catch(()=>{e||((0,d.zN)(r("打开失败")),L(""))}).finally(()=>{e||R(!1)}),()=>{e=!0};L(null)},[j?.url]),(0,n.useEffect)(()=>{const e=()=>z(e=>e+1);return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[]);const pe=(0,n.useRef)(O);pe.current=O,(0,n.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"/"===e.key&&(e.preventDefault(),e.stopPropagation(),pe.current())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,n.useEffect)(()=>{_e(),he()},[G,V,_e,he]);const ge=(0,n.useCallback)(oe.throttle(e=>{if(!W.current||!Y.current)return;const t=parseFloat(getComputedStyle(W.current).fontSize),r=e.clientX/t,n=window.innerWidth/t-4,s=2.25+Y.current.offsetWidth/t;r<=n&&r>=s&&I(parseFloat(r.toFixed(2)))},32),[]),we=()=>{U(!1),W.current?.removeEventListener("pointermove",ge)},xe=e=>{const t=B.current;t&&(t.scroll_to_pos(t.is_source_mode()?e.pos+1:e.pos),D(e.pos))},ye=async(e=!1)=>{if(!j?.name||!j?.path)return;const t=B.current?.get_markdown();if(void 0===t)return;const n=j.path.slice(0,j.path.length-j.name.length),s=`${encodeURIComponent(n)}${j.name}`;(await f.$M.post(`save/${s}`,{context:t})).code===m.m.Success?(M(!1),e||(0,d.SK)(r("保存成功"))):(0,d.zN)(r("保存失败"))},ke=(0,n.useRef)(ye);ke.current=ye;const be=(0,n.useRef)(H);be.current=H;const Ee=ne?.auto_save_interval??0;(0,n.useEffect)(()=>{if(j.readonly||Ee<=0)return;const e=setInterval(()=>{be.current&&ke.current(!0)},1e3*Ee);return()=>clearInterval(e)},[Ee,j.readonly]);const je=()=>{window.print()},Se=(0,n.useRef)(V);Se.current=V;const Ce=(0,n.useRef)(xe);Ce.current=xe;const Ne=(0,n.useRef)(je);Ne.current=je,(0,n.useEffect)(()=>{t?.on_dirty?.(H)},[H]),(0,n.useEffect)(()=>{t?.register?.({save:e=>ke.current(e),export_pdf:()=>Ne.current(),toggle_mode:()=>pe.current(),mode:()=>Se.current,goto_heading:e=>Ce.current(e),dirty:()=>be.current})},[]);const Le=()=>{E({}),M(!1),L(null),B.current=null,b?.close?.()},Ae=(0,n.useMemo)(()=>j?.url??"md_editor",[j?.url]);if(!j?.name)return null;const Re=!!t,He=(0,w.jsxs)("div",{className:"md-editor-context",ref:W,children:[A&&(0,w.jsxs)("div",{className:"common-box common-box-center",children:[r("加载中"),"..."]}),!A&&null!==N&&(0,w.jsxs)(n.Fragment,{children:[!Re&&X&&(0,w.jsx)("div",{className:"md-outline-panel",style:{width:`${K}em`},children:(0,w.jsx)(Q.default,{items:P,active_pos:F,on_click:xe})}),!Re&&X&&(0,w.jsx)("div",{className:"md-editor-divider",ref:Y,onPointerDown:()=>{U(!0),W.current?.addEventListener("pointermove",ge)},onPointerUp:we}),!Re&&T&&(0,w.jsx)("div",{className:"md-editor-drag-overlay",onPointerUp:we}),(0,w.jsx)("div",{className:"md-editor-scroll",children:(0,w.jsxs)("div",{className:"md-editor-sheet",children:["wysiwyg"===V&&(0,w.jsx)(x,{get_view:()=>B.current?.get_view()??null,refresh_key:G}),(0,w.jsx)(p.A,{value:N,ref:B,initial_source_mode:"source"===V,doc_path:j?.path,on_ready:e=>{const t=e.is_source_mode()?ee(e.get_markdown()):e.get_headings();ve.current=t,$(t),D(-1)},on_change:()=>{H||M(!0),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{const e=B.current?.get_markdown()??"";e&&S(e)},800)},on_save:()=>ke.current(),on_selection_change:()=>z(e=>e+1),on_source_mode_change:e=>{J(e?"source":"wysiwyg"),z(e=>e+1)}},Ae),"wysiwyg"===V&&(0,w.jsx)(Z,{get_view:()=>B.current?.get_view()??null,on_insert_table:()=>{B.current?.insert_table(3,3),M(!0)}})]})})]})]});return Re?He:(0,w.jsxs)("div",{id:"md-editor-container",ref:me,children:[(0,w.jsx)(l.A,{ignore_tags:!0,left_children:[(0,w.jsx)(a.rA,{title:r("关闭"),icon:"close",onClick:Le},1),(0,w.jsx)("div",{className:"md-editor-title",children:j.name},3),...H&&!j.readonly?[(0,w.jsx)(a.rA,{title:r("保存"),icon:"save",onClick:ye},2)]:[],(0,w.jsx)(a.rA,{title:r("大纲"),icon:"list",onClick:()=>q(e=>!e),selected:X},4),...j.readonly?[]:[(0,w.jsx)(a.rA,{title:r("wysiwyg"===V?"源码模式":"实时编辑模式"),icon:"wysiwyg"===V?"code":"edit",onClick:O},5)],...j.readonly?[]:[(0,w.jsx)(se,{on_change:async e=>{const t=await f.wm.post(_.s.user_save_private_attr,{is_md_theme:!0,md_editor_theme:e});t?.code===m.m.Success?(fe.current=e,await de(),(0,d.SK)(r("保存成功"))):(0,d.zN)(r("保存失败"))}},8)],(0,w.jsx)(a.rA,{title:r("导出PDF"),icon:"print",onClick:je},7),...k&&!j.readonly?[(0,w.jsx)(a.rA,{title:r("编辑器设置"),icon:"settings",onClick:()=>{Le(),g(ie.o.md_editor_setting_page)}},6)]:[]]}),He]})}}}]);
|