chore(react): port create_pane_button

This commit is contained in:
Elian Doran 2025-09-16 23:05:43 +03:00
parent a4e8e62452
commit 88bc6739ca
No known key found for this signature in database
3 changed files with 22 additions and 18 deletions

View File

@ -126,7 +126,7 @@ export default class DesktopLayout {
.child(<MovePaneButton direction="left" />) .child(<MovePaneButton direction="left" />)
.child(<MovePaneButton direction="right" />) .child(<MovePaneButton direction="right" />)
.child(<ClosePaneButton />) .child(<ClosePaneButton />)
.child(new CreatePaneButton()) .child(<CreatePaneButton />)
) )
.child(<Ribbon />) .child(<Ribbon />)
.child(<SharedInfo />) .child(<SharedInfo />)

View File

@ -1,17 +0,0 @@
import { t } from "../../services/i18n.js";
import OnClickButtonWidget from "./onclick_button.js";
export default class CreatePaneButton extends OnClickButtonWidget {
constructor() {
super();
this.icon("bx-dock-right")
.title(t("create_pane_button.create_new_split"))
.titlePlacement("bottom")
.onClick((widget, e) => {
widget.triggerCommand("openNewNoteSplit", { ntxId: widget.getClosestNtxId() });
e.stopPropagation();
})
.class("icon-action");
}
}

View File

@ -0,0 +1,21 @@
import { useContext } from "preact/hooks";
import { t } from "../../services/i18n.js";
import ActionButton from "../react/ActionButton.jsx";
import { ParentComponent } from "../react/react_utils.jsx";
import BasicWidget from "../basic_widget.js";
export default function CreatePaneButton() {
const widget = useContext(ParentComponent) as BasicWidget | undefined;
return (
<ActionButton
icon="bx bx-dock-right"
text={t("create_pane_button.create_new_split")}
onClick={(e) => {
widget?.triggerCommand("openNewNoteSplit", { ntxId: widget.getClosestNtxId() });
e.stopPropagation();
}}
/>
)
}