Document not defined error

I am getting document not defined error when i am using,
document.getElementById

I have included “dom” inside package.json lib.

[original thread by asvinwin123]

Hi, in which context?

You can only access DOM in browser context, i.e. from frontend extension entry module. It is not accessible from backend entry points or VS Code extensions (Theia plugins).

[asvinwin123]

I am using in theia plugins frontend context

[asvinwin123]

I am also getting navigator is not defined error

Plugins are never running in the main browser process, either in web worker or in Node.js process. Both don’t have access to DOM.

You can use webviews of VS Code extensions to integrate iframe in Theia or create a native Theia extension to have access to the DOM of main window.

[asvinwin123]

@anton-kosyakov thank you

[asvinwin123]

May i know how to access plugin from other extensions?

activate method can return an object which is accessible from other VS Code extension with vscode.extensions.getExtension(‘anotherPlugin’).exports

[asvinwin123]

vscode or theia

[asvinwin123]

can i have any sample code to see how to use?

Only VS Code extension can access another VS Code extension apis, native Theia extensions don’t have access to them.

https://vscode.readthedocs.io/en/stable/extensionAPI/vscode-api/#extensions

[asvinwin123]

Thank you @anton-kosyakov