Explorar o código

:art: Find replace supports selecting element types https://github.com/siyuan-note/siyuan/issues/9895

Daniel hai 1 ano
pai
achega
a379e24b3b
Modificáronse 1 ficheiros con 37 adicións e 10 borrados
  1. 37 10
      kernel/model/storage.go

+ 37 - 10
kernel/model/storage.go

@@ -160,16 +160,17 @@ func getRecentDocs() (ret []*RecentDoc, err error) {
 }
 
 type Criterion struct {
-	Name       string          `json:"name"`
-	Sort       int             `json:"sort"`       //  0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时)
-	Group      int             `json:"group"`      // 0:不分组,1:按文档分组
-	HasReplace bool            `json:"hasReplace"` // 是否有替换
-	Method     int             `json:"method"`     //  0:文本,1:查询语法,2:SQL,3:正则表达式
-	HPath      string          `json:"hPath"`
-	IDPath     []string        `json:"idPath"`
-	K          string          `json:"k"`     // 搜索关键字
-	R          string          `json:"r"`     // 替换关键字
-	Types      *CriterionTypes `json:"types"` // 类型过滤选项
+	Name         string                 `json:"name"`
+	Sort         int                    `json:"sort"`       //  0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时)
+	Group        int                    `json:"group"`      // 0:不分组,1:按文档分组
+	HasReplace   bool                   `json:"hasReplace"` // 是否有替换
+	Method       int                    `json:"method"`     //  0:文本,1:查询语法,2:SQL,3:正则表达式
+	HPath        string                 `json:"hPath"`
+	IDPath       []string               `json:"idPath"`
+	K            string                 `json:"k"`            // 搜索关键字
+	R            string                 `json:"r"`            // 替换关键字
+	Types        *CriterionTypes        `json:"types"`        // 类型过滤选项
+	ReplaceTypes *CriterionReplaceTypes `json:"replaceTypes"` // 替换类型过滤选项
 }
 
 type CriterionTypes struct {
@@ -187,6 +188,32 @@ type CriterionTypes struct {
 	EmbedBlock bool `json:"embedBlock"`
 }
 
+type CriterionReplaceTypes struct {
+	Text       bool `json:"text"`
+	ImgText    bool `json:"img-text"`
+	ImgTitle   bool `json:"img-title"`
+	ImgSrc     bool `json:"img-src"`
+	AText      bool `json:"a-text"`
+	ATitle     bool `json:"a-title"`
+	AHref      bool `json:"a-href"`
+	Code       bool `json:"code"`
+	Em         bool `json:"em"`
+	Strong     bool `json:"strong"`
+	InlineMath bool `json:"inline-math"`
+	InlineMemo bool `json:"inline-memo"`
+	Kbd        bool `json:"kbd"`
+	Mark       bool `json:"mark"`
+	S          bool `json:"s"`
+	Sub        bool `json:"sub"`
+	Sup        bool `json:"sup"`
+	Tag        bool `json:"tag"`
+	U          bool `json:"u"`
+	DocTitle   bool `json:"doc-title"`
+	CodeBlock  bool `json:"code-block"`
+	MathBlock  bool `json:"math-block"`
+	HtmlBlock  bool `json:"html-block"`
+}
+
 var criteriaLock = sync.Mutex{}
 
 func RemoveCriterion(name string) (err error) {