import { useMemo } from "react";
import { SettingsManager, Definition, RowGroup, RowGroupOption, SingleInput, TextField } from "Components/UserSettings";
const { Provider: AutocompleteProvider, useSettings: useAutocompleteSettings } = new SettingsManager<"autocomplete">();
const DISPLAY_OPTIONS = [
{ label: "Citekey", value: "citekey" },
{ label: "Zettlr", value: "zettlr" }
];
const DISPLAY_USE_OPTIONS = {
"preset": "Preset",
"custom": "Custom template"
};
const FORMAT_OPTIONS = [
{ label: "Citation", value: "citation" },
{ label: "Citekey", value: "citekey" },
{ label: "Citekey (raw)", value: "key" },
{ label: "Page reference", value: "pageref" },
{ label: "Popover", value: "popover" },
{ label: "Tag", value: "tag" }
];
const FORMAT_USE_OPTIONS = {
"preset": "Preset",
"custom": "Custom template"
};
const AUTOCOMPLETE_REPLACEMENTS = (
<>
Replacements available:
>
);
function AutocompleteWidget(){
const [
{
display_char,
display_use,
display,
format_char,
format_use,
format,
trigger
},
setOpts
] = useAutocompleteSettings();
const handlers = useMemo(() => {
/* istanbul ignore next */
function updateSingleValue(op, val){
setOpts(prevState => ({
...prevState,
[op]: val
}));
}
return {
updateDisplayChar: (val) => updateSingleValue("display_char", val),
updateDisplayUse: (val) => updateSingleValue("display_use", val),
updateDisplay: (val) => updateSingleValue("display", val),
updateFormatChar: (val) => updateSingleValue("format_char", val),
updateFormatUse: (val) => updateSingleValue("format_use", val),
updateFormat: (val) => updateSingleValue("format", val),
updateTrigger: (val) => updateSingleValue("trigger", val)
};
}, [setOpts]);
return <>
>;
}
export {
AutocompleteProvider,
AutocompleteWidget,
useAutocompleteSettings
};