mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
fix(react/dialogs): add link default text not working
This commit is contained in:
parent
d7c4b8f530
commit
fd1ea05c78
@ -17,7 +17,7 @@ type LinkType = "reference-link" | "external-link" | "hyper-link";
|
|||||||
|
|
||||||
function AddLinkDialogComponent() {
|
function AddLinkDialogComponent() {
|
||||||
const [ textTypeWidget, setTextTypeWidget ] = useState<TextTypeWidget>();
|
const [ textTypeWidget, setTextTypeWidget ] = useState<TextTypeWidget>();
|
||||||
const [ text, setText ] = useState<string>();
|
const initialText = useRef<string>();
|
||||||
const [ linkTitle, setLinkTitle ] = useState("");
|
const [ linkTitle, setLinkTitle ] = useState("");
|
||||||
const hasSelection = textTypeWidget?.hasSelection();
|
const hasSelection = textTypeWidget?.hasSelection();
|
||||||
const [ linkType, setLinkType ] = useState<LinkType>(hasSelection ? "hyper-link" : "reference-link");
|
const [ linkType, setLinkType ] = useState<LinkType>(hasSelection ? "hyper-link" : "reference-link");
|
||||||
@ -26,7 +26,7 @@ function AddLinkDialogComponent() {
|
|||||||
|
|
||||||
useTriliumEvent("showAddLinkDialog", ( { textTypeWidget, text }) => {
|
useTriliumEvent("showAddLinkDialog", ( { textTypeWidget, text }) => {
|
||||||
setTextTypeWidget(textTypeWidget);
|
setTextTypeWidget(textTypeWidget);
|
||||||
setText(text);
|
initialText.current = text;
|
||||||
setShown(true);
|
setShown(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -63,10 +63,10 @@ function AddLinkDialogComponent() {
|
|||||||
|
|
||||||
function onShown() {
|
function onShown() {
|
||||||
const $autocompleteEl = refToJQuerySelector(autocompleteRef);
|
const $autocompleteEl = refToJQuerySelector(autocompleteRef);
|
||||||
if (!text) {
|
if (!initialText.current) {
|
||||||
note_autocomplete.showRecentNotes($autocompleteEl);
|
note_autocomplete.showRecentNotes($autocompleteEl);
|
||||||
} else {
|
} else {
|
||||||
note_autocomplete.setText($autocompleteEl, text);
|
note_autocomplete.setText($autocompleteEl, initialText.current);
|
||||||
}
|
}
|
||||||
|
|
||||||
// to be able to quickly remove entered text
|
// to be able to quickly remove entered text
|
||||||
@ -110,7 +110,6 @@ function AddLinkDialogComponent() {
|
|||||||
<FormGroup label={t("add_link.note")}>
|
<FormGroup label={t("add_link.note")}>
|
||||||
<NoteAutocomplete
|
<NoteAutocomplete
|
||||||
inputRef={autocompleteRef}
|
inputRef={autocompleteRef}
|
||||||
text={text}
|
|
||||||
onChange={setSuggestion}
|
onChange={setSuggestion}
|
||||||
opts={{
|
opts={{
|
||||||
allowExternalLinks: true,
|
allowExternalLinks: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user