@anyblock/any-block-core 3.4.10 → 3.4.12
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/ABAlias.ts +33 -6
- package/converter/abc_code.ts +1 -0
- package/converter/abc_list.ts +154 -14
- package/package.json +1 -1
- package/style/styles.css +1217 -1217
- package/style/styles.scss +1 -1
package/ABAlias.ts
CHANGED
|
@@ -123,18 +123,42 @@ const ABAlias_json_withSub: ABAlias_json[] = [
|
|
|
123
123
|
|
|
124
124
|
// mdit块
|
|
125
125
|
const ABAlias_json_mdit: ABAlias_json[] = [
|
|
126
|
-
{regex: /\|:::_140lne\|(2?tabs?|标签页?)\|/, replacement: "|mditTabs|"},
|
|
126
|
+
{regex: /\|:::_140lne\|((?:mdit2|2)?tabs?|标签页?)\|/, replacement: "|mditTabs|"},
|
|
127
127
|
{regex: "|:::_140lne|demo|", replacement: "|mditDemo|"},
|
|
128
128
|
{regex: "|:::_140lne|abDemo|", replacement: "|mditABDemo|"},
|
|
129
|
-
{regex: /\|:::_140lne\|(2?col|分栏)\|/, replacement: "|mditCol|"},
|
|
130
|
-
{regex: /\|:::_140lne\|(2?card|卡片)\|/, replacement: "|mditCard|"},
|
|
131
|
-
{regex: /\|:::_140lne\|(2?chat|聊天)\|/, replacement: "|mditChat|code(chat)|"},
|
|
129
|
+
{regex: /\|:::_140lne\|((?:mdit2|2)?col|分栏)\|/, replacement: "|mditCol|"},
|
|
130
|
+
{regex: /\|:::_140lne\|((?:mdit2|2)?card|卡片)\|/, replacement: "|mditCard|"},
|
|
131
|
+
{regex: /\|:::_140lne\|((?:mdit2|2)?chat|聊天)\|/, replacement: "|mditChat|code(chat)|"},
|
|
132
|
+
|
|
133
|
+
//
|
|
134
|
+
// {regex: /\|:::_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|"},
|
|
135
|
+
// {regex: /\|:::_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|"},
|
|
136
|
+
// {regex: /\|:::_140lne\|2?(col|分栏)\||\|title2col\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-col)|"},
|
|
137
|
+
// {regex: /\|:::_140lne\|2?(card|卡片)\||\|title2card\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-card)|addClass(ab-lay-vfall)|"},
|
|
138
|
+
// {regex: /\|:::_140lne\|2?(nodes?|节点)\||\|(title2node|title2abMindmap)\|/, replacement: "|title2listdata|listdata2strict|listdata2nodes|"},
|
|
139
|
+
|
|
140
|
+
// list - 多叉多层树
|
|
141
|
+
{regex: /\|:::_140lne\|(?:mdit2|2)?(mermaid|flow|流程图)\|/, replacement: "|mdit2list" + "|list2mermaid|"},
|
|
142
|
+
{regex: /\|:::_140lne\|(?:mdit2|2)?(mehrmaid|mdmermaid)\|/, replacement: "|mdit2list" + "|list2mehrmaidText|code(mehrmaid)|"},
|
|
143
|
+
{regex: /\|:::_140lne\|(?:mdit2|2)?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|mdit2list" + "|list2pumlMindmap|"},
|
|
144
|
+
{regex: /\|:::_140lne\|(?:mdit2|2)?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|mdit2list" + "|list2markmap|"},
|
|
145
|
+
{regex: /\|:::_140lne\|(?:mdit2|2)?(wbs|(工作)?分解(图|结构))\|/, replacement: "|mdit2list" + "|list2pumlWBS|"},
|
|
146
|
+
{regex: /\|:::_140lne\|(?:mdit2|2)?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|mdit2list" + "|list2table|"},
|
|
147
|
+
|
|
148
|
+
// list - lt树 (属于多层一叉树)
|
|
149
|
+
{regex: /\|:::_140lne\|(?:mdit2|2)?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|mdit2list" + "|list2lt|"},
|
|
150
|
+
{regex: /\|:::_140lne\|2?(list|列表)\|/, replacement: "|mdit2list" + "|list2lt|addClass(ab-listtable-likelist)|"},
|
|
151
|
+
{regex: /\|:::_140lne\|(?:mdit2|2)?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|mdit2list" + "|list2dt|"},
|
|
152
|
+
|
|
153
|
+
// list - 二层树
|
|
154
|
+
{regex: /\|:::_140lne\|(fakeList|仿列表)\|/, replacement: "|mdit2list" + "|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|"},
|
|
155
|
+
|
|
156
|
+
// 至后
|
|
157
|
+
{regex: "|mdit2list|", replacement: "|mdit2listdata|listdata2strict|listdata2list|"},
|
|
132
158
|
]
|
|
133
159
|
|
|
134
160
|
// 标题块
|
|
135
161
|
const ABAlias_json_title: ABAlias_json[] = [
|
|
136
|
-
{regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|"},
|
|
137
|
-
|
|
138
162
|
// title - list&title
|
|
139
163
|
{regex: /\|heading_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|"},
|
|
140
164
|
{regex: /\|heading_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|"},
|
|
@@ -157,6 +181,9 @@ const ABAlias_json_title: ABAlias_json[] = [
|
|
|
157
181
|
|
|
158
182
|
// list - 二层树
|
|
159
183
|
{regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list" + "|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|"},
|
|
184
|
+
|
|
185
|
+
// 至后
|
|
186
|
+
{regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|"},
|
|
160
187
|
]
|
|
161
188
|
|
|
162
189
|
// 列表块
|
package/converter/abc_code.ts
CHANGED
package/converter/abc_list.ts
CHANGED
|
@@ -267,7 +267,7 @@ export class ListProcess{
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
/**
|
|
270
|
-
*
|
|
270
|
+
* 标题大纲转列表数据
|
|
271
271
|
*
|
|
272
272
|
* @detail
|
|
273
273
|
* 这里要将标题、正文、列表 的等级合为一块,所以存在偏移值:
|
|
@@ -276,25 +276,35 @@ export class ListProcess{
|
|
|
276
276
|
* 2. 正文等级, = 0, 取值[+1,+Infi]
|
|
277
277
|
* 3. 列表等级, = `(.*)-`个数+1, 取值[0]
|
|
278
278
|
*
|
|
279
|
+
* (比较旧版是正文+10,列表+11,后来允许标题等级为负数。这样方便很多)
|
|
279
280
|
*/
|
|
280
|
-
static title2data(text: string){
|
|
281
|
+
static title2data(text: string): List_ListItem {
|
|
281
282
|
let list_itemInfo:List_ListItem = []
|
|
282
283
|
|
|
283
284
|
const list_text = text.split("\n")
|
|
284
285
|
let mul_mode:"heading"|"para"|"list"|"" = "" // 多行模式,标题/正文/列表/空
|
|
285
|
-
let codeBlockFlag = ''
|
|
286
|
+
let codeBlockFlag = '' // 代码块标志,避免在代码块内识别结束符号
|
|
286
287
|
for (let line of list_text) {
|
|
287
|
-
// heading和mdit
|
|
288
|
+
// heading和mdit类型都需要跳过代码块内的结束标志
|
|
288
289
|
if (codeBlockFlag == '') {
|
|
289
290
|
const match = line.match(ABReg.reg_code)
|
|
290
|
-
if (match && match[3]) {
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
if (match && match[3]) { // 进入代码块。则将内容添加添加到最后的列表项 (不能是标题列表项)
|
|
292
|
+
if (mul_mode === "heading" || mul_mode === "") {
|
|
293
|
+
list_itemInfo.push({
|
|
294
|
+
content: line,
|
|
295
|
+
level: 0
|
|
296
|
+
})
|
|
297
|
+
mul_mode = "para"
|
|
298
|
+
} else {
|
|
299
|
+
codeBlockFlag = match[1]+match[3]
|
|
300
|
+
list_itemInfo[list_itemInfo.length-1].content += "\n" + line;
|
|
301
|
+
}
|
|
302
|
+
continue
|
|
293
303
|
}
|
|
294
304
|
}
|
|
295
|
-
else {
|
|
305
|
+
else { // 在代码块内,找代码块的结束标志
|
|
296
306
|
if (line.indexOf(codeBlockFlag) == 0) codeBlockFlag = ''
|
|
297
|
-
list_itemInfo[list_itemInfo.length-1].content
|
|
307
|
+
list_itemInfo[list_itemInfo.length-1].content += "\n" + line; continue
|
|
298
308
|
}
|
|
299
309
|
|
|
300
310
|
//
|
|
@@ -304,7 +314,7 @@ export class ListProcess{
|
|
|
304
314
|
removeTailBlank()
|
|
305
315
|
list_itemInfo.push({
|
|
306
316
|
content: match_heading[4],
|
|
307
|
-
level: (match_heading[3].length-1)-10
|
|
317
|
+
level: (match_heading[3].length-1) - 10
|
|
308
318
|
})
|
|
309
319
|
mul_mode = "heading"
|
|
310
320
|
}
|
|
@@ -312,16 +322,16 @@ export class ListProcess{
|
|
|
312
322
|
removeTailBlank()
|
|
313
323
|
list_itemInfo.push({
|
|
314
324
|
content: match_list[4],
|
|
315
|
-
level: match_list[1].length+1
|
|
325
|
+
level: match_list[1].length + 1
|
|
316
326
|
})
|
|
317
327
|
mul_mode = "list"
|
|
318
328
|
}
|
|
319
329
|
else if (/^\S/.test(line) && mul_mode=="list"){ // 3. 带缩进且在列表层级中
|
|
320
|
-
list_itemInfo[list_itemInfo.length-1].content
|
|
330
|
+
list_itemInfo[list_itemInfo.length-1].content += "\n" + line
|
|
321
331
|
}
|
|
322
332
|
else { // 4. 正文层级
|
|
323
333
|
if (mul_mode=="para") {
|
|
324
|
-
list_itemInfo[list_itemInfo.length-1].content
|
|
334
|
+
list_itemInfo[list_itemInfo.length-1].content += "\n" + line
|
|
325
335
|
}
|
|
326
336
|
else if(/^\s*$/.test(line)){
|
|
327
337
|
continue
|
|
@@ -329,7 +339,7 @@ export class ListProcess{
|
|
|
329
339
|
else{
|
|
330
340
|
list_itemInfo.push({
|
|
331
341
|
content: line,
|
|
332
|
-
level: 0
|
|
342
|
+
level: 0
|
|
333
343
|
})
|
|
334
344
|
mul_mode = "para"
|
|
335
345
|
}
|
|
@@ -345,6 +355,125 @@ export class ListProcess{
|
|
|
345
355
|
}
|
|
346
356
|
}
|
|
347
357
|
|
|
358
|
+
/**
|
|
359
|
+
* MarkdownIt 转列表数据
|
|
360
|
+
*
|
|
361
|
+
* @detail
|
|
362
|
+
* 与 title2data 的逻辑基本相同
|
|
363
|
+
*
|
|
364
|
+
* 这里要将Mdit标识 (@xxx)、正文、列表 的等级合为一块,所以存在偏移值:
|
|
365
|
+
*
|
|
366
|
+
* 1. Mdit等级, = `@<数字>`-100,
|
|
367
|
+
* 2. 正文等级, = 0, 取值[+1,+Infi]
|
|
368
|
+
* 3. 列表等级, = `(.*)-`个数+1, 取值[0]
|
|
369
|
+
*
|
|
370
|
+
* 例如:
|
|
371
|
+
*
|
|
372
|
+
* :::
|
|
373
|
+
*
|
|
374
|
+
* @1 AAA
|
|
375
|
+
*
|
|
376
|
+
* aaa
|
|
377
|
+
*
|
|
378
|
+
* @2 BBB
|
|
379
|
+
*
|
|
380
|
+
* @2 B22
|
|
381
|
+
*
|
|
382
|
+
* ccc
|
|
383
|
+
* ddd
|
|
384
|
+
*
|
|
385
|
+
* @1 A22
|
|
386
|
+
*
|
|
387
|
+
* :::
|
|
388
|
+
*
|
|
389
|
+
* 会被转化为
|
|
390
|
+
*
|
|
391
|
+
* - AAA
|
|
392
|
+
* - BBB
|
|
393
|
+
* - B22
|
|
394
|
+
* - ccc
|
|
395
|
+
* ddd
|
|
396
|
+
* - A22
|
|
397
|
+
*/
|
|
398
|
+
static mdit2data(text: string): List_ListItem {
|
|
399
|
+
let list_itemInfo: List_ListItem = []
|
|
400
|
+
|
|
401
|
+
const list_text = text.split("\n")
|
|
402
|
+
let mul_mode: "mdit" | "para" | "list" | "" = "" // 多行模式,mdit/正文/列表/空
|
|
403
|
+
let codeBlockFlag = '' // 代码块标志,避免在代码块内识别结束符号
|
|
404
|
+
for (let line of list_text) {
|
|
405
|
+
// heading和mdit类型都需要跳过代码块内的结束标志
|
|
406
|
+
if (codeBlockFlag == '') {
|
|
407
|
+
const match = line.match(ABReg.reg_code)
|
|
408
|
+
if (match && match[3]) { // 进入代码块。则将内容添加到最后的列表项 (不能是mdit列表项)
|
|
409
|
+
if (mul_mode === "mdit" || mul_mode === "") {
|
|
410
|
+
list_itemInfo.push({
|
|
411
|
+
content: line,
|
|
412
|
+
level: 0
|
|
413
|
+
})
|
|
414
|
+
mul_mode = "para"
|
|
415
|
+
} else {
|
|
416
|
+
codeBlockFlag = match[1] + match[3]
|
|
417
|
+
list_itemInfo[list_itemInfo.length-1].content += "\n" + line
|
|
418
|
+
}
|
|
419
|
+
continue
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
else { // 在代码块内,找代码块的结束标志
|
|
423
|
+
if (line.indexOf(codeBlockFlag) == 0) codeBlockFlag = ''
|
|
424
|
+
list_itemInfo[list_itemInfo.length-1].content += "\n" + line
|
|
425
|
+
continue
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
//
|
|
429
|
+
const match_mdit = line.match(/^(\s*)@(\d+)\s+(.*)$/)
|
|
430
|
+
const match_list = line.match(ABReg.reg_list_noprefix)
|
|
431
|
+
if (match_mdit && !match_mdit[1]) { // 1. Mdit层级(只识别根处)
|
|
432
|
+
removeTailBlank()
|
|
433
|
+
list_itemInfo.push({
|
|
434
|
+
content: match_mdit[3],
|
|
435
|
+
level: Number(match_mdit[2]) - 100
|
|
436
|
+
})
|
|
437
|
+
mul_mode = "mdit"
|
|
438
|
+
}
|
|
439
|
+
else if (match_list) { // 2. 列表层级 ~~(只识别根处)~~
|
|
440
|
+
removeTailBlank()
|
|
441
|
+
list_itemInfo.push({
|
|
442
|
+
content: match_list[4],
|
|
443
|
+
level: match_list[1].length + 1
|
|
444
|
+
})
|
|
445
|
+
mul_mode = "list"
|
|
446
|
+
}
|
|
447
|
+
else if (/^\S/.test(line) && mul_mode == "list") { // 3. 带缩进且在列表层级中
|
|
448
|
+
list_itemInfo[list_itemInfo.length-1].content += "\n" + line
|
|
449
|
+
}
|
|
450
|
+
else { // 4. 正文层级
|
|
451
|
+
if (mul_mode == "para") {
|
|
452
|
+
list_itemInfo[list_itemInfo.length-1].content += "\n" + line
|
|
453
|
+
}
|
|
454
|
+
else if (/^\s*$/.test(line)) {
|
|
455
|
+
continue
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
list_itemInfo.push({
|
|
459
|
+
content: line,
|
|
460
|
+
level: 0
|
|
461
|
+
})
|
|
462
|
+
mul_mode = "para"
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
removeTailBlank()
|
|
468
|
+
return list_itemInfo
|
|
469
|
+
|
|
470
|
+
function removeTailBlank(){
|
|
471
|
+
if (mul_mode == "para" || mul_mode == "list") {
|
|
472
|
+
list_itemInfo[list_itemInfo.length-1].content = list_itemInfo[list_itemInfo.length-1].content.replace(/\s*$/, "")
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
348
477
|
// 这种类型的列表只有两层
|
|
349
478
|
private static old_ulist2data(text: string){
|
|
350
479
|
// 列表文本转列表数据
|
|
@@ -581,6 +710,17 @@ export const abc_title2listdata = ABConvert.factory({
|
|
|
581
710
|
}
|
|
582
711
|
})
|
|
583
712
|
|
|
713
|
+
export const abc_mdit2listdata = ABConvert.factory({
|
|
714
|
+
id: "mdit2listdata",
|
|
715
|
+
name: "mdit到listdata",
|
|
716
|
+
process_param: ABConvert_IOEnum.text,
|
|
717
|
+
process_return: ABConvert_IOEnum.list_stream,
|
|
718
|
+
detail: "mdit到listdata",
|
|
719
|
+
process: (el, header, content: string): List_ListItem=>{
|
|
720
|
+
return ListProcess.mdit2data(content) as List_ListItem
|
|
721
|
+
}
|
|
722
|
+
})
|
|
723
|
+
|
|
584
724
|
const _abc_listdata2list = ABConvert.factory({
|
|
585
725
|
id: "listdata2list",
|
|
586
726
|
name: "listdata到列表",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anyblock/any-block-core",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.12",
|
|
4
4
|
"description": "You can flexibility to create a 'Block' by many means. It also provides many useful features, like `list to table`. (obsidian/markdown-it/vuepress plugin/app)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|