paas-component-library 1.1.2 → 1.1.4
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/paas-ui.js +21926 -84098
- package/dist/paas-ui.umd.cjs +55 -856
- package/dist/style.css +1 -1
- package/package.json +1 -8
- package/src/components/MentionInput/index.vue +13 -16
- package/src/components/index.js +0 -11
- package/src/components/PaasMdEditor/index.vue +0 -89
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paas-component-library",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
"./PaasUploadModal": "./src/components/PaasUploadModal/index.vue",
|
|
33
33
|
"./PaasUpload": "./src/components/PaasUpload/index.vue",
|
|
34
34
|
"./PaasEditor": "./src/components/PaasEditor/index.vue",
|
|
35
|
-
"./PaasMdEditor": "./src/components/PaasMdEditor/index.vue",
|
|
36
35
|
"./PaasTreePanel": "./src/components/PaasTreePanel/index.vue",
|
|
37
36
|
"./PaasIcon": "./src/components/PaasIcon/index.vue",
|
|
38
37
|
"./PaasForm": "./src/components/PaasForm/index.vue",
|
|
@@ -74,12 +73,6 @@
|
|
|
74
73
|
"@codemirror/state": "^6.5.3",
|
|
75
74
|
"@codemirror/theme-one-dark": "^6.1.3",
|
|
76
75
|
"@codemirror/view": "^6.39.8",
|
|
77
|
-
"@toast-ui/editor-plugin-chart": "^3.0.1",
|
|
78
|
-
"@toast-ui/editor-plugin-code-syntax-highlight": "^3.1.0",
|
|
79
|
-
"@toast-ui/editor-plugin-color-syntax": "^3.1.0",
|
|
80
|
-
"@toast-ui/editor-plugin-table-merged-cell": "^3.1.0",
|
|
81
|
-
"@toast-ui/editor-plugin-uml": "^3.0.1",
|
|
82
|
-
"@toast-ui/vue-editor": "^3",
|
|
83
76
|
"@vueup/vue-quill": "^1.2.0",
|
|
84
77
|
"ant-design-vue": "4.x",
|
|
85
78
|
"axios": "^1.7.7",
|
|
@@ -434,7 +434,7 @@ export default {
|
|
|
434
434
|
}
|
|
435
435
|
|
|
436
436
|
// 创建完整的路径值和标签
|
|
437
|
-
const fullValue =
|
|
437
|
+
const fullValue = '${' + this.currentPathValues.join('.') + '}';
|
|
438
438
|
const fullLabel = this.currentPathLabels.join('/');
|
|
439
439
|
|
|
440
440
|
// 在当前位置插入标签(只在后方添加空格)
|
|
@@ -487,8 +487,8 @@ export default {
|
|
|
487
487
|
const spaceAfter = document.createTextNode(' ');
|
|
488
488
|
mentionEl.parentNode?.insertBefore(spaceAfter, mentionEl.nextSibling);
|
|
489
489
|
|
|
490
|
-
//
|
|
491
|
-
const cursorMarker = document.createTextNode('
|
|
490
|
+
// 在标签后插入空格作为光标位置
|
|
491
|
+
const cursorMarker = document.createTextNode(' ');
|
|
492
492
|
mentionEl.parentNode?.insertBefore(cursorMarker, spaceAfter.nextSibling);
|
|
493
493
|
|
|
494
494
|
// 设置光标位置
|
|
@@ -505,8 +505,8 @@ export default {
|
|
|
505
505
|
// 如果出现索引错误,使用替代方案
|
|
506
506
|
console.error("Error inserting mention tag:", e);
|
|
507
507
|
|
|
508
|
-
//
|
|
509
|
-
const cursorMarker = document.createTextNode('
|
|
508
|
+
// 创建空格用于光标定位
|
|
509
|
+
const cursorMarker = document.createTextNode(' ');
|
|
510
510
|
|
|
511
511
|
// 直接在光标位置插入整个HTML片段
|
|
512
512
|
const fragment = document.createDocumentFragment();
|
|
@@ -516,7 +516,7 @@ export default {
|
|
|
516
516
|
range.deleteContents();
|
|
517
517
|
range.insertNode(fragment);
|
|
518
518
|
|
|
519
|
-
//
|
|
519
|
+
// 设置光标到空格位置
|
|
520
520
|
const selection = window.getSelection();
|
|
521
521
|
if (selection) {
|
|
522
522
|
const cursorRange = document.createRange();
|
|
@@ -574,7 +574,7 @@ export default {
|
|
|
574
574
|
const text = textNode.textContent || '';
|
|
575
575
|
if (startOffset <= text.length) {
|
|
576
576
|
const prevChar = text[startOffset - 1];
|
|
577
|
-
if (prevChar === '
|
|
577
|
+
if (prevChar === ' ') { // 空格字符,光标位置标记
|
|
578
578
|
// 检查前一个节点是否是标签
|
|
579
579
|
const prevNode = textNode.previousSibling;
|
|
580
580
|
if (prevNode && prevNode.classList && prevNode.classList.contains('mention-tag')) {
|
|
@@ -798,7 +798,7 @@ export default {
|
|
|
798
798
|
}
|
|
799
799
|
} else if (target.classList.contains('mention-tag')) {
|
|
800
800
|
// 如果点击标签本身,将光标移到标签后
|
|
801
|
-
const cursorMarker = document.createTextNode('
|
|
801
|
+
const cursorMarker = document.createTextNode(' ');
|
|
802
802
|
target.parentNode?.insertBefore(cursorMarker, target.nextSibling);
|
|
803
803
|
|
|
804
804
|
const newRange = document.createRange();
|
|
@@ -825,11 +825,8 @@ export default {
|
|
|
825
825
|
let remainingText = value;
|
|
826
826
|
let lastIndex = 0;
|
|
827
827
|
|
|
828
|
-
// 匹配
|
|
829
|
-
|
|
830
|
-
// 支持格式:$aaa, $aaa.bbb, $xxx-bbb, $aaa_bb, $user_name.first-name 等
|
|
831
|
-
// 支持任意非空白字符(包括字母、数字、符号、中文、-、_ 等)
|
|
832
|
-
const mentionRegex = new RegExp(`\\${this.SAVE_SYMBOL}[^\\s]+(?=\\s|$)`, 'g');
|
|
828
|
+
// 匹配 ${xxx.xxx.xxx} 格式
|
|
829
|
+
const mentionRegex = /\$\{[^\}]+\}/g;
|
|
833
830
|
let match;
|
|
834
831
|
|
|
835
832
|
while ((match = mentionRegex.exec(remainingText)) !== null) {
|
|
@@ -841,7 +838,7 @@ export default {
|
|
|
841
838
|
|
|
842
839
|
// 创建标签
|
|
843
840
|
const fullMatch = match[0];
|
|
844
|
-
const pathWithoutPrefix = fullMatch.substring(
|
|
841
|
+
const pathWithoutPrefix = fullMatch.substring(2, fullMatch.length - 1); // 移除 ${ 和 }
|
|
845
842
|
|
|
846
843
|
// 从路径到名称的映射中获取标签名称
|
|
847
844
|
let label = this.pathToNameMap.get(pathWithoutPrefix) || pathWithoutPrefix;
|
|
@@ -861,8 +858,8 @@ export default {
|
|
|
861
858
|
htmlContent += this.convertTextToHtml(remaining);
|
|
862
859
|
}
|
|
863
860
|
|
|
864
|
-
//
|
|
865
|
-
htmlContent += '
|
|
861
|
+
// 在末尾添加空格作为光标位置
|
|
862
|
+
htmlContent += ' ';
|
|
866
863
|
|
|
867
864
|
// 将换行符转换为 <br> 标签以便在 contenteditable 中正确显示
|
|
868
865
|
this.inputRef.innerHTML = htmlContent.replace(/\n/g, '<br>');
|
package/src/components/index.js
CHANGED
|
@@ -2,14 +2,6 @@ import './style.css';
|
|
|
2
2
|
|
|
3
3
|
import '@vueup/vue-quill/dist/vue-quill.snow.css';
|
|
4
4
|
|
|
5
|
-
import '@toast-ui/chart/dist/toastui-chart.css';
|
|
6
|
-
import 'tui-color-picker/dist/tui-color-picker.css';
|
|
7
|
-
|
|
8
|
-
import '@toast-ui/editor-plugin-code-syntax-highlight/dist/toastui-editor-plugin-code-syntax-highlight.css';
|
|
9
|
-
import '@toast-ui/editor-plugin-color-syntax/dist/toastui-editor-plugin-color-syntax.css';
|
|
10
|
-
import '@toast-ui/editor-plugin-table-merged-cell/dist/toastui-editor-plugin-table-merged-cell.css';
|
|
11
|
-
import '@toast-ui/editor/dist/toastui-editor.css';
|
|
12
|
-
|
|
13
5
|
import PaasDate from "./PaasDate/index.vue";
|
|
14
6
|
import PaasMenu from "./PaasMenu/index.vue";
|
|
15
7
|
import MentionInput from "./MentionInput/index.vue";
|
|
@@ -31,7 +23,6 @@ import FormTextarea from "./form/FormTextarea/index.vue";
|
|
|
31
23
|
import FormRadio from "./form/FormRadio/index.vue";
|
|
32
24
|
import FormCheckbox from "./form/FormCheckbox/index.vue";
|
|
33
25
|
import PaasEditor from "./PaasEditor/index.vue";
|
|
34
|
-
import PaasMdEditor from "./PaasMdEditor/index.vue";
|
|
35
26
|
import PaasTreePanel from "./PaasTreePanel/index.vue";
|
|
36
27
|
import PaasIcon from "./PaasIcon/index.vue";
|
|
37
28
|
import PaasCodeEditor from "./PaasCodeEditor/index.vue";
|
|
@@ -68,7 +59,6 @@ const component = [
|
|
|
68
59
|
FormDateRange,
|
|
69
60
|
PaasUpload,
|
|
70
61
|
PaasEditor,
|
|
71
|
-
PaasMdEditor,
|
|
72
62
|
PaasTreePanel,
|
|
73
63
|
PaasForm,
|
|
74
64
|
FormTextarea,
|
|
@@ -118,7 +108,6 @@ export {
|
|
|
118
108
|
FormDateRange,
|
|
119
109
|
PaasUpload,
|
|
120
110
|
PaasEditor,
|
|
121
|
-
PaasMdEditor,
|
|
122
111
|
PaasTreePanel,
|
|
123
112
|
PaasForm,
|
|
124
113
|
FormTextarea,
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div ref="editorRef"></div>
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script>
|
|
6
|
-
import '@toast-ui/editor/dist/i18n/zh-cn';
|
|
7
|
-
import Editor from '@toast-ui/editor';
|
|
8
|
-
|
|
9
|
-
//uml插件
|
|
10
|
-
import uml from '@toast-ui/editor-plugin-uml';
|
|
11
|
-
//代码高亮插件
|
|
12
|
-
import codeSyntaxHighlight from '@toast-ui/editor-plugin-code-syntax-highlight';
|
|
13
|
-
//图表插件
|
|
14
|
-
import chart from '@toast-ui/editor-plugin-chart';
|
|
15
|
-
//文本颜色选择插件
|
|
16
|
-
import colorSyntax from '@toast-ui/editor-plugin-color-syntax';
|
|
17
|
-
//表格合并插件
|
|
18
|
-
import tableMergedCell from '@toast-ui/editor-plugin-table-merged-cell';
|
|
19
|
-
|
|
20
|
-
export default {
|
|
21
|
-
name: 'PaasMdEditor',
|
|
22
|
-
computed: {
|
|
23
|
-
see() {
|
|
24
|
-
return this.$store?.forms?.see || false;
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
props: {
|
|
28
|
-
height: {
|
|
29
|
-
type: String,
|
|
30
|
-
default: '55vh'
|
|
31
|
-
},
|
|
32
|
-
modelValue: {
|
|
33
|
-
type: String,
|
|
34
|
-
default: ''
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
emits: ['update:modelValue'],
|
|
38
|
-
data() {
|
|
39
|
-
return {
|
|
40
|
-
editorInstance: null,
|
|
41
|
-
hostname: window.location.protocol + '//' + window.location.host,
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
mounted() {
|
|
45
|
-
const editorContainer = this.$refs.editorRef;
|
|
46
|
-
let markdown = '';
|
|
47
|
-
if (this.modelValue) {
|
|
48
|
-
markdown = this.modelValue.replace("$hostname", this.hostname);
|
|
49
|
-
}
|
|
50
|
-
this.editorInstance = new Editor({
|
|
51
|
-
el: editorContainer,
|
|
52
|
-
height: this.height,
|
|
53
|
-
previewStyle: 'vertical',
|
|
54
|
-
initialEditType: 'wysiwyg',
|
|
55
|
-
initialValue: markdown,
|
|
56
|
-
language: 'zh-CN',
|
|
57
|
-
usageStatistics: false,
|
|
58
|
-
readOnly: this.see,
|
|
59
|
-
plugins: this.see ? [] : [codeSyntaxHighlight, chart, uml, colorSyntax, tableMergedCell],
|
|
60
|
-
hooks: this.see ? {} : {
|
|
61
|
-
addImageBlobHook: async (blob, callback) => {
|
|
62
|
-
let url;
|
|
63
|
-
const uploadUrl = "/system/open/minio/image/uploadFile";
|
|
64
|
-
const formData = new FormData();
|
|
65
|
-
formData.append('file', blob, blob.name || 'image.png');
|
|
66
|
-
let res = await this.$upload(uploadUrl, formData);
|
|
67
|
-
if (res.data.code == this.$success) {
|
|
68
|
-
this.$message.success(res.data.msg);
|
|
69
|
-
url = res.data.data.newName;
|
|
70
|
-
}
|
|
71
|
-
callback(this.hostname + '/system/open/minio/preview?filename=' + url, blob.name || '图片');
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
this.editorInstance.on('change', () => {
|
|
77
|
-
let markdown = this.editorInstance.getMarkdown();
|
|
78
|
-
|
|
79
|
-
markdown = markdown.replace(this.hostname, "$hostname");
|
|
80
|
-
if (markdown !== this.modelValue) {
|
|
81
|
-
this.$emit('update:modelValue', markdown);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
},
|
|
85
|
-
beforeDestroy() {
|
|
86
|
-
this.editorInstance && this.editorInstance.destroy();
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
</script>
|