mirror of
https://github.com/zadam/trilium.git
synced 2025-11-07 05:46:10 +01:00
Merge branch 'master' into next61
# Conflicts: # src/becca/entities/bnote.js # src/public/app/components/note_context.js # src/public/app/layouts/desktop_layout.js # src/public/app/services/note_content_renderer.js # src/public/app/services/utils.js # src/public/app/widgets/ribbon_widgets/file_properties.js # src/public/app/widgets/ribbon_widgets/note_info_widget.js # src/services/notes.js
This commit is contained in:
@@ -74,6 +74,50 @@ export default class SplitNoteContainer extends FlexContainer {
|
||||
appContext.tabManager.removeNoteContext(ntxId);
|
||||
}
|
||||
|
||||
async moveThisNoteSplitCommand({ntxId, isMovingLeft}) {
|
||||
if (!ntxId) {
|
||||
logError("empty ntxId!");
|
||||
return;
|
||||
}
|
||||
|
||||
const contexts = appContext.tabManager.noteContexts;
|
||||
|
||||
const currentIndex = contexts.findIndex(c => c.ntxId === ntxId);
|
||||
const leftIndex = isMovingLeft ? currentIndex - 1 : currentIndex;
|
||||
|
||||
if (currentIndex === -1 || leftIndex < 0 || leftIndex + 1 >= contexts.length) {
|
||||
logError(`invalid context! currentIndex: ${currentIndex}, leftIndex: ${leftIndex}, contexts.length: ${contexts.length}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (contexts[leftIndex].isEmpty() && contexts[leftIndex + 1].isEmpty()) {
|
||||
// no op
|
||||
return;
|
||||
}
|
||||
|
||||
const ntxIds = contexts.map(c => c.ntxId);
|
||||
const newNtxIds = [
|
||||
...ntxIds.slice(0, leftIndex),
|
||||
ntxIds[leftIndex + 1],
|
||||
ntxIds[leftIndex],
|
||||
...ntxIds.slice(leftIndex + 2),
|
||||
];
|
||||
const isChangingMainContext = !contexts[leftIndex].mainNtxId;
|
||||
|
||||
this.triggerCommand("noteContextReorder", {
|
||||
ntxIdsInOrder: newNtxIds,
|
||||
oldMainNtxId: isChangingMainContext ? ntxIds[leftIndex] : null,
|
||||
newMainNtxId: isChangingMainContext ? ntxIds[leftIndex + 1]: null,
|
||||
});
|
||||
|
||||
// reorder the note context widgets
|
||||
this.$widget.find(`[data-ntx-id="${ntxIds[leftIndex]}"]`)
|
||||
.insertAfter(this.$widget.find(`[data-ntx-id="${ntxIds[leftIndex + 1]}"]`));
|
||||
|
||||
// activate context that now contains the original note
|
||||
await appContext.tabManager.activateNoteContext(isMovingLeft ? ntxIds[leftIndex + 1] : ntxIds[leftIndex]);
|
||||
}
|
||||
|
||||
activeContextChangedEvent() {
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user