@blueking/ai-ui-sdk 0.2.0-beta.20 → 0.2.0-beta.21
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.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-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 +19 -0
- package/dist/components/render-markdown/common.ts.js +41 -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 +226 -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/{mark-down.d.ts → view.d.ts} +2 -27
- package/dist/components/render-markdown/view.postcss.css +91 -0
- package/dist/components/render-markdown/view.ts.js +116 -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 +0 -4
- package/dist/hooks/use-form-leave-confirm.ts.js +2 -0
- package/package.json +7 -4
- 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
|
@@ -0,0 +1,226 @@
|
|
|
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
|
+
import { defineComponent, h, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
30
|
+
import Editor from '@toast-ui/editor';
|
|
31
|
+
import { commonConfig } from './common.ts.js';
|
|
32
|
+
import '@toast-ui/editor/dist/toastui-editor.css';
|
|
33
|
+
import './edit.postcss.css';
|
|
34
|
+
var EditorMode;
|
|
35
|
+
(function(EditorMode) {
|
|
36
|
+
EditorMode["Markdown"] = "markdown";
|
|
37
|
+
EditorMode["Wysiwyg"] = "wysiwyg";
|
|
38
|
+
})(EditorMode || (EditorMode = {}));
|
|
39
|
+
export default defineComponent({
|
|
40
|
+
props: {
|
|
41
|
+
modelValue: {
|
|
42
|
+
type: String
|
|
43
|
+
},
|
|
44
|
+
placeholder: {
|
|
45
|
+
type: String
|
|
46
|
+
},
|
|
47
|
+
height: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: '500px'
|
|
50
|
+
},
|
|
51
|
+
disabled: {
|
|
52
|
+
type: Boolean
|
|
53
|
+
},
|
|
54
|
+
fontSize: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: '14px'
|
|
57
|
+
},
|
|
58
|
+
backgroundColor: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: '#fff'
|
|
61
|
+
},
|
|
62
|
+
mode: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: "wysiwyg"
|
|
65
|
+
},
|
|
66
|
+
isSimpleToolbar: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: false
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
emits: {
|
|
72
|
+
'update:modelValue': (value)=>value
|
|
73
|
+
},
|
|
74
|
+
setup (props, { emit }) {
|
|
75
|
+
const editorRef = ref();
|
|
76
|
+
let editor;
|
|
77
|
+
const handleChange = ()=>{
|
|
78
|
+
const value = (editor === null || editor === void 0 ? void 0 : editor.getMarkdown()) || '';
|
|
79
|
+
emit('update:modelValue', value);
|
|
80
|
+
};
|
|
81
|
+
const handleInit = ()=>{
|
|
82
|
+
const defaultMode = props.mode || "wysiwyg";
|
|
83
|
+
// 切换模式按钮
|
|
84
|
+
const modeSwitchEl = document.createElement('section');
|
|
85
|
+
modeSwitchEl.className = 'toastui-editor-toolbar-custom-button g-cursor-pointer';
|
|
86
|
+
modeSwitchEl.innerHTML = '<i class="bkaidev-icon bkaidev-qiehuan g-mr-4 g-text-16"></i>切换代码模式';
|
|
87
|
+
modeSwitchEl.dataset.mode = defaultMode;
|
|
88
|
+
modeSwitchEl.addEventListener('click', ()=>{
|
|
89
|
+
const mode = modeSwitchEl.dataset.mode;
|
|
90
|
+
if (mode === "markdown") {
|
|
91
|
+
editor.changeMode("wysiwyg");
|
|
92
|
+
modeSwitchEl.dataset.mode = "wysiwyg";
|
|
93
|
+
modeSwitchEl.innerHTML = '<i class="bkaidev-icon bkaidev-qiehuan g-mr-4 g-text-16"></i>切换代码模式';
|
|
94
|
+
} else {
|
|
95
|
+
editor.changeMode("markdown");
|
|
96
|
+
modeSwitchEl.dataset.mode = "markdown";
|
|
97
|
+
modeSwitchEl.innerHTML = '<i class="bkaidev-icon bkaidev-qiehuan g-mr-4 g-text-16"></i>切换富文本模式';
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
// 全屏按钮复用 use-click-proxy 的全局 full-screen 代理。
|
|
101
|
+
const fullScreenEl = document.createElement('section');
|
|
102
|
+
fullScreenEl.className = 'toastui-editor-toolbar-custom-button g-cursor-pointer g-ml-12';
|
|
103
|
+
fullScreenEl.innerHTML = [
|
|
104
|
+
'<span class="click-full-screen">',
|
|
105
|
+
'<i class="ai-ui-sdk-icon ai-ui-sdk-full-screen g-mr-4 g-text-14"></i>全屏',
|
|
106
|
+
'</span>',
|
|
107
|
+
'<span class="click-un-full-screen">',
|
|
108
|
+
'<i class="ai-ui-sdk-icon ai-ui-sdk-un-full-screen g-mr-4 g-text-14"></i>取消全屏',
|
|
109
|
+
'</span>'
|
|
110
|
+
].join('');
|
|
111
|
+
// 初始化编辑器
|
|
112
|
+
editor = new Editor(_object_spread({
|
|
113
|
+
el: editorRef.value,
|
|
114
|
+
initialEditType: defaultMode,
|
|
115
|
+
previewStyle: 'vertical',
|
|
116
|
+
hideModeSwitch: true,
|
|
117
|
+
autofocus: false,
|
|
118
|
+
toolbarItems: [
|
|
119
|
+
[
|
|
120
|
+
'heading',
|
|
121
|
+
'bold',
|
|
122
|
+
'italic',
|
|
123
|
+
'strike'
|
|
124
|
+
],
|
|
125
|
+
...props.isSimpleToolbar ? [] : [
|
|
126
|
+
[
|
|
127
|
+
'hr',
|
|
128
|
+
'quote'
|
|
129
|
+
],
|
|
130
|
+
[
|
|
131
|
+
'ul',
|
|
132
|
+
'ol',
|
|
133
|
+
'task',
|
|
134
|
+
'indent',
|
|
135
|
+
'outdent'
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
'table',
|
|
139
|
+
'image',
|
|
140
|
+
'link'
|
|
141
|
+
],
|
|
142
|
+
[
|
|
143
|
+
'code',
|
|
144
|
+
'codeblock'
|
|
145
|
+
]
|
|
146
|
+
],
|
|
147
|
+
[
|
|
148
|
+
{
|
|
149
|
+
name: 'modeSwitch',
|
|
150
|
+
el: modeSwitchEl
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: 'fullScreen',
|
|
154
|
+
el: fullScreenEl
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
],
|
|
158
|
+
placeholder: props.placeholder,
|
|
159
|
+
initialValue: props.modelValue || '',
|
|
160
|
+
height: props.height,
|
|
161
|
+
events: {
|
|
162
|
+
change: handleChange
|
|
163
|
+
}
|
|
164
|
+
}, commonConfig));
|
|
165
|
+
};
|
|
166
|
+
const handleDestroy = ()=>{
|
|
167
|
+
editor.destroy();
|
|
168
|
+
editor = null;
|
|
169
|
+
};
|
|
170
|
+
const handleDisabled = ()=>{
|
|
171
|
+
const root = editorRef.value;
|
|
172
|
+
const editContent = root.querySelector('.ww-mode [contenteditable]');
|
|
173
|
+
const toolbar = root.querySelector('.toastui-editor-toolbar');
|
|
174
|
+
// 禁用事件
|
|
175
|
+
if (root) {
|
|
176
|
+
const stopEvent = (event)=>{
|
|
177
|
+
event.preventDefault();
|
|
178
|
+
event.stopPropagation();
|
|
179
|
+
event.stopImmediatePropagation();
|
|
180
|
+
};
|
|
181
|
+
if (props.disabled) {
|
|
182
|
+
root.addEventListener('beforeinput', stopEvent, true);
|
|
183
|
+
root.addEventListener('input', stopEvent, true);
|
|
184
|
+
root.addEventListener('paste', stopEvent, true);
|
|
185
|
+
root.addEventListener('cut', stopEvent, true);
|
|
186
|
+
root.addEventListener('drop', stopEvent, true);
|
|
187
|
+
root.addEventListener('compositionstart', stopEvent, true);
|
|
188
|
+
} else {
|
|
189
|
+
root.removeEventListener('beforeinput', stopEvent, true);
|
|
190
|
+
root.removeEventListener('input', stopEvent, true);
|
|
191
|
+
root.removeEventListener('paste', stopEvent, true);
|
|
192
|
+
root.removeEventListener('cut', stopEvent, true);
|
|
193
|
+
root.removeEventListener('drop', stopEvent, true);
|
|
194
|
+
root.removeEventListener('compositionstart', stopEvent, true);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (editContent) {
|
|
198
|
+
// 设置样式
|
|
199
|
+
editContent.setAttribute('contenteditable', String(!props.disabled));
|
|
200
|
+
editContent.style.cursor = props.disabled ? 'not-allowed' : 'auto';
|
|
201
|
+
}
|
|
202
|
+
if (toolbar) {
|
|
203
|
+
toolbar.style.pointerEvents = props.disabled ? 'none' : 'auto';
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
watch(()=>props.modelValue, (value)=>{
|
|
207
|
+
if (!editor) return;
|
|
208
|
+
if (value !== editor.getMarkdown()) {
|
|
209
|
+
editor.setMarkdown(value || '');
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
onMounted(()=>{
|
|
213
|
+
handleInit();
|
|
214
|
+
handleDisabled();
|
|
215
|
+
});
|
|
216
|
+
onBeforeUnmount(handleDestroy);
|
|
217
|
+
watch(()=>props.disabled, handleDisabled);
|
|
218
|
+
return ()=>h('section', {
|
|
219
|
+
ref: editorRef,
|
|
220
|
+
class: `full-screen-wrap ${props.disabled ? 'is-disabled' : ''}`,
|
|
221
|
+
style: {
|
|
222
|
+
backgroundColor: props.backgroundColor
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
});
|
|
@@ -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
|
+
});
|
|
@@ -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;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
.aidev-markdown-preview .toastui-editor-contents,
|
|
2
|
+
.toastui-editor .toastui-editor-contents,
|
|
3
|
+
.toastui-editor-md-preview .toastui-editor-contents {
|
|
4
|
+
font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.aidev-markdown-preview .toastui-editor-contents pre, .toastui-editor .toastui-editor-contents pre, .toastui-editor-md-preview .toastui-editor-contents pre {
|
|
8
|
+
max-height: 500px;
|
|
9
|
+
overflow-y: auto;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.aidev-markdown-preview .toastui-editor-contents pre::-webkit-scrollbar, .toastui-editor .toastui-editor-contents pre::-webkit-scrollbar, .toastui-editor-md-preview .toastui-editor-contents pre::-webkit-scrollbar {
|
|
13
|
+
width: 6px;
|
|
14
|
+
height: 6px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.aidev-markdown-preview .toastui-editor-contents pre::-webkit-scrollbar-thumb, .toastui-editor .toastui-editor-contents pre::-webkit-scrollbar-thumb, .toastui-editor-md-preview .toastui-editor-contents pre::-webkit-scrollbar-thumb {
|
|
18
|
+
width: 6px;
|
|
19
|
+
height: 6px;
|
|
20
|
+
border-radius: 3px;
|
|
21
|
+
background-color: #dcdee5;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.aidev-markdown-preview .toastui-editor-contents pre::-webkit-scrollbar-thumb:hover, .toastui-editor .toastui-editor-contents pre::-webkit-scrollbar-thumb:hover, .toastui-editor-md-preview .toastui-editor-contents pre::-webkit-scrollbar-thumb:hover {
|
|
25
|
+
background-color: #979ba5;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.aidev-markdown-preview .toastui-editor-contents code, .toastui-editor .toastui-editor-contents code, .toastui-editor-md-preview .toastui-editor-contents code {
|
|
29
|
+
font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.aidev-markdown-preview .toastui-editor-contents p,
|
|
33
|
+
.aidev-markdown-preview .toastui-editor-contents td,
|
|
34
|
+
.toastui-editor .toastui-editor-contents p,
|
|
35
|
+
.toastui-editor .toastui-editor-contents td,
|
|
36
|
+
.toastui-editor-md-preview .toastui-editor-contents p,
|
|
37
|
+
.toastui-editor-md-preview .toastui-editor-contents td {
|
|
38
|
+
color: #4d4f56;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.aidev-markdown-preview .toastui-editor-contents h1, .toastui-editor .toastui-editor-contents h1, .toastui-editor-md-preview .toastui-editor-contents h1 {
|
|
42
|
+
margin: 32px 0 20px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.aidev-markdown-preview .toastui-editor-contents h2, .toastui-editor .toastui-editor-contents h2, .toastui-editor-md-preview .toastui-editor-contents h2 {
|
|
46
|
+
margin: 24px 0 16px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.aidev-markdown-preview .toastui-editor-contents h3, .toastui-editor .toastui-editor-contents h3, .toastui-editor-md-preview .toastui-editor-contents h3 {
|
|
50
|
+
margin: 18px 0 12px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.aidev-markdown-preview .toastui-editor-contents h4, .toastui-editor .toastui-editor-contents h4, .toastui-editor-md-preview .toastui-editor-contents h4 {
|
|
54
|
+
margin: 14px 0 8px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.aidev-markdown-preview .toastui-editor-contents h5,
|
|
58
|
+
.aidev-markdown-preview .toastui-editor-contents h6,
|
|
59
|
+
.toastui-editor .toastui-editor-contents h5,
|
|
60
|
+
.toastui-editor .toastui-editor-contents h6,
|
|
61
|
+
.toastui-editor-md-preview .toastui-editor-contents h5,
|
|
62
|
+
.toastui-editor-md-preview .toastui-editor-contents h6 {
|
|
63
|
+
margin: 10px 0 4px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.aidev-markdown-preview .toastui-editor-contents i, .toastui-editor .toastui-editor-contents i, .toastui-editor-md-preview .toastui-editor-contents i {
|
|
67
|
+
font-style: normal;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.aidev-markdown-preview .toastui-editor-contents table th, .toastui-editor .toastui-editor-contents table th, .toastui-editor-md-preview .toastui-editor-contents table th {
|
|
71
|
+
background-color: #f5f7fa;
|
|
72
|
+
color: #4d4f56;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.aidev-markdown-preview .toastui-editor-contents .markdown-code-copy-wrap, .toastui-editor .toastui-editor-contents .markdown-code-copy-wrap, .toastui-editor-md-preview .toastui-editor-contents .markdown-code-copy-wrap {
|
|
76
|
+
position: relative;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.aidev-markdown-preview .toastui-editor-contents .markdown-code-copy-button, .toastui-editor .toastui-editor-contents .markdown-code-copy-button, .toastui-editor-md-preview .toastui-editor-contents .markdown-code-copy-button {
|
|
80
|
+
position: absolute;
|
|
81
|
+
top: 4px;
|
|
82
|
+
right: 8px;
|
|
83
|
+
font-size: 14px;
|
|
84
|
+
color: #979ba5;
|
|
85
|
+
cursor: pointer;
|
|
86
|
+
user-select: none;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.aidev-markdown-preview .toastui-editor-contents .markdown-code-copy-button:hover, .toastui-editor .toastui-editor-contents .markdown-code-copy-button:hover, .toastui-editor-md-preview .toastui-editor-contents .markdown-code-copy-button:hover {
|
|
90
|
+
color: #313238;
|
|
91
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
import { defineComponent, h, onMounted, onUnmounted, ref, watch } from 'vue';
|
|
30
|
+
import { filterXss } from '@blueking/xss-filter';
|
|
31
|
+
import Viewer from '@toast-ui/editor/dist/toastui-editor-viewer';
|
|
32
|
+
import { commonConfig } from './common.ts.js';
|
|
33
|
+
import '@toast-ui/editor/dist/toastui-editor-viewer.css';
|
|
34
|
+
import './view.postcss.css';
|
|
35
|
+
export default defineComponent({
|
|
36
|
+
props: {
|
|
37
|
+
value: {
|
|
38
|
+
type: String
|
|
39
|
+
},
|
|
40
|
+
previewBackground: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: '#fff'
|
|
43
|
+
},
|
|
44
|
+
padding: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: '12px 16px'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
setup (props) {
|
|
50
|
+
const viewerRef = ref();
|
|
51
|
+
let viewer;
|
|
52
|
+
const handleInit = ()=>{
|
|
53
|
+
viewer = new Viewer(_object_spread({
|
|
54
|
+
el: viewerRef.value,
|
|
55
|
+
initialValue: props.value,
|
|
56
|
+
customHTMLSanitizer: (html)=>filterXss(html, {
|
|
57
|
+
whiteList: {
|
|
58
|
+
a: [
|
|
59
|
+
'href',
|
|
60
|
+
'target',
|
|
61
|
+
'class',
|
|
62
|
+
'title'
|
|
63
|
+
],
|
|
64
|
+
section: [
|
|
65
|
+
'class'
|
|
66
|
+
],
|
|
67
|
+
i: [
|
|
68
|
+
'class'
|
|
69
|
+
],
|
|
70
|
+
span: [
|
|
71
|
+
'class',
|
|
72
|
+
'data-variable-index'
|
|
73
|
+
],
|
|
74
|
+
svg: [
|
|
75
|
+
'class'
|
|
76
|
+
],
|
|
77
|
+
use: [
|
|
78
|
+
'href'
|
|
79
|
+
],
|
|
80
|
+
ul: [
|
|
81
|
+
'class'
|
|
82
|
+
],
|
|
83
|
+
li: [
|
|
84
|
+
'class',
|
|
85
|
+
'title'
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
onTagAttr: (_tag, name, value)=>{
|
|
89
|
+
if (name === 'data-nodeid') {
|
|
90
|
+
return `${name}="${value}"`;
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
}, commonConfig));
|
|
96
|
+
};
|
|
97
|
+
const handleDestroy = ()=>{
|
|
98
|
+
viewer.destroy();
|
|
99
|
+
viewer = null;
|
|
100
|
+
};
|
|
101
|
+
watch(()=>props.value, (value)=>{
|
|
102
|
+
if (!viewer) return;
|
|
103
|
+
viewer.setMarkdown(value || '');
|
|
104
|
+
});
|
|
105
|
+
onMounted(handleInit);
|
|
106
|
+
onUnmounted(handleDestroy);
|
|
107
|
+
return ()=>h('section', {
|
|
108
|
+
ref: viewerRef,
|
|
109
|
+
class: 'g-height-full g-scrollbar aidev-markdown-preview',
|
|
110
|
+
style: {
|
|
111
|
+
'background-color': props.previewBackground,
|
|
112
|
+
padding: props.padding
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
.router-tab[data-v-
|
|
2
|
+
.router-tab[data-v-or6whvdj] {
|
|
3
3
|
margin-top: 2px;
|
|
4
4
|
height: 42px;
|
|
5
5
|
background: #FFFFFF;
|
|
6
6
|
box-shadow: 0 2px 4px 0 #1919290d;
|
|
7
7
|
padding: 0 24px;
|
|
8
8
|
}
|
|
9
|
-
.router-tab a[data-v-
|
|
9
|
+
.router-tab a[data-v-or6whvdj] {
|
|
10
10
|
padding: 0 8px;
|
|
11
11
|
margin-right: 24px;
|
|
12
12
|
font-size: 14px;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
color: #4D4F56;
|
|
16
16
|
box-sizing: border-box;
|
|
17
17
|
}
|
|
18
|
-
.router-tab a.router-link-exact-active[data-v-
|
|
18
|
+
.router-tab a.router-link-exact-active[data-v-or6whvdj] {
|
|
19
19
|
color: #3A84FF;
|
|
20
20
|
border-bottom: 2px solid #3A84FF;
|
|
21
21
|
}
|