Skip to content

Commit

Permalink
Merge remote-tracking branch 'forke-siyuan/dev' into v0.30
Browse files Browse the repository at this point in the history
  • Loading branch information
Soltus committed Apr 21, 2024
2 parents 4178a4f + 2a8d5ee commit 753c4d6
Show file tree
Hide file tree
Showing 19 changed files with 92 additions and 40 deletions.
2 changes: 1 addition & 1 deletion app/appearance/langs/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
"sortByRankDesc": "Relevance DESC",
"sortByRankAsc": "Relevance ASC",
"saveCriterion": "Save query criteria",
"useCriterion": "After clearing, the last query condition can be used",
"useCriterion": "Search criteria will be saved for next query",
"removeCriterion": "Remove query criteria",
"group": "Group",
"noGroupBy": "No grouping",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
"sortByRankDesc": "Relevancia DESC",
"sortByRankAsc": "Relevancia ASC",
"saveCriterion": "Guardar criterios de consulta",
"useCriterion": "Después de borrar, se puede usar la última condición de consulta",
"useCriterion": "Los criterios de búsqueda se guardarán para la siguiente consulta",
"removeCriterion": "Eliminar criterios de consulta",
"grupo": "Grupo",
"noGroupBy": "Sin agrupar",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
"sortByRankDesc": "DESC de pertinence",
"sortByRankAsc": "ASC de pertinence",
"saveCriterion": "Enregistrer les critères de requête",
"useCriterion": "Après effacement, la dernière condition de requête peut être utilisée",
"useCriterion": "Les critères de recherche seront enregistrés pour la prochaine requête",
"removeCriterion": "Supprimer les critères de requête",
"groupe": "Groupe",
"noGroupBy": "Aucun regroupement",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/zh_CHT.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
"sortByRankDesc": "按相關度降序",
"sortByRankAsc": "按相關度升序",
"saveCriterion": "保存查詢條件",
"useCriterion": "清空後可使用上一次的查詢條件",
"useCriterion": "搜尋條件將保存到下次查詢中",
"removeCriterion": "清空查詢條件",
"group": "分組",
"noGroupBy": "不分組",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
"sortByRankDesc": "按相关度降序",
"sortByRankAsc": "按相关度升序",
"saveCriterion": "保存查询条件",
"useCriterion": "清空后可使用上一次的查询条件",
"useCriterion": "搜索条件将保存到下一次查询中",
"removeCriterion": "清空查询条件",
"group": "分组",
"noGroupBy": "不分组",
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sillot",
"version": "0.30.1210",
"version": "0.30.1300",
"syv": "3.0.11",
"sypv": "[]",
"description": "Build Your Eternal Digital Garden",
Expand Down
3 changes: 1 addition & 2 deletions app/src/layout/dock/Backlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,7 @@ export class Backlink extends Model {
this.status[this.blockId].backlinkMOpenIds.push(data.backmentions[index].id);
}
});
if (window.siyuan.config.editor.backmentionExpandCount === 0) {
// 设置为 0 时需折叠
if (data.mentionsCount === 0) {
this.status[this.blockId].backlinkMStatus = 3;
} else {
if (data.linkRefsCount === 0) {
Expand Down
5 changes: 4 additions & 1 deletion app/src/protyle/render/av/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {avRender} from "./render";
import {addView, openViewMenu} from "./view";
import {isOnlyMeta, writeText} from "../../util/compatibility";
import {openSearchAV} from "./relation";
import {Constants} from "../../../constants";

export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => {
window.sout.tracker("invoked");
Expand Down Expand Up @@ -89,7 +90,9 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
searchElement.style.width = "128px";
searchElement.style.paddingLeft = "";
searchElement.style.paddingRight = "";

Check notice on line 92 in app/src/protyle/render/av/action.ts

View check run for this annotation

codefactor.io / CodeFactor

app/src/protyle/render/av/action.ts#L35-L92

Complex Method
searchElement.focus();
setTimeout(() => {
searchElement.focus();
}, Constants.TIMEOUT_TRANSITION);
event.preventDefault();
event.stopPropagation();
return true;
Expand Down
2 changes: 1 addition & 1 deletion app/src/protyle/util/insertHTML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
updateCellsValue(protyle, blockElement as HTMLElement, text);
} else if (cellsElement.length > 0) {
updateCellsValue(protyle, blockElement as HTMLElement, text, cellsElement);
} else {
} else if (hasClosestByClassName(range.startContainer, "av__title")) {
range.insertNode(document.createTextNode(text));
range.collapse(false);
updateAVName(protyle, blockElement);
Expand Down
2 changes: 1 addition & 1 deletion app/src/protyle/wysiwyg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,7 @@ export class WYSIWYG {
return;
}
const blockElement = hasClosestBlock(event.target);
if (blockElement && (!getContenteditableElement(blockElement) || hasClosestByClassName(event.target, "av__cursor"))) {
if (blockElement && !getContenteditableElement(blockElement)) {
event.stopPropagation();
event.preventDefault();
return;
Expand Down
6 changes: 3 additions & 3 deletions app/src/protyle/wysiwyg/keydown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,11 +933,11 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
const selectElements = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");
if (selectElements.length > 0) {
selectElements[0].setAttribute("data-reftext", "true");
focusByRange(getEditorRange(nodeElement));
document.execCommand("copy");
} else {
nodeElement.setAttribute("data-reftext", "true");
writeText(`((${nodeElement.getAttribute("data-node-id")} "*"))`);
}
focusByRange(getEditorRange(nodeElement));
document.execCommand("copy");
}
event.preventDefault();
event.stopPropagation();
Expand Down
16 changes: 6 additions & 10 deletions kernel/api/av.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func addAttributeViewValues(c *gin.Context) {
return
}

pushRefreshAttrView(avID)
util.PushReloadAttrView(avID)
}

func removeAttributeViewValues(c *gin.Context) {
Expand All @@ -160,7 +160,7 @@ func removeAttributeViewValues(c *gin.Context) {
return
}

pushRefreshAttrView(avID)
util.PushReloadAttrView(avID)
}

func addAttributeViewKey(c *gin.Context) {
Expand All @@ -186,7 +186,7 @@ func addAttributeViewKey(c *gin.Context) {
return
}

pushRefreshAttrView(avID)
util.PushReloadAttrView(avID)
}

func removeAttributeViewKey(c *gin.Context) {
Expand All @@ -208,7 +208,7 @@ func removeAttributeViewKey(c *gin.Context) {
return
}

pushRefreshAttrView(avID)
util.PushReloadAttrView(avID)
}

func sortAttributeViewKey(c *gin.Context) {
Expand All @@ -235,7 +235,7 @@ func sortAttributeViewKey(c *gin.Context) {
return
}

pushRefreshAttrView(avID)
util.PushReloadAttrView(avID)
}

func getAttributeViewFilterSort(c *gin.Context) {
Expand Down Expand Up @@ -509,9 +509,5 @@ func setAttributeViewBlockAttr(c *gin.Context) {
blockAttributeViewKeys := model.UpdateAttributeViewCell(nil, avID, keyID, rowID, cellID, value)
ret.Data = blockAttributeViewKeys

pushRefreshAttrView(avID)
}

func pushRefreshAttrView(avID string) {
util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]interface{}{"id": avID})
util.PushReloadAttrView(avID)
}
13 changes: 10 additions & 3 deletions kernel/av/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func IsMirror(avID string) bool {
return nil != blockIDs && 1 < len(blockIDs)
}

func RemoveBlockRel(avID, blockID string) {
func RemoveBlockRel(avID, blockID string, existBlockTree func(string) bool) (ret bool) {
AttributeViewBlocksLock.Lock()
defer AttributeViewBlocksLock.Unlock()

Expand Down Expand Up @@ -95,10 +95,13 @@ func RemoveBlockRel(avID, blockID string) {
var newBlockIDs []string
for _, v := range blockIDs {
if v != blockID {
newBlockIDs = append(newBlockIDs, v)
if existBlockTree(v) {
newBlockIDs = append(newBlockIDs, v)
}
}
}
avBlocks[avID] = newBlockIDs
ret = len(newBlockIDs) != len(blockIDs)

data, err = msgpack.Marshal(avBlocks)
if nil != err {
Expand All @@ -109,6 +112,7 @@ func RemoveBlockRel(avID, blockID string) {
logging.LogErrorf("write attribute view blocks failed: %s", err)
return
}
return
}

func BatchUpsertBlockRel(nodes []*ast.Node) {
Expand Down Expand Up @@ -161,7 +165,7 @@ func BatchUpsertBlockRel(nodes []*ast.Node) {
}
}

func UpsertBlockRel(avID, blockID string) {
func UpsertBlockRel(avID, blockID string) (ret bool) {
AttributeViewBlocksLock.Lock()
defer AttributeViewBlocksLock.Unlock()

Expand All @@ -186,9 +190,11 @@ func UpsertBlockRel(avID, blockID string) {
}

blockIDs := avBlocks[avID]
oldLen := len(blockIDs)
blockIDs = append(blockIDs, blockID)
blockIDs = gulu.Str.RemoveDuplicatedElem(blockIDs)
avBlocks[avID] = blockIDs
ret = oldLen != len(blockIDs)

data, err := msgpack.Marshal(avBlocks)
if nil != err {
Expand All @@ -199,4 +205,5 @@ func UpsertBlockRel(avID, blockID string) {
logging.LogErrorf("write attribute view blocks failed: %s", err)
return
}
return
}
2 changes: 1 addition & 1 deletion kernel/bazaar/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ func downloadPackage(repoURLHash string, pushProgress bool, systemID string) (da
repoURLHash = strings.TrimPrefix(repoURLHash, "https://github.com/")
u := util.BazaarOSSServer + "/package/" + repoURLHash
buf := &bytes.Buffer{}
resp, err := httpclient.NewBrowserRequest().SetOutput(buf).SetDownloadCallback(func(info req.DownloadInfo) {
resp, err := httpclient.NewCloudFileRequest2m().SetOutput(buf).SetDownloadCallback(func(info req.DownloadInfo) {
if pushProgress {
progress := float32(info.DownloadedSize) / float32(info.Response.ContentLength)
//logging.LogDebugf("downloading bazaar package [%f]", progress)
Expand Down
15 changes: 15 additions & 0 deletions kernel/filesys/json_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ func genTreeByJSON(node *ast.Node, tree *parse.Tree, idMap *map[string]bool, nee
*needFix = true
return // 忽略空查询嵌入块
}
case ast.NodeCodeBlock:
if 4 > len(node.Children) {
// https://ld246.com/article/1713689223067
existCode := false
for _, child := range node.Children {
if ast.NodeCodeBlockCode.String() == child.TypeStr {
existCode = true
break
}
}
if !existCode {
*needFix = true
return // 忽略空代码块
}
}
}

fixLegacyData(tree.Context.Tip, node, idMap, needFix, needMigrate2Spec1)
Expand Down
17 changes: 9 additions & 8 deletions kernel/model/attribute_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,7 @@ func unbindAttributeViewBlock(operation *Operation, tx *Transaction) (err error)
unbindBlockAv(tx, operation.AvID, value.BlockID)
}
value.BlockID = operation.NextID
value.IsDetached = true
if nil != value.Block {
value.Block.ID = operation.NextID
}
Expand Down Expand Up @@ -1602,7 +1603,7 @@ func updateAttributeViewColRelation(operation *Operation) (err error) {
}
if !isSameAv {
err = av.SaveAttributeView(destAv)
util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]interface{}{"id": destAv.ID})
util.PushReloadAttrView(destAv.ID)
}

av.UpsertAvBackRel(srcAv.ID, destAv.ID)
Expand Down Expand Up @@ -2419,7 +2420,7 @@ func removeAttributeViewBlock(srcIDs []string, avID string, tx *Transaction) (er

relatedAvIDs := av.GetSrcAvIDs(avID)
for _, relatedAvID := range relatedAvIDs {
util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]interface{}{"id": relatedAvID})
util.PushReloadAttrView(relatedAvID)
}

err = av.SaveAttributeView(attrView)
Expand Down Expand Up @@ -2648,23 +2649,23 @@ func sortAttributeViewRow(operation *Operation) (err error) {
}

var rowID string
var index, previousIndex int
var idx, previousIndex int
for i, r := range view.Table.RowIDs {
if r == operation.ID {
rowID = r
index = i
idx = i
break
}
}
if "" == rowID {
rowID = operation.ID
view.Table.RowIDs = append(view.Table.RowIDs, rowID)
index = len(view.Table.RowIDs) - 1
idx = len(view.Table.RowIDs) - 1
}

switch view.LayoutType {
case av.LayoutTypeTable:
view.Table.RowIDs = append(view.Table.RowIDs[:index], view.Table.RowIDs[index+1:]...)
view.Table.RowIDs = append(view.Table.RowIDs[:idx], view.Table.RowIDs[idx+1:]...)
for i, r := range view.Table.RowIDs {
if r == operation.PreviousID {
previousIndex = i + 1
Expand Down Expand Up @@ -2934,7 +2935,7 @@ func RemoveAttributeViewKey(avID, keyID string) (err error) {
}

av.SaveAttributeView(destAv)
util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]interface{}{"id": destAv.ID})
util.PushReloadAttrView(destAv.ID)

if !destAvRelSrcAv {
av.RemoveAvRel(destAv.ID, attrView.ID)
Expand Down Expand Up @@ -3250,7 +3251,7 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string,

relatedAvIDs := av.GetSrcAvIDs(avID)
for _, relatedAvID := range relatedAvIDs {
util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]interface{}{"id": relatedAvID})
util.PushReloadAttrView(relatedAvID)
}

if err = av.SaveAttributeView(attrView); nil != err {
Expand Down
Loading

0 comments on commit 753c4d6

Please sign in to comment.