@evolvere/sgp-ui 1.6.9 → 1.6.10
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/lib/alert.js +2 -2
- package/lib/aside.js +2 -2
- package/lib/autocomplete.js +4 -4
- package/lib/avatar.js +2 -2
- package/lib/backtop.js +4 -4
- package/lib/badge.js +2 -2
- package/lib/breadcrumb-item.js +2 -2
- package/lib/breadcrumb.js +2 -2
- package/lib/button-group.js +2 -2
- package/lib/button.js +2 -2
- package/lib/calendar.js +6 -6
- package/lib/card.js +2 -2
- package/lib/carousel-item.js +2 -2
- package/lib/carousel.js +4 -4
- package/lib/cascader-panel.js +12 -12
- package/lib/cascader.js +13 -13
- package/lib/checkbox-button.js +9 -9
- package/lib/checkbox-group.js +9 -9
- package/lib/checkbox.js +2 -2
- package/lib/col.js +2 -2
- package/lib/collapse-item.js +7 -7
- package/lib/collapse.js +2 -2
- package/lib/color-picker.js +2 -2
- package/lib/container.js +2 -2
- package/lib/date-picker.js +10 -10
- package/lib/descriptions-item.js +2 -2
- package/lib/descriptions.js +2 -2
- package/lib/dialog.js +2 -2
- package/lib/divider.js +2 -2
- package/lib/drawer.js +2 -2
- package/lib/dropdown-item.js +2 -2
- package/lib/dropdown-menu.js +2 -2
- package/lib/dropdown.js +4 -4
- package/lib/editor.js +258 -32
- package/lib/empty.js +2 -2
- package/lib/footer.js +2 -2
- package/lib/form-item.js +4 -4
- package/lib/form.js +2 -2
- package/lib/header.js +2 -2
- package/lib/icon.js +2 -2
- package/lib/image.js +4 -4
- package/lib/index.js +1 -1
- package/lib/infinite-scroll.js +2 -2
- package/lib/input-number.js +6 -6
- package/lib/input.js +4 -4
- package/lib/link.js +2 -2
- package/lib/loading.js +4 -4
- package/lib/main.js +2 -2
- package/lib/menu-item-group.js +2 -2
- package/lib/menu-item.js +6 -6
- package/lib/menu.js +2 -2
- package/lib/message-box.js +6 -6
- package/lib/message.js +4 -4
- package/lib/notification.js +4 -4
- package/lib/option-group.js +2 -2
- package/lib/option.js +4 -4
- package/lib/page-header.js +2 -2
- package/lib/pagination.js +6 -6
- package/lib/popconfirm.js +4 -4
- package/lib/popover.js +2 -2
- package/lib/progress.js +2 -2
- package/lib/radio-button.js +2 -2
- package/lib/radio-group.js +2 -2
- package/lib/radio.js +2 -2
- package/lib/rate.js +2 -2
- package/lib/rdc-sgp-ui.common.js +321 -97
- package/lib/result.js +2 -2
- package/lib/row.js +2 -2
- package/lib/scrollbar.js +4 -4
- package/lib/select.js +15 -15
- package/lib/skeleton-item.js +2 -2
- package/lib/skeleton.js +2 -2
- package/lib/slider.js +6 -6
- package/lib/spinner.js +2 -2
- package/lib/step.js +2 -2
- package/lib/steps.js +2 -2
- package/lib/submenu.js +6 -6
- package/lib/switch.js +4 -4
- package/lib/tab-pane.js +2 -2
- package/lib/table-column.js +2 -2
- package/lib/table.js +19 -17
- package/lib/tabs.js +2 -2
- package/lib/tag.js +2 -2
- package/lib/time-picker.js +11 -11
- package/lib/time-select.js +6 -6
- package/lib/timeline-item.js +2 -2
- package/lib/timeline.js +2 -2
- package/lib/tooltip.js +2 -2
- package/lib/transfer.js +4 -4
- package/lib/tree.js +7 -7
- package/lib/upload.js +10 -10
- package/package.json +3 -1
- package/packages/editor/src/html-security.js +180 -0
- package/packages/editor/src/index.vue +68 -15
- package/packages/editor/src/video-security.js +1 -0
- package/packages/theme-chalk/package.json +1 -1
- package/src/index.js +1 -1
|
@@ -3,15 +3,23 @@
|
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script>
|
|
6
|
+
import {
|
|
7
|
+
MAX_IMAGE_COUNT,
|
|
8
|
+
MAX_IMAGE_SIZE,
|
|
9
|
+
isSafeLink,
|
|
10
|
+
isSafeMediaSource,
|
|
11
|
+
sanitizeEditorHtml,
|
|
12
|
+
validateImageFiles
|
|
13
|
+
} from './html-security';
|
|
6
14
|
import { validateOnlineVideo } from './video-security';
|
|
7
15
|
|
|
8
|
-
let signIsEditorChange = true;
|
|
9
16
|
export default {
|
|
10
17
|
name: 'ElEditor',
|
|
11
18
|
data() {
|
|
12
19
|
return {
|
|
13
20
|
editor: null,
|
|
14
|
-
editorData: ''
|
|
21
|
+
editorData: '',
|
|
22
|
+
isEditorChange: true
|
|
15
23
|
};
|
|
16
24
|
},
|
|
17
25
|
props: {
|
|
@@ -69,7 +77,8 @@ export default {
|
|
|
69
77
|
editor.config.uploadImgServer = '/apiv2/nfs/file/upload/wangEditor';
|
|
70
78
|
}
|
|
71
79
|
editor.config.showLinkImg = false;
|
|
72
|
-
editor.config.uploadImgMaxSize =
|
|
80
|
+
editor.config.uploadImgMaxSize = MAX_IMAGE_SIZE;
|
|
81
|
+
editor.config.uploadImgMaxLength = MAX_IMAGE_COUNT;
|
|
73
82
|
editor.config.emotions = [
|
|
74
83
|
{
|
|
75
84
|
title: 'emoji',
|
|
@@ -83,6 +92,46 @@ export default {
|
|
|
83
92
|
...this.options
|
|
84
93
|
};
|
|
85
94
|
|
|
95
|
+
const customPasteTextHandle = editor.config.pasteTextHandle;
|
|
96
|
+
const customLinkCheck = editor.config.linkCheck;
|
|
97
|
+
const customLinkImgCheck = editor.config.linkImgCheck;
|
|
98
|
+
const customUploadImgBefore = editor.config.uploadImgHooks && editor.config.uploadImgHooks.before;
|
|
99
|
+
|
|
100
|
+
// Security-sensitive settings cannot be relaxed through component options.
|
|
101
|
+
editor.config.uploadImgServer = '/apiv2/nfs/file/upload/wangEditor';
|
|
102
|
+
editor.config.uploadImgShowBase64 = false;
|
|
103
|
+
editor.config.showLinkImg = false;
|
|
104
|
+
editor.config.uploadImgAccept = ['jpg', 'jpeg', 'png', 'gif'];
|
|
105
|
+
editor.config.uploadImgMaxSize = MAX_IMAGE_SIZE;
|
|
106
|
+
editor.config.uploadImgMaxLength = MAX_IMAGE_COUNT;
|
|
107
|
+
editor.config.withCredentials = true;
|
|
108
|
+
editor.config.pasteTextHandle = content => sanitizeEditorHtml(
|
|
109
|
+
typeof customPasteTextHandle === 'function' ? customPasteTextHandle(content) : content
|
|
110
|
+
);
|
|
111
|
+
editor.config.linkCheck = (text, link) => {
|
|
112
|
+
if (!isSafeLink(link)) return '链接地址不安全,仅支持 http、https、mailto 和 tel';
|
|
113
|
+
return typeof customLinkCheck === 'function' ? customLinkCheck(text, link) : true;
|
|
114
|
+
};
|
|
115
|
+
editor.config.linkImgCheck = (src, alt, href) => {
|
|
116
|
+
if (!isSafeMediaSource(src) || (href && !isSafeLink(href))) {
|
|
117
|
+
return '图片地址不安全';
|
|
118
|
+
}
|
|
119
|
+
return typeof customLinkImgCheck === 'function'
|
|
120
|
+
? customLinkImgCheck(src, alt, href)
|
|
121
|
+
: true;
|
|
122
|
+
};
|
|
123
|
+
editor.config.uploadImgHooks = {
|
|
124
|
+
...editor.config.uploadImgHooks,
|
|
125
|
+
before: (xhr, currentEditor, files) => {
|
|
126
|
+
if (!validateImageFiles(files)) {
|
|
127
|
+
return {prevent: true, msg: '仅允许上传 10 张以内、单张不超过 5MB 的 JPG、PNG 或 GIF 图片'};
|
|
128
|
+
}
|
|
129
|
+
return typeof customUploadImgBefore === 'function'
|
|
130
|
+
? customUploadImgBefore(xhr, currentEditor, files)
|
|
131
|
+
: undefined;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
86
135
|
// wangEditor 4 inserts online-video markup with insertHTML. Always run the
|
|
87
136
|
// built-in security check before an optional consumer-provided validator.
|
|
88
137
|
const customOnlineVideoCheck = editor.config.onlineVideoCheck;
|
|
@@ -95,29 +144,27 @@ export default {
|
|
|
95
144
|
};
|
|
96
145
|
|
|
97
146
|
editor.config.onchange = newHtml => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
this.$emit('input',
|
|
147
|
+
const safeHtml = sanitizeEditorHtml(newHtml);
|
|
148
|
+
this.isEditorChange = false;
|
|
149
|
+
this.$emit('input', safeHtml);
|
|
101
150
|
this.$nextTick(() => {
|
|
102
|
-
|
|
151
|
+
this.isEditorChange = true;
|
|
103
152
|
});
|
|
104
|
-
this.$emit('change', {html:
|
|
153
|
+
this.$emit('change', {html: safeHtml, text: editor.txt.text(), editor});
|
|
105
154
|
};
|
|
106
155
|
|
|
107
156
|
editor.config.onblur = newHtml => {
|
|
108
|
-
|
|
109
|
-
this.$emit('blur', {html: newHtml, text: editor.txt.text(), editor});
|
|
157
|
+
this.$emit('blur', {html: sanitizeEditorHtml(newHtml), text: editor.txt.text(), editor});
|
|
110
158
|
};
|
|
111
159
|
|
|
112
160
|
editor.config.onfocus = newHtml => {
|
|
113
|
-
|
|
114
|
-
this.$emit('focus', {html: newHtml, text: editor.txt.text(), editor});
|
|
161
|
+
this.$emit('focus', {html: sanitizeEditorHtml(newHtml), text: editor.txt.text(), editor});
|
|
115
162
|
};
|
|
116
163
|
|
|
117
164
|
editor.create();
|
|
118
165
|
|
|
119
166
|
const initValue = (this.value !== undefined && this.value !== null) ? this.value : this.content;
|
|
120
|
-
editor.txt.html(initValue);
|
|
167
|
+
editor.txt.html(sanitizeEditorHtml(initValue || ''));
|
|
121
168
|
if (this.disabled) {
|
|
122
169
|
editor.disable();
|
|
123
170
|
}
|
|
@@ -135,10 +182,16 @@ export default {
|
|
|
135
182
|
}
|
|
136
183
|
},
|
|
137
184
|
value() {
|
|
138
|
-
if (this.editor &&
|
|
139
|
-
this.editor.txt.html(this.value);
|
|
185
|
+
if (this.editor && this.isEditorChange) {
|
|
186
|
+
this.editor.txt.html(sanitizeEditorHtml(this.value || ''));
|
|
140
187
|
}
|
|
141
188
|
}
|
|
189
|
+
},
|
|
190
|
+
beforeDestroy() {
|
|
191
|
+
if (this.editor) {
|
|
192
|
+
this.editor.destroy();
|
|
193
|
+
this.editor = null;
|
|
194
|
+
}
|
|
142
195
|
}
|
|
143
196
|
};
|
|
144
197
|
</script>
|