-
Notifications
You must be signed in to change notification settings - Fork 30
/
UbbCodeExtension.tsx
149 lines (135 loc) · 6.02 KB
/
UbbCodeExtension.tsx
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
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
147
148
149
// A '.tsx' file enables JSX support in the TypeScript compiler,
// for more information see the following page on the TypeScript wiki:
// https://github.com/Microsoft/TypeScript/wiki/JSX
import * as Ubb from './Core';
import { NoUbbTagHandler } from './NoUbbTagHandler';
import { BTagHandler } from './BTagHandler';
import { ImageTagHandler } from './ImageTagHandler';
import { ITagHandler } from './ITagHandler';
import { SizeTagHandler } from './SizeTagHandler';
import { QuoteTagHandler } from './QuoteTagHandler';
import { ColorTagHandler } from './ColorTagHandler';
import { UrlTagHandler } from './URLTagHandler';
import { UTagHandler } from './UTagHandler';
import { DelTagHandler } from './DelTagHandler';
import { AudioTagHandler } from './AudioTagHandler';
import { VideoTagHandler } from './VideoTagHandler';
import { CursorTagHandler } from './CursorTagHandler';
import { EnglishTagHandler } from './EnglishTagHandler';
import { UserTagHandler } from './UserTagHandler';
import { CodeTagHandler } from './CodeTagHandler';
import { FontTagHandler } from './FontTagHandler';
import { AlignTagHandler } from './AlignTagHandler';
import { UploadTagHandler } from './UploadTagHandler';
import { LeftTagHandler } from './LeftTagHandler';
import { CenterTagHandler } from './CenterTagHandler';
import { RightTagHandler } from './RightTagHandler';
import { TableTagHandler } from './TableTagHandler';
import { TdTagHandler } from './TdTagHandler';
import { ThTagHandler } from './ThTagHandler';
import { TrTagHandler } from './TrTagHandler';
import { TopicTagHandler } from './TopicTagHandler';
import { BoardTagHandler } from './BoardTagHandler';
import { MdTagHandler } from './MdTagHandler';
import { PmTagHandler } from './PmTagHandler'
import { BiliTagHandler } from './BiliTagHandler'
// import SandBoxTagHandler from './SandboxTagHandler';
import LineTagHandler from './LineTagHandler';
import EmTagHandler from './EmTagHandler';
import AcTagHandler from './AcTagHandler';
import MahjongTagHandler from './MahjongTagHandler';
import TbTagHandler from './TbTagHandler';
import BiliTextHandler from './BiliTextHandler';
import UrlTextHandler from './UrlTextHandler';
import UrlTextHandler2 from './UrlTextHandler2';
import NeedReplyTagHandler from './NeedReplyTagHandler';
import Ms from './MsTagHandler';
import CC98 from './CC98TagHandler';
import { PosterOnlyTagHanlder } from './PosterOnlyTagHandler';
import { AllowViewerTagHanlder } from './AllowViewerTagHanlder';
import { MathTagHandler, MathTextHandler } from './MathTagHandler';
/**
* 创建一个解析签名档用的engine
*/
export function createSignatureEngine(): Ubb.UbbCodeEngine {
const engine = new Ubb.UbbCodeEngine();
engine.handlers.register(BTagHandler);
engine.handlers.register(ImageTagHandler);
engine.handlers.register(ITagHandler);
engine.handlers.register(SizeTagHandler);
engine.handlers.register(ColorTagHandler);
engine.handlers.register(UrlTagHandler);
engine.handlers.register(UTagHandler);
engine.handlers.register(DelTagHandler);
engine.handlers.register(AudioTagHandler);
engine.handlers.register(FontTagHandler);
engine.handlers.register(AlignTagHandler);
engine.handlers.register(LeftTagHandler);
engine.handlers.register(CenterTagHandler);
engine.handlers.register(RightTagHandler);
engine.handlers.register(TopicTagHandler);
engine.handlers.register(BoardTagHandler);
engine.handlers.register(PmTagHandler);
engine.handlers.register(NoUbbTagHandler);
engine.handlers.registerText(UrlTextHandler);
engine.handlers.registerText(UrlTextHandler2);
return engine;
}
/**
* 创建一个具有所有功能的默认引擎。
*/
export function createEngine(): Ubb.UbbCodeEngine {
const engine = new Ubb.UbbCodeEngine();
// 在此处添加引擎所支持的所有标签处理器
engine.handlers.register(BTagHandler);
engine.handlers.register(ImageTagHandler);
engine.handlers.register(ITagHandler);
engine.handlers.register(SizeTagHandler);
engine.handlers.register(QuoteTagHandler);
engine.handlers.register(ColorTagHandler);
engine.handlers.register(UrlTagHandler);
engine.handlers.register(UTagHandler);
engine.handlers.register(DelTagHandler);
engine.handlers.register(AudioTagHandler);
engine.handlers.register(VideoTagHandler);
engine.handlers.register(CursorTagHandler);
engine.handlers.register(EnglishTagHandler);
engine.handlers.register(UserTagHandler);
engine.handlers.register(CodeTagHandler);
engine.handlers.register(FontTagHandler);
engine.handlers.register(AlignTagHandler);
engine.handlers.register(UploadTagHandler);
engine.handlers.register(LeftTagHandler);
engine.handlers.register(CenterTagHandler);
engine.handlers.register(RightTagHandler);
engine.handlers.register(TableTagHandler);
engine.handlers.register(TdTagHandler);
engine.handlers.register(ThTagHandler);
engine.handlers.register(TrTagHandler);
engine.handlers.register(TopicTagHandler);
engine.handlers.register(BoardTagHandler);
engine.handlers.register(MdTagHandler);
engine.handlers.register(LineTagHandler);
engine.handlers.register(PmTagHandler);
engine.handlers.register(NoUbbTagHandler);
engine.handlers.register(BiliTagHandler);
engine.handlers.register(MathTagHandler);
engine.handlers.register(NeedReplyTagHandler);
engine.handlers.register(PosterOnlyTagHanlder);
engine.handlers.register(AllowViewerTagHanlder);
// 以下是未命名标签处理程序(单个标签处理程序能处理多个标签名),注意未命名标签处理程序的命中和注册顺序有关
engine.handlers.register(EmTagHandler);
engine.handlers.register(AcTagHandler);
engine.handlers.register(MahjongTagHandler);
engine.handlers.register(Ms);
engine.handlers.register(CC98);
engine.handlers.register(TbTagHandler);
// 以下是文字处理程序,注意文字的处理顺序完全取决于处理程序,请注意控制处理程序的顺序
//engine.handlers.registerText(BiliTextHandler);
engine.handlers.registerText(UrlTextHandler);
engine.handlers.registerText(UrlTextHandler2);
engine.handlers.registerText(MathTextHandler);
return engine;
}
// 重新导出核心功能
export * from './Core';