-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathAcTagHandler.tsx
26 lines (20 loc) · 979 Bytes
/
AcTagHandler.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
// 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 AcTagHandler extends Ubb.RecursiveTagHandler {
get supportedTagNames(): RegExp {
return /ac\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 = /ac/gi;
const tagName = tagData.tagName;
const acId = tagName.replace(reg, "");
const url = `/static/images/ac/${acId}.png`;
return context.options.allowEmotion ? <div style={{ display: "inline" }}><img src={url} alt="" />{innerContent}</div> : <div style={{ display: "inline" }}>{innerContent}</div>;
}
}