mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +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 = { |     const config: EditorConfig = { | ||||||
|         licenseKey, |         licenseKey, | ||||||
|         placeholder: t("editable_text.placeholder"), |         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: { |         codeBlock: { | ||||||
|             languages: buildListOfLanguages() |             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. |     // Enable premium plugins. | ||||||
|     if (hasPremiumLicense) { |     if (hasPremiumLicense) { | ||||||
|         config.extraPlugins = [ |         config.extraPlugins = [ | ||||||
|   | |||||||
| @@ -5,26 +5,40 @@ const TPL = /*html*/` | |||||||
| <div class="options-section"> | <div class="options-section"> | ||||||
|     <h4>Features</h4> |     <h4>Features</h4> | ||||||
|  |  | ||||||
|     <label class="tn-checkbox"> |     <div> | ||||||
|         <input type="checkbox" name="emoji-completion-enabled" /> |         <label class="tn-checkbox"> | ||||||
|         Enable Emoji auto-completion |             <input type="checkbox" name="emoji-completion-enabled" /> | ||||||
|     </label> |             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> | </div> | ||||||
| `; | `; | ||||||
|  |  | ||||||
| export default class EditorFeaturesOptions extends OptionsWidget { | export default class EditorFeaturesOptions extends OptionsWidget { | ||||||
|  |  | ||||||
|     private $emojiCompletionEnabledCheckbox!: JQuery<HTMLElement>; |     private $emojiCompletionEnabledCheckbox!: JQuery<HTMLElement>; | ||||||
|  |     private $noteCompletionEnabledCheckbox!: JQuery<HTMLElement>; | ||||||
|  |  | ||||||
|     doRender() { |     doRender() { | ||||||
|         this.$widget = $(TPL); |         this.$widget = $(TPL); | ||||||
|  |  | ||||||
|         this.$emojiCompletionEnabledCheckbox = this.$widget.find(`input[name="emoji-completion-enabled"]`); |         this.$emojiCompletionEnabledCheckbox = this.$widget.find(`input[name="emoji-completion-enabled"]`); | ||||||
|         this.$emojiCompletionEnabledCheckbox.on("change", () => this.updateCheckboxOption("textNoteEmojiCompletionEnabled", this.$emojiCompletionEnabledCheckbox)) |         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) { |     optionsLoaded(options: OptionMap) { | ||||||
|         this.setCheckboxState(this.$emojiCompletionEnabledCheckbox, options.textNoteEmojiCompletionEnabled); |         this.setCheckboxState(this.$emojiCompletionEnabledCheckbox, options.textNoteEmojiCompletionEnabled); | ||||||
|  |         this.setCheckboxState(this.$noteCompletionEnabledCheckbox, options.textNoteCompletionEnabled); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -86,6 +86,7 @@ const ALLOWED_OPTIONS = new Set<OptionNames>([ | |||||||
|     "textNoteEditorType", |     "textNoteEditorType", | ||||||
|     "textNoteEditorMultilineToolbar", |     "textNoteEditorMultilineToolbar", | ||||||
|     "textNoteEmojiCompletionEnabled", |     "textNoteEmojiCompletionEnabled", | ||||||
|  |     "textNoteCompletionEnabled", | ||||||
|     "layoutOrientation", |     "layoutOrientation", | ||||||
|     "backgroundEffects", |     "backgroundEffects", | ||||||
|     "allowedHtmlTags", |     "allowedHtmlTags", | ||||||
|   | |||||||
| @@ -179,6 +179,7 @@ const defaultOptions: DefaultOption[] = [ | |||||||
|     { name: "textNoteEditorType", value: "ckeditor-balloon", isSynced: true }, |     { name: "textNoteEditorType", value: "ckeditor-balloon", isSynced: true }, | ||||||
|     { name: "textNoteEditorMultilineToolbar", value: "false", isSynced: true }, |     { name: "textNoteEditorMultilineToolbar", value: "false", isSynced: true }, | ||||||
|     { name: "textNoteEmojiCompletionEnabled", value: "true", isSynced: true }, |     { name: "textNoteEmojiCompletionEnabled", value: "true", isSynced: true }, | ||||||
|  |     { name: "textNoteCompletionEnabled", value: "true", isSynced: true }, | ||||||
|  |  | ||||||
|     // HTML import configuration |     // HTML import configuration | ||||||
|     { name: "layoutOrientation", value: "vertical", isSynced: false }, |     { name: "layoutOrientation", value: "vertical", isSynced: false }, | ||||||
|   | |||||||
| @@ -13,6 +13,10 @@ export default class MentionCustomization extends Plugin { | |||||||
| 		return [ Mention ]; | 		return [ Mention ]; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  |     public static get pluginName() { | ||||||
|  | 		return "MentionCustomization" as const; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	afterInit() { | 	afterInit() { | ||||||
| 		const editor = this.editor; | 		const editor = this.editor; | ||||||
| 		// override standard mention command (see https://github.com/ckeditor/ckeditor5/issues/6470) | 		// override standard mention command (see https://github.com/ckeditor/ckeditor5/issues/6470) | ||||||
|   | |||||||
| @@ -118,7 +118,10 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions<KeyboardActi | |||||||
|     editedNotesOpenInRibbon: boolean; |     editedNotesOpenInRibbon: boolean; | ||||||
|     codeBlockWordWrap: boolean; |     codeBlockWordWrap: boolean; | ||||||
|     textNoteEditorMultilineToolbar: boolean; |     textNoteEditorMultilineToolbar: boolean; | ||||||
|  |     /** Whether keyboard auto-completion for emojis is triggered when typing `:`. */ | ||||||
|     textNoteEmojiCompletionEnabled: boolean; |     textNoteEmojiCompletionEnabled: boolean; | ||||||
|  |     /** Whether keyboard auto-completion for notes is triggered when typing `@` in text notes (attribute editing is not affected). */ | ||||||
|  |     textNoteCompletionEnabled: boolean; | ||||||
|     backgroundEffects: boolean; |     backgroundEffects: boolean; | ||||||
|  |  | ||||||
|     // Share settings |     // Share settings | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user