generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathPattern.ts
47 lines (43 loc) · 1.07 KB
/
Pattern.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { CardIDTag } from 'cardHead';
import { Component } from 'obsidian';
import { Operation, PatternSchedule } from 'schedule';
import { TagParser } from 'tag';
import { Card } from './card';
export type PatternProps ={
view:Component
showAns:boolean
}
// 卡片的展示模式
export abstract class Pattern {
TagID: string;
private pcard: Card;
get schedule(): PatternSchedule {
return this.card.getSchedule(this.TagID)
}
get card(): Card {
return this.pcard
}
constructor(card:Card, id:string) {
this.pcard = card
this.TagID = id
}
Pronounce() {}
abstract SubmitOpt(opt: Operation): Promise<void>;
abstract Component(props:PatternProps): JSX.Element;
abstract insertPatternID(): void;
async InitAosrID() {
this.insertPatternID()
await this.card.commitFile({ID:true})
}
}
export function prettyText (text:string):string {
let tags = TagParser.parse(text)
for (let tag of tags.Tags) {
if (tag.Head != CardIDTag) {
continue
}
text = text.replace(tag.Original, ()=>{return ""})
}
text = text.replace("#multicloze", ()=>{return ""})
return text
}