Skip to content

Build your personal knowledge base with Trilium Notes

split window WIP

zadamb7bd5396d147
diff --git a/src/public/app/layouts/desktop_layout.js b/src/public/app/layouts/desktop_layout.js
index 8cfeebc6e2..8d4746a5a4 100644
--- a/src/public/app/layouts/desktop_layout.js
+++ b/src/public/app/layouts/desktop_layout.js
@@ -40,6 +40,7 @@ import SpacerWidget from "../widgets/spacer.js";
import QuickSearchWidget from "../widgets/quick_search.js";
import ButtonWidget from "../widgets/button_widget.js";
import ProtectedSessionStatusWidget from "../widgets/protected_session_status.js";
+import PaneContainer from "../widgets/containers/pane_container.js";
const RIGHT_PANE_CSS = `
<style>
@@ -181,51 +182,48 @@ export default class DesktopLayout {
.child(new TitleBarButtonsWidget())
.css('height', '36px')
)
- .child(new FlexContainer('row').class('title-row')
- .css('align-items: center;')
- .cssBlock('.title-row > * { margin: 5px; }')
- .overflowing()
- .child(new NoteIconWidget())
- .child(new NoteTitleWidget())
- .child(new NotePathsWidget().hideInZenMode())
- .child(new NoteTypeWidget().hideInZenMode())
- .child(new NoteActionsWidget().hideInZenMode())
- )
- .child(
- new TabCachingWidget(() => new CollapsibleSectionContainer()
- .child(new SearchDefinitionWidget())
- .child(new NotePropertiesWidget())
- .child(new FilePropertiesWidget())
- .child(new ImagePropertiesWidget())
- .child(new PromotedAttributesWidget())
- .child(new OwnedAttributeListWidget())
- .child(new InheritedAttributesWidget())
- )
- )
- .child(new NoteUpdateStatusWidget())
- .child(
- new TabCachingWidget(() => new ScrollingContainer()
- .child(new SqlTableSchemasWidget())
- .child(new NoteDetailWidget())
- .child(new NoteListWidget())
- .child(new SearchResultWidget())
- .child(new SqlResultWidget())
+ .child(new TabCachingWidget(() =>
+ new PaneContainer(() =>
+ new FlexContainer('column')
+ .css("flex-grow", "1")
+ .child(new FlexContainer('row').class('title-row')
+ .css('align-items: center;')
+ .cssBlock('.title-row > * { margin: 5px; }')
+ .overflowing()
+ .child(new NoteIconWidget())
+ .child(new NoteTitleWidget())
+ .child(new NotePathsWidget().hideInZenMode())
+ .child(new NoteTypeWidget().hideInZenMode())
+ .child(new NoteActionsWidget().hideInZenMode())
+ .child(new ButtonWidget()
+ .icon("bx-window-open bx-rotate-90")
+ .title("Create new pane")
+ .command("openNewPane"))
+ )
+ .child(
+ new CollapsibleSectionContainer()
+ .child(new SearchDefinitionWidget())
+ .child(new NotePropertiesWidget())
+ .child(new FilePropertiesWidget())
+ .child(new ImagePropertiesWidget())
+ .child(new PromotedAttributesWidget())
+ .child(new OwnedAttributeListWidget())
+ .child(new InheritedAttributesWidget())
+ )
+ .child(new NoteUpdateStatusWidget())
+ .child(
+ new ScrollingContainer()
+ .child(new SqlTableSchemasWidget())
+ .child(new NoteDetailWidget())
+ .child(new NoteListWidget())
+ .child(new SearchResultWidget())
+ .child(new SqlResultWidget())
+ )
+ .child(new SimilarNotesWidget())
+ .child(...this.customWidgets.get('center-pane'))
+ )
)
)
- .child(new TabCachingWidget(() => new SimilarNotesWidget()))
- .child(...this.customWidgets.get('center-pane'))
- // .child(new SidePaneContainer('right')
- // .cssBlock(RIGHT_PANE_CSS)
- // .hideInZenMode()
- // .child(new NoteInfoWidget())
- // .child(new TabCachingWidget(() => new CalendarWidget()))
- // .child(new TabCachingWidget(() => new EditedNotesWidget()))
- // .child(new TabCachingWidget(() => new LinkMapWidget()))
- // .child(new TabCachingWidget(() => new NoteRevisionsWidget()))
- // .child(new TabCachingWidget(() => new WhatLinksHereWidget()))
- // .child(...this.customWidgets.get('right-pane'))
- // )
- // .child(new SidePaneToggles().hideInZenMode())
);
}
}
diff --git a/src/public/app/services/tab_context.js b/src/public/app/services/tab_context.js
index 8bb1c92f36..6310a3fd1d 100644
--- a/src/public/app/services/tab_context.js
+++ b/src/public/app/services/tab_context.js
@@ -16,6 +16,7 @@ class TabContext extends Component {
this.tabId = tabId || utils.randomString(4);
this.hoistedNoteId = hoistedNoteId;
+ this.parentTabId = null;
}
setEmpty() {
diff --git a/src/public/app/widgets/containers/pane_container.js b/src/public/app/widgets/containers/pane_container.js
new file mode 100644
index 0000000000..197305e4fe
--- /dev/null
+++ b/src/public/app/widgets/containers/pane_container.js
@@ -0,0 +1,38 @@
+import FlexContainer from "./flex_container.js";
+import appContext from "../../services/app_context.js";
+import TabContext from "../../services/tab_context.js";
+
+export default class PaneContainer extends FlexContainer {
+ constructor(widgetFactory) {
+ super('row');
+
+ this.counter = 0;
+
+ this.widgetFactory = widgetFactory;
+
+ this.child(this.widgetFactory());
+
+ this.id('pane-container-widget');
+ this.css('flex-grow', '1');
+ }
+
+ async openNewPaneCommand() {
+ const newWidget = this.widgetFactory();
+
+ this.$widget.append(newWidget.render());
+
+ const tabContext = new TabContext();
+ appContext.tabManager.tabContexts.push(tabContext);
+ appContext.tabManager.child(tabContext);
+
+ tabContext.parentTabId = appContext.tabManager.getActiveTabContext().tabId;
+
+ await newWidget.handleEvent('setTabContext', { tabContext });
+
+ this.child(newWidget);
+
+ tabContext.setEmpty();
+
+ appContext.tabManager.activateTab(tabContext.tabId);
+ }
+}
diff --git a/src/public/app/widgets/tab_aware_widget.js b/src/public/app/widgets/tab_aware_widget.js
index c9fa7b2e52..b54c68df6f 100644
--- a/src/public/app/widgets/tab_aware_widget.js
+++ b/src/public/app/widgets/tab_aware_widget.js
@@ -6,6 +6,10 @@ export default class TabAwareWidget extends BasicWidget {
return this.tabContext && this.tabContext.tabId === tabId;
}
+ isTabOrParent(tabId) {
+ return this.tabContext && (this.tabContext.tabId === tabId || this.tabContext.parentTabId === tabId);
+ }
+
isNote(noteId) {
return this.noteId === noteId;
}
diff --git a/src/public/app/widgets/tab_caching_widget.js b/src/public/app/widgets/tab_caching_widget.js
index 331e3235dd..c8e59a694c 100644
--- a/src/public/app/widgets/tab_caching_widget.js
+++ b/src/public/app/widgets/tab_caching_widget.js
@@ -53,7 +53,7 @@ export default class TabCachingWidget extends TabAwareWidget {
toggleExt(show) {
for (const tabId in this.widgets) {
- this.widgets[tabId].toggleExt(show && this.isTab(tabId));
+ this.widgets[tabId].toggleExt(show && this.isTabOrParent(tabId));
}
}
@@ -65,7 +65,11 @@ export default class TabCachingWidget extends TabAwareWidget {
handleEventInChildren(name, data) {
if (['tabNoteSwitched', 'tabNoteSwitchedAndActivated'].includes(name)) {
// this event is propagated only to the widgets of a particular tab
- const widget = this.widgets[data.tabContext.tabId];
+ let widget = this.widgets[data.tabContext.tabId];
+
+ if (!widget) {
+ widget = this.widgets[data.tabContext.parentTabId];
+ }
if (widget && (widget.hasBeenAlreadyShown || name === 'tabNoteSwitchedAndActivated')) {
widget.hasBeenAlreadyShown = true;
@@ -78,7 +82,11 @@ export default class TabCachingWidget extends TabAwareWidget {
}
if (name === 'activeTabChanged') {
- const widget = this.widgets[data.tabContext.tabId];
+ let widget = this.widgets[data.tabContext.tabId];
+
+ if (!widget) {
+ widget = this.widgets[data.tabContext.parentTabId];
+ }
if (widget.hasBeenAlreadyShown) {
return Promise.resolve();
@@ -92,4 +100,4 @@ export default class TabCachingWidget extends TabAwareWidget {
return super.handleEventInChildren(name, data);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/services/search/services/search.js b/src/services/search/services/search.js
index bbf7a924c6..d2bb854543 100644
--- a/src/services/search/services/search.js
+++ b/src/services/search/services/search.js
@@ -216,7 +216,7 @@ function highlightSearchResults(searchResults, highlightedTokens) {
result.highlightedNotePathTitle += ` "mime: ${note.mime}'`;
}
- for (const attr of note.attributes) {
+ for (const attr of note.getAttributes()) {
if (highlightedTokens.find(token => attr.name.toLowerCase().includes(token)
|| attr.value.toLowerCase().includes(token))) {