Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(md): xss过滤规则增加可排除标签渲染; fix(md): 调整标题工具按钮选中文字后多余复制选取内容问题 #1793

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ export class MDRenderService {
setCustomXssRules(rules: ICustomXssRule[]) {
if (rules) {
rules.forEach((rule) => {
this.xssWhiteList[rule['key']] = rule['value'];
if (rule['value'] === null) {
delete this.xssWhiteList[rule['key']];
} else {
this.xssWhiteList[rule['key']] = rule['value'];
}
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/devui-vue/devui/editor-md/src/editor-md-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface MdPlugin {

export interface ICustomXssRule {
key: string;
value: string[];
value: string[] | null;
}

export interface ICustomRenderRule {
Expand Down
6 changes: 2 additions & 4 deletions packages/devui-vue/devui/editor-md/src/toolbar-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ class ToolBarHandler {

if (cursor.ch !== 0) {
editor.setCursor(cursor.line, 0);
editor.replaceSelection('# ' + selection);
editor.setCursor(cursor.line, cursor.ch + 2);
editor.replaceSelection('# ');
} else {
editor.replaceSelection('# ' + selection);
}
Expand All @@ -89,8 +88,7 @@ class ToolBarHandler {

if (cursor.ch !== 0) {
editor.setCursor(cursor.line, 0);
editor.replaceSelection('## ' + selection);
editor.setCursor(cursor.line, cursor.ch + 3);
editor.replaceSelection('## ');
} else {
editor.replaceSelection('## ' + selection);
}
Expand Down
6 changes: 5 additions & 1 deletion packages/devui-vue/docs/components/editor-md/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export default defineComponent({
key: 'kbd',
value: [], // 为空表示过滤所有属性,放开属性则添加对应项,如['id', 'style']
},
{
key: 'input',
value: null, // value值为null,则对应标签不会被渲染
}
])
const customRendererRules = ref([
{
Expand Down Expand Up @@ -635,7 +639,7 @@ interface ICustomRenderRule {
```ts
interface ICustomXssRule {
key: string;
value: string[];
value: string[] | null;
}
```

Expand Down
2 changes: 1 addition & 1 deletion packages/devui-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-devui",
"version": "1.6.3-markdown.1",
"version": "1.6.3-markdown.2",
"license": "MIT",
"description": "DevUI components based on Vite and Vue3",
"keywords": [
Expand Down
Loading