Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

ApiResult

ApiResult<T>: { data: T; message: string; status: "ok" | "error" }

Type parameters

  • T = any

Type declaration

  • data: T
  • message: string
  • status: "ok" | "error"

Functions

abortExtensionInstallation

  • abortExtensionInstallation(): Promise<any>
  • Abort extension installation

    Returns Promise<any>

choosePath

  • choosePath(options: Record<string, any>): Promise<{ canceled: boolean; filePaths: string[] }>
  • Launch app to choose a path.

    Parameters

    • options: Record<string, any>

    Returns Promise<{ canceled: boolean; filePaths: string[] }>

commentHistoryVersion

  • commentHistoryVersion(file: PathItem, version: string, msg: string): Promise<any>
  • Parameters

    • file: PathItem
    • version: string
    • msg: string

    Returns Promise<any>

convertFile

  • convertFile(source: string, fromType: "markdown" | "html", toType: "print" | "html" | "docx" | "rst" | "adoc", resourcePath: string): Promise<Response>
  • Convert file

    Parameters

    • source: string
    • fromType: "markdown" | "html"
    • toType: "print" | "html" | "docx" | "rst" | "adoc"
    • resourcePath: string

    Returns Promise<Response>

copyFile

  • Copy a file

    Parameters

    Returns Promise<ApiResult<any>>

deleteFile

  • Delete a file or dir.

    Parameters

    Returns Promise<ApiResult<any>>

deleteHistoryVersion

  • deleteHistoryVersion(file: PathItem, version: string): Promise<any>
  • Parameters

    Returns Promise<any>

deleteTmpFile

  • deleteTmpFile(name: string): Promise<ApiResult<any>>
  • Remove temporary file.

    Parameters

    • name: string

    Returns Promise<ApiResult<any>>

deleteUserFile

  • deleteUserFile(name: string): Promise<ApiResult<any>>
  • Remove user file.

    Parameters

    • name: string

    Returns Promise<ApiResult<any>>

disableExtension

  • disableExtension(id: string): Promise<any>
  • Disable extension

    Parameters

    • id: string

    Returns Promise<any>

enableExtension

  • enableExtension(id: string): Promise<any>
  • Enable extension

    Parameters

    • id: string

    Returns Promise<any>

fetchCustomStyles

  • fetchCustomStyles(): Promise<string[]>
  • Fetch custom styles.

    Returns Promise<string[]>

fetchHistoryContent

  • fetchHistoryContent(file: PathItem, version: string): Promise<string>
  • Parameters

    Returns Promise<string>

fetchHistoryList

  • fetchHistoryList(file: PathItem): Promise<{ list: { comment: string; name: string }[]; size: number }>
  • Parameters

    Returns Promise<{ list: { comment: string; name: string }[]; size: number }>

fetchHttp

  • fetchHttp(input: RequestInfo, init?: RequestInit): Promise<any>
  • Parameters

    • input: RequestInfo
    • Optional init: RequestInit

    Returns Promise<any>

fetchInstalledExtensions

  • fetchInstalledExtensions(): Promise<{ enabled: boolean; id: string; isDev?: boolean }[]>
  • Fetch installed extensions

    Returns Promise<{ enabled: boolean; id: string; isDev?: boolean }[]>

fetchSettings

  • fetchSettings(): Promise<Record<string, any>>
  • Fetch settings.

    Returns Promise<Record<string, any>>

fetchTree

  • Fetch file tree from a repository.

    Parameters

    Returns Promise<Components.Tree.Node[]>

installExtension

  • installExtension(id: string, url: string): Promise<any>
  • Install extension

    Parameters

    • id: string
    • url: string

    Returns Promise<any>

moveFile

  • Move / Rename a file or dir.

    Parameters

    Returns Promise<ApiResult<any>>

proxyRequest

  • proxyRequest(url: string, reqOptions?: Record<string, any>, usePost?: boolean): Promise<Response>
  • Proxy request.

    Parameters

    • url: string

      URL

    • reqOptions: Record<string, any> = {}
    • usePost: boolean = false

    Returns Promise<Response>

