mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
tweaks, fixes, refactorings, creating new note from detail, not tree
This commit is contained in:
parent
0b4a44a403
commit
2f680c4326
@ -1,41 +1,41 @@
|
||||
import addLinkDialog from '../dialogs/add_link.js';
|
||||
import jumpToNoteDialog from '../dialogs/jump_to_note.js';
|
||||
import attributesDialog from '../dialogs/attributes.js';
|
||||
import noteRevisionsDialog from '../dialogs/note_revisions.js';
|
||||
import noteSourceDialog from '../dialogs/note_source.js';
|
||||
import recentChangesDialog from '../dialogs/recent_changes.js';
|
||||
import optionsDialog from '../dialogs/options.js';
|
||||
import sqlConsoleDialog from '../dialogs/sql_console.js';
|
||||
import markdownImportDialog from '../dialogs/markdown_import.js';
|
||||
import exportDialog from '../dialogs/export.js';
|
||||
import addLinkDialog from './dialogs/add_link.js';
|
||||
import jumpToNoteDialog from './dialogs/jump_to_note.js';
|
||||
import attributesDialog from './dialogs/attributes.js';
|
||||
import noteRevisionsDialog from './dialogs/note_revisions.js';
|
||||
import noteSourceDialog from './dialogs/note_source.js';
|
||||
import recentChangesDialog from './dialogs/recent_changes.js';
|
||||
import optionsDialog from './dialogs/options.js';
|
||||
import sqlConsoleDialog from './dialogs/sql_console.js';
|
||||
import markdownImportDialog from './dialogs/markdown_import.js';
|
||||
import exportDialog from './dialogs/export.js';
|
||||
|
||||
import cloning from './cloning.js';
|
||||
import contextMenu from './tree_context_menu.js';
|
||||
import dragAndDropSetup from './drag_and_drop.js';
|
||||
import exportService from './export.js';
|
||||
import link from './link.js';
|
||||
import messagingService from './messaging.js';
|
||||
import noteDetailService from './note_detail.js';
|
||||
import noteType from './note_type.js';
|
||||
import protected_session from './protected_session.js';
|
||||
import searchNotesService from './search_notes.js';
|
||||
import FrontendScriptApi from './frontend_script_api.js';
|
||||
import ScriptContext from './script_context.js';
|
||||
import sync from './sync.js';
|
||||
import treeService from './tree.js';
|
||||
import treeChanges from './branches.js';
|
||||
import treeUtils from './tree_utils.js';
|
||||
import utils from './utils.js';
|
||||
import server from './server.js';
|
||||
import entrypoints from './entrypoints.js';
|
||||
import noteTooltipService from './note_tooltip.js';
|
||||
import bundle from "./bundle.js";
|
||||
import treeCache from "./tree_cache.js";
|
||||
import libraryLoader from "./library_loader.js";
|
||||
import hoistedNoteService from './hoisted_note.js';
|
||||
import noteTypeService from './note_type.js';
|
||||
import linkService from './link.js';
|
||||
import noteAutocompleteService from './note_autocomplete.js';
|
||||
import cloning from './services/cloning.js';
|
||||
import contextMenu from './services/tree_context_menu.js';
|
||||
import dragAndDropSetup from './services/drag_and_drop.js';
|
||||
import exportService from './services/export.js';
|
||||
import link from './services/link.js';
|
||||
import messagingService from './services/messaging.js';
|
||||
import noteDetailService from './services/note_detail.js';
|
||||
import noteType from './services/note_type.js';
|
||||
import protected_session from './services/protected_session.js';
|
||||
import searchNotesService from './services/search_notes.js';
|
||||
import FrontendScriptApi from './services/frontend_script_api.js';
|
||||
import ScriptContext from './services/script_context.js';
|
||||
import sync from './services/sync.js';
|
||||
import treeService from './services/tree.js';
|
||||
import treeChanges from './services/branches.js';
|
||||
import treeUtils from './services/tree_utils.js';
|
||||
import utils from './services/utils.js';
|
||||
import server from './services/server.js';
|
||||
import entrypoints from './services/entrypoints.js';
|
||||
import noteTooltipService from './services/note_tooltip.js';
|
||||
import bundle from "./services/bundle.js";
|
||||
import treeCache from "./services/tree_cache.js";
|
||||
import libraryLoader from "./services/library_loader.js";
|
||||
import hoistedNoteService from './services/hoisted_note.js';
|
||||
import noteTypeService from './services/note_type.js';
|
||||
import linkService from './services/link.js';
|
||||
import noteAutocompleteService from './services/note_autocomplete.js';
|
||||
|
||||
// required for CKEditor image upload plugin
|
||||
window.glob.getCurrentNode = treeService.getCurrentNode;
|
@ -1,15 +1,13 @@
|
||||
import treeService from "./tree.js";
|
||||
import noteDetailService from "./note_detail.js";
|
||||
import dragAndDropSetup from "./drag_and_drop.js";
|
||||
import treeCache from "./tree_cache.js";
|
||||
import treeBuilder from "./tree_builder.js";
|
||||
import contextMenuWidget from "./context_menu.js";
|
||||
import confirmDialog from "../dialogs/confirm.js";
|
||||
import server from "./server.js";
|
||||
import promptDialog from "../dialogs/prompt.js";
|
||||
import ContextMenuItemsContainer from "./context_menu_items_container.js";
|
||||
import treeChangesService from "./branches.js";
|
||||
import utils from "./utils.js";
|
||||
import treeService from "./services/tree.js";
|
||||
import noteDetailService from "./services/note_detail.js";
|
||||
import dragAndDropSetup from "./services/drag_and_drop.js";
|
||||
import treeCache from "./services/tree_cache.js";
|
||||
import treeBuilder from "./services/tree_builder.js";
|
||||
import contextMenuWidget from "./services/context_menu.js";
|
||||
import ContextMenuItemsContainer from "./services/context_menu_items_container.js";
|
||||
import treeChangesService from "./services/branches.js";
|
||||
import utils from "./services/utils.js";
|
||||
import treeUtils from "./services/tree_utils.js";
|
||||
|
||||
const $leftPane = $("#left-pane");
|
||||
const $tree = $("#tree");
|
||||
@ -56,24 +54,6 @@ async function showTree() {
|
||||
},
|
||||
clones: {
|
||||
highlightActiveClones: true
|
||||
},
|
||||
renderNode: function (event, data) {
|
||||
const node = data.node;
|
||||
const $nodeSpan = $(node.span);
|
||||
|
||||
// check if span of node already rendered
|
||||
if (!$nodeSpan.data('rendered')) {
|
||||
const addNoteButton = $('<button class="action-button" title="Add new sub-note" type="button" class="btn">+</button>');
|
||||
|
||||
addNoteButton.click(() => {
|
||||
alert("Add new note");
|
||||
});
|
||||
|
||||
$nodeSpan.append(addNoteButton);
|
||||
|
||||
// span rendered
|
||||
$nodeSpan.data('rendered', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -86,13 +66,26 @@ $("#note-menu-button").click(async e => {
|
||||
const isNotRoot = note.noteId !== 'root';
|
||||
|
||||
const itemsContainer = new ContextMenuItemsContainer([
|
||||
{title: "Delete note", cmd: "delete", uiIcon: "trash"}
|
||||
{title: "Insert note after", cmd: "insertNoteAfter", uiIcon: "plus"},
|
||||
{title: "Insert child note", cmd: "insertChildNote", uiIcon: "plus"},
|
||||
{title: "Delete this note", cmd: "delete", uiIcon: "trash"}
|
||||
]);
|
||||
|
||||
itemsContainer.enableItem("insertNoteAfter", isNotRoot && parentNote.type !== 'search');
|
||||
itemsContainer.enableItem("insertChildNote", note.type !== 'search');
|
||||
itemsContainer.enableItem("delete", isNotRoot && parentNote.type !== 'search');
|
||||
alert("A");
|
||||
|
||||
contextMenuWidget.initContextMenu(e, itemsContainer, (event, cmd) => {
|
||||
if (cmd === "delete") {
|
||||
if (cmd === "insertNoteAfter") {
|
||||
const parentNoteId = node.data.parentNoteId;
|
||||
const isProtected = treeUtils.getParentProtectedStatus(node);
|
||||
|
||||
treeService.createNote(node, parentNoteId, 'after', isProtected);
|
||||
}
|
||||
else if (cmd === "insertChildNote") {
|
||||
treeService.createNote(node, node.data.noteId, 'into');
|
||||
}
|
||||
else if (cmd === "delete") {
|
||||
treeChangesService.deleteNodes([node]);
|
||||
|
||||
// move to the tree
|
@ -90,11 +90,11 @@ async function reload() {
|
||||
await loadNoteDetail(getCurrentNoteId());
|
||||
}
|
||||
|
||||
async function switchToNote(noteId, mobile) {
|
||||
async function switchToNote(noteId) {
|
||||
if (getCurrentNoteId() !== noteId) {
|
||||
await saveNoteIfChanged();
|
||||
|
||||
await loadNoteDetail(noteId, mobile);
|
||||
await loadNoteDetail(noteId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ import bundleService from "./bundle.js";
|
||||
import infoService from "./info.js";
|
||||
import server from "./server.js";
|
||||
import noteDetailService from "./note_detail.js";
|
||||
import utils from "./utils.js";
|
||||
|
||||
let codeEditor = null;
|
||||
|
||||
@ -94,7 +95,7 @@ function onNoteChange(func) {
|
||||
codeEditor.on('change', func);
|
||||
}
|
||||
|
||||
$(document).bind('keydown', "ctrl+return", executeCurrentNote);
|
||||
utils.bindShortcut("ctrl+return", executeCurrentNote);
|
||||
|
||||
$executeScriptButton.click(executeCurrentNote);
|
||||
|
||||
|
@ -681,6 +681,7 @@ export default {
|
||||
setPrefix,
|
||||
createNewTopLevelNote,
|
||||
createNote,
|
||||
createNoteInto,
|
||||
getSelectedNodes,
|
||||
clearSelectedNodes,
|
||||
sortAlphabetically,
|
||||
|
@ -80,7 +80,7 @@ function cut(nodes) {
|
||||
}
|
||||
|
||||
const contextMenuItems = [
|
||||
{title: "Insert note here <kbd>Ctrl+O</kbd>", cmd: "insertNoteHere", uiIcon: "plus"},
|
||||
{title: "Insert note after <kbd>Ctrl+O</kbd>", cmd: "insertNoteAfter", uiIcon: "plus"},
|
||||
{title: "Insert child note <kbd>Ctrl+P</kbd>", cmd: "insertChildNote", uiIcon: "plus"},
|
||||
{title: "Delete <kbd>Delete</kbd>", cmd: "delete", uiIcon: "trash"},
|
||||
{title: "----"},
|
||||
@ -114,7 +114,7 @@ async function getContextMenuItems(event) {
|
||||
const itemsContainer = new ContextMenuItemsContainer(contextMenuItems);
|
||||
|
||||
// Modify menu entries depending on node status
|
||||
itemsContainer.enableItem("insertNoteHere", isNotRoot && parentNote.type !== 'search');
|
||||
itemsContainer.enableItem("insertNoteAfter", isNotRoot && parentNote.type !== 'search');
|
||||
itemsContainer.enableItem("insertChildNote", note.type !== 'search');
|
||||
itemsContainer.enableItem("delete", isNotRoot && parentNote.type !== 'search');
|
||||
itemsContainer.enableItem("copy", isNotRoot);
|
||||
@ -146,7 +146,7 @@ function selectContextMenuItem(event, cmd) {
|
||||
// context menu is always triggered on current node
|
||||
const node = treeService.getCurrentNode();
|
||||
|
||||
if (cmd === "insertNoteHere") {
|
||||
if (cmd === "insertNoteAfter") {
|
||||
const parentNoteId = node.data.parentNoteId;
|
||||
const isProtected = treeUtils.getParentProtectedStatus(node);
|
||||
|
||||
|
@ -53,4 +53,12 @@
|
||||
padding: 10px 0 10px 0;
|
||||
margin: 0 10px 0 16px;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
#context-menu-container {
|
||||
padding: 3px 0 0;
|
||||
}
|
||||
|
||||
#context-menu-container .dropdown-item {
|
||||
padding: 0 7px 0 10px;
|
||||
}
|
@ -514,14 +514,6 @@ table.promoted-attributes-in-tooltip td, table.promoted-attributes-in-tooltip th
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#context-menu-container {
|
||||
padding: 3px 0 0;
|
||||
}
|
||||
|
||||
#context-menu-container .dropdown-item {
|
||||
padding: 0 7px 0 10px;
|
||||
}
|
||||
|
||||
/* if modal height overflows, then only modal body scrolls */
|
||||
.modal-body {
|
||||
max-height: calc(100vh - 200px);
|
||||
|
@ -238,7 +238,7 @@
|
||||
<link href="stylesheets/style.css" rel="stylesheet">
|
||||
<link href="stylesheets/desktop.css" rel="stylesheet">
|
||||
|
||||
<script src="javascripts/services/bootstrap.js" crossorigin type="module"></script>
|
||||
<script src="javascripts/desktop.js" crossorigin type="module"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="libraries/jam/css/jam.min.css">
|
||||
|
||||
|
@ -88,7 +88,7 @@
|
||||
<link href="libraries/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="libraries/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<script src="javascripts/services/mobile.js" crossorigin type="module"></script>
|
||||
<script src="javascripts/mobile.js" crossorigin type="module"></script>
|
||||
|
||||
<link href="stylesheets/style.css" rel="stylesheet">
|
||||
<link href="stylesheets/mobile.css" rel="stylesheet">
|
||||
|
Loading…
x
Reference in New Issue
Block a user