🎨 Improve Paste and Paste as plain text Fix https://github.com/siyuan-note/siyuan/issues/8289

This commit is contained in:
Liang Ding 2023-05-17 21:48:01 +08:00
parent dd6bfbe4ba
commit aef5130436
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
7 changed files with 14 additions and 9 deletions

View file

@ -819,7 +819,7 @@
"themeLight": "Light",
"themeDark": "Dark",
"themeOS": "Follow the system",
"pasteAsPlainText": "Paste As Plain Text",
"pasteAsPlainText": "Paste as plain text",
"assets": "Assets",
"alignCenter": "Center",
"alignLeft": "Left",

View file

@ -50,9 +50,9 @@ export const pasteAsPlainText = async (protyle: IProtyle) => {
}
/// #endif
if (localFiles.length === 0) {
// https://github.com/siyuan-note/siyuan/issues/8010
// Inline-level elements support pasted as plain text https://github.com/siyuan-note/siyuan/issues/8010
navigator.clipboard.readText().then(textPlain => {
insertHTML(protyle.lute.BlockDOM2Content(protyle.lute.Md2BlockDOM(textPlain)), protyle);
insertHTML(protyle.lute.BlockDOM2EscapeMarkerContent(protyle.lute.Md2BlockDOM(textPlain)), protyle);
});
}
};

View file

@ -147,6 +147,8 @@ declare class Lute {
public BlockDOM2Content(text: string): string;
public BlockDOM2EscapeMarkerContent(text: string): string;
public SetTextMark(enable: boolean): void;
public SetHeadingID(enable: boolean): void;

File diff suppressed because one or more lines are too long

View file

@ -6,7 +6,7 @@ require (
github.com/88250/clipboard v0.1.5
github.com/88250/css v0.1.2
github.com/88250/gulu v1.2.3-0.20230501031728-4d62370997cd
github.com/88250/lute v1.7.6-0.20230514021025-e7cf9adb9658
github.com/88250/lute v1.7.6-0.20230517134223-ed6fca094739
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
github.com/ClarkThan/ahocorasick v0.0.0-20230220142845-f237b6348b3e
@ -72,7 +72,7 @@ require (
github.com/bytedance/sonic v1.8.8 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/dlclark/regexp2 v1.9.0 // indirect
github.com/dlclark/regexp2 v1.10.0 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect

View file

@ -10,6 +10,8 @@ github.com/88250/gulu v1.2.3-0.20230501031728-4d62370997cd h1:PgbmnoTqfVbYyhUljo
github.com/88250/gulu v1.2.3-0.20230501031728-4d62370997cd/go.mod h1:pTWnjt+6qUqNnP9xltswsJxgCBVu3C7eW09u48LWX0k=
github.com/88250/lute v1.7.6-0.20230514021025-e7cf9adb9658 h1:Eg1wbQtCHZNjuMd5Z1SwMuV3QPUmOFu3Qp3vLp1Z/Pg=
github.com/88250/lute v1.7.6-0.20230514021025-e7cf9adb9658/go.mod h1:+wUqx/1kdFDbWtxn9LYJlaCOAeol2pjSO6w+WJTVQsg=
github.com/88250/lute v1.7.6-0.20230517134223-ed6fca094739 h1:tz5dSdqWg1plGwiIpTYFXeYnSwMIW2XCfO9pJMU4Sck=
github.com/88250/lute v1.7.6-0.20230517134223-ed6fca094739/go.mod h1:+wUqx/1kdFDbWtxn9LYJlaCOAeol2pjSO6w+WJTVQsg=
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c h1:Dl/8S9iLyPMTElnWIBxmjaLiWrkI5P4a21ivwAn5pU0=
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=
@ -65,6 +67,8 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUn
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dlclark/regexp2 v1.9.0 h1:pTK/l/3qYIKaRXuHnEnIf7Y5NxfRPfpb7dis6/gdlVI=
github.com/dlclark/regexp2 v1.9.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0=
github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q=
github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo=
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=

View file

@ -55,7 +55,6 @@ import (
func HTML2Markdown(htmlStr string) (markdown string, err error) {
assetDirPath := filepath.Join(util.DataDir, "assets")
luteEngine := util.NewLute()
luteEngine.SetProtyleWYSIWYG(false)
tree := luteEngine.HTML2Tree(htmlStr)
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering || ast.NodeLinkDest != n.Type {