-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
从其他地方粘贴时保留颜色 #2799
New issue
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
Comments
支持。 场景: 所以保留粘贴来源的文章样式的需求也需要关注,不仅仅是颜色。 onenote是无损保存网页和word样式的(以html存储),虽然OneNote也是以内容块存储的,但和思源markdown有一定的技术区别。 |
暂时不考虑了,这个以后如果需求的人多了再考虑。 |
需求:支持从word中复制,粘贴到思源里附带颜色 以及思源导出到word时,也带上颜色 |
搞不了哦,因为是按 Markdown 解析的 |
发现思源解析html,就算html格式很标准,有span style=color:red ,粘贴之后,也是完全不保留颜色,把lute的解析html方法都试了一遍,确实都不解析 目前想到一个间接方法,先把html带颜色的文字替换为链接,链接的href内容为style内容,用lute解析为思源能直接粘贴的dom后,再替换为span style,最后替换剪贴板 不过这里遇到一个问题,思源解析html是用的什么方法,我用lute.html2blockdom,发现不支持解析word的上下标,但是直接粘贴到思源就可以解析成功 |
外部替换的话建议直接替换为思源的 DOM 行级元素结构,就是类似 |
恩,我已经实现好了,是通过替换siyuanHTML实现的,因为我发现只有纯文本和siyuan HTML,有 另外用lute.html2blockdom也不能把html的span color保留,所有才想到先转为链接,再转为span的曲线救国方法 所以才需要插件自己把html解析为siyuan dom,进行处理 |
另外lute能否处理行内样式嵌套呢 html = `<strong><u><span data-type="text" style=" color:#61afef;">SetSpellcheck</span></u><strong>`
// Convert to BlockDOM using Lute
let lute = window.Lute.New();
lute.SetSpellcheck(window.siyuan.config.editor.spellcheck);
lute.SetProtyleMarkNetImg(window.siyuan.config.editor.displayNetImgMark);
lute.SetHTMLTag2TextMark(true);
lute.SetTextMark(true);
lute.SetHeadingID(false);
lute.SetYamlFrontMatter(false);
lute.SetInlineMathAllowDigitAfterOpenMarker(true);
lute.SetToC(false);
lute.SetIndentCodeBlock(false);
lute.SetParagraphBeginningSpace(true);
lute.SetSetext(false);
lute.SetFootnotes(false);
lute.SetLinkRef(false);
lute.SetImgPathAllowSpace(true);
lute.SetKramdownIAL(false);
lute.SetTag(true);
lute.SetSuperBlock(true);
lute.SetMark(true);
lute.SetSub(true);
lute.SetSup(true);
lute.SetProtyleWYSIWYG(true);
lute.SetKramdownSpanIAL(true);
lute.SetInlineUnderscore(true);
lute.SetGFMStrikethrough(true);
lute.SetGFMStrikethrough1(true);
result = lute.HTML2BlockDOM(html); 输出是
但是这样u被嵌套,就无法渲染
|
支持不了嵌套的,设计上就是仅支持平铺。 |
好的,那我就自己写代码拆分吧 |
怎么我看上面的意思是 lute 的输出是嵌套的 |
发现斜体解析有点问题,
lute.SetProtyleWYSIWYG(false);
lute.SetProtyleWYSIWYG(true); |
我的想法是直接在外部转换 SiYuan DOM 吧,不要使用 siyuan/lute 工具链转换,不然问题比较多。 |
老铁,改 Lute 不太现实,你懂的…… |
嗯嗯了解,我再想想方法 |
https://ld246.com/article/1630365945652
The text was updated successfully, but these errors were encountered: