Skip to content

Commit

Permalink
feat: 优化处理base64数据的时机和正则,确保base64数据能够及时被替换成占位符
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsonliu committed Dec 6, 2023
1 parent e313d0c commit 5bbb803
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ export default class Editor {
if (this.options.writingStyle !== 'normal') {
this.initWritingStyle();
}
// 处理特殊字符,主要将base64等大文本替换成占位符,以提高可读性
this.dealSpecialWords();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/utils/regexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ export function getDetailRule() {
return ret;
}

// 匹配图片URL里的base64
export const imgBase64Reg = /(!\[[^\n]*?\]\(data:image\/[a-z]{1,10};base64,)([^)]+)\)/g;
// 匹配图片URL里的base64,[name](data:image/png;base64,xxx) 和 ![alt](data:image/png;base64,xxx) 这两种形式的都处理
export const imgBase64Reg = /(\[[^\n]*?\]\(data:image\/[a-z]{1,10};base64,)([^)]+)\)/g;

// 匹配图片{}里的data-xml属性
export const imgDrawioXmlReg = /(!\[[^\n]*?\]\([^)]+\)\{[^}]* data-xml=)([^}]+)\}/g;
Expand Down

0 comments on commit 5bbb803

Please sign in to comment.