feat - added callout qoute collapsible setting;
Feat - added show full suggestion setting;
This commit is contained in:
@@ -295,16 +295,26 @@ export default class PassageSuggest extends EditorSuggest<PassageSuggestion> {
|
||||
|
||||
/** Generates an excerpt for the suggestion. */
|
||||
private generateExcerpt(text: string): string {
|
||||
text = text.split(/<\/sup>/, 2)[1];
|
||||
text = text.replace(/<sup>\d+<\/sup>/g, '');
|
||||
text = text.replace(/^(?:> |- )/gm, '');
|
||||
if(this.settings.fullSuggestion){
|
||||
text = text.replace(/(?:<sup>)/g, "");
|
||||
text = text.replace(/(?:<\/sup>)/g, "");
|
||||
}
|
||||
else{
|
||||
text = text.split(/<\/sup>/, 2)[1];
|
||||
text = text.replace(/<sup>\d+<\/sup>/g, "");
|
||||
text = text.replace(/^(?:> |- )/gm, "");
|
||||
}
|
||||
|
||||
text = text.replace(
|
||||
/<span(?:\s+\w+=['"][^'"]+['"])*>([^<]+)<\/span>/g,
|
||||
'$1'
|
||||
"$1"
|
||||
);
|
||||
text = text.replace(/\n/g, ' ');
|
||||
text = text.replace(/ {2,}/g, ' ');
|
||||
return text.slice(0, 45) + '...';
|
||||
if(!this.settings.fullSuggestion)
|
||||
text = text.replace(/\n/g, ' ');
|
||||
text = text.replace(/ {2,}/g, " ");
|
||||
if (this.settings.fullSuggestion)
|
||||
return text;
|
||||
return text.slice(0, 45) + "...";
|
||||
}
|
||||
|
||||
/** Formats the final text for suggestion. */
|
||||
@@ -358,8 +368,9 @@ export default class PassageSuggest extends EditorSuggest<PassageSuggestion> {
|
||||
if (linkToPassage)
|
||||
stringRef = this.generatePassageLink(passageRef, context);
|
||||
else stringRef = passageRef.stringify();
|
||||
formatted = `> [!quote]${this.settings.callout.collapsible? '+' : ''} ${stringRef}\n`;
|
||||
|
||||
formatted = `> [!${type}] ${stringRef}\n`;
|
||||
formatted = `> [!${type}]${this.settings.callout.collapsible? '+' : ''} ${stringRef}\n`;
|
||||
formatted += texts.join('\n\n').trim();
|
||||
formatted = formatted.replace(/\n/gm, '\n> ');
|
||||
formatted += '\n\n';
|
||||
|
||||
Reference in New Issue
Block a user