Skip to content

Commit

Permalink
Merge branch 'dev' into dev-menu-id
Browse files Browse the repository at this point in the history
  • Loading branch information
TCOTC authored Sep 26, 2024
2 parents a80393d + f125f3b commit d51fb08
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 20 deletions.
15 changes: 14 additions & 1 deletion app/src/config/exportConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {showMessage} from "../dialog/message";
import {showFileInFolder} from "../util/pathName";
import {Constants} from "../constants";
import {openByMobile} from "../protyle/util/compatibility";
import {exportLayout} from "../layout/util";
import {exitSiYuan} from "../dialog/processSystem";

export const exportConfig = {
element: undefined as Element,
Expand Down Expand Up @@ -234,7 +236,18 @@ export const exportConfig = {
item.addEventListener("change", (event: InputEvent & { target: HTMLInputElement }) => {
const formData = new FormData();
formData.append("file", event.target.files[0]);
fetchPost("/api/system/importConf", formData);
fetchPost("/api/system/importConf", formData, response => {
if (response.code !== 0) {
showMessage(response.msg);
return
}

showMessage(window.siyuan.languages.imported);
exportLayout({
errorExit: true,
cb: exitSiYuan
});
});
});
} else {
item.addEventListener("change", () => {
Expand Down
9 changes: 6 additions & 3 deletions app/src/protyle/wysiwyg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2278,7 +2278,7 @@ export class WYSIWYG {
}

const embedItemElement = hasClosestByClassName(event.target, "protyle-wysiwyg__embed");
if (embedItemElement && !ctrlIsPressed) {
if (embedItemElement) {
const embedId = embedItemElement.getAttribute("data-id");
checkFold(embedId, (zoomIn, action) => {
/// #if MOBILE
Expand Down Expand Up @@ -2320,8 +2320,11 @@ export class WYSIWYG {
}
/// #endif
});
event.stopPropagation();
return;
// https://github.com/siyuan-note/siyuan/issues/12585
if (!ctrlIsPressed) {
event.stopPropagation();
return;
}
}

if (commonClick(event, protyle)) {
Expand Down
5 changes: 3 additions & 2 deletions app/src/protyle/wysiwyg/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
let focusHR = false;
if (["---", "___", "***"].includes(editElement.textContent) && type !== "NodeCodeBlock") {
html = `<div data-node-id="${id}" data-type="NodeThematicBreak" class="hr"><div></div></div>`;
const nextBlockElement = getNextBlock(editElement);
if (nextBlockElement) {
// https://github.com/siyuan-note/siyuan/issues/12593
const nextBlockElement = blockElement.nextElementSibling;
if (nextBlockElement && nextBlockElement.getAttribute("data-node-id")) {
if (!isNotEditBlock(nextBlockElement)) {
focusBlock(nextBlockElement);
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/stage/protyle/js/lute/lute.min.js

Large diffs are not rendered by default.

24 changes: 20 additions & 4 deletions kernel/api/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,46 @@ func importSyncProviderWebDAV(c *gin.Context) {
return
}

tmpDir := filepath.Join(util.TempDir, "import")
if err = os.MkdirAll(tmpDir, 0755); err != nil {
importDir := filepath.Join(util.TempDir, "import")
if err = os.MkdirAll(importDir, 0755); err != nil {
logging.LogErrorf("import WebDAV provider failed: %s", err)
ret.Code = -1
ret.Msg = err.Error()
return
}

tmp := filepath.Join(tmpDir, f.Filename)
tmp := filepath.Join(importDir, f.Filename)
if err = os.WriteFile(tmp, data, 0644); err != nil {
logging.LogErrorf("import WebDAV provider failed: %s", err)
ret.Code = -1
ret.Msg = err.Error()
return
}

tmpDir := filepath.Join(importDir, "webdav")
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
logging.LogErrorf("import WebDAV provider failed: %s", err)
ret.Code = -1
ret.Msg = err.Error()
return
}

tmp = filepath.Join(tmpDir, f.Filename[:len(f.Filename)-4])
entries, err := os.ReadDir(tmpDir)
if err != nil {
logging.LogErrorf("import WebDAV provider failed: %s", err)
ret.Code = -1
ret.Msg = err.Error()
return
}

if 1 != len(entries) {
logging.LogErrorf("invalid WebDAV provider package")
ret.Code = -1
ret.Msg = "invalid WebDAV provider package"
return
}

tmp = filepath.Join(tmpDir, entries[0].Name())
data, err = os.ReadFile(tmp)
if err != nil {
logging.LogErrorf("import WebDAV provider failed: %s", err)
Expand Down
25 changes: 20 additions & 5 deletions kernel/api/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,30 +346,46 @@ func importConf(c *gin.Context) {
return
}

tmpDir := filepath.Join(util.TempDir, "import")
if err = os.MkdirAll(tmpDir, 0755); err != nil {
importDir := filepath.Join(util.TempDir, "import")
if err = os.MkdirAll(importDir, 0755); err != nil {
logging.LogErrorf("import conf failed: %s", err)
ret.Code = -1
ret.Msg = err.Error()
return
}

tmp := filepath.Join(tmpDir, f.Filename)
tmp := filepath.Join(importDir, f.Filename)
if err = os.WriteFile(tmp, data, 0644); err != nil {
logging.LogErrorf("import conf failed: %s", err)
ret.Code = -1
ret.Msg = err.Error()
return
}

tmpDir := filepath.Join(importDir, "conf")
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
logging.LogErrorf("import conf failed: %s", err)
ret.Code = -1
ret.Msg = err.Error()
return
}

tmp = filepath.Join(tmpDir, f.Filename[:len(f.Filename)-4])
entries, err := os.ReadDir(tmpDir)
if err != nil {
logging.LogErrorf("import conf failed: %s", err)
ret.Code = -1
ret.Msg = err.Error()
return
}

if 1 != len(entries) {
logging.LogErrorf("invalid conf package")
ret.Code = -1
ret.Msg = "invalid conf package"
return
}

tmp = filepath.Join(tmpDir, entries[0].Name())
data, err = os.ReadFile(tmp)
if err != nil {
logging.LogErrorf("import conf failed: %s", err)
Expand All @@ -394,7 +410,6 @@ func importConf(c *gin.Context) {
}

logging.LogInfof("imported conf")
model.Close(false, true, 1)
}

func getConf(c *gin.Context) {
Expand Down
2 changes: 1 addition & 1 deletion kernel/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02
github.com/88250/lute v1.7.7-0.20240913030339-dd8f3f4ef1fd
github.com/88250/lute v1.7.7-0.20240926090656-72c1e7edbe37
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-20231011042242-30d1ef1347f4
Expand Down
4 changes: 2 additions & 2 deletions kernel/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceT
github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02 h1:3e5+yobj655pTeKOYMbJrnc1mE51ZkbXIxquTYZuYCY=
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02/go.mod h1:MUfzyfmbPrRDZLqxc7aPrVYveatTHRfoUa5TynPS0i8=
github.com/88250/lute v1.7.7-0.20240913030339-dd8f3f4ef1fd h1:NeJKjnczuhE6DWjXQe4xDi2LNC+xoEEjZAPDnYj++PQ=
github.com/88250/lute v1.7.7-0.20240913030339-dd8f3f4ef1fd/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
github.com/88250/lute v1.7.7-0.20240926090656-72c1e7edbe37 h1:VN2/iRrP4X/yCfmFb8/M5PpxrZUq6ciwjbNzcdttMSU=
github.com/88250/lute v1.7.7-0.20240926090656-72c1e7edbe37/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
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=
Expand Down
2 changes: 1 addition & 1 deletion kernel/model/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func SearchDocsByKeyword(keyword string, flashcard bool) (ret []map[string]strin
var rootBlocks []*sql.Block
if 0 < len(keywords) {
for _, box := range boxes {
if util.ContainsSubStr(box.Name, keywords) {
if gulu.Str.Contains(box.Name, keywords) {
if flashcard {
newFlashcardCount, dueFlashcardCount, flashcardCount := countBoxFlashcard(box.ID, deck, deckBlockIDs)
if 0 < flashcardCount {
Expand Down

0 comments on commit d51fb08

Please sign in to comment.