@blueking/ai-ui-sdk 0.2.1 → 0.2.2
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/common/util.d.ts +5 -0
- package/dist/common/util.ts.js +8 -0
- 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.script.vue.js.js +62 -1
- package/dist/components/render-choose-tag/index.vue.css +7 -7
- package/dist/components/render-choose-tag/index.vue.d.ts +1 -0
- 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.script.vue.js +1 -4
- 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.script.vue.js.js +1 -3
- 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.script.vue.js.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/components/search-dataset/index.script.vue.js.js +2 -3
- package/dist/components/render-dataset/components/search-dataset/index.vue.d.ts +0 -1
- package/dist/components/render-dataset-detail-origin-data/components/table/index.script.vue.js +2 -8
- 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.script.vue.js.js +2 -5
- package/dist/components/render-dataset-list/components/main.vue.css +3 -3
- package/dist/components/render-dataset-list/components/main.vue.d.ts +0 -1
- package/dist/components/render-dataset-list/components/main.vue.js +1 -1
- package/dist/components/render-dataset-list/components/table.script.vue.js +1 -4
- package/dist/components/render-dataset-list/index.script.vue.js.js +2 -5
- package/dist/components/render-dataset-list/index.vue.css +2 -2
- package/dist/components/render-dataset-list/index.vue.d.ts +0 -1
- 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 +19 -0
- package/dist/components/render-markdown/common.ts.js +74 -0
- package/dist/components/render-markdown/edit.d.ts +82 -0
- package/dist/components/render-markdown/edit.postcss.css +92 -0
- package/dist/components/render-markdown/edit.ts.js +228 -0
- 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/mark-down-code-copy.d.ts +7 -0
- package/dist/components/render-markdown/mark-down-code-copy.ts.js +73 -0
- package/dist/components/render-markdown/prism-atom-one-dark.postcss.css +192 -0
- package/dist/components/render-markdown/{mark-down.d.ts → view.d.ts} +2 -27
- package/dist/components/render-markdown/view.postcss.css +99 -0
- package/dist/components/render-markdown/view.ts.js +167 -0
- 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/dist/components.d.ts +3 -2
- package/dist/components.ts.js +3 -2
- package/dist/css/tailwind.css +4 -0
- package/dist/hooks/use-form-leave-confirm.ts.js +2 -0
- package/dist/hooks/use-member-http.d.ts +1 -2
- package/dist/hooks/use-member-http.ts.js +23 -27
- package/dist/hooks.d.ts +0 -1
- package/dist/hooks.ts.js +0 -1
- package/dist/http/fetch/index.d.ts +0 -2
- package/dist/http/fetch/index.ts.js +2 -4
- package/dist/http/fetch/success-interceptor.ts.js +1 -5
- package/package.json +8 -5
- package/dist/components/render-markdown/mark-down-code.d.ts +0 -2
- package/dist/components/render-markdown/mark-down-code.ts.js +0 -171
- package/dist/components/render-markdown/mark-down-emoji.d.ts +0 -2
- package/dist/components/render-markdown/mark-down-emoji.ts.js +0 -4
- package/dist/components/render-markdown/mark-down.postcss.css +0 -154
- package/dist/components/render-markdown/mark-down.ts.js +0 -152
- package/dist/hooks/use-display-name.d.ts +0 -3
- package/dist/hooks/use-display-name.ts.js +0 -14
|
@@ -0,0 +1,309 @@
|
|
|
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
|
+
}
|
|
29
|
+
function ownKeys(object, enumerableOnly) {
|
|
30
|
+
var keys = Object.keys(object);
|
|
31
|
+
if (Object.getOwnPropertySymbols) {
|
|
32
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
+
if (enumerableOnly) {
|
|
34
|
+
symbols = symbols.filter(function(sym) {
|
|
35
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
keys.push.apply(keys, symbols);
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
function _object_spread_props(target, source) {
|
|
43
|
+
source = source != null ? source : {};
|
|
44
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
45
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
+
} else {
|
|
47
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
48
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
import katex from 'katex';
|
|
54
|
+
import 'katex/dist/katex.min.css';
|
|
55
|
+
const defaultKatexOptions = {
|
|
56
|
+
throwOnError: false,
|
|
57
|
+
strict: 'ignore',
|
|
58
|
+
trust: false,
|
|
59
|
+
output: 'html'
|
|
60
|
+
};
|
|
61
|
+
const CODE_NODE_TYPES = new Set([
|
|
62
|
+
'code',
|
|
63
|
+
'codeBlock',
|
|
64
|
+
'htmlBlock',
|
|
65
|
+
'htmlInline'
|
|
66
|
+
]);
|
|
67
|
+
function isEscaped(value, index) {
|
|
68
|
+
let count = 0;
|
|
69
|
+
let i = index - 1;
|
|
70
|
+
while(i >= 0 && value[i] === '\\'){
|
|
71
|
+
count += 1;
|
|
72
|
+
i -= 1;
|
|
73
|
+
}
|
|
74
|
+
return count % 2 === 1;
|
|
75
|
+
}
|
|
76
|
+
function findUnescaped(value, search, fromIndex) {
|
|
77
|
+
let index = value.indexOf(search, fromIndex);
|
|
78
|
+
while(index !== -1){
|
|
79
|
+
if (!isEscaped(value, index)) return index;
|
|
80
|
+
index = value.indexOf(search, index + search.length);
|
|
81
|
+
}
|
|
82
|
+
return -1;
|
|
83
|
+
}
|
|
84
|
+
function isInCodeNode(node) {
|
|
85
|
+
let current = node;
|
|
86
|
+
while(current){
|
|
87
|
+
if (current.type && CODE_NODE_TYPES.has(current.type)) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
current = current.parent;
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
export function normalizeLatex(input, options = {}) {
|
|
95
|
+
let value = input.trim();
|
|
96
|
+
if (options.autoEscapePercent !== false) {
|
|
97
|
+
value = value.replace(/(^|[^\\])%/g, '$1\\%');
|
|
98
|
+
}
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
export function renderKatexToHtml(latex, displayMode = true, options = {}) {
|
|
102
|
+
return katex.renderToString(normalizeLatex(latex, options), _object_spread(_object_spread_props(_object_spread({}, defaultKatexOptions), {
|
|
103
|
+
displayMode
|
|
104
|
+
}), options.katexOptions || {}));
|
|
105
|
+
}
|
|
106
|
+
export function createTuiKatexCustomRenderer(options = {}) {
|
|
107
|
+
let mathState = null;
|
|
108
|
+
function toArray(value) {
|
|
109
|
+
return Array.isArray(value) ? value : [
|
|
110
|
+
value
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
function findNextOpen(value, fromIndex) {
|
|
114
|
+
const candidates = [];
|
|
115
|
+
const dollarBlock = findUnescaped(value, '$$', fromIndex);
|
|
116
|
+
if (dollarBlock !== -1) {
|
|
117
|
+
candidates.push({
|
|
118
|
+
index: dollarBlock,
|
|
119
|
+
open: '$$',
|
|
120
|
+
close: '$$',
|
|
121
|
+
display: true
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const bracketBlock = findUnescaped(value, '\\[', fromIndex);
|
|
125
|
+
if (bracketBlock !== -1) {
|
|
126
|
+
candidates.push({
|
|
127
|
+
index: bracketBlock,
|
|
128
|
+
open: '\\[',
|
|
129
|
+
close: '\\]',
|
|
130
|
+
display: true
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const bracketInline = findUnescaped(value, '\\(', fromIndex);
|
|
134
|
+
if (bracketInline !== -1) {
|
|
135
|
+
candidates.push({
|
|
136
|
+
index: bracketInline,
|
|
137
|
+
open: '\\(',
|
|
138
|
+
close: '\\)',
|
|
139
|
+
display: false
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
if (options.enableSingleDollar !== false) {
|
|
143
|
+
let singleDollar = findUnescaped(value, '$', fromIndex);
|
|
144
|
+
while(singleDollar !== -1 && (value[singleDollar - 1] === '$' || value[singleDollar + 1] === '$')){
|
|
145
|
+
singleDollar = findUnescaped(value, '$', singleDollar + 1);
|
|
146
|
+
}
|
|
147
|
+
if (singleDollar !== -1) {
|
|
148
|
+
candidates.push({
|
|
149
|
+
index: singleDollar,
|
|
150
|
+
open: '$',
|
|
151
|
+
close: '$',
|
|
152
|
+
display: false
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (!candidates.length) return null;
|
|
157
|
+
return candidates.sort((a, b)=>{
|
|
158
|
+
if (a.index !== b.index) return a.index - b.index;
|
|
159
|
+
return b.open.length - a.open.length;
|
|
160
|
+
})[0];
|
|
161
|
+
}
|
|
162
|
+
function processText(value) {
|
|
163
|
+
let html = '';
|
|
164
|
+
let index = 0;
|
|
165
|
+
let hasMath = false;
|
|
166
|
+
while(index < value.length){
|
|
167
|
+
if (mathState) {
|
|
168
|
+
hasMath = true;
|
|
169
|
+
const closeIndex = findUnescaped(value, mathState.close, index);
|
|
170
|
+
if (closeIndex === -1) {
|
|
171
|
+
mathState.content += value.slice(index);
|
|
172
|
+
return {
|
|
173
|
+
html,
|
|
174
|
+
hasMath
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
mathState.content += value.slice(index, closeIndex);
|
|
178
|
+
try {
|
|
179
|
+
html += renderKatexToHtml(mathState.content, mathState.display, options);
|
|
180
|
+
} catch (e) {
|
|
181
|
+
html += `${mathState.open}${mathState.content}${mathState.close}`;
|
|
182
|
+
}
|
|
183
|
+
index = closeIndex + mathState.close.length;
|
|
184
|
+
mathState = null;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const nextOpen = findNextOpen(value, index);
|
|
188
|
+
if (!nextOpen) {
|
|
189
|
+
html += value.slice(index);
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
hasMath = true;
|
|
193
|
+
html += value.slice(index, nextOpen.index);
|
|
194
|
+
mathState = {
|
|
195
|
+
open: nextOpen.open,
|
|
196
|
+
close: nextOpen.close,
|
|
197
|
+
display: nextOpen.display,
|
|
198
|
+
content: ''
|
|
199
|
+
};
|
|
200
|
+
index = nextOpen.index + nextOpen.open.length;
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
html,
|
|
204
|
+
hasMath
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function flushUnclosedMath() {
|
|
208
|
+
if (!mathState) return '';
|
|
209
|
+
const raw = `${mathState.open}${mathState.content}`;
|
|
210
|
+
mathState = null;
|
|
211
|
+
return raw;
|
|
212
|
+
}
|
|
213
|
+
function renderBlock(node) {
|
|
214
|
+
let html = '';
|
|
215
|
+
try {
|
|
216
|
+
html = renderKatexToHtml(node.literal || '', true, options);
|
|
217
|
+
} catch (error) {
|
|
218
|
+
html = `<pre><code>${String(error)}</code></pre>`;
|
|
219
|
+
}
|
|
220
|
+
return [
|
|
221
|
+
{
|
|
222
|
+
type: 'openTag',
|
|
223
|
+
tagName: 'div',
|
|
224
|
+
outerNewLine: true,
|
|
225
|
+
classNames: [
|
|
226
|
+
'tui-katex-block'
|
|
227
|
+
]
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
type: 'html',
|
|
231
|
+
content: html
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
type: 'closeTag',
|
|
235
|
+
tagName: 'div',
|
|
236
|
+
outerNewLine: true
|
|
237
|
+
}
|
|
238
|
+
];
|
|
239
|
+
}
|
|
240
|
+
const renderer = {
|
|
241
|
+
paragraph (_node, context) {
|
|
242
|
+
if (context.entering) {
|
|
243
|
+
mathState = null;
|
|
244
|
+
return context.origin();
|
|
245
|
+
}
|
|
246
|
+
const pending = flushUnclosedMath();
|
|
247
|
+
const origin = context.origin();
|
|
248
|
+
if (!pending) return origin;
|
|
249
|
+
return [
|
|
250
|
+
{
|
|
251
|
+
type: 'html',
|
|
252
|
+
content: pending
|
|
253
|
+
},
|
|
254
|
+
...toArray(origin)
|
|
255
|
+
];
|
|
256
|
+
},
|
|
257
|
+
text (node) {
|
|
258
|
+
const value = node.literal || '';
|
|
259
|
+
if (isInCodeNode(node)) {
|
|
260
|
+
return {
|
|
261
|
+
type: 'text',
|
|
262
|
+
content: value
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
const result = processText(value);
|
|
266
|
+
if (!result.hasMath) {
|
|
267
|
+
return {
|
|
268
|
+
type: 'text',
|
|
269
|
+
content: value
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
type: 'html',
|
|
274
|
+
content: result.html
|
|
275
|
+
};
|
|
276
|
+
},
|
|
277
|
+
softbreak (_node, context) {
|
|
278
|
+
if (mathState) {
|
|
279
|
+
mathState.content += '\n';
|
|
280
|
+
return {
|
|
281
|
+
type: 'text',
|
|
282
|
+
content: ''
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
return context.origin();
|
|
286
|
+
},
|
|
287
|
+
linebreak (_node, context) {
|
|
288
|
+
if (mathState) {
|
|
289
|
+
mathState.content += '\n';
|
|
290
|
+
return {
|
|
291
|
+
type: 'text',
|
|
292
|
+
content: ''
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
return context.origin();
|
|
296
|
+
},
|
|
297
|
+
/**
|
|
298
|
+
* 支持 TUI custom block:
|
|
299
|
+
*
|
|
300
|
+
* $$katex
|
|
301
|
+
* \frac{15}{5000}\times 100\%=0.3\%
|
|
302
|
+
* $$
|
|
303
|
+
*/ katex: renderBlock,
|
|
304
|
+
/**
|
|
305
|
+
* 这里 latex 也按数学公式处理,不走 latex.js。
|
|
306
|
+
*/ latex: renderBlock
|
|
307
|
+
};
|
|
308
|
+
return renderer;
|
|
309
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type Prism from 'prismjs';
|
|
2
|
+
import type { PluginContext, PluginInfo } from '@toast-ui/editor';
|
|
3
|
+
export type PrismHighlighter = typeof Prism;
|
|
4
|
+
export interface MarkDownCodeCopyPluginOptions {
|
|
5
|
+
highlighter?: PrismHighlighter;
|
|
6
|
+
}
|
|
7
|
+
export declare const MarkDownCodeCopyPlugin: (_context: PluginContext, options?: MarkDownCodeCopyPluginOptions) => PluginInfo;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const BACKTICK_COUNT = 3;
|
|
2
|
+
// 给块级代码增加右上角复制按钮,同时保留 Prism 语法高亮。
|
|
3
|
+
export const MarkDownCodeCopyPlugin = (_context, options = {})=>({
|
|
4
|
+
toHTMLRenderers: {
|
|
5
|
+
codeBlock (markdownNode) {
|
|
6
|
+
const node = markdownNode;
|
|
7
|
+
const infoWords = node.info ? node.info.split(/\s+/) : [];
|
|
8
|
+
const language = infoWords[0];
|
|
9
|
+
const preClasses = [];
|
|
10
|
+
const codeAttrs = {};
|
|
11
|
+
const tokens = [];
|
|
12
|
+
if (node.fenceLength > BACKTICK_COUNT) {
|
|
13
|
+
codeAttrs['data-backticks'] = node.fenceLength;
|
|
14
|
+
}
|
|
15
|
+
if (language) {
|
|
16
|
+
preClasses.push(`lang-${language}`);
|
|
17
|
+
codeAttrs['data-language'] = language;
|
|
18
|
+
}
|
|
19
|
+
var _node_literal;
|
|
20
|
+
tokens.push({
|
|
21
|
+
type: 'openTag',
|
|
22
|
+
tagName: 'pre',
|
|
23
|
+
classNames: [
|
|
24
|
+
...preClasses,
|
|
25
|
+
'markdown-code-copy-wrap'
|
|
26
|
+
]
|
|
27
|
+
}, {
|
|
28
|
+
type: 'openTag',
|
|
29
|
+
tagName: 'i',
|
|
30
|
+
classNames: [
|
|
31
|
+
'ai-ui-sdk-icon',
|
|
32
|
+
'ai-ui-sdk-copy',
|
|
33
|
+
'markdown-code-copy-button',
|
|
34
|
+
'click-copy'
|
|
35
|
+
],
|
|
36
|
+
attributes: {
|
|
37
|
+
'data-clipboard-text': encodeURIComponent((_node_literal = node.literal) !== null && _node_literal !== void 0 ? _node_literal : ''),
|
|
38
|
+
title: '复制代码'
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
type: 'closeTag',
|
|
42
|
+
tagName: 'i'
|
|
43
|
+
}, {
|
|
44
|
+
type: 'openTag',
|
|
45
|
+
tagName: 'code',
|
|
46
|
+
attributes: codeAttrs
|
|
47
|
+
});
|
|
48
|
+
const highlighter = options.highlighter;
|
|
49
|
+
const registeredLang = language && (highlighter === null || highlighter === void 0 ? void 0 : highlighter.languages[language]);
|
|
50
|
+
if (language && registeredLang) {
|
|
51
|
+
var _node_literal1;
|
|
52
|
+
tokens.push({
|
|
53
|
+
type: 'html',
|
|
54
|
+
content: highlighter.highlight((_node_literal1 = node.literal) !== null && _node_literal1 !== void 0 ? _node_literal1 : '', registeredLang, language)
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
var _node_literal2;
|
|
58
|
+
tokens.push({
|
|
59
|
+
type: 'text',
|
|
60
|
+
content: (_node_literal2 = node.literal) !== null && _node_literal2 !== void 0 ? _node_literal2 : ''
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
tokens.push({
|
|
64
|
+
type: 'closeTag',
|
|
65
|
+
tagName: 'code'
|
|
66
|
+
}, {
|
|
67
|
+
type: 'closeTag',
|
|
68
|
+
tagName: 'pre'
|
|
69
|
+
});
|
|
70
|
+
return tokens;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prism.js theme like highlight.js atom-one-dark
|
|
3
|
+
* Background: #282c34
|
|
4
|
+
* Foreground: #abb2bf
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
code[class*='language-'],
|
|
8
|
+
pre[class*='language-'] {
|
|
9
|
+
color: #abb2bf;
|
|
10
|
+
background: none;
|
|
11
|
+
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
|
12
|
+
font-size: 14px;
|
|
13
|
+
line-height: 1.6;
|
|
14
|
+
text-align: left;
|
|
15
|
+
white-space: pre;
|
|
16
|
+
word-spacing: normal;
|
|
17
|
+
word-break: normal;
|
|
18
|
+
word-wrap: normal;
|
|
19
|
+
tab-size: 2;
|
|
20
|
+
hyphens: none;
|
|
21
|
+
text-shadow: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
pre[class*='language-'] {
|
|
25
|
+
margin: 12px 0;
|
|
26
|
+
padding: 16px;
|
|
27
|
+
overflow: auto;
|
|
28
|
+
border-radius: 8px;
|
|
29
|
+
background: #282c34;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:not(pre) > code[class*='language-'],
|
|
33
|
+
pre[class*='language-'] {
|
|
34
|
+
background: #282c34;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
:not(pre) > code[class*='language-'] {
|
|
38
|
+
padding: 2px 6px;
|
|
39
|
+
border-radius: 4px;
|
|
40
|
+
color: #e06c75;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* Toast UI Editor preview / viewer 兜底 */
|
|
44
|
+
.toastui-editor-contents pre,
|
|
45
|
+
.tui-editor-contents pre {
|
|
46
|
+
background: #282c34 !important;
|
|
47
|
+
color: #abb2bf !important;
|
|
48
|
+
border-radius: 8px;
|
|
49
|
+
padding: 16px;
|
|
50
|
+
overflow-x: auto;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.toastui-editor-contents pre code,
|
|
54
|
+
.tui-editor-contents pre code {
|
|
55
|
+
background: transparent !important;
|
|
56
|
+
color: #abb2bf !important;
|
|
57
|
+
text-shadow: none !important;
|
|
58
|
+
font-family: Consolas,
|
|
59
|
+
Monaco,
|
|
60
|
+
'Andale Mono',
|
|
61
|
+
'Ubuntu Mono',
|
|
62
|
+
monospace;
|
|
63
|
+
font-size: 14px;
|
|
64
|
+
line-height: 1.6;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.toastui-editor-contents pre code span,
|
|
68
|
+
.tui-editor-contents pre code span,
|
|
69
|
+
.toastui-editor-contents .token,
|
|
70
|
+
.tui-editor-contents .token {
|
|
71
|
+
text-shadow: none !important;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* 注释 */
|
|
75
|
+
.token.comment,
|
|
76
|
+
.token.prolog,
|
|
77
|
+
.token.doctype,
|
|
78
|
+
.token.cdata {
|
|
79
|
+
color: #5c6370;
|
|
80
|
+
font-style: italic;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* 标点 */
|
|
84
|
+
.token.punctuation {
|
|
85
|
+
color: #abb2bf;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* 命名空间 */
|
|
89
|
+
.token.namespace {
|
|
90
|
+
opacity: .7;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* 标签、属性、选择器 */
|
|
94
|
+
.token.tag,
|
|
95
|
+
.token.selector {
|
|
96
|
+
color: #e06c75;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.token.attr-name {
|
|
100
|
+
color: #d19a66;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.token.attr-value,
|
|
104
|
+
.token.string,
|
|
105
|
+
.token.char,
|
|
106
|
+
.token.inserted {
|
|
107
|
+
color: #98c379;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* 关键字 */
|
|
111
|
+
.token.keyword,
|
|
112
|
+
.token.atrule {
|
|
113
|
+
color: #c678dd;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* 布尔、数字、常量 */
|
|
117
|
+
.token.boolean,
|
|
118
|
+
.token.number,
|
|
119
|
+
.token.constant,
|
|
120
|
+
.token.symbol {
|
|
121
|
+
color: #d19a66;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* 函数 */
|
|
125
|
+
.token.function {
|
|
126
|
+
color: #61afef;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* 类名、类型 */
|
|
130
|
+
.token.class-name,
|
|
131
|
+
.token.builtin {
|
|
132
|
+
color: #e5c07b;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* 属性、变量 */
|
|
136
|
+
.token.property,
|
|
137
|
+
.token.variable {
|
|
138
|
+
color: #e06c75;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* 操作符 */
|
|
142
|
+
.token.operator {
|
|
143
|
+
color: #56b6c2;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* 正则、重要内容 */
|
|
147
|
+
.token.regex,
|
|
148
|
+
.token.important {
|
|
149
|
+
color: #c678dd;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* URL / 实体 */
|
|
153
|
+
.token.url,
|
|
154
|
+
.token.entity {
|
|
155
|
+
color: #56b6c2;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* 删除 */
|
|
159
|
+
.token.deleted {
|
|
160
|
+
color: #e06c75;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* bold / italic */
|
|
164
|
+
.token.bold {
|
|
165
|
+
font-weight: 700;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.token.italic {
|
|
169
|
+
font-style: italic;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/* Prism line numbers 插件兼容 */
|
|
173
|
+
pre[class*='language-'].line-numbers {
|
|
174
|
+
position: relative;
|
|
175
|
+
padding-left: 3.8em;
|
|
176
|
+
counter-reset: linenumber;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.line-numbers .line-numbers-rows {
|
|
180
|
+
border-right: 1px solid #3e4451;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.line-numbers-rows > span::before {
|
|
184
|
+
color: #636d83;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* 选中文本 */
|
|
188
|
+
pre[class*='language-'] ::selection,
|
|
189
|
+
code[class*='language-'] ::selection {
|
|
190
|
+
background: #3e4451;
|
|
191
|
+
color: inherit;
|
|
192
|
+
}
|
|
@@ -1,30 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import '
|
|
3
|
-
import 'x-mavon-editor/dist/highlightjs/styles/atom-one-dark.min.css';
|
|
4
|
-
import './mark-down.postcss';
|
|
5
|
-
export type MdProp = {
|
|
6
|
-
modelValue?: string;
|
|
7
|
-
codeStyle?: string;
|
|
8
|
-
previewBackground?: string;
|
|
9
|
-
defaultOpen: string;
|
|
10
|
-
editable: boolean;
|
|
11
|
-
subfield: boolean;
|
|
12
|
-
toolbarsFlag: boolean;
|
|
13
|
-
boxShadow: boolean;
|
|
14
|
-
ref?: (elm: MdRef) => void;
|
|
15
|
-
xssOptions: {
|
|
16
|
-
whiteList: {
|
|
17
|
-
[key: string]: string[];
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
externalLink: {
|
|
21
|
-
[key: string]: (param?: string) => string;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
type MdRef = {
|
|
25
|
-
$paste: () => void;
|
|
26
|
-
markdownIt: MarkdownIt;
|
|
27
|
-
};
|
|
1
|
+
import '@toast-ui/editor/dist/toastui-editor-viewer.css';
|
|
2
|
+
import './view.postcss';
|
|
28
3
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
29
4
|
value: {
|
|
30
5
|
type: StringConstructor;
|