mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
initial implementation of link dialog (buggy and feature incomplete)
This commit is contained in:
parent
9259db9f87
commit
169825abff
@ -84,6 +84,22 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="insertLinkDialog" title="Recent notes" style="display: none;">
|
||||||
|
<form>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="noteAutocomplete">Link to note</label>
|
||||||
|
<input id="noteAutocomplete" style="width: 100%;">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="linkTitle">Link title</label>
|
||||||
|
<input id="linkTitle" style="width: 100%;">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button id="addLinkButton" class="btn btn-sm">Add link</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
const baseUrl = '';
|
const baseUrl = '';
|
||||||
</script>
|
</script>
|
||||||
|
@ -92,4 +92,61 @@ $(document).on('click', 'div.popover-content a', function(e) {
|
|||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let linkInfo;
|
||||||
|
|
||||||
|
$(document).bind('keydown', 'alt+l', function() {
|
||||||
|
$("#insertLinkDialog").dialog({
|
||||||
|
modal: true
|
||||||
|
});
|
||||||
|
|
||||||
|
let autocompleteItems = [];
|
||||||
|
|
||||||
|
for (let noteId in globalNoteNames) {
|
||||||
|
autocompleteItems.push({
|
||||||
|
value: globalNoteNames[noteId] + " (" + noteId + ")",
|
||||||
|
label: globalNoteNames[noteId]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#noteAutocomplete").autocomplete({
|
||||||
|
source: autocompleteItems,
|
||||||
|
change: function(event, ui) {
|
||||||
|
let val = $("#noteAutocomplete").val();
|
||||||
|
|
||||||
|
val = val.replace(/ \([A-Za-z0-9]{22}\)/, "");
|
||||||
|
|
||||||
|
$("#linkTitle").val(val);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//const noteDetail = $('#noteDetail');
|
||||||
|
|
||||||
|
//linkInfo = noteDetail.summernote('invoke', 'editor.getLinkInfo');
|
||||||
|
//noteDetail.summernote('invoke', 'editor.saveRange');
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#addLinkButton").click(function() {
|
||||||
|
let val = $("#noteAutocomplete").val();
|
||||||
|
|
||||||
|
const noteIdMatch = / \(([A-Za-z0-9]{22})\)/.exec(val);
|
||||||
|
|
||||||
|
if (noteIdMatch !== null) {
|
||||||
|
const noteId = noteIdMatch[1];
|
||||||
|
const linkTitle = $("#linkTitle").val();
|
||||||
|
|
||||||
|
const noteDetail = $('#noteDetail');
|
||||||
|
|
||||||
|
noteDetail.summernote('createLink', {
|
||||||
|
text: globalNoteNames[noteId],
|
||||||
|
url: 'app#' + noteId,
|
||||||
|
isNewWindow: true
|
||||||
|
// range: linkInfo.range
|
||||||
|
});
|
||||||
|
|
||||||
|
//noteDetail.summernote('invoke', 'editor.restoreRange');
|
||||||
|
|
||||||
|
$("#insertLinkDialog").dialog("close");
|
||||||
|
}
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user