We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
paste
事件总线paste在用event.preventDefault();拦截并用event.detail.resolve回传魔改后内容时候应该绕过思源本身的粘贴内容处理逻辑(例如绕过过滤出text/html里的代码文本)
event.preventDefault();
event.detail.resolve
用如下代码拦截粘贴事件
this.eventBus.on("paste", this.handlePasteEvent);
handlePasteEvent = (event: any) => { console.log("paste handler"); event.preventDefault(); const originalText = event.detail.textPlain.trim(); console.log("originalText: ", originalText); const processedText = this.detectLanguageAndTransferToMarkdownCodeFormat(originalText); event.detail.resolve({ textPlain: processedText, }); };
如果剪贴板内容提供方只提供text/plain, 一切工作正常; 但是如果剪贴板内容提供方同时提供text/html和text/plain的话,思源会检测到text/html,自动用思源内部的逻辑处理text/html,最后给我从handlePasteEvent回传的按我需求魔改后的text/plain固执的加上思源预处理的上下文,(例如从IDE粘贴过来的内容,即使是我自己回传的text/plain,也会被思源加上md的代码块的三个反撇)。
No response
ref. zxkmm/siyuan_auto_codeblock#3 zxkmm/siyuan_auto_codeblock#1
The text was updated successfully, but these errors were encountered:
Vanessa219
No branches or pull requests
TLDR
事件总线paste在用
event.preventDefault();
拦截并用event.detail.resolve
回传魔改后内容时候应该绕过思源本身的粘贴内容处理逻辑(例如绕过过滤出text/html里的代码文本)Details
用如下代码拦截粘贴事件
如果剪贴板内容提供方只提供text/plain, 一切工作正常;
但是如果剪贴板内容提供方同时提供text/html和text/plain的话,思源会检测到text/html,自动用思源内部的逻辑处理text/html,最后给我从handlePasteEvent回传的按我需求魔改后的text/plain固执的加上思源预处理的上下文,(例如从IDE粘贴过来的内容,即使是我自己回传的text/plain,也会被思源加上md的代码块的三个反撇)。
Describe the candidate solution
No response
Other information
ref.
zxkmm/siyuan_auto_codeblock#3
zxkmm/siyuan_auto_codeblock#1
The text was updated successfully, but these errors were encountered: