mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-14 03:04:21 +01:00
🎨 Improve "Paste as plain text" after copying PDF annotations https://github.com/siyuan-note/siyuan/issues/11992
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
5c0cc375b4
commit
f922745aa7
2 changed files with 12 additions and 0 deletions
|
|
@ -104,8 +104,12 @@ export class Title {
|
|||
event.stopPropagation();
|
||||
let textPlain = await readText() || "";
|
||||
if (textPlain) {
|
||||
// 对 <<assets/...>> 进行内部转义 https://github.com/siyuan-note/siyuan/issues/11992
|
||||
textPlain = textPlain.replace(/<<assets\//g, "__@lt2assets/@__").replace(/>>/g, "__@gt2@__");
|
||||
// 对 HTML 标签进行内部转义,避免被 Lute 解析以后变为小写 https://github.com/siyuan-note/siyuan/issues/10620
|
||||
textPlain = textPlain.replace(/</g, ";;;lt;;;").replace(/>/g, ";;;gt;;;");
|
||||
// 反转义 <<assets/...>>
|
||||
textPlain = textPlain.replace(/__@lt2assets\/@__/g, "<<assets/").replace(/__@gt2@__/g, ">>");
|
||||
enableLuteMarkdownSyntax(protyle);
|
||||
let content = protyle.lute.BlockDOM2EscapeMarkerContent(protyle.lute.Md2BlockDOM(textPlain));
|
||||
restoreLuteMarkdownSyntax(protyle);
|
||||
|
|
@ -273,7 +277,9 @@ export class Title {
|
|||
accelerator: "⇧⌘V",
|
||||
click: async () => {
|
||||
let textPlain = await readText() || "";
|
||||
textPlain = textPlain.replace(/<<assets\//g, "__@lt2assets/@__").replace(/>>/g, "__@gt2@__");
|
||||
textPlain = textPlain.replace(/</g, ";;;lt;;;").replace(/>/g, ";;;gt;;;");
|
||||
textPlain = textPlain.replace(/__@lt2assets\/@__/g, "<<assets/").replace(/__@gt2@__/g, ">>");
|
||||
enableLuteMarkdownSyntax(protyle);
|
||||
let content = protyle.lute.BlockDOM2EscapeMarkerContent(protyle.lute.Md2BlockDOM(textPlain));
|
||||
restoreLuteMarkdownSyntax(protyle);
|
||||
|
|
|
|||
|
|
@ -175,9 +175,15 @@ export const pasteAsPlainText = async (protyle: IProtyle) => {
|
|||
// 删掉 <span data-type\="text".*>text</span> 标签,只保留文本
|
||||
textPlain = textPlain.replace(/<span data-type="text".*?>(.*?)<\/span>/g, "$1");
|
||||
|
||||
// 对 <<assets/...>> 进行内部转义 https://github.com/siyuan-note/siyuan/issues/11992
|
||||
textPlain = textPlain.replace(/<<assets\//g, "__@lt2assets/@__").replace(/>>/g, "__@gt2@__");
|
||||
|
||||
// 对 HTML 标签进行内部转义,避免被 Lute 解析以后变为小写 https://github.com/siyuan-note/siyuan/issues/10620
|
||||
textPlain = textPlain.replace(/</g, ";;;lt;;;").replace(/>/g, ";;;gt;;;");
|
||||
|
||||
// 反转义 <<assets/...>>
|
||||
textPlain = textPlain.replace(/__@lt2assets\/@__/g, "<<assets/").replace(/__@gt2@__/g, ">>");
|
||||
|
||||
// 反转义内置需要解析的 HTML 标签
|
||||
textPlain = textPlain.replace(/__@sub@__/g, "<sub>").replace(/__@\/sub@__/g, "</sub>");
|
||||
textPlain = textPlain.replace(/__@sup@__/g, "<sup>").replace(/__@\/sup@__/g, "</sup>");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue