aboutsummaryrefslogtreecommitdiff
path: root/editor/editor.ts
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-08-29 13:53:00 +0700
committerShulhan <ms@kilabit.info>2021-08-29 13:53:00 +0700
commit7940feda7d50c404fb245b645c8261d6cb4dd768 (patch)
tree1d688fde2e998e8c2fb1cfd9b0ccf53022743177 /editor/editor.ts
parent51e7db8b61ec21628fc0ed2f5f48bfff47962684 (diff)
downloadpakakeh.ts-7940feda7d50c404fb245b645c8261d6cb4dd768.tar.xz
editor: simplify the Open method
Previously, the Open method call the predefined options OpenFile, which in turn may send request to remote server. This changes simplify it by accepting node interface that has been filled with content and metadata.
Diffstat (limited to 'editor/editor.ts')
-rw-r--r--editor/editor.ts21
1 files changed, 3 insertions, 18 deletions
diff --git a/editor/editor.ts b/editor/editor.ts
index 56a3ece..8f175ac 100644
--- a/editor/editor.ts
+++ b/editor/editor.ts
@@ -14,8 +14,6 @@ export interface WuiEditorOptions {
id: string
is_editable: boolean
- OpenFile(path: string): WuiResponseInterface
-
// Handler that will be called when user select lines.
OnSelection(begin: number, end: number): void
@@ -335,21 +333,10 @@ export class WuiEditor {
}
}
- async OpenFile(path: string): Promise<WuiResponseInterface> {
- let res = await this.opts.OpenFile(path)
- if (!res) {
- return { code: 500 } as WuiResponseInterface
- }
- if (res.code != 200) {
- return res
- }
- if (!res.data) {
- return res
- }
-
- this.active_file = res.data as WuiVfsNodeInterface
+ Open(node: WuiVfsNodeInterface): void {
+ this.active_file = node
- let content = this.active_file.content as string
+ let content = node.content as string
content = content.replace("\r\n", "\n")
this.raw_lines = content.split("\n")
@@ -360,8 +347,6 @@ export class WuiEditor {
}
this.render()
-
- return res
}
private clearSelection() {