Skip to content

Commit 07c485c

Browse files
committed
1. **Refactor(core):** Refactored the plugin style import mechanism and renamed styleTemplater to styleManager.
2. **Refactor(commander):** Refactored the plugin architecture. 3. **Feat(core):** Added the `ToggleSort` control to `fast-form` and optimized `Control_Transfer`. 4. **Feat(markdownlint):** Introduced `RIGHT_CLICK_TABLE_ACTION` and `RIGHT_CLICK_INDICATOR_ACTION` configuration parameters. 5. **Improve(core):** Enhanced overall performance and reduced the uncompressed package size. 6. **Improve(core):** Refined the English localization (i18n). 7. **Improve(window_tab):** Improved the UI styling. 8. **Improve(markmap):** Optimized export performance. 9. **Change:** The `Enhance Export` plugin is now disabled by default. 10. **Chore:** Added an `.editorconfig` file.
1 parent 9d595ad commit 07c485c

147 files changed

Lines changed: 31341 additions & 31185 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

README-cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
| 37 | cjk_symbol_pairing | 中文符号配对 | |
5757
| 38 | resize_table | 调整表格行高列宽 | |
5858
| 39 | resize_image | 调整图片显示大小 | |
59-
| 40 | export_enhance | 导出 HTML 时避免图片丢失 | |
59+
| 40 | export_enhance | 导出 HTML/PDF 时避免图片丢失 | × |
6060
| 41 | sidebar_enhance | 显示其他扩展名文件、记忆折叠状态、拖拽排序 | |
6161
| 42 | markdownlint | markdown 格式检查 | |
6262
| 43 | truncate_text | 暂时隐藏内容,提高大文件渲染性能 | × |
@@ -426,7 +426,7 @@ docker run -d --name plantuml-server -p 8080:8080 plantuml/plantuml-server:jetty
426426

427427
### export_enhance
428428

429-
导出 HTML 时,将图片转为 base64,避免图片丢失。
429+
导出 HTML/PDF 时,将图片转为 base64,避免图片丢失。
430430

431431

