@anyblock/any-block-core 3.4.6

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.
@@ -0,0 +1,237 @@
1
+ /**
2
+ * 转换器_文字版
3
+ *
4
+ * md_str <-> md_str
5
+ */
6
+
7
+ import {ABConvert_IOEnum, ABConvert, type ABConvert_SpecSimp} from "./ABConvert"
8
+ import {ABConvertManager} from "../ABConvertManager"
9
+ import {ABReg} from "../ABSetting"
10
+
11
+ /**
12
+ * 将registerABProcessor的调用分成两步是因为:
13
+ * 1. 能方便在大纲里快速找到想要的处理器
14
+ * 2. 让处理器能互相调用
15
+ */
16
+
17
+ const _abc_addQuote = ABConvert.factory({
18
+ id: "addQuote",
19
+ name: "增加引用块",
20
+ match: "addQuote",
21
+ detail: "在文本的每行前面加上 `> `",
22
+ process_param: ABConvert_IOEnum.text,
23
+ process_return: ABConvert_IOEnum.text,
24
+ process: (el, header, content: string): string=>{
25
+ return content.split("\n").map((line)=>{return "> "+line}).join("\n")
26
+ }
27
+ })
28
+
29
+ const _abc_addCode = ABConvert.factory({
30
+ id: "addCode",
31
+ name: "增加代码块",
32
+ match: /^(addCode|code)(\((.*)\))?$/,
33
+ default: "code()",
34
+ detail: "在文本的前后均加上一行代码块围栏。不加`()`表示用原文本的第一行作为代码类型,括号类型为空表示代码类型为空",
35
+ process_param: ABConvert_IOEnum.text,
36
+ process_return: ABConvert_IOEnum.text,
37
+ process: (el, header, content: string): string=>{
38
+ let matchs = header.match(/^(addCode|code)(\((.*)\))?$/)
39
+ if (!matchs) return content
40
+ if (matchs[2]) content = matchs[3]+"\n"+content
41
+ return "``````"+content+"\n``````"
42
+ }
43
+ })
44
+
45
+ const abc_xQuote = ABConvert.factory({
46
+ id: "xQuote",
47
+ name: "去除引用块",
48
+ match: /^(xQuote|Xquote)$/,
49
+ detail: "在文本的每行前面删除 `> `",
50
+ process_param: ABConvert_IOEnum.text,
51
+ process_return: ABConvert_IOEnum.text,
52
+ process: (el, header, content: string): string=>{
53
+ return content.split("\n").map(line=>{
54
+ return line.replace(/^>\s/, "")
55
+ }).join("\n")
56
+ }
57
+ })
58
+
59
+ const abc_xCode = ABConvert.factory({
60
+ id: "xCode",
61
+ name: "去除代码块",
62
+ match: /^(xCode|Xcode)(\((true|false|)\))?$/,
63
+ default: "xCode(true)",
64
+ detail: "参数为是否移除代码类型, Xcode默认为false, Xcode默认为true。记法: code|Xcode 或 code()|Xcode()内容不变",
65
+ process_param: ABConvert_IOEnum.text,
66
+ process_return: ABConvert_IOEnum.text,
67
+ process: (el, header, content: string): string=>{
68
+ let matchs = header.match(/^(xCode|Xcode)(\((true|false|)\))?$/)
69
+ if (!matchs) return content
70
+ let remove_flag:boolean
71
+ if (matchs[2]=="") remove_flag=false
72
+ else remove_flag= (matchs[3]!="false")
73
+ let list_content = content.split("\n")
74
+ // 开始去除
75
+ let code_flag = ""
76
+ let line_start = -1
77
+ let line_end = -1
78
+ for (let i=0; i<list_content.length; i++){
79
+ if (code_flag==""){ // 寻找开始标志
80
+ const match_tmp = list_content[i].match(ABReg.reg_code)
81
+ if(match_tmp){
82
+ code_flag = match_tmp[3]
83
+ line_start = i
84
+ }
85
+ }
86
+ else { // 寻找结束标志
87
+ if(list_content[i].indexOf(code_flag)>=0){
88
+ line_end = i
89
+ break
90
+ }
91
+ }
92
+ }
93
+ if(line_start>=0 && line_end>0) { // 避免有头无尾的情况
94
+ if(remove_flag) list_content[line_start] = list_content[line_start].replace(/^```(.*)$|^~~~(.*)$/, "")
95
+ else list_content[line_start] = list_content[line_start].replace(/^```|^~~~/, "")
96
+ list_content[line_end] = list_content[line_end].replace(/^```|^~~~/, "")
97
+ content = list_content.join("\n")//.trim()
98
+ }
99
+ return content
100
+ }
101
+ })
102
+
103
+ const _abc_x = ABConvert.factory({
104
+ id: "x",
105
+ name: "去除代码或引用块",
106
+ match: /^(x|X)$/,
107
+ process_param: ABConvert_IOEnum.text,
108
+ process_return: ABConvert_IOEnum.text,
109
+ process: (el, header, content: string): string=>{
110
+ let flag = ""
111
+ for (let line of content.split("\n")){
112
+ if (ABReg.reg_code.test(line)) {flag="code";break}
113
+ else if (ABReg.reg_quote.test(line)) {flag="quote";break}
114
+ }
115
+ if (flag=="code") return abc_xCode.process(el, header, content) as string
116
+ else if (flag=="quote") return abc_xQuote.process(el, header, content) as string
117
+ return content
118
+ }
119
+ })
120
+
121
+ const _abc_slice = ABConvert.factory({
122
+ id: "slice",
123
+ name: "切片",
124
+ match: /^slice\((\s*\d+\s*)(,\s*-?\d+\s*)?\)$/,
125
+ detail: "和js的slice方法是一样的。例如 `[slice(1, -1)]`",
126
+ process_param: ABConvert_IOEnum.text,
127
+ process_return: ABConvert_IOEnum.text,
128
+ process: (el, header, content: string): string=>{
129
+ // slice好像不怕溢出或交错,会自动变空数组。就很省心,不用判断太多的东西
130
+ const list_match = header.match(/^slice\((\s*\d+\s*)(,\s*-?\d+\s*)?\)$/)
131
+ if (!list_match) return content
132
+ const arg1 = Number(list_match[1].trim())
133
+ if (isNaN(arg1)) return content
134
+ // 单参数
135
+ if (!list_match[2]) return content.split("\n").slice(arg1).join("\n")
136
+ const arg2 = Number(list_match[2].replace(",","").trim())
137
+ // 单参数
138
+ if (isNaN(arg2)) return content.split("\n").slice(arg1).join("\n")
139
+ // 双参数
140
+ else return content.split("\n").slice(arg1, arg2).join("\n")
141
+ }
142
+ })
143
+
144
+ const _abc_add = ABConvert.factory({
145
+ id: "add",
146
+ name: "增添内容",
147
+ match: /^add\((.*?)(,\s*-?\d+\s*)?\)$/,
148
+ detail: "增添. 参数2为行序, 默认0, 行尾-1。会插行增添",
149
+ process_param: ABConvert_IOEnum.text,
150
+ process_return: ABConvert_IOEnum.text,
151
+ process: (el, header, content: string): string=>{
152
+ const list_match = header.match(/^add\((.*?)(,\s*-?\d+\s*)?\)$/)
153
+ if (!list_match) return content
154
+ if (!list_match[1]) return content
155
+ const arg1 = (list_match[1].trim())
156
+ if (!arg1) return content
157
+ let arg2:number
158
+ if (!list_match[2]) arg2 = 0
159
+ else{
160
+ arg2 = Number(list_match[2].replace(",","").trim())
161
+ if (isNaN(arg2)) {
162
+ arg2 = 0
163
+ }
164
+ }
165
+ const list_content = content.split("\n")
166
+ if (arg2>=0 && arg2<list_content.length) list_content[arg2] = arg1+"\n"+list_content[arg2]
167
+ else if(arg2<0 && (arg2*-1)<=list_content.length) {
168
+ arg2 = list_content.length+arg2
169
+ list_content[arg2] = arg1+"\n"+list_content[arg2]
170
+ }
171
+ return list_content.join("\n")
172
+ }
173
+ })
174
+
175
+ const _abc_listroot = ABConvert.factory({
176
+ id: "listroot",
177
+ name: "增加列表根",
178
+ match: /^listroot\((.*)\)$/,
179
+ default: "listroot(root)",
180
+ detail: "每行前面加两空格,并在首行插入 `- ` 开头的根列表项",
181
+ process_param: ABConvert_IOEnum.text,
182
+ process_return: ABConvert_IOEnum.text,
183
+ process: (el, header, content: string): string=>{
184
+ const list_match = header.match(/^listroot\((.*)\)$/)
185
+ if (!list_match) return content
186
+ const arg1 = list_match[1].trim()
187
+ content = content.split("\n").map(line=>{return " "+line}).join("\n")
188
+ content = "- "+arg1+"\n"+content
189
+ return content
190
+ }
191
+ })
192
+
193
+ const _abc_addList = ABConvert.factory({
194
+ id: "addList",
195
+ name: "缩进转列表",
196
+ detail: "缩进转列表",
197
+ default: "缩进转列表。对于空行的处理有两种策略:一是空行表示下一个列表,单换行表示同一列表项。二是忽略空行。暂时仅为策略二",
198
+ process_param: ABConvert_IOEnum.text,
199
+ process_return: ABConvert_IOEnum.text,
200
+ process: (el, header, content: string): string=>{
201
+ const lists = content.trimEnd().split("\n")
202
+ let newContent = ''
203
+ for (const item of lists) {
204
+ if (item.trim() == '') continue // 策略二。忽略空行
205
+ const match = item.match(/^(\s*)(.*)/)
206
+ if (match) {
207
+ newContent += '\n' + match[1] + '- ' + match[2]
208
+ }
209
+ else {} // 不应该存在这种情况,忽略
210
+ }
211
+ return newContent
212
+ }
213
+ })
214
+
215
+ const _abc_xList = ABConvert.factory({
216
+ id: "xList",
217
+ name: "列表转缩进",
218
+ match: /^(xList|Xlist)$/,
219
+ detail: "列表转缩进。对于多行内容的列表项,默认换行项删除前置空格并使用 `; ` 拼接,拼接符暂不支持自定义",
220
+ process_param: ABConvert_IOEnum.text,
221
+ process_return: ABConvert_IOEnum.text,
222
+ process: (el, header, content: string): string=>{
223
+ const lists = content.trimEnd().split("\n")
224
+ let newContent = ''
225
+ for (const item of lists) {
226
+ const match = item.match(ABReg.reg_list_noprefix)
227
+ if (match) {
228
+ newContent += '\n' + match[1] + match[4]
229
+ }
230
+ else if (newContent != '') {
231
+ newContent += '; ' + item.trimStart()
232
+ }
233
+ else {} // 通常是前面的空行或非列表,忽略
234
+ }
235
+ return newContent.slice(1) // 去除头部 `\n`
236
+ }
237
+ })
package/demo.ts ADDED
@@ -0,0 +1,236 @@
1
+ /**
2
+ * 由于有别名模块,以及支持处理器串行。别名和demo部分均不绑定到处理器上,而是作为独立模块
3
+ */
4
+
5
+ export type ContextMenuItem = {
6
+ label: string
7
+ // 如果是字符串则表示黏贴该字符串,方便声明demo模板 (TODO demo模板可能需要配图和help url?)
8
+ callback?: string | ((str?: string) => void)
9
+ icon?: string // 目前仅obsidian环境有效,使用lucide图标
10
+ detail?: string // 悬浮时展示说明 (为安全起见,目前仅支持图片链接而非任意html)
11
+ children?: ContextMenuItems
12
+ }
13
+ export type ContextMenuItems = ContextMenuItem[]
14
+
15
+ // const root_menu_convert: ContextMenuItems = [
16
+ // { label: '未检测到选中文本 (未开发)' },
17
+ // ]
18
+
19
+ export const root_menu_demo: ContextMenuItems = [
20
+ // 分类注意项: 与程序中的分类不同,这里的分类是为了方便用户查找。
21
+ // 所以初始结构和转换后的结构都算(如表格),且更倾向于结果结构
22
+ // 尾部最好加一个 `\n\n`
23
+
24
+ // list
25
+ {
26
+ label: 'list', children: [
27
+ { label: '列表转表格',
28
+ detail: 'https://cdn.pkmer.cn/images/202508241625503.png!pkmer', // 'https://github.com/any-block/any-block/blob/main/docs/assets/list2table3.png',
29
+ callback:
30
+ `[table]
31
+
32
+ - 1
33
+ - 2
34
+ - 3
35
+ - 2
36
+ - 4 | <
37
+ - 5
38
+ - 6
39
+ - 7\n\n` },
40
+ { label: '列表转目录', callback: `[dir]
41
+
42
+ - vue-demo/
43
+ - build/, 项目构建(webpack)相关代码
44
+ - config/, 配置目录,包括端口号等。我们初学可以使用默认的
45
+ - node_modules/, npm 加载的项目依赖模块
46
+ - src/, 这里是我们要开发的目录
47
+ - assets/, 放置一些图片,如logo等
48
+ - components, 目录里面放了一个组件文件,可以不用
49
+ - App.vue, 项目入口文件,我们也可以直接将组件写这里,而不使用 components 目录
50
+ - main.js, 项目的核心文件。
51
+ - static/, 静态资源目录,如图片、字体等
52
+ - test/, 初始测试目录,可删除
53
+ - .eslintignore
54
+ - .gitignore, git配置
55
+ - .index.html, 首页入口文件,你可以添加一些 meta 信息或统计代码啥的
56
+ - package.json, 项目配置文件
57
+ - READED.md, 项目的说明文档,markdown 格式<br>手动换行测试<br>自动换行测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试k
58
+ - ...\n\n` },
59
+ ]
60
+ },
61
+ // mindmap
62
+ {
63
+ label: 'mindmap', children: [
64
+ { label: 'node',
65
+ detail: 'https://cdn.pkmer.cn/images/202508241625515.png!pkmer',
66
+ callback: `[nodes]
67
+
68
+ - a
69
+ - b
70
+ - c
71
+ - d
72
+ - e
73
+ - f\n\n` },
74
+ { label: 'plantuml mindmap', callback: `[mindmap]
75
+
76
+ - a
77
+ - b
78
+ - c
79
+ - d
80
+ - e
81
+ - f\n\n` },
82
+ { label: 'pumlWBS', callback: `[list2pumlWBS]
83
+
84
+ - vue-demo/
85
+ - build/
86
+ - config/
87
+ - node_modules/
88
+ - src/
89
+ - < assets/
90
+ - < a
91
+ - b
92
+ - < c
93
+ - d
94
+ - e
95
+ - components
96
+ - App.vue
97
+ - main.js
98
+ - static/
99
+ - test/\n\n` },
100
+ { label: 'mermaid', callback: `[mermaid]
101
+
102
+ - 树结构
103
+ - 基本术语
104
+ - A
105
+ - B(BB)
106
+ - C(CC)
107
+ - A
108
+ - 性质
109
+ - 基本运算
110
+ - 二叉树
111
+ - 分支1
112
+ - 分支2\n\n` },
113
+ { label: 'mermaid mindmap', callback: `[listroot(root((mindmap)))|list2mindmap]
114
+
115
+ - Origins
116
+ - Long history
117
+ - ::icon(fa fa-book)
118
+ - Popularisation
119
+ - British popular psychology author Tony Buzan
120
+ - Research
121
+ - On effectiveness<br/>and features
122
+ - On Automatic creation
123
+ - Uses
124
+ - Creative techniques
125
+ - Strategic planning
126
+ - Argument mapping
127
+ - Tools
128
+ - Pen and paper
129
+ - Mermaid\n\n` },
130
+ { label: 'markmap', callback: `[list2markmap]
131
+
132
+ - Links
133
+ - [Website](https://markmap.js.org/)
134
+ - [GitHub](https://github.com/gera2ld/markmap)
135
+ - Related Projects
136
+ - [coc-markmap](https://github.com/gera2ld/coc-markmap) for Neovim
137
+ - [markmap-vscode](https://marketplace.visualstudio.com/items?itemName=gera2ld.markmap-vscode) for VSCode
138
+ - [eaf-markmap](https://github.com/emacs-eaf/eaf-markmap) for Emacs
139
+ - Features
140
+ - Lists
141
+ - **strong** ~~del~~ *italic* ==highlight==
142
+ - \`inline code\`
143
+ - [x] checkbox
144
+ - Katex: $x = {-b \pm \sqrt{b^2-4ac} \over 2a}$ <\!-- markmap: fold -->
145
+ - [More Katex Examples](#?d=gist:af76a4c245b302206b16aec503dbe07b:katex.md)
146
+ - Now we can wrap very very very very long text based on \`maxWidth\` option\n\n` }
147
+ ]
148
+ },
149
+ // table
150
+ {
151
+ label: 'table', children: [
152
+ { label: '列表转表格', callback:
153
+ `[table]
154
+
155
+ - 1
156
+ - 2
157
+ - 3
158
+ - 2
159
+ - 4 | <
160
+ - 5
161
+ - 6
162
+ - 7\n\n` },
163
+ { label: '合并表格', callback:
164
+ `[exTable]
165
+
166
+ |*A*| a | < |
167
+ |---|---|---|
168
+ | ^ | 2 | 3 |\n\n` },
169
+ ]
170
+ },
171
+ // heading
172
+ {
173
+ label: 'heading', children: [
174
+ { label: '标题转表格', callback: () => console.warn('执行了操作2.2.1') },
175
+ ]
176
+ },
177
+ // callout
178
+ {
179
+ label: 'callout', children: [
180
+ { label: 'note', callback: `> [!note]\n> \n> Note demo.\n\n` },
181
+ { label: 'warning', callback: `> [!warning]\n> \n> Warning demo.\n\n` },
182
+ { label: 'tip', callback: `> [!tip]\n> \n> Tip demo.\n\n` },
183
+ { label: 'note_complex', callback: `> [!note]+ title\n> Note demo.\n\n` },
184
+ ]
185
+ },
186
+ // mdit container
187
+ {
188
+ label: 'mdit container', children: [
189
+ { label: 'note', callback: `:::note\nNote demo.\n:::\n\n` },
190
+ { label: 'warning', callback: `:::warning\nWarning demo.\n:::\n\n` },
191
+ { label: 'tip', callback: `:::tip\nTip demo.\n:::\n\n` },
192
+ { label: 'note_complex', callback: `:::note+ title\nNote demo.\n:::\n\n` },
193
+ ]
194
+ },
195
+ // two layout
196
+ {
197
+ label: 'two layout', children: [
198
+ { label: 'col', callback: `:::col
199
+
200
+ @col
201
+
202
+ text1
203
+
204
+ @col
205
+
206
+ text2
207
+
208
+ @col
209
+
210
+ text3
211
+
212
+ :::\n\n` },
213
+ { label: 'tabs', callback: `:::tabs
214
+
215
+ @tab title1
216
+
217
+ text1
218
+
219
+ @tab title2
220
+
221
+ text2
222
+
223
+ @tab title3
224
+
225
+ text3
226
+
227
+ :::\n\n` },
228
+ ]
229
+ },
230
+ ]
231
+
232
+ export const root_menu: ContextMenuItems = [
233
+ // TODO 转换菜单需要选中文本且文本满足一定规则才会显示,并根据内容进行推荐
234
+ { label: 'AnyBlock', icon: 'list-plus', children: root_menu_demo },
235
+ // { label: '转化为AnyBlock', icon: 'list-plus', children: root_menu_convert }
236
+ ]
package/index.min.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * - obsidian版的,那么index.ts是入口函数
3
+ * - mdit版的,那么index_mdit.ts是入口函数
4
+ */
5
+
6
+ // 转换器模块
7
+ export { ABConvertManager } from "./ABConvertManager"
8
+ // 加载所有转换器 (都是可选的,可自行增删。当然,如果A转换器依赖B转换器,那么你导入A必然导入B)
9
+ export {} from "./converter/abc_text"
10
+ export {} from "./converter/abc_code"
11
+ export {} from "./converter/abc_list"
12
+ export {} from "./converter/abc_c2list"
13
+ export {} from "./converter/abc_table"
14
+ export {} from "./converter/abc_dir_tree"
15
+ export {} from "./converter/abc_deco"
16
+ export {} from "./converter/abc_ex"
17
+ export {} from "./converter/abc_mdit_container"
18
+ export {} from "./converter/abc_echarts"
19
+ // export {} from "./converter/abc_plantuml" // 可选建议:156.3KB。由于在线渲染,相对下面两个没那么高
20
+ export {} from "./converter/abc_mermaid" // 可选建议:新版无额外依赖,旧版非 min 环境下 7.1MB
21
+ // export {} from "./converter/abc_markmap" // 可选建议:1.3MB
22
+
23
+ // 定义环境条件
24
+ import { ABCSetting } from "./ABSetting"
25
+ ABCSetting.env = "obsidian-min"
26
+ export { ABCSetting } from "./ABSetting"
package/index.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * - obsidian版的,那么index.ts是入口函数
3
+ * - mdit版的,那么index_mdit.ts是入口函数
4
+ */
5
+
6
+ // 转换器模块
7
+ export { ABConvertManager } from "./ABConvertManager"
8
+ // 加载所有转换器 (都是可选的,可自行增删。当然,如果A转换器依赖B转换器,那么你导入A必然导入B)
9
+ export {} from "./converter/abc_text"
10
+ export {} from "./converter/abc_code"
11
+ export {} from "./converter/abc_list"
12
+ export {} from "./converter/abc_c2list"
13
+ export {} from "./converter/abc_table"
14
+ export {} from "./converter/abc_dir_tree"
15
+ export {} from "./converter/abc_deco"
16
+ export {} from "./converter/abc_ex"
17
+ export {} from "./converter/abc_mdit_container"
18
+ export {} from "./converter/abc_echarts"
19
+ export {} from "./converter/abc_plantuml" // 可选建议:156.3KB。由于在线渲染,相对下面两个没那么高
20
+ export {} from "./converter/abc_mermaid" // 可选建议:新版无额外依赖,旧版非 min 环境下 7.1MB
21
+ export {} from "./converter/abc_markmap" // 可选建议:1.3MB
22
+
23
+ // 定义环境条件
24
+ import { ABCSetting } from "./ABSetting"
25
+ ABCSetting.env = "obsidian"
26
+ export { ABCSetting } from "./ABSetting"
package/locales/en.ts ADDED
@@ -0,0 +1,88 @@
1
+ export default {
2
+ // commands (utils.ts)
3
+ 'any-block-rebuild-view': 'Refresh/rebuild current view',
4
+ 'any-block-rebuild-view-btn': 'Rebuild View',
5
+
6
+ 'any-block-to-codeblock': 'Convert anyblock section into codeblock format',
7
+ 'any-block-to-codeblock-success': 'Convert success! Generated to ',
8
+ 'any-block-to-codeblock-fail': 'Convert failed, please check the console for details',
9
+
10
+ 'any-block-delete-ab-header': 'Delete AnyBlock header',
11
+ 'any-block-switch-disable': 'Toggle AnyBlock enable/disable',
12
+
13
+ // setting.ts
14
+ 'Mini docs': `Mini docs`,
15
+ 'see website for detail': `See
16
+ <a href="https://lincdocs.github.io/AnyBlock/README.show.html">website</a>
17
+ /
18
+ <a href="https://github.com/LincZero/obsidian-any-block">github</a>
19
+ for more details | Author: <a href="https://github.com/LincZero">LincZero</a>`,
20
+ 'Mini docs menu': `How to visualize the creation of AnyBlock?`,
21
+ 'Mini docs menu2': `It is recommended to use
22
+ <a href="https://github.com/any-menu/any-menu">AnyMenu</a>
23
+ plugin (developed by the same author) to quickly enter AnyBlock templates using the menu panel or search box.`,
24
+
25
+ 'Selector manager': 'Selector',
26
+ 'Selector manager2': 'This section is for query only and cannot be edited',
27
+
28
+ 'AliasSystem manager': 'Alias system',
29
+ 'AliasSystem manager2': 'It can be viewed in the main page using the `[info_alias]` processor',
30
+ 'AliasSystem manager3': 'This section can also be modified by opening the `data.json` file in the plugin folder',
31
+ 'AliasSystem manager4': 'Add a new registration instruction',
32
+ 'AliasSystem manager5': 'Add a new registration instructionAdd a new registration instruction (old, will not be used)',
33
+
34
+ 'Convertor manager': 'Convertor',
35
+ 'Convertor manager2': 'It can be viewed in the main page using the `[info_converter]` processor',
36
+ 'Convertor manager3': 'This section is for query only and cannot be edited',
37
+
38
+ 'Custom alias': 'Custom alias',
39
+ 'Custom alias2': 'Alias matching rule',
40
+ 'Custom alias3': 'If `/` is used to enclose it, it indicates a regular expression.',
41
+ 'Custom alias4': 'Alias replacement',
42
+ 'Custom alias5': 'The parameter-based replacement function is currently not available. It will be enabled only when there is a need for multiple users.',
43
+
44
+ 'Custom processor': 'Custom processor - deprecated',
45
+ 'Custom processor2': 'Processor id',
46
+ 'Custom processor3': 'Without conflicting with other processors',
47
+ 'Custom processor4': 'Processor name',
48
+ 'Custom processor5': 'You can fill it in freely. It\'s for your own reference',
49
+ 'Custom processor6': 'Processor matching rule',
50
+ 'Custom processor7': 'Using `/` including it indicates a regular expression',
51
+ 'Custom processor8': 'Processor replacement',
52
+ 'Custom processor9': 'Using `/` including it indicates a regular expression',
53
+
54
+ 'Pro': 'Pro',
55
+ 'Pro2': 'Pro version enhanced settings',
56
+ 'Pro disable': 'Disable pro feat',
57
+ 'Pro disable2': '(The modification requires restarting the plugin) \
58
+ Disable the Pro version features. Once enabled, they will be equivalent to the non-Pro version functions. This is convenient for debugging bugs or checking whether the function is generated by this module.',
59
+ 'Pro editableblock render': 'EditableBlock default render',
60
+ 'Pro editableblock render2': 'EditableBlock default render mode',
61
+ 'Pro editableblock render21': '- Read mode: you need to press the middle key to enter the editing mode. Press the middle key / Esc / move the cursor outside to complete the editing.',
62
+ 'Pro editableblock render22': '- Teal time: allows for direct editing but requires more performance.',
63
+ 'Pro editableblock render23': '- Simple text area: Display as plain text, suitable for cases where the sub-block does not contain complex markdown.',
64
+ 'Pro editableblock render24': '- Only take over during editing (developing)',
65
+ 'Pro editableblock render3': 'Read mode',
66
+ 'Pro editableblock render4': 'Real mode',
67
+ 'Pro editableblock render5': 'Simple text area',
68
+ 'Pro alias override': 'Pro alias override',
69
+ 'Pro alias override2': '(The modification requires restarting the plugin) \
70
+ Replace the original processor behavior with the corresponding Pro processor behavior. If disabled, the editable version and the original version will use different processor names.',
71
+ 'Pro callout': 'Callout selector',
72
+ 'Pro callout2': 'Use the Callout selector and enable editable Callout',
73
+
74
+ 'License': 'License',
75
+ 'License2': 'This is a license for the Pro version. The display of expiration time needs to be updated by reopening the settings panel.\n\
76
+ By adopting a dual-licensing mechanism, a certain period of default free licenses (coexisting with the user licenses) will be provided with each update.',
77
+ 'License key': 'License key',
78
+ 'License Expiry': 'License Expiry. The display of expiration time needs to be updated by reopening the settings panel.',
79
+
80
+ // General
81
+ 'Submit': 'Submit',
82
+ 'Edit': 'Edit',
83
+ 'Refresh': 'Refresh',
84
+ 'Delete': 'Delete',
85
+ 'Save': 'Save',
86
+ 'Cancel': 'Cancel',
87
+ 'Close': 'Close',
88
+ }
@@ -0,0 +1,27 @@
1
+ // Code from https://github.com/valentine195/obsidian-admonition/blob/master/src/lang/helpers.ts
2
+
3
+ import { ABCSetting } from '../ABSetting';
4
+ import en from './en';
5
+ import zhCN from './zh-cn'
6
+
7
+ const localeMap: { [key: string]: Partial<typeof en> } = {
8
+ en,
9
+ 'zh': zhCN,
10
+ 'zh-TW': zhCN,
11
+ // 'zh-cn': zhCN, // moment.locale 则是 zh-cn, getLanguage 不是
12
+ };
13
+
14
+ let locale: Partial<typeof en> | undefined
15
+
16
+ export function t(str: keyof typeof en): string {
17
+ if (locale == undefined) {
18
+ // 别名
19
+ if (ABCSetting.state.language == 'English') ABCSetting.state.language = 'en'
20
+ else if (ABCSetting.state.language == '中文') ABCSetting.state.language = 'zh'
21
+
22
+ locale = localeMap[ABCSetting.state.language]
23
+ }
24
+
25
+ // console.log('locale', ABCSetting.state.language)
26
+ return (locale && locale[str]) || en[str];
27
+ }