mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
refactor(client/options): deduplicate editor feature checkbox
This commit is contained in:
parent
97b5ea0798
commit
71ce9c459e
@ -10,7 +10,7 @@ import Column from "../../react/Column";
|
|||||||
import { FormSelectGroup, FormSelectWithGroups } from "../../react/FormSelect";
|
import { FormSelectGroup, FormSelectWithGroups } from "../../react/FormSelect";
|
||||||
import { Themes } from "@triliumnext/highlightjs";
|
import { Themes } from "@triliumnext/highlightjs";
|
||||||
import { ensureMimeTypesForHighlighting, loadHighlightingTheme } from "../../../services/syntax_highlight";
|
import { ensureMimeTypesForHighlighting, loadHighlightingTheme } from "../../../services/syntax_highlight";
|
||||||
import { normalizeMimeTypeForCKEditor } from "@triliumnext/commons";
|
import { normalizeMimeTypeForCKEditor, type OptionNames } from "@triliumnext/commons";
|
||||||
import { getHtml } from "../../react/RawHtml";
|
import { getHtml } from "../../react/RawHtml";
|
||||||
import type { CSSProperties } from "preact/compat";
|
import type { CSSProperties } from "preact/compat";
|
||||||
import FormText from "../../react/FormText";
|
import FormText from "../../react/FormText";
|
||||||
@ -69,26 +69,25 @@ function FormattingToolbar() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function EditorFeatures() {
|
function EditorFeatures() {
|
||||||
const [ textNoteEmojiCompletionEnabled, setTextNoteEmojiCompletionEnabled] = useTriliumOptionBool("textNoteEmojiCompletionEnabled");
|
|
||||||
const [ textNoteCompletionEnabled, setTextNoteCompletionEnabled ] = useTriliumOptionBool("textNoteCompletionEnabled");
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OptionsSection title={t("editorfeatures.title")}>
|
<OptionsSection title={t("editorfeatures.title")}>
|
||||||
<FormCheckbox
|
<EditorFeature name="emoji-completion-enabled" optionName="textNoteEmojiCompletionEnabled" label={t("editorfeatures.emoji_completion_enabled")} />
|
||||||
name="emoji-completion-enabled"
|
<EditorFeature name="note-completion-enabled" optionName="textNoteCompletionEnabled" label={t("editorfeatures.note_completion_enabled")} />
|
||||||
label={t("editorfeatures.emoji_completion_enabled")}
|
|
||||||
currentValue={textNoteEmojiCompletionEnabled} onChange={setTextNoteEmojiCompletionEnabled}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormCheckbox
|
|
||||||
name="note-completion-enabled"
|
|
||||||
label={t("editorfeatures.note_completion_enabled")}
|
|
||||||
currentValue={textNoteCompletionEnabled} onChange={setTextNoteCompletionEnabled}
|
|
||||||
/>
|
|
||||||
</OptionsSection>
|
</OptionsSection>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function EditorFeature({ optionName, name, label }: { optionName: OptionNames, name: string, label: string }) {
|
||||||
|
const [ featureEnabled, setFeatureEnabled ] = useTriliumOptionBool(optionName);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FormCheckbox
|
||||||
|
name={name} label={label}
|
||||||
|
currentValue={featureEnabled} onChange={setFeatureEnabled}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function HeadingStyle() {
|
function HeadingStyle() {
|
||||||
const [ headingStyle, setHeadingStyle ] = useTriliumOption("headingStyle");
|
const [ headingStyle, setHeadingStyle ] = useTriliumOption("headingStyle");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user