generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.ts
701 lines (590 loc) · 22.9 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
import { Hash } from 'crypto';
import { App, MarkdownPreviewView, Notice, Plugin, PluginSettingTab, Setting, ToggleComponent, FuzzySuggestModal, SuggestModal, TFile } from 'obsidian';
export default class WorkbenchPlugin extends Plugin {
settings: WorkbenchSettings;
async onload() {
//load data from saved settings
this.settings = (await this.loadData()) || new WorkbenchSettings();
this.addRibbonIcon('pencil', 'Workbench', () => {
let obsidianApp = this.app;
let workbenchNoteTitle = this.settings.workbenchNoteName;
let files = obsidianApp.vault.getFiles();
const workbenchNoteFile = files.filter(e => e.name === workbenchNoteTitle //hat-tip 🎩 to @MrJackPhil for this little workflow
|| e.path === workbenchNoteTitle
|| e.basename === workbenchNoteTitle
)[0];
obsidianApp.workspace.openLinkText(workbenchNoteTitle, workbenchNoteFile.path, true, MarkdownPreviewView);
});
this.addCommand({
id: 'workbench-link-current-note',
name: 'Link the current note/page in your Workbench.',
checkCallback: (checking: boolean) => {
let leaf = this.app.workspace.activeLeaf;
if (leaf) {
if (!checking) {
this.linkNoteInWorkbench();
}
return true;
}
return false;
}
});
this.addCommand({
id: 'workbench-embed-current-note',
name: 'Embed the current note/page in your Workbench.',
checkCallback: (checking: boolean) => {
let leaf = this.app.workspace.activeLeaf;
if (leaf) {
if (!checking) {
this.embedNoteInWorkbench();
}
return true;
}
return false;
}
});
this.addCommand({
id: 'workbench-link-current-block',
name: 'Link the current line/block in your Workbench.',
checkCallback: (checking: boolean) => {
let leaf = this.app.workspace.activeLeaf;
if (leaf) {
if (!checking) {
this.linkBlockInWorkbench();
}
return true;
}
return false;
}
});
this.addCommand({
id: 'workbench-embed-current-block',
name: 'Embed the current line/block into your Workbench.',
checkCallback: (checking: boolean) => {
let leaf = this.app.workspace.activeLeaf;
if (leaf) {
if (!checking) {
this.embedBlockInWorkbench();
}
return true;
}
return false;
}
});
this.addCommand({
id: 'workbench-copy-current-block',
name: 'Copy the current line/block into your Workbench.',
checkCallback: (checking: boolean) => {
let leaf = this.app.workspace.activeLeaf;
if (leaf) {
if (!checking) {
this.copyBlockIntoWorkbench();
}
return true;
}
return false;
}
});
this.addCommand({
id: 'workbench-copy-and-link-current-block',
name: 'Copy the current line/block into your Workbench as a markdown link to the line/block.',
checkCallback: (checking: boolean) => {
let leaf = this.app.workspace.activeLeaf;
if (leaf) {
if (!checking) {
this.copyLineAndLinkToBlock();
}
return true;
}
return false;
}
});
this.addCommand({
id: 'workbench-link-current-section',
name: 'Link the current heading/section into your Workbench.',
checkCallback: (checking: boolean) => {
let leaf = this.app.workspace.activeLeaf;
if (leaf) {
if (!checking) {
this.linkSectionInWorkbench();
}
return true;
}
return false;
}
});
this.addCommand({
id: 'workbench-embed-current-section',
name: 'Embed the current heading/section into your Workbench.',
checkCallback: (checking: boolean) => {
let leaf = this.app.workspace.activeLeaf;
if (leaf) {
if (!checking) {
this.embedSectionInWorkbench();
}
return true;
}
return false;
}
});
this.addCommand({
id: 'clear-workbench',
name: 'Clear the workbench note.',
callback: () => {
this.clearWorkbench();
}
});
this.addCommand({
id: 'insert-workbench',
name: 'Insert the contents of the workbench note.',
checkCallback: (checking: boolean) => {
let leaf = this.app.workspace.activeLeaf;
if (leaf) {
if (!checking) {
this.insertWorkbench();
}
return true;
}
return false;
}
});
this.addCommand({
id: 'choose-new-workbench',
name: 'Change your Workbench.',
checkCallback: (checking: boolean) => {
let leaf = this.app.workspace.activeLeaf;
if (leaf) {
if (!checking) {
this.changeWorkbench();
}
return true;
}
return false;
}
});
this.addSettingTab(new WorkbenchSettingTab(this.app, this));
this.registerDomEvent(document, 'click', (evt: MouseEvent) => {
if (this.settings.altClickType != "Nothing") {
if (evt.altKey) {
if ((evt.target.className === "internal-link") || (evt.target.className.includes("cm-hmd-internal-link"))) {
this.altClick(evt);
}
}
}
if (this.settings.metaAltClickType != "Nothing") {
if (evt.metaKey && evt.altKey) {
if ((evt.target.className.includes("cm-hmd-internal-link"))) {
new Notice("Sorry, this doesn't work when you click directly on a link. Try clicking outside of the link!");
} else if ((evt.target.className.includes("CodeMirror-line")) || evt.target.className.includes("cm")) {
let currentFile = this.app.workspace.activeLeaf.view.file;
this.metaAltClick(evt, currentFile);
}
}
}
});
}
onunload() {
console.log('Unloading the Workbench plugin.');
}
insertWorkbench() {
let obsidianApp = this.app;
let workbenchNoteTitle = this.settings.workbenchNoteName;
let files = obsidianApp.vault.getFiles();
const workbenchNoteFile = files.filter(e => e.name === workbenchNoteTitle //hat-tip 🎩 to @MrJackPhil for this little workflow
|| e.path === workbenchNoteTitle
|| e.basename === workbenchNoteTitle
)[0];
let currentNoteFile = obsidianApp.workspace.activeLeaf.view.file;
let editor = obsidianApp.workspace.activeLeaf.view.sourceMode.cmEditor;
let cursor = editor.getCursor();
let doc = editor.getDoc();
obsidianApp.vault.read(workbenchNoteFile).then(function (result) {
doc.replaceRange(result, cursor);
editor.focus();
});
}
clearWorkbench() {
let obsidianApp = this.app;
let workbenchNoteTitle = this.settings.workbenchNoteName;
let editor = obsidianApp.workspace.activeLeaf.view.sourceMode.cmEditor;
let cursor = editor.getCursor();
let files = obsidianApp.vault.getFiles();
const workbenchNoteFile = files.filter(e => e.name === workbenchNoteTitle //hat-tip 🎩 to @MrJackPhil for this little workflow
|| e.path === workbenchNoteTitle
|| e.basename === workbenchNoteTitle
)[0];
obsidianApp.vault.modify(workbenchNoteFile, "");
editor.setCursor(cursor);
editor.focus();
}
saveToWorkbench(theMaterial: string, saveAction: string) {
let obsidianApp = this.app;
let editor = obsidianApp.workspace.activeLeaf.view.sourceMode.cmEditor;
let cursor = editor.getCursor();
let blankLine = this.settings.includeBlankLine;
let linePrefix = this.settings.workbenchLinePrefix;
let workbenchNoteTitle = this.settings.workbenchNoteName;
let files = obsidianApp.vault.getFiles();
const workbenchNoteFile = files.filter(e => e.name === workbenchNoteTitle //hat-tip 🎩 to @MrJackPhil for this little workflow
|| e.path === workbenchNoteTitle
|| e.basename === workbenchNoteTitle
)[0];
if (!workbenchNoteFile) {
let noteText = linePrefix + theMaterial;
let newWorkbenchFile = obsidianApp.vault.create(workbenchNoteTitle + ".md", noteText);
} else { // The file exists
let previousNoteText = "";
obsidianApp.vault.read(workbenchNoteFile).then(function (result) {
let previousNoteText = result;
let lineSpacing = "\n";
if (blankLine) {
lineSpacing = "\n\n";
}
let newNoteText = previousNoteText + lineSpacing + linePrefix + theMaterial;
obsidianApp.vault.modify(workbenchNoteFile, newNoteText);
new Notice("Added " + saveAction + " to the workbench.")
});
}
editor.setCursor(cursor);
editor.focus();
}
createBlockHash(inputText: string): string { // Credit to https://stackoverflow.com/a/1349426
let obsidianApp = this.app;
let result = '';
var characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < 7; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
getBlock(inputLine: string, noteFile: object): string { //Returns the string of a block ID if block is found, or "" if not.
let obsidianApp = this.app;
let noteBlocks = obsidianApp.metadataCache.getFileCache(noteFile).blocks;
let blockString = "";
if (noteBlocks) { // the file does contain blocks. If not, return ""
for (let eachBlock in noteBlocks) { // iterate through the blocks.
let blockRegExp = new RegExp("(" + eachBlock + ")$", "gim");
if (inputLine.match(blockRegExp)) { // if end of inputLine matches block, return it
blockString = eachBlock;
return blockString;
}
}
return blockString;
}
return blockString;
}
altClick(someMouseEvent: Event) {
let obsidianApp = this.app;
let clickType = this.settings.altClickType;
let linkPrefix = "";
if (clickType === "Embed") {
linkPrefix = "!";
}
let newMaterial = linkPrefix + "[[" + someMouseEvent.target.innerText + "]]";
this.saveToWorkbench(newMaterial, "a link to the selected note");
}
metaAltClick(someMouseEvent: Event, activeFile: object) {
let obsidianApp = this.app;
let editor = obsidianApp.workspace.activeLeaf.view.sourceMode.cmEditor;
let lineNumber = editor.getCursor().line;
let lineText = editor.getLine(lineNumber);
// Get the file and create a link to it
let currentNoteFile = activeFile;
let noteLink = obsidianApp.metadataCache.fileToLinktext(currentNoteFile, currentNoteFile.path, true);
let clickType = this.settings.metaAltClickType;
if (lineText != "") {
if (clickType === "Copy") {
let newMaterial = lineText;
this.saveToWorkbench(newMaterial, "a copy of the selected line/block");
} else {
let linkPrefix = "";
if (clickType === "Embed") {
linkPrefix = "!";
}
if (this.getBlock(lineText, currentNoteFile) === "") { // The line is not already a block
lineText = lineText.trim();
let lineBlockID = this.createBlockHash(lineText).toString();
let lineWithBlock = lineText + " ^" + lineBlockID;
obsidianApp.vault.read(currentNoteFile).then(function (result) {
let previousNoteText = result;
let newNoteText = previousNoteText.replace(lineText, lineWithBlock);
obsidianApp.vault.modify(currentNoteFile, newNoteText);
})
} else {
let lineBlockID = this.getBlock(lineText, currentNoteFile);
}
let newMaterial = linkPrefix + "[[" + noteLink + "#^" + lineBlockID + "]]";
this.saveToWorkbench(newMaterial, "a link to the selected line/block");
}
} else {
new Notice("There is nothing on the selected line.");
}
}
linkNoteInWorkbench() { // Saves a link to the current note to the workbench
let obsidianApp = this.app;
let currentView = obsidianApp.workspace.activeLeaf.view;
// Get the file and create a link to it
let currentNoteFile = obsidianApp.workspace.activeLeaf.view.file;
let noteLink = obsidianApp.metadataCache.fileToLinktext(currentNoteFile, currentNoteFile.path, true);
let editor = currentView.sourceMode.cmEditor;
let newMaterial = "[[" + noteLink + "]]";
this.saveToWorkbench(newMaterial, "a link to the current note");
}
embedNoteInWorkbench() { // Saves an embed of the current note to the workbench
let obsidianApp = this.app;
// Get the file and create a link to it
let currentNoteFile = obsidianApp.workspace.activeLeaf.view.file;
let noteLink = obsidianApp.metadataCache.fileToLinktext(currentNoteFile, currentNoteFile.path, true);
let newMaterial = "![[" + noteLink + "]]";
this.saveToWorkbench(newMaterial, "an embed of the current note");
}
linkSectionInWorkbench() { // Saves a link to the current heading to the workbench
let obsidianApp = this.app;
// get the heading
let currentView = obsidianApp.workspace.activeLeaf.view;
let currentNoteFile = currentView.file;
let editor = currentView.sourceMode.cmEditor;
var cursor = editor.getCursor();
let currentLineNumber = cursor.line;
// Stuck here. For some reason the action only works once on some sections tktktk
let headings = obsidianApp.metadataCache.getFileCache(currentNoteFile).headings;
let sectionHeading;
if (!headings) {
new Notice("No headings found in the current document.");
return;
} else { // check what heading is closest above the current line
for (let eachHeading of headings) {
let headingLineNumber = eachHeading.position.start.line;
if (headingLineNumber > currentLineNumber) {
new Notice("All headings are below the cursor. Link the note or a block instead.")
return;
}
if (headingLineNumber == currentLineNumber) {
sectionHeading = eachHeading;
break;
} else if (headingLineNumber > currentLineNumber) {
break;
}
sectionHeading = eachHeading;
}
}
let noteLink = obsidianApp.metadataCache.fileToLinktext(currentNoteFile, currentNoteFile.path, true);
let newMaterial = "[[" + noteLink + "#" + sectionHeading.heading + "]]";
this.saveToWorkbench(newMaterial, "a link to the current section");
}
embedSectionInWorkbench() { // Saves an embed of the current heading to the workbench
let obsidianApp = this.app;
// get the heading
let currentView = obsidianApp.workspace.activeLeaf.view;
let currentNoteFile = currentView.file;
let editor = currentView.sourceMode.cmEditor;
var cursor = editor.getCursor();
let currentLineNumber = cursor.line;
console.log(currentLineNumber)
// Stuck here. For some reason the action only works once on some sections tktktk
let headings = obsidianApp.metadataCache.getFileCache(currentNoteFile).headings;
let sectionHeading;
if (!headings) {
new Notice("No headings found in the current document.");
return;
} else { // check what heading is closest above the current line
for (let eachHeading of headings) {
let headingLineNumber = eachHeading.position.start.line;
if (headingLineNumber > currentLineNumber) {
new Notice("All headings are below the cursor. Embed the note or a block instead.")
return;
}
if (headingLineNumber == currentLineNumber) {
sectionHeading = eachHeading;
break;
} else if (headingLineNumber > currentLineNumber) {
break;
}
sectionHeading = eachHeading;
}
}
let noteLink = obsidianApp.metadataCache.fileToLinktext(currentNoteFile, currentNoteFile.path, true);
let newMaterial = "![[" + noteLink + "#" + sectionHeading.heading + "]]";
this.saveToWorkbench(newMaterial, "a link to the current section");
}
linkBlockInWorkbench() { // Links the current block to the workbench
let obsidianApp = this.app;
// get the block
let currentView = obsidianApp.workspace.activeLeaf.view;
let currentNoteFile = currentView.file;
let editor = currentView.sourceMode.cmEditor;
var cursor = editor.getCursor();
let lineText = editor.getLine(cursor.line);
let lineBlockID = this.getBlock(lineText, currentNoteFile);
if (this.getBlock(lineText, currentNoteFile) === "") { // The line is not already a block
lineBlockID = this.createBlockHash(lineText).toString();
let lineWithBlock = lineText + " ^" + lineBlockID;
obsidianApp.vault.read(currentNoteFile).then(function (result) {
let previousNoteText = result;
let newNoteText = previousNoteText.replace(lineText, lineWithBlock);
obsidianApp.vault.modify(currentNoteFile, newNoteText);
})
}
let noteLink = obsidianApp.metadataCache.fileToLinktext(currentNoteFile, currentNoteFile.path, true);
let newMaterial = "[[" + noteLink + "#^" + lineBlockID + "]]";
this.saveToWorkbench(newMaterial, "a link to the current block");
}
embedBlockInWorkbench() { // Saves an embed of the current block to the workbench
let obsidianApp = this.app;
// get the block
let currentView = obsidianApp.workspace.activeLeaf.view;
let currentNoteFile = currentView.file;
let editor = currentView.sourceMode.cmEditor;
var cursor = editor.getCursor();
let lineText = editor.getLine(cursor.line);
let lineBlockID = this.getBlock(lineText, currentNoteFile);
if (this.getBlock(lineText, currentNoteFile) === "") { // The line is not already a block
lineBlockID = this.createBlockHash(lineText).toString();
let lineWithBlock = lineText + " ^" + lineBlockID;
obsidianApp.vault.read(currentNoteFile).then(function (result) {
let previousNoteText = result;
let newNoteText = previousNoteText.replace(lineText, lineWithBlock);
obsidianApp.vault.modify(currentNoteFile, newNoteText);
})
}
let noteLink = obsidianApp.metadataCache.fileToLinktext(currentNoteFile, currentNoteFile.path, true);
let newMaterial = "![[" + noteLink + "#^" + lineBlockID + "]]";
this.saveToWorkbench(newMaterial, "a link to the current block");
}
copyBlockIntoWorkbench() { // Copies the content of the current block to the workbench
let obsidianApp = this.app;
let currentView = obsidianApp.workspace.activeLeaf.view;
let editor = currentView.sourceMode.cmEditor;
var cursor = editor.getCursor();
let lineText = editor.getLine(cursor.line);
let newMaterial = lineText;
this.saveToWorkbench(newMaterial, "a copy of the current block");
}
copyLineAndLinkToBlock() { // Copies the content of the current block to the workbench
let obsidianApp = this.app;
let currentView = obsidianApp.workspace.activeLeaf.view;
let currentNoteFile = currentView.file;
let editor = currentView.sourceMode.cmEditor;
var cursor = editor.getCursor();
let lineText = editor.getLine(cursor.line);
let blockIDRegex = new RegExp("/(\s){0,1}[\^]{1}([a-zA-Z0-9\-]+)$/", "gim");
let lineTextWithoutBlockID = lineText.replace(blockIDRegex, "");
let lineBlockID = this.getBlock(lineText, currentNoteFile);
if (this.getBlock(lineText, currentNoteFile) === "") { // The line is not already a block
console.log("This line is not currently a block. Adding a block ID.");
lineBlockID = this.createBlockHash(lineText).toString();
let lineWithBlock = lineText + " ^" + lineBlockID;
obsidianApp.vault.read(currentNoteFile).then(function (result) {
let previousNoteText = result;
let newNoteText = previousNoteText.replace(lineText, lineWithBlock);
obsidianApp.vault.modify(currentNoteFile, newNoteText);
})
}
let noteLink = obsidianApp.metadataCache.fileToLinktext(currentNoteFile, currentNoteFile.path, true);
let encodedNoteLink = encodeURIComponent(noteLink);
let newMaterial = "[" + lineTextWithoutBlockID + "]" + "(" + encodedNoteLink + "#^" + lineBlockID + ")";
this.saveToWorkbench(newMaterial, "a linked copy of the current block");
}
changeWorkbench() {
let obsidianApp = this.app;
new workbenchNameModal(obsidianApp).open();
}
}
class workbenchNameModal extends FuzzySuggestModal<string> { // thanks to Licat for the assist!
app: App;
constructor(app: App) {
super(app);
this.app = app;
}
getItems(): string[] {
let files = this.app.vault.getMarkdownFiles();
let fileList = files.map(file => file.name);
return fileList;
}
getItemText(item: string): string {
return item;
}
onChooseItem(item: string, evt: MouseEvent | KeyboardEvent): void {
let workbenchPlugin = this.app.plugins.getPlugin("workbench-obsidian");
workbenchPlugin.settings.workbenchNoteName = item;
workbenchPlugin.saveData(workbenchPlugin.settings);
new Notice("Your workbench is now " + item);
}
}
class WorkbenchSettings {
workbenchNoteName = "Workbench";
workbenchLinePrefix = "";
altClickType = "Link";
metaAltClickType = "Embed";
includeBlankLine = false;
}
class WorkbenchSettingTab extends PluginSettingTab {
display(): void {
let {containerEl} = this;
const plugin: any = (this as any).plugin;
containerEl.empty();
containerEl.createEl('h2', {text: 'Workbench Settings'});
new Setting(containerEl)
.setName('Workbench note name')
.setDesc('Provide a title for the workbench note. Default is Workbench.')
.addText(text =>
text
.setPlaceholder('Workbench')
.setValue(plugin.settings.workbenchNoteName)
.onChange((value) => {
plugin.settings.workbenchNoteName = value;
plugin.saveData(plugin.settings);
}));
new Setting(containerEl)
.setName('Workbench line prefix')
.setDesc('Set the prefix to each line added to Workbench. Default is nothing.')
.addText(text =>
text
.setPlaceholder('')
.setValue(plugin.settings.workbenchLinePrefix)
.onChange((value) => {
plugin.settings.workbenchLinePrefix = value;
plugin.saveData(plugin.settings);
}));
new Setting(containerEl)
.setName('Blank lines')
.setDesc('Toggle whether there should be a blank line between each Workbench entry.')
.addToggle((toggle) => {
toggle.setValue(plugin.settings.includeBlankLine);
toggle.onChange(async (value) => {
plugin.settings.includeBlankLine = value;
plugin.saveData(plugin.settings);
});
});
new Setting(containerEl)
.setName('Alt+Click type')
.setDesc('Set what happens when you alt+click on a link. Default is to copy the link into the Workbench. Note: if your cursor is not already on the targeted line, you may need to double-click!')
.addDropdown(dropDown =>
dropDown
.addOption("Link", "Link selected note in Workbench")
.addOption("Embed", "Embed selected note in Workbench")
.addOption("Nothing", "Nothing")
.setValue(plugin.settings.altClickType)
.onChange((value: string) => {
plugin.settings.altClickType = value;
plugin.saveData(plugin.settings);
this.display();
}));
new Setting(containerEl)
.setName('Meta+Alt+Click type')
.setDesc('Set what happens when you cmd/ctrl+alt+click on a line. Default is to link the line as a block into the Workbench. Note: if your cursor is not already on the targeted line, you may need to double-click!')
.addDropdown(dropDown =>
dropDown
.addOption("Link", "Link block")
.addOption("Embed", "Embed block")
.addOption("Copy", "Copy line")
.addOption("Nothing", "Nothing")
.setValue(plugin.settings.metaAltClickType)
.onChange((value: string) => {
plugin.settings.metaAltClickType = value;
plugin.saveData(plugin.settings);
this.display();
}));
}
}