mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	feat(emoji): add an option to disable them (closes #5852)
This commit is contained in:
		| @@ -179,7 +179,8 @@ export async function buildConfig(opts: BuildEditorOptions): Promise<EditorConfi | ||||
|             allow: JSON.parse(options.get("allowedHtmlTags")) | ||||
|         }, | ||||
|         // This value must be kept in sync with the language defined in webpack.config.js. | ||||
|         language: "en" | ||||
|         language: "en", | ||||
|         removePlugins: getDisabledPlugins() | ||||
|     }; | ||||
|  | ||||
|     // Set up content language. | ||||
| @@ -231,3 +232,13 @@ function getLicenseKey() { | ||||
|  | ||||
|     return premiumLicenseKey; | ||||
| } | ||||
|  | ||||
| function getDisabledPlugins() { | ||||
|     let disabledPlugins: string[] = []; | ||||
|  | ||||
|     if (options.get("textNoteEmojiEnabled") !== "true") { | ||||
|         disabledPlugins.push("Emoji"); | ||||
|     } | ||||
|  | ||||
|     return disabledPlugins; | ||||
| } | ||||
|   | ||||
| @@ -46,6 +46,7 @@ import LanguageOptions from "./options/i18n/language.js"; | ||||
| import type BasicWidget from "../basic_widget.js"; | ||||
| import CodeTheme from "./options/code_notes/code_theme.js"; | ||||
| import RelatedSettings from "./options/appearance/related_settings.js"; | ||||
| import EditorFeaturesOptions from "./options/text_notes/features.js"; | ||||
|  | ||||
| const TPL = /*html*/`<div class="note-detail-content-widget note-detail-printable"> | ||||
|     <style> | ||||
| @@ -85,6 +86,7 @@ const CONTENT_WIDGETS: Record<OptionPages | "_backendLog", (typeof NoteContextAw | ||||
|     ], | ||||
|     _optionsTextNotes: [ | ||||
|         EditorOptions, | ||||
|         EditorFeaturesOptions, | ||||
|         HeadingStyleOptions, | ||||
|         CodeBlockOptions, | ||||
|         TableOfContentsOptions, | ||||
|   | ||||
| @@ -0,0 +1,30 @@ | ||||
| import { OptionMap } from "@triliumnext/commons"; | ||||
| import OptionsWidget from "../options_widget"; | ||||
|  | ||||
| const TPL = /*html*/` | ||||
| <div class="options-section"> | ||||
|     <h4>Features</h4> | ||||
|  | ||||
|     <label class="tn-checkbox"> | ||||
|         <input type="checkbox" name="emoji-enabled" /> | ||||
|         Enable Emoji support and auto-completion | ||||
|     </label> | ||||
| </div> | ||||
| `; | ||||
|  | ||||
| export default class EditorFeaturesOptions extends OptionsWidget { | ||||
|  | ||||
|     private $emojiEnabledCheckbox!: JQuery<HTMLElement>; | ||||
|  | ||||
|     doRender() { | ||||
|         this.$widget = $(TPL); | ||||
|  | ||||
|         this.$emojiEnabledCheckbox = this.$widget.find(`input[name="emoji-enabled"]`); | ||||
|         this.$emojiEnabledCheckbox.on("change", () => this.updateCheckboxOption("textNoteEmojiEnabled", this.$emojiEnabledCheckbox)) | ||||
|     } | ||||
|  | ||||
|     optionsLoaded(options: OptionMap) { | ||||
|         this.setCheckboxState(this.$emojiEnabledCheckbox, options.textNoteEmojiEnabled); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -85,6 +85,7 @@ const ALLOWED_OPTIONS = new Set<OptionNames>([ | ||||
|     "languages", | ||||
|     "textNoteEditorType", | ||||
|     "textNoteEditorMultilineToolbar", | ||||
|     "textNoteEmojiEnabled", | ||||
|     "layoutOrientation", | ||||
|     "backgroundEffects", | ||||
|     "allowedHtmlTags", | ||||
|   | ||||
| @@ -178,6 +178,7 @@ const defaultOptions: DefaultOption[] = [ | ||||
|     // Text note configuration | ||||
|     { name: "textNoteEditorType", value: "ckeditor-balloon", isSynced: true }, | ||||
|     { name: "textNoteEditorMultilineToolbar", value: "false", isSynced: true }, | ||||
|     { name: "textNoteEmojiEnabled", value: "true", isSynced: true }, | ||||
|  | ||||
|     // HTML import configuration | ||||
|     { name: "layoutOrientation", value: "vertical", isSynced: false }, | ||||
|   | ||||
| @@ -118,6 +118,7 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions<KeyboardActi | ||||
|     editedNotesOpenInRibbon: boolean; | ||||
|     codeBlockWordWrap: boolean; | ||||
|     textNoteEditorMultilineToolbar: boolean; | ||||
|     textNoteEmojiEnabled: boolean; | ||||
|     backgroundEffects: boolean; | ||||
|  | ||||
|     // Share settings | ||||
|   | ||||
		Reference in New Issue
	
	Block a user