diff --git a/app/Models/WebSocketDialogMsg.php b/app/Models/WebSocketDialogMsg.php
index 2a67ca38d..895058d1d 100644
--- a/app/Models/WebSocketDialogMsg.php
+++ b/app/Models/WebSocketDialogMsg.php
@@ -305,9 +305,16 @@ class WebSocketDialogMsg extends AbstractModel
preg_match("/data-value=\"(.*?)\"/", $str, $matchValye);
$text = str_replace($matchs[0][$key], "[:{$matchChar[1]}:{$matchId[1]}:{$matchValye[1]}:]", $text);
}
+ // 处理链接
+ preg_match_all("/]*?href=([\"'])(.*?)\\1[^>]*?>([^<]*?)<\/a>/is", $text, $matchs);
+ foreach ($matchs[2] as $key => $str) {
+ $herf = $matchs[2][$key];
+ $title = $matchs[3][$key] ?: $herf;
+ $text = str_replace($matchs[0][$key], "{$title}", $text);
+ }
// 过滤标签
- $text = strip_tags($text, '
-
');
- $text = preg_replace("/\<(blockquote|strong|pre|ol|ul|li|em|p|s|u).*?\>/is", "<$1>", $text);
+ $text = strip_tags($text, ' -
');
+ $text = preg_replace("/\<(blockquote|strong|pre|ol|ul|li|em|p|s|u).*?\>/is", "<$1>", $text); // 不用去除a标签,上面已经处理过了
$text = preg_replace("/\[:IMAGE:(.*?):(.*?):(.*?):(.*?):(.*?):\]/i", "
", $text);
$text = preg_replace("/\[:@:(.*?):(.*?):\]/i", "@$2", $text);
$text = preg_replace("/\[:#:(.*?):(.*?):\]/i", "#$2", $text);
diff --git a/resources/assets/js/pages/manage/components/ChatInput/index.vue b/resources/assets/js/pages/manage/components/ChatInput/index.vue
index bf5291dcf..c4b552e59 100755
--- a/resources/assets/js/pages/manage/components/ChatInput/index.vue
+++ b/resources/assets/js/pages/manage/components/ChatInput/index.vue
@@ -372,9 +372,21 @@ export default {
// Clipboard Matcher (保留图片跟空格,清除其余所以样式)
this.quill.clipboard.addMatcher(Node.ELEMENT_NODE, (node, delta) => {
- delta.ops = delta.ops.map(op => ({
- insert: op.insert
- }))
+ delta.ops = delta.ops.map(op => {
+ console.log(op);
+ const obj = {
+ attributes: {},
+ insert: op.insert
+ };
+ if (op.attributes) {
+ ['bold', 'strike', 'italic', 'underline', 'list', 'blockquote', 'link'].some(item => {
+ if (op.attributes[item]) {
+ obj.attributes[item] = op.attributes[item]
+ }
+ })
+ }
+ return obj
+ })
return delta
})