🎨 Ignore editor Markdown settings when copying and pasting inline elements https://github.com/siyuan-note/siyuan/issues/14690

This commit is contained in:
Daniel 2025-04-24 17:01:52 +08:00
parent bb42e8dd12
commit 89d9d16a06
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017

View File

@ -1,4 +1,4 @@
import {getTextStar, paste} from "../util/paste"; import {enableLuteMarkdownSyntax, getTextStar, paste, restoreLuteMarkdownSyntax} from "../util/paste";
import { import {
hasClosestBlock, hasClosestBlock,
hasClosestByAttribute, hasClosestByAttribute,
@ -442,7 +442,9 @@ export class WYSIWYG {
.replace(new RegExp(Constants.ZWSP, "g"), ""); .replace(new RegExp(Constants.ZWSP, "g"), "");
event.clipboardData.setData("text/plain", textPlain); event.clipboardData.setData("text/plain", textPlain);
event.clipboardData.setData("text/html", selectTableElement ? html : protyle.lute.BlockDOM2HTML(selectAVElement ? textPlain : html)); event.clipboardData.setData("text/html", selectTableElement ? html : protyle.lute.BlockDOM2HTML(selectAVElement ? textPlain : html));
enableLuteMarkdownSyntax(protyle);
event.clipboardData.setData("text/siyuan", selectTableElement ? protyle.lute.HTML2BlockDOM(html) : html); event.clipboardData.setData("text/siyuan", selectTableElement ? protyle.lute.HTML2BlockDOM(html) : html);
restoreLuteMarkdownSyntax(protyle);
}); });
this.element.addEventListener("mousedown", (event: MouseEvent) => { this.element.addEventListener("mousedown", (event: MouseEvent) => {
@ -1702,7 +1704,9 @@ export class WYSIWYG {
textPlain = textPlain.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382 textPlain = textPlain.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382
event.clipboardData.setData("text/plain", textPlain); event.clipboardData.setData("text/plain", textPlain);
event.clipboardData.setData("text/html", selectTableElement ? html : protyle.lute.BlockDOM2HTML(selectAVElement ? textPlain : html)); event.clipboardData.setData("text/html", selectTableElement ? html : protyle.lute.BlockDOM2HTML(selectAVElement ? textPlain : html));
enableLuteMarkdownSyntax(protyle);
event.clipboardData.setData("text/siyuan", selectTableElement ? protyle.lute.HTML2BlockDOM(html) : html); event.clipboardData.setData("text/siyuan", selectTableElement ? protyle.lute.HTML2BlockDOM(html) : html);
restoreLuteMarkdownSyntax(protyle);
}); });
let beforeContextmenuRange: Range; let beforeContextmenuRange: Range;