MCPcopy
hub / github.com/wavetermdev/waveterm / WebViewModel

Class WebViewModel

frontend/app/view/webview/webview.tsx:47–751  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47export class WebViewModel implements ViewModel {
48 viewType: string;
49 blockId: string;
50 tabModel: TabModel;
51 noPadding?: Atom<boolean>;
52 blockAtom: Atom<Block>;
53 viewIcon: Atom<string | IconButtonDecl>;
54 viewName: Atom<string>;
55 viewText: Atom<HeaderElem[]>;
56 hideViewName: Atom<boolean>;
57 url: PrimitiveAtom<string>;
58 homepageUrl: Atom<string>;
59 urlInputFocused: PrimitiveAtom<boolean>;
60 isLoading: PrimitiveAtom<boolean>;
61 urlWrapperClassName: PrimitiveAtom<string>;
62 refreshIcon: PrimitiveAtom<string>;
63 webviewRef: React.RefObject<WebviewTag>;
64 urlInputRef: React.RefObject<HTMLInputElement>;
65 nodeModel: BlockNodeModel;
66 endIconButtons?: Atom<IconButtonDecl[]>;
67 mediaPlaying: PrimitiveAtom<boolean>;
68 mediaMuted: PrimitiveAtom<boolean>;
69 modifyExternalUrl?: (url: string) => string;
70 domReady: PrimitiveAtom<boolean>;
71 hideNav: Atom<boolean>;
72 searchAtoms?: SearchAtoms;
73 typeaheadOpen: PrimitiveAtom<boolean>;
74 partitionOverride: PrimitiveAtom<string> | null;
75 userAgentType: Atom<string>;
76 env: WebViewEnv;
77 ctrlShiftUnsubFn: (() => void) | null = null;
78
79 constructor({ blockId, nodeModel, tabModel, waveEnv }: ViewModelInitType) {
80 this.nodeModel = nodeModel;
81 this.tabModel = tabModel;
82 this.viewType = "web";
83 this.blockId = blockId;
84 this.env = waveEnv;
85 this.noPadding = atom(true);
86 this.blockAtom = this.env.wos.getWaveObjectAtom<Block>(`block:${blockId}`);
87 this.url = atom();
88 const defaultUrlAtom = this.env.getSettingsKeyAtom("web:defaulturl");
89 this.homepageUrl = atom((get) => {
90 const defaultUrl = get(defaultUrlAtom);
91 const pinnedUrl = get(this.blockAtom)?.meta?.pinnedurl;
92 return pinnedUrl ?? defaultUrl;
93 });
94 this.urlWrapperClassName = atom("");
95 this.urlInputFocused = atom(false);
96 this.isLoading = atom(false);
97 this.refreshIcon = atom("rotate-right");
98 this.viewIcon = atom("globe");
99 this.viewName = atom("Web");
100 this.hideViewName = atom(true);
101 this.urlInputRef = createRef<HTMLInputElement>();
102 this.webviewRef = createRef<WebviewTag>();
103 this.domReady = atom(false);
104 this.hideNav = this.env.getBlockMetaKeyAtom(blockId, "web:hidenav");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected