-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathCC98TagHandler.tsx
34 lines (28 loc) · 1.24 KB
/
CC98TagHandler.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
// 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 React from 'react';
import * as Ubb from './Core';
export default class CC98TagHandler extends Ubb.RecursiveTagHandler {
get supportedTagNames(): RegExp {
return /CC98\d{2}/i;
}
getTagMode(tagData: Ubb.UbbTagData): Ubb.UbbTagMode {
return Ubb.UbbTagMode.Empty;
}
execCore(innerContent: React.ReactNode, tagData: Ubb.UbbTagData, context: Ubb.UbbCodeContext): React.ReactNode {
const reg = /CC98/gi;
const tagName = tagData.tagName;
const id = tagName.replace(reg, "");
let url = `/static/images/CC98/CC98${id}.gif`;
//CC9815 - CC9830 为PNG格式
if (Number(id) > 14 && Number(id) < 31) {
url = `/static/images/CC98/CC98${id}.png`;
}
//CC9836 - CC9837 为PNG格式
if (Number(id) > 35) {
url = `/static/images/CC98/CC98${id}.png`;
}
return context.options.allowEmotion ? <div style={{ display: "inline" }}><img src={url} alt="" />{innerContent}</div> : <div style={{ display: "inline" }}>{innerContent}</div>;
}
}