readFile

  • readFile(file: PathItem, asBase64?: boolean): Promise<{ content: string; hash: string; stat: FileStat }>
  • Read a file.

    Parameters

    Returns Promise<{ content: string; hash: string; stat: FileStat }>

readTmpFile

  • readTmpFile(name: string): Promise<Response>
  • Read temporary file.

    Parameters

    • name: string

    Returns Promise<Response>

readUserFile

  • readUserFile(name: string): Promise<Response>
  • Read user file.

    Parameters

    • name: string

    Returns Promise<Response>

rpc

  • rpc(code: string): Promise<any>
  • Eval cade on Electron main process

    await ctx.api.rpc('return 1 + 1') // result 2 await ctx.api.rpc(return require('os').platform()) // result 'darwin' await ctx.api.rpc(return require('./constant').APP_NAME) // result 'yank-note'

    Parameters

    • code: string

      Function body

    Returns Promise<any>

runCode

  • runCode(cmd: string | { args: string[]; cmd: string }, code: string, outputStream: true): Promise<ReadableStreamDefaultReader>
  • runCode(cmd: string | { args: string[]; cmd: string }, code: string, outputStream?: false): Promise<string>
  • Run code.

    Parameters

    • cmd: string | { args: string[]; cmd: string }
    • code: string
    • outputStream: true

    Returns Promise<ReadableStreamDefaultReader>

    result

  • Parameters

    • cmd: string | { args: string[]; cmd: string }
    • code: string
    • Optional outputStream: false

    Returns Promise<string>

search

  • search(controller: AbortController, query: ITextQuery): Promise<SearchReturn>
  • Search files.

    Parameters

    • controller: AbortController
    • query: ITextQuery

    Returns Promise<SearchReturn>

uninstallExtension

  • uninstallExtension(id: string): Promise<any>
  • Uninstall extension

    Parameters

    • id: string

    Returns Promise<any>

upload

  • upload(repo: string, fileBase64Url: string, filePath: string): Promise<ApiResult<any>>
  • Upload file.

    Parameters

    • repo: string
    • fileBase64Url: string
    • filePath: string

    Returns Promise<ApiResult<any>>

watchFile

  • watchFile(repo: string, path: string, options: WatchOptions, onResult: (result: { eventName: "add" | "change" | "unlink"; path: string; stats?: Stats }) => void, onError: (error: Error) => void): Promise<{ abort: () => void; result: Promise<null | string> }>
  • Watch a file.

    Parameters

    • repo: string
    • path: string
    • options: WatchOptions
    • onResult: (result: { eventName: "add" | "change" | "unlink"; path: string; stats?: Stats }) => void
        • (result: { eventName: "add" | "change" | "unlink"; path: string; stats?: Stats }): void
        • Parameters

          • result: { eventName: "add" | "change" | "unlink"; path: string; stats?: Stats }
            • eventName: "add" | "change" | "unlink"
            • path: string
            • Optional stats?: Stats

          Returns void

    • onError: (error: Error) => void
        • (error: Error): void
        • Parameters

          • error: Error

          Returns void

    Returns Promise<{ abort: () => void; result: Promise<null | string> }>

writeFile

  • writeFile(file: Doc, content?: string, asBase64?: boolean): Promise<{ hash: string; stat: FileStat }>
  • Write content to a file.

    Parameters

    • file: Doc
    • content: string = ''
    • asBase64: boolean = false

    Returns Promise<{ hash: string; stat: FileStat }>

writeSettings

  • writeSettings(data: Record<string, any>): Promise<ApiResult<any>>
  • Write settings.

    Parameters

    • data: Record<string, any>

    Returns Promise<ApiResult<any>>

writeTmpFile

  • writeTmpFile(name: string, data: string, asBase64?: boolean): Promise<ApiResult<{ path: string }>>
  • Write temporary file.

    Parameters

    • name: string
    • data: string
    • asBase64: boolean = false

    Returns Promise<ApiResult<{ path: string }>>

writeUserFile

  • writeUserFile(name: string, data: string, asBase64?: boolean): Promise<ApiResult<{ path: string }>>
  • Write user file.

    Parameters

    • name: string
    • data: string
    • asBase64: boolean = false

    Returns Promise<ApiResult<{ path: string }>>

Generated using TypeDoc