mirror of
https://github.com/zadam/trilium.git
synced 2025-11-16 18:25:51 +01:00
feat(mention): disable auto-completion
This commit is contained in:
@@ -29,22 +29,6 @@ export async function buildConfig(opts: BuildEditorOptions): Promise<EditorConfi
|
||||
const config: EditorConfig = {
|
||||
licenseKey,
|
||||
placeholder: t("editable_text.placeholder"),
|
||||
mention: {
|
||||
feeds: [
|
||||
{
|
||||
marker: "@",
|
||||
feed: (queryText: string) => noteAutocompleteService.autocompleteSourceForCKEditor(queryText),
|
||||
itemRenderer: (item) => {
|
||||
const itemElement = document.createElement("button");
|
||||
|
||||
itemElement.innerHTML = `${(item as Suggestion).highlightedNotePathTitle} `;
|
||||
|
||||
return itemElement;
|
||||
},
|
||||
minimumCharacters: 0
|
||||
}
|
||||
],
|
||||
},
|
||||
codeBlock: {
|
||||
languages: buildListOfLanguages()
|
||||
},
|
||||
@@ -192,6 +176,26 @@ export async function buildConfig(opts: BuildEditorOptions): Promise<EditorConfi
|
||||
}
|
||||
}
|
||||
|
||||
// Mention customisation.
|
||||
if (options.get("textNoteCompletionEnabled") === "true") {
|
||||
config.mention = {
|
||||
feeds: [
|
||||
{
|
||||
marker: "@",
|
||||
feed: (queryText: string) => noteAutocompleteService.autocompleteSourceForCKEditor(queryText),
|
||||
itemRenderer: (item) => {
|
||||
const itemElement = document.createElement("button");
|
||||
|
||||
itemElement.innerHTML = `${(item as Suggestion).highlightedNotePathTitle} `;
|
||||
|
||||
return itemElement;
|
||||
},
|
||||
minimumCharacters: 0
|
||||
}
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
// Enable premium plugins.
|
||||
if (hasPremiumLicense) {
|
||||
config.extraPlugins = [
|
||||
|
||||
@@ -5,26 +5,40 @@ const TPL = /*html*/`
|
||||
<div class="options-section">
|
||||
<h4>Features</h4>
|
||||
|
||||
<label class="tn-checkbox">
|
||||
<input type="checkbox" name="emoji-completion-enabled" />
|
||||
Enable Emoji auto-completion
|
||||
</label>
|
||||
<div>
|
||||
<label class="tn-checkbox">
|
||||
<input type="checkbox" name="emoji-completion-enabled" />
|
||||
Enable Emoji auto-completion
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="tn-checkbox">
|
||||
<input type="checkbox" name="note-completion-enabled" />
|
||||
Enable note auto-completion
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
export default class EditorFeaturesOptions extends OptionsWidget {
|
||||
|
||||
private $emojiCompletionEnabledCheckbox!: JQuery<HTMLElement>;
|
||||
private $noteCompletionEnabledCheckbox!: JQuery<HTMLElement>;
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
|
||||
this.$emojiCompletionEnabledCheckbox = this.$widget.find(`input[name="emoji-completion-enabled"]`);
|
||||
this.$emojiCompletionEnabledCheckbox.on("change", () => this.updateCheckboxOption("textNoteEmojiCompletionEnabled", this.$emojiCompletionEnabledCheckbox))
|
||||
|
||||
this.$noteCompletionEnabledCheckbox = this.$widget.find(`input[name="note-completion-enabled"]`);
|
||||
this.$noteCompletionEnabledCheckbox.on("change", () => this.updateCheckboxOption("textNoteCompletionEnabled", this.$noteCompletionEnabledCheckbox))
|
||||
}
|
||||
|
||||
optionsLoaded(options: OptionMap) {
|
||||
this.setCheckboxState(this.$emojiCompletionEnabledCheckbox, options.textNoteEmojiCompletionEnabled);
|
||||
this.setCheckboxState(this.$noteCompletionEnabledCheckbox, options.textNoteCompletionEnabled);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user