feat(emoji): add an option to disable them (closes #5852)

This commit is contained in:
Elian Doran 2025-06-23 22:10:41 +03:00
parent 1ac086b88e
commit ba94616b87
No known key found for this signature in database
6 changed files with 47 additions and 1 deletions

View File

@ -179,7 +179,8 @@ export async function buildConfig(opts: BuildEditorOptions): Promise<EditorConfi
allow: JSON.parse(options.get("allowedHtmlTags")) allow: JSON.parse(options.get("allowedHtmlTags"))
}, },
// This value must be kept in sync with the language defined in webpack.config.js. // 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. // Set up content language.
@ -231,3 +232,13 @@ function getLicenseKey() {
return premiumLicenseKey; return premiumLicenseKey;
} }
function getDisabledPlugins() {
let disabledPlugins: string[] = [];
if (options.get("textNoteEmojiEnabled") !== "true") {
disabledPlugins.push("Emoji");
}
return disabledPlugins;
}

View File

@ -46,6 +46,7 @@ import LanguageOptions from "./options/i18n/language.js";
import type BasicWidget from "../basic_widget.js"; import type BasicWidget from "../basic_widget.js";
import CodeTheme from "./options/code_notes/code_theme.js"; import CodeTheme from "./options/code_notes/code_theme.js";
import RelatedSettings from "./options/appearance/related_settings.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"> const TPL = /*html*/`<div class="note-detail-content-widget note-detail-printable">
<style> <style>
@ -85,6 +86,7 @@ const CONTENT_WIDGETS: Record<OptionPages | "_backendLog", (typeof NoteContextAw
], ],
_optionsTextNotes: [ _optionsTextNotes: [
EditorOptions, EditorOptions,
EditorFeaturesOptions,
HeadingStyleOptions, HeadingStyleOptions,
CodeBlockOptions, CodeBlockOptions,
TableOfContentsOptions, TableOfContentsOptions,

View File

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

View File

@ -85,6 +85,7 @@ const ALLOWED_OPTIONS = new Set<OptionNames>([
"languages", "languages",
"textNoteEditorType", "textNoteEditorType",
"textNoteEditorMultilineToolbar", "textNoteEditorMultilineToolbar",
"textNoteEmojiEnabled",
"layoutOrientation", "layoutOrientation",
"backgroundEffects", "backgroundEffects",
"allowedHtmlTags", "allowedHtmlTags",

View File

@ -178,6 +178,7 @@ const defaultOptions: DefaultOption[] = [
// Text note configuration // Text note configuration
{ 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: "textNoteEmojiEnabled", value: "true", isSynced: true },
// HTML import configuration // HTML import configuration
{ name: "layoutOrientation", value: "vertical", isSynced: false }, { name: "layoutOrientation", value: "vertical", isSynced: false },

View File

@ -118,6 +118,7 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions<KeyboardActi
editedNotesOpenInRibbon: boolean; editedNotesOpenInRibbon: boolean;
codeBlockWordWrap: boolean; codeBlockWordWrap: boolean;
textNoteEditorMultilineToolbar: boolean; textNoteEditorMultilineToolbar: boolean;
textNoteEmojiEnabled: boolean;
backgroundEffects: boolean; backgroundEffects: boolean;
// Share settings // Share settings