432432

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ English | [简体中文](https://github.com/obgnail/typora_plugin/blob/master/RE
5656
| 37 | cjk_symbol_pairing | CJK Symbol Pairing | |
5757
| 38 | resize_table | Table Resizer | |
5858
| 39 | resize_image | Image Resizer | |
59-
| 40 | export_enhance | Avoid image loss when exporting to HTML | |
59+
| 40 | export_enhance | Avoid image loss when exporting to HTML/PDF | × |
6060
| 41 | sidebar_enhance | Drag & drop to rearrange、Display non-Markdown files、Keep Fold State | |
6161
| 42 | markdownlint | Markdownlint Check | |
6262
| 43 | truncate_text | Hide content to improve performance for large files | × |
@@ -358,12 +358,10 @@ Usage: Place the cursor on the table -> Right-click menu -> Interactive Plugins
358358

359359
### export_enhance
360360

361-
When exporting HTML, convert images to base64 to avoid image loss.
361+
When exporting HTML/PDF, convert images to base64 to avoid image loss.
362362

363363
### sidebar_enhance
364364

365-
366-
367365
- Drag & drop outline to rearrange
368366
- Display non-Markdown files in the sidebar
369367
- Keep Fold Outline State

develop/build/aes-ecb.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import ECB from "crypto-js/mode-ecb"
55
import Pkcs7 from "crypto-js/pad-pkcs7"
66

77
const encrypt = (text, key) => {
8-
const k = Base64.parse(key)
9-
const t = Utf8.parse(text)
10-
const r = AES.encrypt(t, k, { mode: ECB, padding: Pkcs7 })
11-
return r.toString()
8+
const k = Base64.parse(key)
9+
const t = Utf8.parse(text)
10+
const r = AES.encrypt(t, k, { mode: ECB, padding: Pkcs7 })
11+
return r.toString()
1212
}
1313

1414
const decrypt = (text, key) => {
15-
const k = Base64.parse(key)
16-
const r = AES.decrypt(text, k, { mode: ECB, padding: Pkcs7 })
17-
return Utf8.stringify(r)
15+
const k = Base64.parse(key)
16+
const r = AES.decrypt(text, k, { mode: ECB, padding: Pkcs7 })
17+
return Utf8.stringify(r)
1818
}
1919

2020
export { encrypt, decrypt }

develop/build/index.cjs

Lines changed: 203 additions & 203 deletions
Large diffs are not rendered by default.

develop/build/mdast.mjs

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
1-
import { fromMarkdown } from 'mdast-util-from-markdown'
2-
import { toMarkdown } from 'mdast-util-to-markdown'
1+
import { fromMarkdown } from "mdast-util-from-markdown"
2+
import { toMarkdown } from "mdast-util-to-markdown"
33

4-
import { gfmFromMarkdown, gfmToMarkdown } from 'mdast-util-gfm'
5-
import { mathFromMarkdown, mathToMarkdown } from 'mdast-util-math'
6-
import { ofmFromMarkdown, ofmToMarkdown } from '@moritzrs/mdast-util-ofm'
4+
import { gfmFromMarkdown, gfmToMarkdown } from "mdast-util-gfm"
5+
import { mathFromMarkdown, mathToMarkdown } from "mdast-util-math"
6+
import { ofmFromMarkdown, ofmToMarkdown } from "@moritzrs/mdast-util-ofm"
77

8-
import { math } from 'micromark-extension-math'
9-
import { gfm } from 'micromark-extension-gfm'
10-
import { ofm } from '@moritzrs/micromark-extension-ofm'
8+
import { math } from "micromark-extension-math"
9+
import { gfm } from "micromark-extension-gfm"
10+
import { ofm } from "@moritzrs/micromark-extension-ofm"
1111

1212
const fromMD = md => fromMarkdown(md, {
13-
extensions: [
14-
gfm(),
15-
math(),
16-
ofm(),
17-
],
18-
mdastExtensions: [
19-
gfmFromMarkdown(),
20-
mathFromMarkdown(),
21-
ofmFromMarkdown(),
22-
]
13+
extensions: [
14+
gfm(),
15+
math(),
16+
ofm(),
17+
],
18+
mdastExtensions: [
19+
gfmFromMarkdown(),
20+
mathFromMarkdown(),
21+
ofmFromMarkdown(),
22+
],
2323
})
2424

2525
const toMD = tree => toMarkdown(tree, {
26-
extensions: [
27-
gfmToMarkdown(),
28-
mathToMarkdown(),
29-
ofmToMarkdown(),
30-
]
26+
extensions: [
27+
gfmToMarkdown(),
28+
mathToMarkdown(),
29+
ofmToMarkdown(),
30+
],
3131
})
3232

3333
const TYPE = {
34-
blockquote: "blockquote",
35-
break: "break",
36-
code: "code",
37-
definition: "definition",
38-
emphasis: "emphasis",
39-
heading: "heading",
40-
html: "html",
41-
image: "image",
42-
imageReference: "imageReference",
43-
inlineCode: "inlineCode",
44-
link: "link",
45-
linkReference: "linkReference",
46-
list: "list",
47-
listItem: "listItem",
48-
paragraph: "paragraph",
49-
root: "root",
50-
strong: "strong",
51-
text: "text",
52-
thematicBreak: "thematicBreak",
53-
delete: "delete",
54-
footnoteDefinition: "footnoteDefinition",
55-
footnoteReference: "footnoteReference",
56-
table: "table",
57-
tableCell: "tableCell",
58-
tableRow: "tableRow",
59-
yaml: "yaml",
60-
math: "math",
61-
inlineMath: "inlineMath",
62-
wikiLink: "ofmWikilink",
63-
tag: "ofmTag",
64-
callout: "ofmCallout"
34+
blockquote: "blockquote",
35+
break: "break",
36+
code: "code",
37+
definition: "definition",
38+
emphasis: "emphasis",
39+
heading: "heading",
40+
html: "html",
41+
image: "image",
42+
imageReference: "imageReference",
43+
inlineCode: "inlineCode",
44+
link: "link",
45+
linkReference: "linkReference",
46+
list: "list",
47+
listItem: "listItem",
48+
paragraph: "paragraph",
49+
root: "root",
50+
strong: "strong",
51+
text: "text",
52+
thematicBreak: "thematicBreak",
53+
delete: "delete",
54+
footnoteDefinition: "footnoteDefinition",
55+
footnoteReference: "footnoteReference",
56+
table: "table",
57+
tableCell: "tableCell",
58+
tableRow: "tableRow",
59+
yaml: "yaml",
60+
math: "math",
61+
inlineMath: "inlineMath",
62+
wikiLink: "ofmWikilink",
63+
tag: "ofmTag",
64+
callout: "ofmCallout",
6565
}
6666

6767
export { fromMD, toMD, TYPE }

develop/scripts/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const rpc = require("./rpc")
44
const serve = require("./serve")
55

66
function check_env() {
7-
fs.accessSync(process.env.TYPORA_PATH)
7+
fs.accessSync(process.env.TYPORA_PATH)
88
}
99

1010
function run_script(script = "sync") {
11-
const scripts = { sync, rpc, serve }
12-
const fn = scripts[script]
13-
fn?.()
11+
const scripts = { sync, rpc, serve }
12+
const fn = scripts[script]
13+
fn?.()
1414
}
1515

1616
check_env()

develop/scripts/rpc.js

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,67 +8,67 @@ const rpc = require("node-json-rpc")
88
const typoraPath = process.env.TYPORA_PATH
99

1010
const getSettings = async () => {
11-
const isObject = value => {
12-
const type = typeof value
13-
return value !== null && (type === "object" || type === "function")
11+
const isObject = value => {
12+
const type = typeof value
13+
return value !== null && (type === "object" || type === "function")
14+
}
15+
const merge = (source, other) => {
16+
if (!isObject(source) || !isObject(other)) {
17+
return other === undefined ? source : other
1418
}
15-
const merge = (source, other) => {
16-
if (!isObject(source) || !isObject(other)) {
17-
return other === undefined ? source : other
18-
}
19-
return Object.keys({ ...source, ...other }).reduce((obj, key) => {
20-
const isArray = Array.isArray(source[key]) && Array.isArray(other[key])
21-
obj[key] = isArray ? other[key] : merge(source[key], other[key])
22-
return obj
23-
}, Array.isArray(source) ? [] : {})
24-
}
25-
const readTOML = async (p) => {
26-
try {
27-
const content = await fs.readFile(p, "utf-8")
28-
return toml.parse(content)
29-
} catch (e) {
30-
}
31-
return {}
19+
return Object.keys({ ...source, ...other }).reduce((obj, key) => {
20+
const isArray = Array.isArray(source[key]) && Array.isArray(other[key])
21+
obj[key] = isArray ? other[key] : merge(source[key], other[key])
22+
return obj
23+
}, Array.isArray(source) ? [] : {})
24+
}
25+
const readTOML = async (p) => {
26+
try {
27+
const content = await fs.readFile(p, "utf-8")
28+
return toml.parse(content)
29+
} catch (e) {
3230
}
31+
return {}
32+
}
3333

34-
const userTOML = "settings.user.toml"
35-
const defaultTOML = "settings.default.toml"
36-
const originSettingsPath = path.resolve("../plugin/global/settings/")
37-
const homeSettingsPath = path.join(os.homedir(), ".config", "typora_plugin")
38-
const paths = [
39-
path.join(originSettingsPath, defaultTOML),
40-
path.join(originSettingsPath, userTOML),
41-
path.join(homeSettingsPath, userTOML),
42-
]
43-
const files = await Promise.all(paths.map(readTOML))
44-
return files.reduce(merge)
34+
const userTOML = "settings.user.toml"
35+
const defaultTOML = "settings.default.toml"
36+
const originSettingsPath = path.resolve("../plugin/global/settings/")
37+
const homeSettingsPath = path.join(os.homedir(), ".config", "typora_plugin")
38+
const paths = [
39+
path.join(originSettingsPath, defaultTOML),
40+
path.join(originSettingsPath, userTOML),
41+
path.join(homeSettingsPath, userTOML),
42+
]
43+
const files = await Promise.all(paths.map(readTOML))
44+
return files.reduce(merge)
4545
}
4646

4747
const initRPC = (options) => {
48-
const client = new rpc.Client(options)
49-
const cli = {
50-
self: client,
51-
call: async (method, params) => new Promise((resolve, reject) => {
52-
client.call({ method, params }, (err, resp) => {
53-
if (err) reject(err)
54-
else resolve(resp)
55-
})
56-
}),
57-
eval: async (x) => cli.call("eval", [x]),
58-
invoke: async (plugin, fn, ...args) => cli.call("invokePlugin", [plugin, fn, ...args]),
59-
startTypora: () => child_process.exec(typoraPath),
60-
closeTypora: () => cli.eval("JSBridge.invoke('window.close')"),
61-
}
62-
return cli
48+
const client = new rpc.Client(options)
49+
const cli = {
50+
self: client,
51+
call: async (method, params) => new Promise((resolve, reject) => {
52+
client.call({ method, params }, (err, resp) => {
53+
if (err) reject(err)
54+
else resolve(resp)
55+
})
56+
}),
57+
eval: async (x) => cli.call("eval", [x]),
58+
invoke: async (plugin, fn, ...args) => cli.call("invokePlugin", [plugin, fn, ...args]),
59+
startTypora: () => child_process.exec(typoraPath),
60+
closeTypora: () => cli.eval("JSBridge.invoke('window.close')"),
61+
}
62+
return cli
6363
}
6464

6565
const run = async () => {
66-
const settings = await getSettings()
67-
const jsonRPC = settings.json_rpc
68-
if (!jsonRPC || jsonRPC.ENABLE !== true) {
69-
throw new Error("plugin 'json_rpc' must be enabled")
70-
}
71-
return initRPC(jsonRPC.SERVER_OPTIONS)
66+
const settings = await getSettings()
67+
const jsonRPC = settings.json_rpc
68+
if (!jsonRPC || jsonRPC.ENABLE !== true) {
69+
throw new Error("plugin 'json_rpc' must be enabled")
70+
}
71+
return initRPC(jsonRPC.SERVER_OPTIONS)
7272
}
7373

7474
module.exports = run

develop/scripts/serve.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ const sync = require("./sync")
22
const rpc = require("./rpc")
33

44
module.exports = async () => {
5-
const cli = await rpc()
6-
sync(() => {
7-
cli.startTypora()
8-
cli.closeTypora()
9-
})
5+
const cli = await rpc()
6+
sync(() => {
7+
cli.startTypora()
8+
cli.closeTypora()
9+
})
1010
}

0 commit comments

Comments
 (0)