Skip to content

Latest commit

 

History

History
313 lines (236 loc) · 9.8 KB

api.md

File metadata and controls

313 lines (236 loc) · 9.8 KB

API

Table of contents


Static methods

WindowManager.mount

mount WindowManager

const manager = await WindowManager. mount(
     room: room,
     container: document. getElementById("container")
     // full configuration see below
);

parameter

name type default desc
room [require] Room room instance
container [require] HTMLElement room mount container
containerSizeRatio [optional] number 9 / 16 The aspect ratio of the multi-window area, the default is 9 : 16
chessboard [optional] boolean true The space outside the multi-window area displays PS checkerboard background, default true
collectorContainer [optional] HTMLElement dom for multi-window minimize icon mount
collectorStyles [optional] Partial{CSSStyleDeclaration} Configure collector style
overwriteStyles [optional] string The style to use for the overlay window
cursor [optional] boolean false Turn on cursor sync
disableCameraTransform [optional] boolean Disable camera movement for the main whiteboard
prefersColorScheme [optional] string light auto, light, dark
debug [optional] boolean false print log information
applianceIcons [optional] {ApplianceNames, string} Configure the teaching aid picture used by the cursor

WindowManager. register

Register APP to WindowManager

WindowManager. register({
    kind: "hello World",
    src: NetlessApp,
    appOptions: () => "appOptions",
    addHooks: (emitter) => {
        emitter.on("created", result => {
            console.log("HelloWordResult", result);
        });
        emitter.on("focus", result => {
            console.log("HelloWorld focus", result);
        })
        emitter.on("destroy", result => {
            console.log("HelloWorld destroy", result);
        })
    }
})

WindowManager.registered

Get the registered App

WindowManager.registered

setContainer

Set whiteboard mount container

WindowManager.setContainer(document.getElementById("container"));

setCollectorContainer

Set container mounted by Collector

WindowManager.setCollectorContainer(document.getElementById("collector-container"));

Instance methods

addApp

add app to whiteboard

const appId = await manager.addApp({
     kind: "hello World"
     options: { // optional configuration
         scenePath: "/hello-world"
     }
})

For specific parameters, please refer to the requirements of APP itself

closeApp

Close any open APP

manager.closeApp(appId)

focusApp

Switch the app of the current focus, and set this app to the front

manager.focusApp(appId)

setMainViewSceneIndex

Set the SceneIndex of the main whiteboard

manager.setMainViewSceneIndex(1)

setBoxState

Set the current boxState

manager.setBoxState("normal") // boxState: normal | maximized | minimized

cleanCurrentScene

Clear the handwriting of the currently focused view

manager.cleanCurrentScene()

redo

Redo the last operation on the currently focused view

manager.redo()

undo

Undo the last action on the currently focused view

manager.undo()

nextPage

Switch main whiteboard to next page

const success = await manager.nextPage()
if (!success) {
     // reached the last page
}

prevPage

Switch main whiteboard to previous page

const success = await manager.prevPage()
if (!success) {
     // have reached the first page
}

addPage

Add a page to the main whiteboard

manager.addPage() // add a page at the end by default
manager.addPage({ after: true }) // add a page after the current page
manager.addPage({ scene: { name: "page2" } }) // pass in page information

removePage

remove a page When there is only one page left, the last page is not allowed to be deleted

const success = await manager.removePage() // delete the current page by default
const success = await manager.removePage(1) // can delete the specified index

refresh

Refreshes manager internal state for copy attributes from other rooms

manager.refresh()

setContainerSizeRatio

Set the aspect ratio of the whiteboard synchronization area

manager.setContainerSizeRatio(10 / 16)

Instance attributes

name type default desc
mainView View main whiteboard
mainViewSceneIndex number The SceneIndex of the current main whiteboard
mainViewScenesLength number mainView's scenes length
boxState string current window status
darkMode boolean dark mode
prefersColorScheme string color theme
focused string focus app
canRedoSteps number The number of steps that the currently focused view can redo
canRedoSteps number The number of steps that the currently focused view can undo
sceneState SceneState Compatible with the sceneState property of the original SDK, only valid for mainView
pageState PageState Combine the index and scenes modification of mainView

event callback

manager.emitter.on(events, listener)
name type default desc
mainViewModeChange ViewVisionMode
mainViewSceneIndexChange index: number
boxStateChange string normal,minimized,maximized
darkModeChange boolean
prefersColorSchemeChange string auto,light,dark
cameraStateChange CameraState
focusedChange string, undefined The appId of the current focus, undefined for the main whiteboard
mainViewScenesLengthChange number fires when mainView scenes are added or removed
canRedoStepsChange number The view of the current focus can redo the number of steps to change
canUndoStepsChange number The current focus view can undo the step change
loadApp LoadAppEvent Load remote APP event
ready undefined Triggered when all apps are created
sceneStateChange SceneState Fired when sceneState is modified
pageStateChange PageState
fullscreenChange boolean Triggered when the full-screen status changes |
appsChange string[] Triggered when the list of opened apps changes
type LoadAppEvent = {
     kind: string;
     status: "start" | "success" | "failed";
     reason?: string;
}
type PageState = {
     index: number;
     length: number;
}