mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 08:30:42 +02:00
🎨 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:
parent
2f70ef43a1
commit
93422c134d
5 changed files with 23 additions and 7 deletions
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue