Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegate most ribbon actions to sidebar #1013

Draft
wants to merge 21 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
63ff941
feat(sidebar): always display the sidebar
eliandoran Jan 19, 2025
1480d79
chore(client/ts): port left_pane_toggle
eliandoran Jan 19, 2025
bebe66a
feat(layout): create toggle button for sidebar
eliandoran Jan 19, 2025
2883942
feat(layout): use same sidebar icon, but flipped
eliandoran Jan 19, 2025
d74c5ea
feat(layout): implement hide/show pane
eliandoran Jan 19, 2025
1893f2e
fix(sidebar): split being visible when collapsed
eliandoran Jan 19, 2025
507339b
style(next): use same background as left pane for right pane
eliandoran Jan 19, 2025
761ac68
chore(client/ts): port note_paths
eliandoran Jan 19, 2025
6081d93
feat(sidebar): move note paths to sidebar
eliandoran Jan 19, 2025
95b2da0
chore(client/ts): port similar_notes
eliandoran Jan 19, 2025
b1bb3ad
feat(sidebar): move similar notes to sidebar
eliandoran Jan 19, 2025
5e74e7e
chore(client/ts): port note_map
eliandoran Jan 19, 2025
0ece70e
feat(sidebar): move note_map to sidebar
eliandoran Jan 19, 2025
c6fef4e
chore(client/ts): port zpetne_odkazy
eliandoran Jan 19, 2025
89c4e0b
feat(sidebar): port backlinks widget partially
eliandoran Jan 19, 2025
b16c2ee
chore(client/ts): port note_info_widget
eliandoran Jan 19, 2025
b7b5e2c
feat(sidebar): port note info widget
eliandoran Jan 19, 2025
a6d7543
feat(sidebar): display note info on one line
eliandoran Jan 19, 2025
3caba91
chore(client/ts): port ribbon_container
eliandoran Jan 19, 2025
0053eb2
feat(ribbon): always display text
eliandoran Jan 19, 2025
74b78e7
Merge remote-tracking branch 'origin/develop' into feature/better_sid…
eliandoran Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/becca/similarity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ interface DateLimits {
maxDate: string;
}

interface SimilarNote {
score: number;
notePath: string[];
noteId: string;
}

function filterUrlValue(value: string) {
return value
.replace(/https?:\/\//gi, "")
Expand Down Expand Up @@ -247,7 +253,7 @@ function hasConnectingRelation(sourceNote: BNote, targetNote: BNote) {
return sourceNote.getAttributes().find((attr) => attr.type === "relation" && ["includenotelink", "imagelink"].includes(attr.name) && attr.value === targetNote.noteId);
}

async function findSimilarNotes(noteId: string) {
async function findSimilarNotes(noteId: string): Promise<SimilarNote[] | undefined> {
const results = [];
let i = 0;

Expand Down Expand Up @@ -417,6 +423,7 @@ async function findSimilarNotes(noteId: string) {

// this takes care of note hoisting
if (!notePath) {
// TODO: This return is suspicious, it should probably be continue
return;
}

Expand Down
4 changes: 4 additions & 0 deletions src/public/app/components/app_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ export type CommandMappings = {
openNoteInNewTab: CommandData;
openNoteInNewSplit: CommandData;
openNoteInNewWindow: CommandData;
hideLeftPane: CommandData;
showLeftPane: CommandData;
toggleLeftPane: CommandData;
toggleRightPane: CommandData;

openInTab: ContextMenuCommandData;
openNoteInSplit: ContextMenuCommandData;
Expand Down
2 changes: 1 addition & 1 deletion src/public/app/components/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class TypedComponent<ChildT extends TypedComponent<ChildT>> {
return this;
}

handleEvent<T extends EventNames>(name: T, data: EventData<T>): Promise<unknown[] | unknown> | null {
handleEvent<T extends EventNames>(name: T, data: EventData<T>): Promise<unknown[] | unknown> | null | undefined {
try {
const callMethodPromise = this.initialized ? this.initialized.then(() => this.callMethod((this as any)[`${name}Event`], data)) : this.callMethod((this as any)[`${name}Event`], data);

Expand Down
4 changes: 4 additions & 0 deletions src/public/app/components/root_command_executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ export default class RootCommandExecutor extends Component {
options.toggle("leftPaneVisible");
}

toggleRightPaneCommand() {
options.toggle("rightPaneVisible");
}

async showBackendLogCommand() {
await appContext.tabManager.openTabWithNoteWithHoisting("_backendLog", { activate: true });
}
Expand Down
12 changes: 6 additions & 6 deletions src/public/app/entities/fnote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ const NOTE_TYPE_ICONS = {
* end user. Those types should be used only for checking against, they are
* not for direct use.
*/
type NoteType = "file" | "image" | "search" | "noteMap" | "launcher" | "doc" | "contentWidget" | "text" | "relationMap" | "render" | "canvas" | "mermaid" | "book" | "webView" | "code" | "mindMap";
export type NoteType = "file" | "image" | "search" | "noteMap" | "launcher" | "doc" | "contentWidget" | "text" | "relationMap" | "render" | "canvas" | "mermaid" | "book" | "webView" | "code" | "mindMap";

interface NotePathRecord {
export interface NotePathRecord {
isArchived: boolean;
isInHoistedSubTree: boolean;
isSearch: boolean;
isSearch?: boolean;
notePath: string[];
isHidden: boolean;
}
Expand Down Expand Up @@ -401,14 +401,14 @@ class FNote {
return notePaths;
}

getSortedNotePathRecords(hoistedNoteId = "root") {
getSortedNotePathRecords(hoistedNoteId = "root"): NotePathRecord[] {
const isHoistedRoot = hoistedNoteId === "root";

const notePaths = this.getAllNotePaths().map((path) => ({
const notePaths: NotePathRecord[] = this.getAllNotePaths().map((path) => ({
notePath: path,
isInHoistedSubTree: isHoistedRoot || path.includes(hoistedNoteId),
isArchived: path.some((noteId) => froca.notes[noteId].isArchived),
isSearch: path.find((noteId) => froca.notes[noteId].type === "search"),
isSearch: path.some((noteId) => froca.notes[noteId].type === "search"),
isHidden: path.includes("_hidden")
}));

Expand Down
18 changes: 12 additions & 6 deletions src/public/app/layouts/desktop_layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import ScrollPaddingWidget from "../widgets/scroll_padding.js";
import ClassicEditorToolbar from "../widgets/ribbon_widgets/classic_editor_toolbar.js";
import options from "../services/options.js";
import utils from "../services/utils.js";
import RightPaneToggleWidget from "../widgets/buttons/right_pane_toggle.js";

export default class DesktopLayout {
constructor(customWidgets) {
Expand Down Expand Up @@ -118,6 +119,7 @@ export default class DesktopLayout {
.child(new FlexContainer("row").id("tab-row-left-spacer"))
.optChild(launcherPaneIsHorizontal, new LeftPaneToggleWidget(true))
.child(new TabRowWidget().class("full-width"))
.child(new RightPaneToggleWidget())
.optChild(customTitleBarButtons, new TitleBarButtonsWidget())
.css("height", "40px")
.css("background-color", "var(--launcher-pane-background-color)")
Expand All @@ -139,7 +141,11 @@ export default class DesktopLayout {
new FlexContainer("column")
.id("rest-pane")
.css("flex-grow", "1")
.optChild(!fullWidthTabBar, new FlexContainer("row").child(new TabRowWidget()).optChild(customTitleBarButtons, new TitleBarButtonsWidget()).css("height", "40px"))
.optChild(!fullWidthTabBar, new FlexContainer("row")
.child(new TabRowWidget())
.optChild(customTitleBarButtons, new TitleBarButtonsWidget())
.child(new RightPaneToggleWidget())
.css("height", "40px"))
.child(
new FlexContainer("row")
.filling()
Expand Down Expand Up @@ -184,10 +190,6 @@ export default class DesktopLayout {
.ribbon(new BasicPropertiesWidget())
.ribbon(new OwnedAttributeListWidget())
.ribbon(new InheritedAttributesWidget())
.ribbon(new NotePathsWidget())
.ribbon(new NoteMapRibbonWidget())
.ribbon(new SimilarNotesWidget())
.ribbon(new NoteInfoWidget())
.button(new RevisionsButton())
.button(new NoteActionsWidget())
)
Expand All @@ -202,7 +204,6 @@ export default class DesktopLayout {
.child(new RelationMapButtons())
.child(new CopyImageReferenceButton())
.child(new SvgExportButton())
.child(new BacklinksWidget())
.child(new HideFloatingButtonsButton())
)
.child(new MermaidWidget())
Expand All @@ -229,9 +230,14 @@ export default class DesktopLayout {
)
.child(
new RightPaneContainer()
.child(new NotePathsWidget())
.child(new TocWidget())
.child(new HighlightsListWidget())
.child(new SimilarNotesWidget())
.child(new BacklinksWidget())
.child(new NoteMapRibbonWidget())
.child(...this.customWidgets.get("right-pane"))
.child(new NoteInfoWidget())
)
)
)
Expand Down
4 changes: 3 additions & 1 deletion src/public/app/services/load_results.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { OptionNames } from "../../../services/options_interface.js";
import type { AttributeType } from "../entities/fattribute.js";
import type { EntityChange } from "../server_types.js";

Expand All @@ -8,6 +9,7 @@ interface NoteRow {
}

interface BranchRow {
noteId?: string;
branchId: string;
componentId: string;
parentNoteId?: string;
Expand Down Expand Up @@ -182,7 +184,7 @@ export default class LoadResults {
this.optionNames.push(name);
}

isOptionReloaded(name: string) {
isOptionReloaded(name: OptionNames) {
return this.optionNames.includes(name);
}

Expand Down
4 changes: 1 addition & 3 deletions src/public/app/services/resizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ function setupLeftPaneResizer(leftPaneVisible: boolean) {
}
}

function setupRightPaneResizer() {
function setupRightPaneResizer(rightPaneVisible: boolean) {
if (rightInstance) {
rightInstance.destroy();
rightInstance = null;
}

const rightPaneVisible = $("#right-pane").is(":visible");

if (!rightPaneVisible) {
$("#center-pane").css("width", "100%");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import options from "../../services/options.js";
import splitService from "../../services/resizer.js";
import CommandButtonWidget from "./command_button.js";
import { t } from "../../services/i18n.js";
import type { EventData } from "../../components/app_context.js";

export default class LeftPaneToggleWidget extends CommandButtonWidget {
constructor(isHorizontalLayout) {

constructor(isHorizontalLayout: boolean) {
super();

this.class(isHorizontalLayout ? "toggle-button" : "launcher-button");
Expand Down Expand Up @@ -32,7 +34,7 @@ export default class LeftPaneToggleWidget extends CommandButtonWidget {
splitService.setupLeftPaneResizer(options.is("leftPaneVisible"));
}

entitiesReloadedEvent({ loadResults }) {
entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
if (loadResults.isOptionReloaded("leftPaneVisible")) {
this.refreshIcon();
}
Expand Down
29 changes: 29 additions & 0 deletions src/public/app/widgets/buttons/right_pane_toggle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import splitService from "../../services/resizer.js";
import options from "../../services/options.js";
import CommandButtonWidget from "./command_button.js";
import type { EventData } from "../../components/app_context.js";

export default class RightPaneToggleWidget extends CommandButtonWidget {

constructor() {
super();

this.class("toggle-button");
this.css("transform", "scaleX(-1)");
this.settings.icon = "bx-sidebar";
this.settings.command = "toggleRightPane";
}

refreshIcon(): void {
super.refreshIcon();

splitService.setupRightPaneResizer(options.is("rightPaneVisible"));
}

entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
if (loadResults.isOptionReloaded("rightPaneVisible")) {
this.refreshIcon();
}
}

}
Loading
Loading