mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-06 21:45:36 +00:00
perf: 保留粘贴的a标签
This commit is contained in:
parent
965895de5c
commit
66a5428ec5
@ -305,9 +305,16 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
preg_match("/data-value=\"(.*?)\"/", $str, $matchValye);
|
preg_match("/data-value=\"(.*?)\"/", $str, $matchValye);
|
||||||
$text = str_replace($matchs[0][$key], "[:{$matchChar[1]}:{$matchId[1]}:{$matchValye[1]}:]", $text);
|
$text = str_replace($matchs[0][$key], "[:{$matchChar[1]}:{$matchId[1]}:{$matchValye[1]}:]", $text);
|
||||||
}
|
}
|
||||||
|
// 处理链接
|
||||||
|
preg_match_all("/<a[^>]*?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], "<a href=\"{$herf}\" target=\"_blank\">{$title}</a>", $text);
|
||||||
|
}
|
||||||
// 过滤标签
|
// 过滤标签
|
||||||
$text = strip_tags($text, '<blockquote> <strong> <pre> <ol> <ul> <li> <em> <p> <s> <u>');
|
$text = strip_tags($text, '<blockquote> <strong> <pre> <ol> <ul> <li> <em> <p> <s> <u> <a>');
|
||||||
$text = preg_replace("/\<(blockquote|strong|pre|ol|ul|li|em|p|s|u).*?\>/is", "<$1>", $text);
|
$text = preg_replace("/\<(blockquote|strong|pre|ol|ul|li|em|p|s|u).*?\>/is", "<$1>", $text); // 不用去除a标签,上面已经处理过了
|
||||||
$text = preg_replace("/\[:IMAGE:(.*?):(.*?):(.*?):(.*?):(.*?):\]/i", "<img class=\"$1\" width=\"$2\" height=\"$3\" src=\"{{RemoteURL}}$4\" alt=\"$5\"/>", $text);
|
$text = preg_replace("/\[:IMAGE:(.*?):(.*?):(.*?):(.*?):(.*?):\]/i", "<img class=\"$1\" width=\"$2\" height=\"$3\" src=\"{{RemoteURL}}$4\" alt=\"$5\"/>", $text);
|
||||||
$text = preg_replace("/\[:@:(.*?):(.*?):\]/i", "<span class=\"mention user\" data-id=\"$1\">@$2</span>", $text);
|
$text = preg_replace("/\[:@:(.*?):(.*?):\]/i", "<span class=\"mention user\" data-id=\"$1\">@$2</span>", $text);
|
||||||
$text = preg_replace("/\[:#:(.*?):(.*?):\]/i", "<span class=\"mention task\" data-id=\"$1\">#$2</span>", $text);
|
$text = preg_replace("/\[:#:(.*?):(.*?):\]/i", "<span class=\"mention task\" data-id=\"$1\">#$2</span>", $text);
|
||||||
|
|||||||
@ -372,9 +372,21 @@ export default {
|
|||||||
|
|
||||||
// Clipboard Matcher (保留图片跟空格,清除其余所以样式)
|
// Clipboard Matcher (保留图片跟空格,清除其余所以样式)
|
||||||
this.quill.clipboard.addMatcher(Node.ELEMENT_NODE, (node, delta) => {
|
this.quill.clipboard.addMatcher(Node.ELEMENT_NODE, (node, delta) => {
|
||||||
delta.ops = delta.ops.map(op => ({
|
delta.ops = delta.ops.map(op => {
|
||||||
insert: op.insert
|
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
|
return delta
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user