Skip to content

Commit 0818a8d

Browse files
committed
Static notification text, change logic for display text creation
1 parent 60ecbcb commit 0818a8d

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

main.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ interface AnchorDisplayTextSettings {
44
includeNoteName : string;
55
whichHeadings: string;
66
includeNotice: boolean;
7-
noticeText: string;
87
sep : string;
98
}
109

1110
const DEFAULT_SETTINGS: AnchorDisplayTextSettings = {
1211
includeNoteName: 'headersOnly',
1312
whichHeadings: 'allHeaders',
1413
includeNotice: false,
15-
noticeText: 'Link changed!',
1614
sep: ' '
1715
}
1816

@@ -48,15 +46,16 @@ export default class AnchorDisplayText extends Plugin {
4846
}
4947
}
5048
const startIndex = (match.index ?? 0) + match[0].length - 2;
51-
if (this.settings.includeNoteName === 'headersOnly') {
52-
editor.replaceRange(`|${displayText}`, {line: cursor.line, ch: startIndex}, undefined, 'headerDisplayText');
53-
} else if (this.settings.includeNoteName === 'noteNameFirst') {
54-
editor.replaceRange(`|${headings[0]}${this.settings.sep}${displayText}`, {line: cursor.line, ch: startIndex}, undefined, 'headerDisplayText');
49+
// add note name to display text if wanted
50+
if (this.settings.includeNoteName === 'noteNameFirst') {
51+
displayText = `${headings[0]}${this.settings.sep}${displayText}`;
5552
} else if (this.settings.includeNoteName === 'noteNameLast') {
56-
editor.replaceRange(`|${displayText}${this.settings.sep}${headings[0]}`, {line: cursor.line, ch: startIndex}, undefined, 'headerDisplayText');
53+
displayText = `${displayText}${this.settings.sep}${headings[0]}`;
5754
}
55+
// change the display text of the link
56+
editor.replaceRange(`|${displayText}`, {line: cursor.line, ch: startIndex}, undefined, 'headerDisplayText');
5857
if (this.settings.includeNotice) {
59-
new Notice (this.settings.noticeText)
58+
new Notice (`Updated anchor link display text.`);
6059
}
6160
}
6261
})

0 commit comments

Comments
 (0)