@blueking/ai-ui-sdk 0.2.0-beta.21 → 0.2.0-beta.23
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/dist/components/render-auto-height-textarea/index.vue.css +11 -11
- package/dist/components/render-auto-height-textarea/index.vue.js +1 -1
- package/dist/components/render-auto-refresh/index.vue.css +8 -8
- package/dist/components/render-auto-refresh/index.vue.js +1 -1
- package/dist/components/render-checkbox/index.vue.css +9 -9
- package/dist/components/render-checkbox/index.vue.js +1 -1
- package/dist/components/render-choose-tag/index.vue.css +7 -7
- package/dist/components/render-choose-tag/index.vue.js +1 -1
- package/dist/components/render-collapse/index.vue.css +2 -2
- package/dist/components/render-collapse/index.vue.js +1 -1
- package/dist/components/render-dataset/components/batch-delete-dataset-data/index.vue.css +3 -3
- package/dist/components/render-dataset/components/batch-delete-dataset-data/index.vue.js +1 -1
- package/dist/components/render-dataset/components/batch-edit-valid-dataset-data/index.vue.css +1 -1
- package/dist/components/render-dataset/components/batch-edit-valid-dataset-data/index.vue.js +1 -1
- package/dist/components/render-dataset/components/dataset-data-tool-icons/index.script.vue.js +1 -1
- package/dist/components/render-dataset/components/dataset-data-valid/index.vue.css +1 -1
- package/dist/components/render-dataset/components/dataset-data-valid/index.vue.js +1 -1
- package/dist/components/render-dataset/components/edit-dataset-data/index.vue.css +3 -3
- package/dist/components/render-dataset/components/edit-dataset-data/index.vue.js +1 -1
- package/dist/components/render-dataset/components/operation-record/index.vue.css +4 -4
- package/dist/components/render-dataset/components/operation-record/index.vue.js +1 -1
- package/dist/components/render-dataset/components/operation-record/table/index.vue.css +1 -1
- package/dist/components/render-dataset/components/operation-record/table/index.vue.js +1 -1
- package/dist/components/render-dataset/components/operation-record/view-op-result/index.vue.css +2 -2
- package/dist/components/render-dataset/components/operation-record/view-op-result/index.vue.js +1 -1
- package/dist/components/render-dataset/components/plus-dataset/index.vue.css +2 -2
- package/dist/components/render-dataset/components/plus-dataset/index.vue.js +1 -1
- package/dist/components/render-dataset/components/plus-dataset-data/form/api.vue.css +2 -2
- package/dist/components/render-dataset/components/plus-dataset-data/form/api.vue.js +1 -1
- package/dist/components/render-dataset/components/plus-dataset-data/form/footer.vue.css +1 -1
- package/dist/components/render-dataset/components/plus-dataset-data/form/footer.vue.js +1 -1
- package/dist/components/render-dataset/components/plus-dataset-data/form/index.vue.css +2 -2
- package/dist/components/render-dataset/components/plus-dataset-data/form/index.vue.js +1 -1
- package/dist/components/render-dataset/components/review-dataset-data/index.vue.css +10 -10
- package/dist/components/render-dataset/components/review-dataset-data/index.vue.js +1 -1
- package/dist/components/render-dataset-detail-origin-data/index.vue.css +3 -3
- package/dist/components/render-dataset-detail-origin-data/index.vue.js +1 -1
- package/dist/components/render-dataset-list/components/main.vue.css +3 -3
- package/dist/components/render-dataset-list/components/main.vue.js +1 -1
- package/dist/components/render-dataset-list/index.vue.css +2 -2
- package/dist/components/render-dataset-list/index.vue.js +1 -1
- package/dist/components/render-file-card/index.vue.css +11 -11
- package/dist/components/render-file-card/index.vue.js +1 -1
- package/dist/components/render-file-type-icon/index.vue.css +5 -5
- package/dist/components/render-file-type-icon/index.vue.js +1 -1
- package/dist/components/render-header/index.vue.css +3 -3
- package/dist/components/render-header/index.vue.js +1 -1
- package/dist/components/render-like/index.vue.css +5 -5
- package/dist/components/render-like/index.vue.js +1 -1
- package/dist/components/render-markdown/common.d.ts +2 -2
- package/dist/components/render-markdown/common.ts.js +35 -2
- package/dist/components/render-markdown/edit.ts.js +7 -5
- package/dist/components/render-markdown/filter-css.d.ts +3 -0
- package/dist/components/render-markdown/filter-css.ts.js +119 -0
- package/dist/components/render-markdown/katex.d.ts +83 -0
- package/dist/components/render-markdown/katex.ts.js +309 -0
- package/dist/components/render-markdown/prism-atom-one-dark.postcss.css +192 -0
- package/dist/components/render-markdown/view.postcss.css +19 -11
- package/dist/components/render-markdown/view.ts.js +55 -4
- package/dist/components/render-router-tab/index.vue.css +3 -3
- package/dist/components/render-router-tab/index.vue.js +1 -1
- package/dist/components/render-t-table/index.vue.css +27 -27
- package/dist/components/render-t-table/index.vue.js +1 -1
- package/dist/components/render-tag-tree/index.vue.css +7 -7
- package/dist/components/render-tag-tree/index.vue.js +1 -1
- package/package.json +2 -1
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
|
|
2
|
-
.upload-file-home[data-v-
|
|
2
|
+
.upload-file-home[data-v-w5xzcq2o] {
|
|
3
3
|
position: relative;
|
|
4
4
|
background: #FFFFFF;
|
|
5
5
|
border: 1px solid #DCDEE5;
|
|
6
6
|
border-radius: 4px;
|
|
7
7
|
padding: 12px 12px 10px 12px;
|
|
8
8
|
}
|
|
9
|
-
.upload-file-home[data-v-
|
|
9
|
+
.upload-file-home[data-v-w5xzcq2o]:hover {
|
|
10
10
|
border: 1px solid #3A84FF;
|
|
11
11
|
}
|
|
12
|
-
.upload-file-home:hover .file-icons[data-v-
|
|
12
|
+
.upload-file-home:hover .file-icons[data-v-w5xzcq2o] {
|
|
13
13
|
display: flex;
|
|
14
14
|
}
|
|
15
|
-
.upload-file-home .file-icon[data-v-
|
|
15
|
+
.upload-file-home .file-icon[data-v-w5xzcq2o] {
|
|
16
16
|
font-size: 32px;
|
|
17
17
|
}
|
|
18
|
-
.upload-file-home .file-content[data-v-
|
|
18
|
+
.upload-file-home .file-content[data-v-w5xzcq2o] {
|
|
19
19
|
font-size: 12px;
|
|
20
20
|
flex: 1;
|
|
21
21
|
align-items: flex-start;
|
|
@@ -23,28 +23,28 @@
|
|
|
23
23
|
font-weight: normal;
|
|
24
24
|
width: 0;
|
|
25
25
|
}
|
|
26
|
-
.upload-file-home .file-content .file-name[data-v-
|
|
26
|
+
.upload-file-home .file-content .file-name[data-v-w5xzcq2o] {
|
|
27
27
|
width: 100%;
|
|
28
28
|
font-size: 14px;
|
|
29
29
|
line-height: 20px;
|
|
30
30
|
}
|
|
31
|
-
.upload-file-home .file-content .file-size[data-v-
|
|
31
|
+
.upload-file-home .file-content .file-size[data-v-w5xzcq2o] {
|
|
32
32
|
font-size: 12px;
|
|
33
33
|
color: #979BA5;
|
|
34
34
|
line-height: 20px;
|
|
35
35
|
}
|
|
36
|
-
.upload-file-home .file-icons[data-v-
|
|
36
|
+
.upload-file-home .file-icons[data-v-w5xzcq2o] {
|
|
37
37
|
display: none;
|
|
38
38
|
color: #979BA5;
|
|
39
39
|
}
|
|
40
|
-
.upload-file-home .file-icons .bkaidev-icon[data-v-
|
|
40
|
+
.upload-file-home .file-icons .bkaidev-icon[data-v-w5xzcq2o] {
|
|
41
41
|
cursor: pointer;
|
|
42
42
|
margin-right: 15px;
|
|
43
43
|
font-size: 16px;
|
|
44
44
|
}
|
|
45
|
-
.upload-file-home .file-icons .bkaidev-icon[data-v-
|
|
45
|
+
.upload-file-home .file-icons .bkaidev-icon[data-v-w5xzcq2o]:hover {
|
|
46
46
|
color: #3A84FF;
|
|
47
47
|
}
|
|
48
|
-
.upload-file-home .file-icons .bkaidev-delete[data-v-
|
|
48
|
+
.upload-file-home .file-icons .bkaidev-delete[data-v-w5xzcq2o] {
|
|
49
49
|
margin: 0;
|
|
50
50
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
.ai-ui-sdk-icon.ai-ui-sdk-pdf[data-v-
|
|
2
|
+
.ai-ui-sdk-icon.ai-ui-sdk-pdf[data-v-qf27p592] {
|
|
3
3
|
color: #EA3636;
|
|
4
4
|
}
|
|
5
|
-
.ai-ui-sdk-icon.ai-ui-sdk-doc-2[data-v-
|
|
5
|
+
.ai-ui-sdk-icon.ai-ui-sdk-doc-2[data-v-qf27p592], .ai-ui-sdk-icon.ai-ui-sdk-ppt-2[data-v-qf27p592], .ai-ui-sdk-icon.ai-ui-sdk-markdown[data-v-qf27p592] {
|
|
6
6
|
color: #3A84FF;
|
|
7
7
|
}
|
|
8
|
-
.ai-ui-sdk-icon.ai-ui-sdk-folder-fill[data-v-
|
|
8
|
+
.ai-ui-sdk-icon.ai-ui-sdk-folder-fill[data-v-qf27p592] {
|
|
9
9
|
color: #C4C6CC;
|
|
10
10
|
}
|
|
11
|
-
.ai-ui-sdk-icon.ai-ui-sdk-excel[data-v-
|
|
11
|
+
.ai-ui-sdk-icon.ai-ui-sdk-excel[data-v-qf27p592] {
|
|
12
12
|
color: #2DCB56;
|
|
13
13
|
}
|
|
14
|
-
.ai-ui-sdk-icon.ai-ui-sdk-wangye[data-v-
|
|
14
|
+
.ai-ui-sdk-icon.ai-ui-sdk-wangye[data-v-qf27p592] {
|
|
15
15
|
color: #14A568;
|
|
16
16
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
|
|
2
|
-
.header-home[data-v-
|
|
2
|
+
.header-home[data-v-qh5nu3ks] {
|
|
3
3
|
width: 100%;
|
|
4
4
|
background: #FFFFFF;
|
|
5
5
|
box-shadow: 0 3px 4px 0 #0000000a;
|
|
6
6
|
}
|
|
7
|
-
.render-tab[data-v-
|
|
7
|
+
.render-tab[data-v-qh5nu3ks] {
|
|
8
8
|
border-bottom: 2px solid transparent;
|
|
9
9
|
}
|
|
10
|
-
.render-tab.active[data-v-
|
|
10
|
+
.render-tab.active[data-v-qh5nu3ks] {
|
|
11
11
|
color: #3A84FF;
|
|
12
12
|
border-bottom: 2px solid #3A84FF;
|
|
13
13
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
|
|
2
|
-
.dislike-icon[data-v-
|
|
2
|
+
.dislike-icon[data-v-q7gttb4y] {
|
|
3
3
|
transform: rotateX(180deg);
|
|
4
4
|
}
|
|
5
|
-
.option-items[data-v-
|
|
5
|
+
.option-items[data-v-q7gttb4y] {
|
|
6
6
|
padding: 1px 8px;
|
|
7
7
|
background-color: #F0F1F5;
|
|
8
8
|
line-height: 22px;
|
|
9
9
|
border-radius: 2px;
|
|
10
10
|
}
|
|
11
|
-
.option-items[data-v-
|
|
11
|
+
.option-items[data-v-q7gttb4y]:hover {
|
|
12
12
|
background-color: #E1ECFF;
|
|
13
13
|
color: #3A84FF;
|
|
14
14
|
}
|
|
15
|
-
.option-items-selected[data-v-
|
|
15
|
+
.option-items-selected[data-v-q7gttb4y]{
|
|
16
16
|
background-color: #E1ECFF;
|
|
17
17
|
}
|
|
18
|
-
[data-v-
|
|
18
|
+
[data-v-q7gttb4y] .bk-form-item {
|
|
19
19
|
margin-bottom: 17px;
|
|
20
20
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EditorOptions } from '@toast-ui/editor';
|
|
2
|
-
import '
|
|
2
|
+
import './prism-atom-one-dark.postcss';
|
|
3
3
|
import '@toast-ui/editor-plugin-code-syntax-highlight/dist/toastui-editor-plugin-code-syntax-highlight.css';
|
|
4
4
|
import 'prismjs/components/prism-markup';
|
|
5
5
|
import 'prismjs/components/prism-css';
|
|
@@ -16,4 +16,4 @@ import 'prismjs/components/prism-java';
|
|
|
16
16
|
import 'prismjs/components/prism-python';
|
|
17
17
|
import 'prismjs/components/prism-go';
|
|
18
18
|
import 'prismjs/components/prism-rust';
|
|
19
|
-
export declare const commonConfig: Pick<EditorOptions, 'usageStatistics' | 'linkAttributes' | 'plugins'>;
|
|
19
|
+
export declare const commonConfig: Pick<EditorOptions, 'usageStatistics' | 'linkAttributes' | 'plugins' | 'customHTMLRenderer'>;
|
|
@@ -1,7 +1,36 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _object_spread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_define_property(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
1
29
|
import Prism from 'prismjs';
|
|
2
30
|
import CodeSyntaxHighlight from '@toast-ui/editor-plugin-code-syntax-highlight';
|
|
31
|
+
import { createTuiKatexCustomRenderer } from './katex.ts.js';
|
|
3
32
|
import { MarkDownCodeCopyPlugin } from './mark-down-code-copy.ts.js';
|
|
4
|
-
import '
|
|
33
|
+
import './prism-atom-one-dark.postcss.css';
|
|
5
34
|
import '@toast-ui/editor-plugin-code-syntax-highlight/dist/toastui-editor-plugin-code-syntax-highlight.css';
|
|
6
35
|
import 'prismjs/components/prism-markup';
|
|
7
36
|
import 'prismjs/components/prism-css';
|
|
@@ -37,5 +66,9 @@ export const commonConfig = {
|
|
|
37
66
|
highlighter: Prism
|
|
38
67
|
}
|
|
39
68
|
]
|
|
40
|
-
]
|
|
69
|
+
],
|
|
70
|
+
customHTMLRenderer: _object_spread({}, createTuiKatexCustomRenderer({
|
|
71
|
+
autoEscapePercent: true,
|
|
72
|
+
enableSingleDollar: true
|
|
73
|
+
}))
|
|
41
74
|
};
|
|
@@ -82,7 +82,7 @@ export default defineComponent({
|
|
|
82
82
|
const defaultMode = props.mode || "wysiwyg";
|
|
83
83
|
// 切换模式按钮
|
|
84
84
|
const modeSwitchEl = document.createElement('section');
|
|
85
|
-
modeSwitchEl.className = 'toastui-editor-toolbar-custom-button g-cursor-pointer';
|
|
85
|
+
modeSwitchEl.className = 'toastui-editor-toolbar-custom-button g-cursor-pointer g-ml-4';
|
|
86
86
|
modeSwitchEl.innerHTML = '<i class="bkaidev-icon bkaidev-qiehuan g-mr-4 g-text-16"></i>切换代码模式';
|
|
87
87
|
modeSwitchEl.dataset.mode = defaultMode;
|
|
88
88
|
modeSwitchEl.addEventListener('click', ()=>{
|
|
@@ -145,10 +145,12 @@ export default defineComponent({
|
|
|
145
145
|
]
|
|
146
146
|
],
|
|
147
147
|
[
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
...props.isSimpleToolbar ? [] : [
|
|
149
|
+
{
|
|
150
|
+
name: 'modeSwitch',
|
|
151
|
+
el: modeSwitchEl
|
|
152
|
+
}
|
|
153
|
+
],
|
|
152
154
|
{
|
|
153
155
|
name: 'fullScreen',
|
|
154
156
|
el: fullScreenEl
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const NUMERIC_PROPS = new Set([
|
|
2
|
+
'height',
|
|
3
|
+
'top',
|
|
4
|
+
'bottom',
|
|
5
|
+
'margin-right',
|
|
6
|
+
'margin-left',
|
|
7
|
+
'border-bottom-width',
|
|
8
|
+
'width',
|
|
9
|
+
'min-width',
|
|
10
|
+
'font-size'
|
|
11
|
+
]);
|
|
12
|
+
const COLOR_PROPS = new Set([
|
|
13
|
+
'color',
|
|
14
|
+
'background-color'
|
|
15
|
+
]);
|
|
16
|
+
const FONT_WEIGHT_PROPS = new Set([
|
|
17
|
+
'font-weight'
|
|
18
|
+
]);
|
|
19
|
+
const VERTICAL_ALIGN_VALUES = new Set([
|
|
20
|
+
'baseline',
|
|
21
|
+
'middle',
|
|
22
|
+
'sub',
|
|
23
|
+
'super',
|
|
24
|
+
'text-top',
|
|
25
|
+
'text-bottom',
|
|
26
|
+
'top',
|
|
27
|
+
'bottom'
|
|
28
|
+
]);
|
|
29
|
+
const DANGEROUS_CSS_VALUE_RE = /(url\s*\(|expression\s*\(|javascript\s*:|vbscript\s*:|data\s*:|@import|var\s*\(|calc\s*\()/i;
|
|
30
|
+
const NUMERIC_VALUE_RE = /^-?\d+(\.\d+)?(em|px|rem|%)?$/i;
|
|
31
|
+
const FONT_WEIGHT_VALUE_RE = /^(normal|bold|bolder|lighter|[1-9]00)$/i;
|
|
32
|
+
const HEX_COLOR_RE = /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
33
|
+
const RGB_COLOR_RE = /^rgba?\(\s*((25[0-5]|2[0-4]\d|1?\d?\d)\s*,\s*){2}(25[0-5]|2[0-4]\d|1?\d?\d)(\s*,\s*(0|1|0?\.\d+))?\s*\)$/i;
|
|
34
|
+
const HSL_COLOR_RE = /^hsla?\(\s*(360|3[0-5]\d|[12]?\d?\d)\s*,\s*(100|[1-9]?\d)%\s*,\s*(100|[1-9]?\d)%(\s*,\s*(0|1|0?\.\d+))?\s*\)$/i;
|
|
35
|
+
const SAFE_COLOR_KEYWORDS = new Set([
|
|
36
|
+
'transparent',
|
|
37
|
+
'currentcolor',
|
|
38
|
+
'black',
|
|
39
|
+
'white',
|
|
40
|
+
'red',
|
|
41
|
+
'green',
|
|
42
|
+
'blue',
|
|
43
|
+
'gray',
|
|
44
|
+
'grey',
|
|
45
|
+
'yellow',
|
|
46
|
+
'orange',
|
|
47
|
+
'purple',
|
|
48
|
+
'pink',
|
|
49
|
+
'brown'
|
|
50
|
+
]);
|
|
51
|
+
const isSafeCssValue = (value)=>{
|
|
52
|
+
return !DANGEROUS_CSS_VALUE_RE.test(value);
|
|
53
|
+
};
|
|
54
|
+
const isSafeNumericValue = (value)=>{
|
|
55
|
+
return NUMERIC_VALUE_RE.test(value);
|
|
56
|
+
};
|
|
57
|
+
const isSafeFontWeightValue = (value)=>{
|
|
58
|
+
if (!FONT_WEIGHT_VALUE_RE.test(value)) return false;
|
|
59
|
+
const num = Number(value);
|
|
60
|
+
if (Number.isNaN(num)) return true;
|
|
61
|
+
return num >= 100 && num <= 900 && num % 100 === 0;
|
|
62
|
+
};
|
|
63
|
+
const isSafeColorValue = (value)=>{
|
|
64
|
+
const normalized = value.trim().toLowerCase();
|
|
65
|
+
if (!isSafeCssValue(normalized)) return false;
|
|
66
|
+
if (SAFE_COLOR_KEYWORDS.has(normalized)) return true;
|
|
67
|
+
if (HEX_COLOR_RE.test(normalized)) return true;
|
|
68
|
+
if (RGB_COLOR_RE.test(normalized)) return true;
|
|
69
|
+
if (HSL_COLOR_RE.test(normalized)) return true;
|
|
70
|
+
return false;
|
|
71
|
+
};
|
|
72
|
+
const isSafeVerticalAlignValue = (value)=>{
|
|
73
|
+
const normalized = value.trim().toLowerCase();
|
|
74
|
+
return VERTICAL_ALIGN_VALUES.has(normalized) || isSafeNumericValue(normalized);
|
|
75
|
+
};
|
|
76
|
+
export const filterStyle = (style)=>{
|
|
77
|
+
return style.split(';').map((item)=>item.trim()).filter(Boolean).map((item)=>{
|
|
78
|
+
const [rawProp, ...rest] = item.split(':');
|
|
79
|
+
const prop = rawProp === null || rawProp === void 0 ? void 0 : rawProp.trim().toLowerCase();
|
|
80
|
+
const value = rest.join(':').trim();
|
|
81
|
+
return {
|
|
82
|
+
prop,
|
|
83
|
+
value,
|
|
84
|
+
normalizedValue: value.toLowerCase()
|
|
85
|
+
};
|
|
86
|
+
}).filter(({ prop, value, normalizedValue })=>{
|
|
87
|
+
if (!prop || !value) return false;
|
|
88
|
+
if (!isSafeCssValue(normalizedValue)) return false;
|
|
89
|
+
if (NUMERIC_PROPS.has(prop)) {
|
|
90
|
+
return isSafeNumericValue(normalizedValue);
|
|
91
|
+
}
|
|
92
|
+
if (COLOR_PROPS.has(prop)) {
|
|
93
|
+
return isSafeColorValue(normalizedValue);
|
|
94
|
+
}
|
|
95
|
+
if (FONT_WEIGHT_PROPS.has(prop)) {
|
|
96
|
+
return isSafeFontWeightValue(normalizedValue);
|
|
97
|
+
}
|
|
98
|
+
if (prop === 'vertical-align') {
|
|
99
|
+
return isSafeVerticalAlignValue(normalizedValue);
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
102
|
+
}).map(({ prop, value })=>`${prop}: ${value}`).join('; ');
|
|
103
|
+
};
|
|
104
|
+
export const cleanStyleAfterXss = (root)=>{
|
|
105
|
+
root.querySelectorAll('[style]').forEach((el)=>{
|
|
106
|
+
const nextStyle = filterStyle(el.getAttribute('style') || '');
|
|
107
|
+
if (nextStyle) {
|
|
108
|
+
el.setAttribute('style', nextStyle);
|
|
109
|
+
} else {
|
|
110
|
+
el.removeAttribute('style');
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
export const filterCSS = (html)=>{
|
|
115
|
+
const template = document.createElement('template');
|
|
116
|
+
template.innerHTML = html;
|
|
117
|
+
cleanStyleAfterXss(template.content);
|
|
118
|
+
return template.innerHTML;
|
|
119
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type KatexOptions } from 'katex';
|
|
2
|
+
import 'katex/dist/katex.min.css';
|
|
3
|
+
type MdNode = {
|
|
4
|
+
literal?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
parent?: MdNode | null;
|
|
7
|
+
};
|
|
8
|
+
export interface TuiKatexOptions {
|
|
9
|
+
/**
|
|
10
|
+
* 兼容 100% 写法。
|
|
11
|
+
* 标准 LaTeX 应该写 100\%
|
|
12
|
+
*/
|
|
13
|
+
autoEscapePercent?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 是否支持 $E=mc^2$。
|
|
16
|
+
* 如果业务里经常出现 $100 这种价格,建议设为 false。
|
|
17
|
+
*/
|
|
18
|
+
enableSingleDollar?: boolean;
|
|
19
|
+
katexOptions?: KatexOptions;
|
|
20
|
+
}
|
|
21
|
+
export declare function normalizeLatex(input: string, options?: TuiKatexOptions): string;
|
|
22
|
+
export declare function renderKatexToHtml(latex: string, displayMode?: boolean, options?: TuiKatexOptions): string;
|
|
23
|
+
export declare function createTuiKatexCustomRenderer(options?: TuiKatexOptions): {
|
|
24
|
+
paragraph(_node: MdNode, context: any): any;
|
|
25
|
+
text(node: MdNode): {
|
|
26
|
+
type: "text";
|
|
27
|
+
content: string;
|
|
28
|
+
} | {
|
|
29
|
+
type: "html";
|
|
30
|
+
content: string;
|
|
31
|
+
};
|
|
32
|
+
softbreak(_node: MdNode, context: any): any;
|
|
33
|
+
linebreak(_node: MdNode, context: any): any;
|
|
34
|
+
/**
|
|
35
|
+
* 支持 TUI custom block:
|
|
36
|
+
*
|
|
37
|
+
* $$katex
|
|
38
|
+
* \frac{15}{5000}\times 100\%=0.3\%
|
|
39
|
+
* $$
|
|
40
|
+
*/
|
|
41
|
+
katex: (node: MdNode) => ({
|
|
42
|
+
type: "openTag";
|
|
43
|
+
tagName: string;
|
|
44
|
+
outerNewLine: boolean;
|
|
45
|
+
classNames: string[];
|
|
46
|
+
content?: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
type: "html";
|
|
49
|
+
content: string;
|
|
50
|
+
tagName?: undefined;
|
|
51
|
+
outerNewLine?: undefined;
|
|
52
|
+
classNames?: undefined;
|
|
53
|
+
} | {
|
|
54
|
+
type: "closeTag";
|
|
55
|
+
tagName: string;
|
|
56
|
+
outerNewLine: boolean;
|
|
57
|
+
classNames?: undefined;
|
|
58
|
+
content?: undefined;
|
|
59
|
+
})[];
|
|
60
|
+
/**
|
|
61
|
+
* 这里 latex 也按数学公式处理,不走 latex.js。
|
|
62
|
+
*/
|
|
63
|
+
latex: (node: MdNode) => ({
|
|
64
|
+
type: "openTag";
|
|
65
|
+
tagName: string;
|
|
66
|
+
outerNewLine: boolean;
|
|
67
|
+
classNames: string[];
|
|
68
|
+
content?: undefined;
|
|
69
|
+
} | {
|
|
70
|
+
type: "html";
|
|
71
|
+
content: string;
|
|
72
|
+
tagName?: undefined;
|
|
73
|
+
outerNewLine?: undefined;
|
|
74
|
+
classNames?: undefined;
|
|
75
|
+
} | {
|
|
76
|
+
type: "closeTag";
|
|
77
|
+
tagName: string;
|
|
78
|
+
outerNewLine: boolean;
|
|
79
|
+
classNames?: undefined;
|
|
80
|
+
content?: undefined;
|
|
81
|
+
})[];
|
|
82
|
+
};
|
|
83
|
+
export {};
|