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"))
},
// 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;
}

View File

@ -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,

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",
"textNoteEditorType",
"textNoteEditorMultilineToolbar",
"textNoteEmojiEnabled",
"layoutOrientation",
"backgroundEffects",
"allowedHtmlTags",

View File

@ -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 },

View File

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