mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +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
|
@ -25,6 +25,7 @@ Below are the detailed changes in this version.
|
|||
* [Dragging multiple files into the editor will cause them to be opened by the default program](https://github.com/siyuan-note/siyuan/pull/15773)
|
||||
* [Improve HTML table clipping](https://github.com/siyuan-note/siyuan/issues/15781)
|
||||
* [Automatically create a new document when clicking on a notebook without documents](https://github.com/siyuan-note/siyuan/issues/15782)
|
||||
* [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)
|
||||
|
||||
### Bugfix
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
* [拖入多個檔案到編輯器不再被預設程式開啟](https://github.com/siyuan-note/siyuan/pull/15773)
|
||||
* [改進 HTML 表格剪藏](https://github.com/siyuan-note/siyuan/issues/15781)
|
||||
* [點選無文件的筆記本時自動新建文件](https://github.com/siyuan-note/siyuan/issues/15782)
|
||||
* [程式碼片段新增欄位 `disabledInPublish`,用於識別發佈服務中是否已停用](https://github.com/siyuan-note/siyuan/issues/15806)
|
||||
|
||||
### 修復缺陷
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
* [拖入多个文件到编辑器不再被默认程序打开](https://github.com/siyuan-note/siyuan/pull/15773)
|
||||
* [改进 HTML 表格剪藏](https://github.com/siyuan-note/siyuan/issues/15781)
|
||||
* [点击无文档的笔记本时自动新建文档](https://github.com/siyuan-note/siyuan/issues/15782)
|
||||
* [代码片段新增字段 `disabledInPublish`,用于标识发布服务中是否禁用](https://github.com/siyuan-note/siyuan/issues/15806)
|
||||
|
||||
### 修复缺陷
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -29,9 +29,10 @@ func NewSnpt() *Snpt {
|
|||
}
|
||||
|
||||
type Snippet struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"` // js/css
|
||||
Enabled bool `json:"enabled"`
|
||||
Content string `json:"content"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"` // js/css
|
||||
Enabled bool `json:"enabled"`
|
||||
DisabledInPublish bool `json:"disabledInPublish"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue