🎨 Add field disabledInPublish to the code snippet to indicate whether it is disabled in the publish service https://github.com/siyuan-note/siyuan/issues/15806

Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2025-09-09 09:18:12 +08:00
parent 2f70ef43a1
commit 93422c134d
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
5 changed files with 23 additions and 7 deletions

View file

@ -55,11 +55,20 @@ func getSnippet(c *gin.Context) {
return
}
isPublish := model.IsReadOnlyRole(model.GetGinContextRole(c))
var snippets []*conf.Snippet
for _, s := range confSnippets {
if ("all" == typ || s.Type == typ) && (2 == enabledArg || s.Enabled == enabled) {
snippets = append(snippets, s)
if isPublish && s.DisabledInPublish {
continue
}
if "all" != typ && s.Type != typ {
continue
}
if 2 != enabledArg && s.Enabled != enabled {
continue
}
snippets = append(snippets, s)
}
if "" != keyword {
@ -101,6 +110,9 @@ func setSnippet(c *gin.Context) {
Content: m["content"].(string),
Enabled: m["enabled"].(bool),
}
if nil != m["disabledInPublish"] {
snippet.DisabledInPublish = m["disabledInPublish"].(bool)
}
if "" == snippet.ID {
snippet.ID = ast.NewNodeID()
}