Skip to content

Commit

Permalink
Merge pull request #1792 from DevCloudFE/fix-md
Browse files Browse the repository at this point in the history
fix(md): 调整标题工具按钮选中文字后多余复制选取内容问题;  feat(md): xss过滤规则增加可排除标签渲染
  • Loading branch information
GreatZPP authored Mar 5, 2024
2 parents 34b0ecd + fe0fa8b commit 1b0b120
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
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

0 comments on commit 1b0b120

Please sign in to comment.