mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-12 08:58:11 +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);
|
||||
$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 = preg_replace("/\<(blockquote|strong|pre|ol|ul|li|em|p|s|u).*?\>/is", "<$1>", $text);
|
||||
$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); // 不用去除a标签,上面已经处理过了
|
||||
$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 task\" data-id=\"$1\">#$2</span>", $text);
|
||||
|
||||
@ -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
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user