Skip to content

Commit f9949e3

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents 12cab15 + 5d015b5 commit f9949e3

File tree

3 files changed

+86
-36
lines changed

3 files changed

+86
-36
lines changed

app/src/menus/protyle.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import {
22
hasClosestBlock,
33
hasClosestByAttribute,
4-
hasClosestByClassName, hasClosestByTag,
5-
hasTopClosestByClassName, isInEmbedBlock
4+
hasClosestByClassName,
5+
hasClosestByTag,
6+
hasTopClosestByClassName,
7+
isInEmbedBlock
68
} from "../protyle/util/hasClosest";
79
import {MenuItem} from "./Menu";
810
import {focusBlock, focusByRange, focusByWbr, getEditorRange, selectAll,} from "../protyle/util/selection";
@@ -24,13 +26,7 @@ import {transaction, updateTransaction} from "../protyle/wysiwyg/transaction";
2426
import {openMenu} from "./commonMenuItem";
2527
import {fetchPost, fetchSyncPost} from "../util/fetch";
2628
import {Constants} from "../constants";
27-
import {
28-
copyPlainText,
29-
readClipboard,
30-
setStorageVal,
31-
updateHotkeyTip,
32-
writeText
33-
} from "../protyle/util/compatibility";
29+
import {copyPlainText, readClipboard, setStorageVal, updateHotkeyTip, writeText} from "../protyle/util/compatibility";
3430
import {preventScroll} from "../protyle/scroll/preventScroll";
3531
import {onGet} from "../protyle/util/onGet";
3632
import {getAllModels} from "../layout/getAll";
@@ -1087,6 +1083,10 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
10871083
const imgElement = assetElement.querySelector("img");
10881084
const titleElement = assetElement.querySelector(".protyle-action__title span") as HTMLElement;
10891085
const html = nodeElement.outerHTML;
1086+
let src = imgElement.getAttribute("src");
1087+
if (!src) {
1088+
src = ""
1089+
}
10901090
if (!protyle.disabled) {
10911091
window.siyuan.menus.menu.append(new MenuItem({
10921092
id: "imageUrlAndTitleAndTooltipText",
@@ -1098,7 +1098,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
10981098
<span data-action="copy" class="block__icon block__icon--show b3-tooltips b3-tooltips__e fn__flex-center" aria-label="${window.siyuan.languages.copy}">
10991099
<svg><use xlink:href="#iconCopy"></use></svg>
11001100
</span>
1101-
</div><textarea spellcheck="false" style="margin:4px 0;width: ${isMobile() ? "100%" : "360px"}" rows="1" class="b3-text-field">${imgElement.getAttribute("src")}</textarea><div class="fn__hr"></div><div class="fn__flex">
1101+
</div><textarea spellcheck="false" style="margin:4px 0;width: ${isMobile() ? "100%" : "360px"}" rows="1" class="b3-text-field">${src}</textarea><div class="fn__hr"></div><div class="fn__flex">
11021102
<span class="fn__flex-center">${window.siyuan.languages.title}</span>
11031103
<span class="fn__space"></span>
11041104
<span data-action="copy" class="block__icon block__icon--show b3-tooltips b3-tooltips__e fn__flex-center" aria-label="${window.siyuan.languages.copy}">

kernel/api/asset.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,15 @@ func getImageOCRText(c *gin.Context) {
113113
return
114114
}
115115

116-
path := arg["path"].(string)
116+
var path string
117+
if nil == arg["path"] {
118+
ret.Data = map[string]interface{}{
119+
"text": "",
120+
}
121+
return
122+
} else {
123+
path = arg["path"].(string)
124+
}
117125

118126
ret.Data = map[string]interface{}{
119127
"text": util.GetAssetText(path),

kernel/av/filter.go

Lines changed: 67 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,16 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, itemID s
233233
}
234234
return true
235235
case FilterQuantifierNone:
236-
if len(value.Rollup.Contents) < len(relVal.Relation.Contents) {
237-
if FilterOperatorIsEmpty == filter.Operator {
236+
if FilterOperatorIsEmpty == filter.Operator {
237+
if len(value.Rollup.Contents) < len(relVal.Relation.Contents) || 1 > len(value.Rollup.Contents) {
238238
return false
239-
} else if FilterOperatorIsNotEmpty == filter.Operator {
239+
}
240+
} else if FilterOperatorIsNotEmpty == filter.Operator {
241+
if 1 > len(value.Rollup.Contents) {
240242
return true
241243
}
242244
}
243245

244-
if 1 > len(filter.Value.Rollup.Contents) {
245-
return true
246-
}
247-
248246
for _, content := range value.Rollup.Contents {
249247
if content.filter(filter.Value.Rollup.Contents[0], filter.RelativeDate, filter.RelativeDate2, filter.Operator) {
250248
return false
@@ -304,12 +302,28 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, itemID s
304302

305303
switch filter.Qualifier {
306304
case FilterQuantifierUndefined, FilterQuantifierAny:
307-
if 1 > len(value.MAsset) { // 说明资源字段为空
308-
if FilterOperatorIsEmpty == filter.Operator {
305+
if FilterOperatorIsEmpty == filter.Operator {
306+
if 1 > len(value.MAsset) {
309307
return true
310-
} else if FilterOperatorIsNotEmpty == filter.Operator {
308+
}
309+
310+
for _, asset := range value.MAsset {
311+
if "" == strings.TrimSpace(asset.Content) {
312+
return true
313+
}
314+
}
315+
return false
316+
} else if FilterOperatorIsNotEmpty == filter.Operator {
317+
if 1 > len(value.MAsset) {
311318
return false
312319
}
320+
321+
for _, asset := range value.MAsset {
322+
if "" != strings.TrimSpace(asset.Content) {
323+
return true
324+
}
325+
}
326+
return false
313327
}
314328

315329
for _, asset := range value.MAsset {
@@ -326,12 +340,28 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, itemID s
326340
}
327341
}
328342
case FilterQuantifierAll:
329-
if 1 > len(value.MAsset) {
330-
if FilterOperatorIsEmpty == filter.Operator {
343+
if FilterOperatorIsEmpty == filter.Operator {
344+
if 1 > len(value.MAsset) {
331345
return true
332-
} else if FilterOperatorIsNotEmpty == filter.Operator {
346+
}
347+
348+
for _, asset := range value.MAsset {
349+
if "" != strings.TrimSpace(asset.Content) {
350+
return false
351+
}
352+
}
353+
return true
354+
} else if FilterOperatorIsNotEmpty == filter.Operator {
355+
if 1 > len(value.MAsset) {
333356
return false
334357
}
358+
359+
for _, asset := range value.MAsset {
360+
if "" == strings.TrimSpace(asset.Content) {
361+
return false
362+
}
363+
}
364+
return true
335365
}
336366

337367
for _, asset := range value.MAsset {
@@ -349,26 +379,38 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, itemID s
349379
}
350380
return true
351381
case FilterQuantifierNone:
352-
if 1 > len(value.MAsset) {
353-
if FilterOperatorIsEmpty == filter.Operator {
354-
return false
355-
} else if FilterOperatorIsNotEmpty == filter.Operator {
382+
if FilterOperatorIsEmpty == filter.Operator {
383+
if 1 > len(value.MAsset) {
356384
return true
357385
}
386+
387+
for _, asset := range value.MAsset {
388+
if "" == strings.TrimSpace(asset.Content) {
389+
return false
390+
}
391+
}
392+
return true
393+
} else if FilterOperatorIsNotEmpty == filter.Operator {
394+
if 1 > len(value.MAsset) {
395+
return false
396+
}
397+
398+
for _, asset := range value.MAsset {
399+
if "" != strings.TrimSpace(asset.Content) {
400+
return false
401+
}
402+
}
403+
return true
358404
}
359405

360406
for _, asset := range value.MAsset {
361407
switch asset.Type {
362408
case AssetTypeFile:
363-
if "" != strings.TrimSpace(asset.Name) {
364-
if filterTextContent(filter.Operator, asset.Name, filterContent) {
365-
return false
366-
}
409+
if filterTextContent(filter.Operator, asset.Name, filterContent) {
410+
return false
367411
}
368-
if "" != strings.TrimSpace(asset.Content) {
369-
if filterTextContent(filter.Operator, asset.Content, filterContent) {
370-
return false
371-
}
412+
if filterTextContent(filter.Operator, asset.Content, filterContent) {
413+
return false
372414
}
373415
case AssetTypeImage:
374416
if filterTextContent(filter.Operator, asset.Content, filterContent) {

0 commit comments

Comments
 (0)