feat(mention): disable auto-completion

This commit is contained in:
Elian Doran
2025-06-23 23:20:51 +03:00
parent 3988bb5321
commit b7f5c0e07a
6 changed files with 47 additions and 20 deletions

View File

@@ -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 = [

View File

@@ -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);
}
}