mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix inserting link
This commit is contained in:
parent
b946599320
commit
34150e7177
@ -1,6 +1,7 @@
|
|||||||
import treeService from '../services/tree.js';
|
import treeService from '../services/tree.js';
|
||||||
import noteAutocompleteService from "../services/note_autocomplete.js";
|
import noteAutocompleteService from "../services/note_autocomplete.js";
|
||||||
import utils from "../services/utils.js";
|
import utils from "../services/utils.js";
|
||||||
|
import appContext from "../services/app_context.js";
|
||||||
|
|
||||||
const $dialog = $("#add-link-dialog");
|
const $dialog = $("#add-link-dialog");
|
||||||
const $form = $("#add-link-form");
|
const $form = $("#add-link-form");
|
||||||
@ -11,7 +12,13 @@ const $addLinkTitleFormGroup = $("#add-link-title-form-group");
|
|||||||
export async function showDialog() {
|
export async function showDialog() {
|
||||||
utils.closeActiveDialog();
|
utils.closeActiveDialog();
|
||||||
|
|
||||||
$addLinkTitleFormGroup.toggle(!hasSelection());
|
appContext.trigger('executeInActiveEditor', {
|
||||||
|
callback: textEditor => {
|
||||||
|
const hasSelection = !textEditor.model.document.selection.isCollapsed;
|
||||||
|
|
||||||
|
$addLinkTitleFormGroup.toggle(!hasSelection);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
glob.activeDialog = $dialog;
|
glob.activeDialog = $dialog;
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) {
|
|||||||
extraOptions.saveSelection = false;
|
extraOptions.saveSelection = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extraOptions.saveSelection) {
|
if (extraOptions.saveSelection && utils.isCKEditorInitialized()) {
|
||||||
[extraOptions.title, extraOptions.content] = parseSelectedHtml(window.cutToNote.getSelectedHtml());
|
[extraOptions.title, extraOptions.content] = parseSelectedHtml(window.cutToNote.getSelectedHtml());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,7 +335,7 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) {
|
|||||||
type: extraOptions.type
|
type: extraOptions.type
|
||||||
});
|
});
|
||||||
|
|
||||||
if (extraOptions.saveSelection) {
|
if (extraOptions.saveSelection && utils.isCKEditorInitialized()) {
|
||||||
// we remove the selection only after it was saved to server to make sure we don't lose anything
|
// we remove the selection only after it was saved to server to make sure we don't lose anything
|
||||||
window.cutToNote.removeSelection();
|
window.cutToNote.removeSelection();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user