Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Oct 20, 2024
2 parents bf70e48 + dc8744a commit 7180105
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 19 deletions.
16 changes: 10 additions & 6 deletions app/src/menus/protyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,10 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
openMenu(protyle.app, imgSrc, false, false);
}
window.siyuan.menus.menu.append(new MenuItem(exportAsset(imgElement.getAttribute("data-src"))).element);
const dataSrc = imgElement.getAttribute("data-src");
if (dataSrc && dataSrc.startsWith("assets/")) {
window.siyuan.menus.menu.append(new MenuItem(exportAsset(dataSrc)).element);
}
if (protyle?.app?.plugins) {
emitOpenMenu({
plugins: protyle.app.plugins,
Expand Down Expand Up @@ -1935,7 +1938,7 @@ export const videoMenu = (protyle: IProtyle, nodeElement: Element, type: string)
}
}];
const src = videoElement.getAttribute("src");
if (src.startsWith("assets/")) {
if (src && src.startsWith("assets/")) {
subMenus.push({
type: "separator"
});
Expand All @@ -1948,16 +1951,17 @@ export const videoMenu = (protyle: IProtyle, nodeElement: Element, type: string)
}
});
}
const VideoSrc = videoElement.getAttribute("src");
if (VideoSrc) {
if (src) {
subMenus.push({
id: "openBy",
label: window.siyuan.languages.openBy,
icon: "iconOpen",
submenu: openMenu(protyle.app, VideoSrc, true, false) as IMenu[]
submenu: openMenu(protyle.app, src, true, false) as IMenu[]
});
}
subMenus.push(exportAsset(src));
if (src && src.startsWith("assets/")) {
subMenus.push(exportAsset(src));
}
return subMenus;
};

Expand Down
10 changes: 8 additions & 2 deletions kernel/av/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const (
FilterOperatorIsFalse FilterOperator = "Is false"
)

func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, rowID string) bool {
func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, rowID string, attrViewCache *map[string]*AttributeView) bool {
if nil == filter || (nil == filter.Value && nil == filter.RelativeDate) {
return true
}
Expand Down Expand Up @@ -117,7 +117,13 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, rowID st
return false
}

destAv, _ := ParseAttributeView(relKey.Relation.AvID)
destAv := (*attrViewCache)[relKey.Relation.AvID]
if nil == destAv {
destAv, _ = ParseAttributeView(relKey.Relation.AvID)
if nil != destAv {
(*attrViewCache)[relKey.Relation.AvID] = destAv
}
}
if nil == destAv {
return false
}
Expand Down
4 changes: 3 additions & 1 deletion kernel/av/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ func (table *Table) FilterRows(attrView *AttributeView) {
}

rows := []*TableRow{}
attrViewCache := map[string]*AttributeView{}
attrViewCache[attrView.ID] = attrView
for _, row := range table.Rows {
pass := true
for j, index := range colIndexes {
Expand All @@ -275,7 +277,7 @@ func (table *Table) FilterRows(attrView *AttributeView) {
break
}

if !row.Cells[index].Value.Filter(table.Filters[j], attrView, row.ID) {
if !row.Cells[index].Value.Filter(table.Filters[j], attrView, row.ID, &attrViewCache) {
pass = false
break
}
Expand Down
36 changes: 26 additions & 10 deletions kernel/model/attribute_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,17 +488,20 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
return
}

attrViewCache := map[string]*av.AttributeView{}
avIDs := strings.Split(avs, ",")
for _, avID := range avIDs {
attrView, err := av.ParseAttributeView(avID)
if err != nil {
logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
unbindBlockAv(nil, avID, blockID)
return
attrView := attrViewCache[avID]
if nil == attrView {
attrView, _ = av.ParseAttributeView(avID)
if nil == attrView {
unbindBlockAv(nil, avID, blockID)
return
}
attrViewCache[avID] = attrView
}

if 1 > len(attrView.Views) {
err = av.ErrViewNotFound
unbindBlockAv(nil, avID, blockID)
return
}
Expand Down Expand Up @@ -568,9 +571,17 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {

relVal := attrView.GetValue(kv.Key.Rollup.RelationKeyID, kv.Values[0].BlockID)
if nil != relVal && nil != relVal.Relation {
destAv, _ := av.ParseAttributeView(relKey.Relation.AvID)
destAv := attrViewCache[relKey.Relation.AvID]
if nil == destAv {
destAv, _ = av.ParseAttributeView(relKey.Relation.AvID)
if nil == destAv {
break
}
attrViewCache[relKey.Relation.AvID] = destAv
}

destKey, _ := destAv.GetKey(kv.Key.Rollup.KeyID)
if nil != destAv && nil != destKey {
if nil != destKey {
for _, bID := range relVal.Relation.BlockIDs {
destVal := destAv.GetValue(kv.Key.Rollup.KeyID, bID)
if nil == destVal {
Expand All @@ -596,9 +607,14 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
break
}

destAv, _ := av.ParseAttributeView(kv.Key.Relation.AvID)
destAv := attrViewCache[kv.Key.Relation.AvID]
if nil == destAv {
break
destAv, _ = av.ParseAttributeView(kv.Key.Relation.AvID)
if nil == destAv {
break
}

attrViewCache[kv.Key.Relation.AvID] = destAv
}

blocks := map[string]*av.Value{}
Expand Down

0 comments on commit 7180105

Please sign in to comment.