perf: 任务描述支持清单

This commit is contained in:
Pang 2024-04-21 21:36:22 +08:00
parent 5e6a21ddc5
commit bd61b8c948
9 changed files with 630 additions and 594 deletions

View File

@ -1945,7 +1945,7 @@ class ProjectController extends AbstractController
$task->pushMsgVisibleAdd($data); $task->pushMsgVisibleAdd($data);
} }
if ($param['visibility_appointor']) { if ($param['visibility_appointor']) {
$newVisibleUserIds = $param['visibility_appointor'] ?? []; $newVisibleUserIds = is_array($param['visibility_appointor']) ? $param['visibility_appointor'] : [];
$deleteUserIds = array_diff($visible, $newVisibleUserIds, $subUserids); $deleteUserIds = array_diff($visible, $newVisibleUserIds, $subUserids);
$addUserIds = array_diff($newVisibleUserIds, $visible); $addUserIds = array_diff($newVisibleUserIds, $visible);
$task->pushMsgVisibleUpdate($data, $deleteUserIds, $addUserIds); $task->pushMsgVisibleUpdate($data, $deleteUserIds, $addUserIds);

View File

@ -352,6 +352,25 @@ class ProjectTask extends AbstractModel
return $query; return $query;
} }
/**
* 生成描述
* @param $content
* @return string
*/
public static function generateDesc($content)
{
$content = preg_replace_callback('/<ul class="tox-checklist">(.+?)<\/ul>/is', function ($matches) {
return preg_replace_callback('/<li([^>]*)>(.+?)<\/li>/is', function ($m) {
if (str_contains($m[1], 'tox-checklist--checked')) {
return "<li{$m[1]}>[√]{$m[2]} </li>";
} else {
return "<li{$m[1]}>[ ]{$m[2]} </li>";
}
}, $matches[0]);
}, $content);
return Base::cutStr(strip_tags($content), 100, 0, "...");
}
/** /**
* 添加任务 * 添加任务
* @param $data * @param $data
@ -407,7 +426,7 @@ class ProjectTask extends AbstractModel
'visibility' => $visibility ?: 1 'visibility' => $visibility ?: 1
]); ]);
if ($content) { if ($content) {
$task->desc = Base::getHtml($content, 100); $task->desc = self::generateDesc($content);
} }
// 标题 // 标题
if (empty($name)) { if (empty($name)) {
@ -901,7 +920,7 @@ class ProjectTask extends AbstractModel
'url' => ProjectTaskContent::saveContent($this->id, $data['content']) 'url' => ProjectTaskContent::saveContent($this->id, $data['content'])
], ],
])->save(); ])->save();
$this->desc = Base::getHtml($data['content'], 100); $this->desc = self::generateDesc($data['content']);
$this->addLog("修改{任务}详细描述"); $this->addLog("修改{任务}详细描述");
$updateMarking['is_update_content'] = true; $updateMarking['is_update_content'] = true;
} }

View File

@ -359,17 +359,6 @@ class Base
} }
} }
/**
* 去除html
* @param $text
* @param int $length
* @return string
*/
public static function getHtml($text, $length = 250)
{
return Base::cutStr(strip_tags($text), $length, 0, "...");
}
/** /**
* *
* 截取字符串 * 截取字符串

File diff suppressed because it is too large Load Diff

View File

@ -69,7 +69,7 @@ export default {
content: this.value, content: this.value,
plugins: [ plugins: [
'advlist autolink lists link image charmap print preview hr anchor pagebreak', 'advlist autolink lists checklist link image charmap print preview hr anchor pagebreak',
'searchreplace visualblocks visualchars code', 'searchreplace visualblocks visualchars code',
'insertdatetime media nonbreaking save table directionality', 'insertdatetime media nonbreaking save table directionality',
'emoticons paste codesample', 'emoticons paste codesample',
@ -81,16 +81,17 @@ export default {
autoresize_bottom_margin: 2, autoresize_bottom_margin: 2,
min_height: 200, min_height: 200,
max_height: 380, max_height: 380,
contextmenu: 'bold italic underline forecolor backcolor | link | codesample | uploadImages imagePreview | preview screenload', contextmenu: 'checklist | bold italic underline forecolor backcolor | link | uploadImages imagePreview | screenload',
valid_elements: 'a[href|title|target=_blank],em,strong/b,div[align],span[style],a,br,p,img[src|alt|witdh|height],pre[class],code', valid_elements: 'a[href|title|target=_blank],em,strong/b,div[align],span[style],a,br,p,img[src|alt|witdh|height],pre[class],code,ol[class],ul[class],li[class]',
extended_valid_elements: 'a[href|title|target=_blank]', extended_valid_elements: 'a[href|title|target=_blank]',
toolbar: false toolbar: false
}, },
optionFull: { optionFull: {
menubar: 'file edit view', menubar: 'file edit view',
valid_elements: 'a[href|title|target=_blank],em,strong/b,div[align],span[style],a,br,p,img[src|alt|witdh|height],pre[class],code', removed_menuitems: 'preview,print',
valid_elements: 'a[href|title|target=_blank],em,strong/b,div[align],span[style],a,br,p,img[src|alt|witdh|height],pre[class],code,ol[class],ul[class],li[class]',
extended_valid_elements: 'a[href|title|target=_blank]', extended_valid_elements: 'a[href|title|target=_blank]',
toolbar: 'uploadImages | bold italic underline | forecolor backcolor' toolbar: 'uploadImages | checklist | bold italic underline | forecolor backcolor'
}, },
operateStyles: {}, operateStyles: {},

View File

@ -22,6 +22,10 @@
opacity: 0; opacity: 0;
} }
.tox-checklist {
padding-inline-start: 26px;
}
.tox-tinymce { .tox-tinymce {
box-shadow: none; box-shadow: none;
box-sizing: border-box; box-sizing: border-box;

View File

@ -0,0 +1,7 @@
// Exports the "checklist" plugin for usage with module loaders
// Usage:
// CommonJS:
// require('tinymce/plugins/checklist')
// ES2015:
// import 'tinymce/plugins/checklist'
require('./plugin.js');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long