Skip to content

Commit 293d3bf

Browse files
committed
🎨 Improve Microsoft Excel Compatibility
1 parent 89e9b5f commit 293d3bf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

app/src/protyle/util/compatibility.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ export const encodeBase64 = (text: string): string => {
2424
};
2525

2626
export const getTextSiyuanFromTextHTML = (html: string) => {
27+
const trimmedHtml = html.trimStart();
28+
if (trimmedHtml.startsWith("<html")) {
29+
const htmlTagEnd = trimmedHtml.indexOf(">");
30+
if (htmlTagEnd > 0) {
31+
const htmlTag = trimmedHtml.substring(0, htmlTagEnd);
32+
// 兼容 Microsoft Excel 应用,HTML 以包含 Excel 命名空间声明的 html 元素开头(备注:从 WPS 复制也有这个命名空间)
33+
if (htmlTag.includes('xmlns:x="urn:schemas-microsoft-com:office:excel"')) {
34+
// 粘贴表格不需要解析 textSiyuan https://ld246.com/article/1763027417781/comment/1763032527460#comments
35+
return {
36+
textSiyuan: "",
37+
textHtml: html
38+
};
39+
}
40+
}
41+
}
2742
const siyuanMatch = html.match(/<!--data-siyuan='([^']+)'-->/);
2843
let textSiyuan = "";
2944
let textHtml = html;

0 commit comments

Comments
 (0)