Skip to content

Commit b69fd04

Browse files
committed
🎨 #15806
1 parent ff909fa commit b69fd04

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/src/config/util/snippets.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ export const openSnippets = () => {
120120
type: target.id === "addCodeSnippetCSS" ? "css" : "js",
121121
name: "",
122122
content: "",
123-
enabled: false
123+
enabled: false,
124+
disabledInPublish: false,
124125
}));
125126
event.stopPropagation();
126127
event.preventDefault();
@@ -195,6 +196,12 @@ const genSnippet = (options: ISnippet) => {
195196
<div class="fn__hr--b"></div>
196197
<div class="fn__flex">
197198
<input type="text" class="fn__size200 b3-text-field" placeholder="${window.siyuan.languages.title}">
199+
<div class="fn__space"></div>
200+
<label class="fn__flex">
201+
<input data-type="disabledInPublish" type="checkbox" class="b3-switch fn__flex-center" ${options.disabledInPublish ? "" : " checked"}>
202+
<div class="fn__space"></div>
203+
<span class="fn__flex-center">${window.siyuan.languages.publishService}</span>
204+
</label>
198205
<div class="fn__flex-1"></div>
199206
<div class="fn__space"></div>
200207
<span aria-label="${window.siyuan.languages.remove}" data-action="remove" class="b3-tooltips b3-tooltips__sw block__icon block__icon--show">
@@ -229,11 +236,12 @@ const setSnippet = (dialog: Dialog, oldSnippets: ISnippet[], removeIds: string[]
229236
const snippets: ISnippet[] = [];
230237
dialog.element.querySelectorAll("[data-id]").forEach((item) => {
231238
snippets.push({
239+
disabledInPublish: !(item.querySelector('.b3-switch[data-type="disabledInPublish"]') as HTMLInputElement).checked,
232240
id: item.getAttribute("data-id"),
233241
name: item.querySelector("input").value,
234242
type: item.getAttribute("data-type"),
235243
content: item.querySelector("textarea").value,
236-
enabled: (item.querySelector(".b3-switch") as HTMLInputElement).checked
244+
enabled: (item.querySelector('.b3-switch[data-type="snippet"]') as HTMLInputElement).checked
237245
});
238246
});
239247
if (objEquals(oldSnippets, snippets) &&

app/src/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ interface ISnippet {
369369
type: string;
370370
enabled: boolean;
371371
content: string;
372+
disabledInPublish: boolean;
372373
}
373374

374375
interface IInbox {

0 commit comments

Comments
 (0)