2024-08-01 07:22:52 +02:00
|
|
|
// Copyright 2024, Command Line Inc.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2024-10-04 05:28:05 +02:00
|
|
|
import { getApi } from "@/app/store/global";
|
2024-10-08 02:20:18 +02:00
|
|
|
import { WebView, WebViewModel } from "@/app/view/webview/webview";
|
|
|
|
import { NodeModel } from "@/layout/index";
|
2024-10-06 22:55:26 +02:00
|
|
|
import { WebviewTag } from "electron";
|
2024-10-08 02:20:18 +02:00
|
|
|
import { atom } from "jotai";
|
|
|
|
import { createRef } from "react";
|
2024-08-01 07:22:52 +02:00
|
|
|
import "./helpview.less";
|
|
|
|
|
2024-10-08 02:20:18 +02:00
|
|
|
class HelpViewModel extends WebViewModel {
|
2024-09-05 06:15:39 +02:00
|
|
|
viewType: string;
|
2024-10-06 22:55:26 +02:00
|
|
|
blockId: string;
|
|
|
|
webviewRef: React.RefObject<WebviewTag>;
|
2024-09-05 06:15:39 +02:00
|
|
|
|
2024-10-08 02:20:18 +02:00
|
|
|
constructor(blockId: string, nodeModel: NodeModel) {
|
|
|
|
super(blockId, nodeModel);
|
|
|
|
this.getSettingsMenuItems = undefined;
|
|
|
|
this.viewText = atom([
|
|
|
|
{
|
|
|
|
elemtype: "iconbutton",
|
|
|
|
icon: "house",
|
|
|
|
click: this.handleHome.bind(this),
|
|
|
|
disabled: this.shouldDisabledHomeButton(),
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
this.homepageUrl = atom(getApi().getDocsiteUrl());
|
2024-09-05 06:15:39 +02:00
|
|
|
this.viewType = "help";
|
2024-10-06 22:55:26 +02:00
|
|
|
this.blockId = blockId;
|
2024-10-08 02:20:18 +02:00
|
|
|
this.viewIcon = atom("circle-question");
|
|
|
|
this.viewName = atom("Help");
|
2024-10-06 22:55:26 +02:00
|
|
|
this.webviewRef = createRef<WebviewTag>();
|
2024-09-05 06:15:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-08 02:20:18 +02:00
|
|
|
function makeHelpViewModel(blockId: string, nodeModel: NodeModel) {
|
|
|
|
return new HelpViewModel(blockId, nodeModel);
|
2024-09-05 06:15:39 +02:00
|
|
|
}
|
|
|
|
|
2024-10-06 22:55:26 +02:00
|
|
|
function HelpView({ model }: { model: HelpViewModel }) {
|
2024-10-04 05:28:05 +02:00
|
|
|
return (
|
|
|
|
<div className="help-view">
|
2024-10-08 02:20:18 +02:00
|
|
|
<WebView blockId={model.blockId} model={model} />
|
2024-10-04 05:28:05 +02:00
|
|
|
</div>
|
|
|
|
);
|
2024-08-01 07:22:52 +02:00
|
|
|
}
|
|
|
|
|
2024-09-05 06:15:39 +02:00
|
|
|
export { HelpView, HelpViewModel, makeHelpViewModel };
|