generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
757 lines (671 loc) · 27.2 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
import {
App,
Modal,
Notice,
parseYaml,
Plugin,
PluginSettingTab,
Setting,
stringifyYaml,
TFile,
TFolder
} from 'obsidian';
import {githubClient} from './client';
import type {GitHubClientOptions, GitHubPost} from './types';
import {
ADD_LABELS_TO_DISCUSSION,
CREATE_DISCUSSION_MUTATION,
CREATE_LABEL_MUTATION,
GET_REPOSITORY_INFO,
UPDATE_DISCUSSION_MUTATION
} from './graphql';
// Remember to rename these classes and interfaces!
const GITHUB_TOKEN = process.env.OGD_GITHUB_TOKEN;
function convertDateFormatToObsidian(dateStr: string) {
// Split the date string into parts
const [year, month, day] = dateStr.split('-');
// Return the reformatted date
return `${month}/${day}/${year}`;
}
function convertDateFormatToGH(dateStr: string) {
// Split the date string into parts
const [month, day, year] = dateStr.split('/');
// Return the reformatted date
return `${year}-${month}-${day}`;
}
interface OGDSettings {
articlesDir: string;
makeMd: boolean;
owner: string;
repo: string;
blogPostCategory: string;
draftLabel: string;
tagLabelPrefix: string;
seriesLabelPrefix: string;
}
const DEFAULT_SETTINGS: OGDSettings = {
articlesDir: 'Blog',
makeMd: false,
owner: "",
repo: "",
blogPostCategory: "Blog Posts",
draftLabel: "state/draft",
tagLabelPrefix: "tag/",
seriesLabelPrefix: "series/",
}
async function executeGitHubGraphQL(query: string, variables: any, token: string) {
const response = await fetch('https://api.github.com/graphql', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
query,
variables,
}),
});
const result = await response.json();
if (result.errors) {
throw new Error(result.errors[0].message);
}
return result.data;
}
async function createOrUpdateLabels(
repoId: string,
existingLabels: Map<string, string>,
labelNames: string[],
token: string
): Promise<Map<string, string>> {
const labelIds = new Map<string, string>();
for (const labelName of labelNames) {
if (existingLabels.has(labelName)) {
labelIds.set(labelName, existingLabels.get(labelName)!);
continue;
}
// Set color based on label type
let color;
if (labelName.startsWith('series/')) {
color = '0E8A16'; // Green for series labels
} else if (labelName.startsWith('tag/')) {
color = '1D76DB'; // Blue for tag labels
} else {
// Default color for any other labels (using a neutral gray)
color = '666666';
}
const result = await executeGitHubGraphQL(
CREATE_LABEL_MUTATION,
{
repositoryId: repoId,
name: labelName,
description: labelName.startsWith('series/') ? labelName.replace('series/', '') : undefined,
color: color
},
token
);
labelIds.set(labelName, result.createLabel.label.id);
}
return labelIds;
}
/**
* Fetches GitHub Discussions for a specified repository
* @param auth - GitHub authentication token
* @param username - GitHub username/organization
* @param repo - Repository name
* @param options - Optional configuration for filtering discussions
* @returns Promise<GitHubPost[]> - Array of GitHub discussions
*/
async function fetchGithubDiscussions(
auth: string,
username: string,
repo: string,
options: {
blogPostCategory?: string,
draftLabel?: string,
tagLabelPrefix?: string,
seriesLabelPrefix?: string,
lastModified?: string
} = {}
): Promise<GitHubPost[]> {
// Validate inputs
if (!auth) throw new Error('GitHub authentication token is required');
if (!username) throw new Error('GitHub username is required');
if (!repo) throw new Error('Repository name is required');
// Create client options
const clientOptions: GitHubClientOptions = {
auth,
repo: {
owner: username,
name: repo
},
mappings: {
blogPostCategory: options.blogPostCategory,
draftLabel: options.draftLabel,
tagLabelPrefix: options.tagLabelPrefix || 'tag/',
seriesLabelPrefix: options.seriesLabelPrefix || 'series/'
}
};
try {
// Initialize the GitHub client
const client = githubClient(clientOptions);
// Fetch all posts
return await client.getAllPosts(options.lastModified);
} catch (error) {
if (error instanceof Error) {
throw new Error(`Failed to fetch GitHub discussions: ${error.message}`);
}
throw new Error('Failed to fetch GitHub discussions');
}
}
export default class ObsidianGithubDiscussions extends Plugin {
settings: OGDSettings;
async onload() {
await this.loadSettings();
// This creates an icon in the left ribbon.
const ribbonIconEl = this.addRibbonIcon('arrow-up', 'Upload Blog to Github Discussions', this.upload());
// This creates an icon in the left ribbon.
const ribbonIconElDown = this.addRibbonIcon('arrow-down', 'Download Blog from Github Discussions', await this.download());
// Perform additional things with the ribbon
ribbonIconEl.addClass('my-plugin-ribbon-class');
ribbonIconElDown.addClass('my-plugin-ribbon-class');
// This adds a settings tab so the user can configure various aspects of the plugin
this.addSettingTab(new OGDSettingsTab(this.app, this));
}
private upload() {
return async (evt: MouseEvent) => {
const passing = await this.checkSettings();
if (!passing) return;
try {
// Get repository info
const repoInfo = await executeGitHubGraphQL(
GET_REPOSITORY_INFO,
{
owner: this.settings.owner,
name: this.settings.repo
},
GITHUB_TOKEN!
);
const repoId = repoInfo.repository.id;
const categoryId = repoInfo.repository.discussionCategories.nodes
.find((cat: any) => cat.name === this.settings.blogPostCategory)?.id;
if (!categoryId) {
new Notice(`Category '${this.settings.blogPostCategory}' not found in repository`);
return;
}
// Create a map of existing labels
const existingLabels = new Map(
repoInfo.repository.labels.nodes.map((label: any) => [label.name, label.id])
);
// Get existing discussions for comparison
const ghArticles = await fetchGithubDiscussions(
GITHUB_TOKEN!,
this.settings.owner,
this.settings.repo,
{
blogPostCategory: this.settings.blogPostCategory,
draftLabel: this.settings.draftLabel,
tagLabelPrefix: this.settings.tagLabelPrefix,
seriesLabelPrefix: this.settings.seriesLabelPrefix
}
);
// Process markdown files
let markdownFiles = this.app.vault.getMarkdownFiles()
.filter(file => file.path.startsWith(this.settings.articlesDir + "/"));
if (this.settings.makeMd) {
const filename = this.settings.articlesDir.split("/").last() + ".md";
markdownFiles = markdownFiles.filter(file => file.name !== filename);
}
// Find new files to create discussions for
const newFiles: { file: TFile; frontMatter: any; sections: string[]; }[] = [];
const existingFiles: { file: TFile; frontMatter: any; sections: string[]; }[] = [];
for (const file of markdownFiles) {
const content = await this.app.vault.read(file);
const sections = content.split("---");
if (sections.length < 3) continue;
const frontMatter = parseYaml(sections[1]);
if (!frontMatter.slug) continue;
const existingPost = ghArticles.find(post => {
const postFrontMatter = parseYaml(post.body.split("---")[1]);
return postFrontMatter.slug === frontMatter.slug;
});
if (existingPost) {
existingFiles.push({ file, frontMatter, sections });
} else {
newFiles.push({ file, frontMatter, sections });
}
}
// Handle new files
if (newFiles.length > 0) {
new OGDModal(this.app, `Create ${newFiles.length} new discussions from local files?`, async (result) => {
if (result) {
for (const { file, frontMatter, sections } of newFiles) {
const body = sections.slice(2).join("---").trim();
const labels: string[] = [];
if (frontMatter.tags) {
labels.push(...frontMatter.tags.map((tag: string) =>
`${this.settings.tagLabelPrefix}${tag}`
));
}
if (frontMatter.series) {
labels.push(`${this.settings.seriesLabelPrefix}${frontMatter.series}`);
}
// Create or update labels
//@ts-ignore
const labelIds = await createOrUpdateLabels(repoId, existingLabels, labels, GITHUB_TOKEN!);
// Prepare frontmatter for GitHub
const githubFrontMatter = {
slug: frontMatter.slug,
description: frontMatter.description,
published: convertDateFormatToGH(frontMatter.published)
};
// Create discussion content
const discussionBody = `---\n${stringifyYaml(githubFrontMatter)}---\n${body}`;
// Create new discussion
const result = await executeGitHubGraphQL(
CREATE_DISCUSSION_MUTATION,
{
repositoryId: repoId,
categoryId: categoryId,
title: file.basename,
body: discussionBody
},
GITHUB_TOKEN!
);
// Add labels to new discussion
await executeGitHubGraphQL(
ADD_LABELS_TO_DISCUSSION,
{
labelableId: result.createDiscussion.discussion.id,
labelIds: Array.from(labelIds.values())
},
GITHUB_TOKEN!
);
}
new Notice(`Created ${newFiles.length} new discussions`);
}
}).open();
}
// Handle existing files
if (existingFiles.length > 0) {
// Prompt for frontmatter and label updates
new OGDModal(this.app, "Would you like to update frontmatter and labels in GitHub Discussions?", async (result) => {
if (result) {
for (const { file, frontMatter } of existingFiles) {
const existingPost = ghArticles.find(post => {
const postFrontMatter = parseYaml(post.body.split("---")[1]);
return postFrontMatter.slug === frontMatter.slug;
});
if (existingPost) {
const labels: string[] = [];
if (frontMatter.tags) {
labels.push(...frontMatter.tags.map((tag: string) =>
`${this.settings.tagLabelPrefix}${tag}`
));
}
if (frontMatter.series) {
labels.push(`${this.settings.seriesLabelPrefix}${frontMatter.series}`);
}
// Create or update labels
//@ts-ignore
const labelIds = await createOrUpdateLabels(repoId, existingLabels, labels, GITHUB_TOKEN!);
// First, remove all existing labels that start with our prefixes
const existingDiscussion = await executeGitHubGraphQL(
`query getDiscussionLabels($id: ID!) {
node(id: $id) {
... on Discussion {
labels(first: 100) {
nodes {
id
name
}
}
}
}
}`,
{ id: existingPost.id },
GITHUB_TOKEN!
);
const existingLabelsToRemove = existingDiscussion.node.labels.nodes
.filter((label: any) =>
label.name.startsWith(this.settings.tagLabelPrefix) ||
label.name.startsWith(this.settings.seriesLabelPrefix)
)
.map((label: any) => label.id);
if (existingLabelsToRemove.length > 0) {
await executeGitHubGraphQL(
`mutation removeLabels($labelableId: ID!, $labelIds: [ID!]!) {
removeLabelsFromLabelable(input: {
labelableId: $labelableId,
labelIds: $labelIds
}) {
clientMutationId
}
}`,
{
labelableId: existingPost.id,
labelIds: existingLabelsToRemove
},
GITHUB_TOKEN!
);
}
// Then add the new labels
if (labelIds.size > 0) {
await executeGitHubGraphQL(
ADD_LABELS_TO_DISCUSSION,
{
labelableId: existingPost.id,
labelIds: Array.from(labelIds.values())
},
GITHUB_TOKEN!
);
}
}
}
new Notice('Updated frontmatter and labels in GitHub Discussions');
}
}).open();
// Prompt for content updates
new OGDModal(this.app, "Would you like to update discussion content in GitHub?", async (result) => {
if (result) {
for (const { file, frontMatter, sections } of existingFiles) {
const existingPost = ghArticles.find(post => {
const postFrontMatter = parseYaml(post.body.split("---")[1]);
return postFrontMatter.slug === frontMatter.slug;
});
if (existingPost) {
const body = sections.slice(2).join("---").trim();
// Prepare frontmatter for GitHub
const githubFrontMatter = {
slug: frontMatter.slug,
description: frontMatter.description,
published: convertDateFormatToGH(frontMatter.published)
};
// Create discussion content
const discussionBody = `---\n${stringifyYaml(githubFrontMatter)}---\n${body}`;
// Update existing discussion
await executeGitHubGraphQL(
UPDATE_DISCUSSION_MUTATION,
{
discussionId: existingPost.id,
title: file.basename,
body: discussionBody
},
GITHUB_TOKEN!
);
}
}
new Notice('Updated discussion content in GitHub');
}
}).open();
}
} catch (error) {
console.error('Error uploading to GitHub:', error);
new Notice(`Error uploading to GitHub: ${error instanceof Error ? error.message : 'Unknown error'}`);
}
};
}
private async download() {
return (evt: MouseEvent) => {
this.checkSettings().then(async passing => {
if (passing) {
// Get existing markdown files
let markdownFiles = this.app.vault.getMarkdownFiles().filter(file => file.path.startsWith(this.settings.articlesDir + "/"));
if (this.settings.makeMd) {
let filename = this.settings.articlesDir.split("/").last() + ".md";
markdownFiles = markdownFiles.filter(file => file.name !== filename);
}
// Fetch GitHub discussions
const ghArticles = await fetchGithubDiscussions(GITHUB_TOKEN!, this.settings.owner, this.settings.repo, {
blogPostCategory: this.settings.blogPostCategory,
draftLabel: this.settings.draftLabel,
tagLabelPrefix: this.settings.tagLabelPrefix,
seriesLabelPrefix: this.settings.seriesLabelPrefix,
});
// Create a map of GitHub articles
const ghArticleMap = new Map<string, any>();
ghArticles.forEach(article => {
const frontMatterString = article.body.split("---")[1];
const body = article.body.split("---").slice(2).join("---").trim();
const frontMatter = parseYaml(frontMatterString);
const tags = article.tags;
const series = article.series;
frontMatter['tags'] = tags;
if (series) {
frontMatter['series'] = series['id'];
}
ghArticleMap.set(frontMatter['slug'], [frontMatter, body, article.title]);
});
// Create a map of existing file slugs
const existingFileSlugs = new Set<string>();
for (const file of markdownFiles) {
const content = await this.app.vault.read(file);
const frontmatter = parseYaml(content.split("---")[1]);
if (frontmatter.slug) {
existingFileSlugs.add(frontmatter.slug);
}
}
// Handle new files
const newArticles = Array.from(ghArticleMap.entries())
.filter(([slug]) => !existingFileSlugs.has(slug));
if (newArticles.length > 0) {
new OGDModal(this.app, `Create ${newArticles.length} new articles from GitHub Discussions?`, async (result) => {
if (result) {
for (const [slug, [frontMatter, body, title]] of newArticles) {
// Create filename from the GitHub discussion title
const fileName = `${title}.md`;
const filePath = `${this.settings.articlesDir}/${fileName}`;
// Format the frontmatter date
if (frontMatter.published) {
frontMatter.published = convertDateFormatToObsidian(frontMatter.published);
}
// Create the file content
const newContent = "---\n" + stringifyYaml(frontMatter) + "---\n" + body;
// Create the new file
await this.app.vault.create(filePath, newContent);
}
new Notice(`Created ${newArticles.length} new articles from GitHub Discussions`);
}
}).open();
}
// Handle existing files updates
new OGDModal(this.app, "Would you like to update frontmatter from Github Discussions?", (result) => {
if (result) {
markdownFiles.map(file => {
this.app.fileManager.processFrontMatter(file, (frontmatter) => {
const ghFrontmatter = ghArticleMap.get(frontmatter['slug'])?.[0];
if (ghFrontmatter) {
frontmatter['description'] = ghFrontmatter['description'];
frontmatter['tags'] = ghFrontmatter['tags'] || [];
frontmatter['published'] = convertDateFormatToObsidian(ghFrontmatter['published']);
console.log(ghFrontmatter);
if (ghFrontmatter['tags']) {
frontmatter['tags'] = ghFrontmatter['tags'];
}
if (ghFrontmatter['series']) {
frontmatter['series'] = ghFrontmatter['series'];
}
}
});
});
}
}).open();
new OGDModal(this.app, "Would you like to update article bodies from Github Discussions?", (result) => {
if (result) {
markdownFiles.map(async file => {
const sections = await this.app.vault.read(file);
const frontmatter = parseYaml(sections.split("---")[1]);
const slug = frontmatter['slug'];
if (ghArticleMap.has(slug)) {
const newContent = "---\n" + stringifyYaml(frontmatter) + "---\n" + ghArticleMap.get(slug)[1];
await this.app.vault.modify(file, newContent);
}
});
}
}).open();
}
});
};
}
private async checkSettings(): Promise<boolean> {
const folders = this.app.vault.getAllLoadedFiles()
.filter(file => file instanceof TFolder);
folders.filter(folder => folder.name === this.settings.articlesDir);
let success = true;
if (folders.length === 0) {
new Notice('OGD: Does the Blog directory exist? Did you configure it in OGDSettings?');
success = false;
return Promise.resolve(success);
}
let markdownFiles = this.app.vault.getMarkdownFiles().filter(file => file.path.startsWith(this.settings.articlesDir + "/"));
if (this.settings.makeMd) {
let filename = this.settings.articlesDir.split("/").last() + ".md";
markdownFiles = markdownFiles.filter(file => file.name !== filename);
}
if (markdownFiles.length === 0) {
new Notice('OGD: No markdown files found in the specified directory.');
} else {
// Do something with the markdown files
new Notice(`OGD: Found ${markdownFiles.length} markdown files in the directory.`);
}
if (!GITHUB_TOKEN) {
new Notice('OGD: This plugin requires an environment variable to be set with the name OGD_GITHUB_TOKEN');
success = false;
}
if (this.settings.owner === "" || this.settings.repo === "") {
new Notice("OGD: Please ensure owner and repo are configured correctly. Owner should be a Github username and repo should be the name of the repository where we want to publish md to discussions.");
success = false;
}
return Promise.resolve(success);
}
onunload() {
}
async loadSettings() {
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
}
async saveSettings() {
await this.saveData(this.settings);
}
}
class OGDModal extends Modal {
constructor(app: App, question: string, onSubmit: (result: boolean) => void) {
super(app);
this.setTitle("OGD Confirmation Dialog:");
let approve = false;
new Setting(this.contentEl)
.setName(question)
.addToggle(toggle => {
toggle.setValue(approve)
.onChange(async (value) => {
approve = value;
})
});
new Setting(this.contentEl)
.addButton((btn) =>
btn
.setButtonText('Submit')
.setCta()
.onClick(() => {
this.close();
onSubmit(approve);
}));
}
}
class OGDSettingsTab extends PluginSettingTab {
plugin: ObsidianGithubDiscussions;
constructor(app: App, plugin: ObsidianGithubDiscussions) {
super(app, plugin);
this.plugin = plugin;
}
display(): void {
const {containerEl} = this;
containerEl.empty();
new Setting(containerEl)
.setName('Blog Articles Directory')
.setDesc('Github Discussion Blog Articles Directory')
.addDropdown(dropdown => {
// Get all folders in the vault
const folders = this.plugin.app.vault.getAllLoadedFiles()
.filter(file => file instanceof TFolder);
// Populate the dropdown with folder paths
folders.forEach(folder => {
dropdown.addOption(folder.path, folder.path);
});
dropdown
.setValue(this.plugin.settings.articlesDir)
.onChange(async (value) => {
this.plugin.settings.articlesDir = value;
await this.plugin.saveSettings();
});
});
new Setting(containerEl)
.setName("Make MD Plugin Installed?")
.setDesc("Set to true if using Make MD, else leave false")
.addToggle(toggle => {
toggle.setValue(this.plugin.settings.makeMd)
.onChange(async (value) => {
this.plugin.settings.makeMd = value;
await this.plugin.saveSettings();
})
});
new Setting(containerEl)
.setName("Repo Owner")
.setDesc("Github User who owns the repo")
.addText(tc => {
tc.setValue(this.plugin.settings.owner)
.onChange(async (value) => {
this.plugin.settings.owner = value;
await this.plugin.saveSettings();
})
});
new Setting(containerEl)
.setName("Repo Name")
.setDesc("Github Repo Name")
.addText(tc => {
tc.setValue(this.plugin.settings.repo)
.onChange(async (value) => {
this.plugin.settings.repo = value;
await this.plugin.saveSettings();
})
})
new Setting(containerEl)
.setName("Blog Post Category")
.setDesc("Optional")
.addText(tc => {
tc.setValue(this.plugin.settings.blogPostCategory)
.onChange(async (value) => {
this.plugin.settings.blogPostCategory = value;
await this.plugin.saveSettings();
})
})
new Setting(containerEl)
.setName("Draft Label")
.setDesc("Optional")
.addText(tc => {
tc.setValue(this.plugin.settings.draftLabel)
.onChange(async (value) => {
this.plugin.settings.draftLabel = value;
await this.plugin.saveSettings();
})
})
new Setting(containerEl)
.setName("Tag Label Prefix")
.setDesc("Optional")
.addText(tc => {
tc.setValue(this.plugin.settings.tagLabelPrefix)
.onChange(async (value) => {
this.plugin.settings.tagLabelPrefix = value;
await this.plugin.saveSettings();
})
})
new Setting(containerEl)
.setName("Series Label Prefix")
.setDesc("Optional")
.addText(tc => {
tc.setValue(this.plugin.settings.seriesLabelPrefix)
.onChange(async (value) => {
this.plugin.settings.seriesLabelPrefix = value;
await this.plugin.saveSettings();
})
})
}
}