npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@onlyoffice/docspace-sdk-js

v1.1.0

Published

Simple integration JavaScript SDK for ONLYOFFICE DocSpace

Downloads

226

Readme

ONLYOFFICE DocSpace JavaScript SDK

Basic concepts

The ONLYOFFICE DocSpace SDK based on JavaScript allows developers to use all the DocSpace possibilities with api.js. You can integrate ONLYOFFICE DocSpace into your own web application, allowing users to create and submit documents directly from your website. For example, you can use the ONLYOFFICE DocSpace React component to integrate ONLYOFFICE DocSpace into React projects.

You don't need to be an experienced JavaScript developer to use the DocSpace JavaScript SDK because we provide you with all the basics. You only need a few lines of JavaScript to set up a fully functional integration.

Follow the steps below to connect DocSpace as a frame to your website.

Step 1. Specifying the DocSpace URL

For the JavaScript SDK to work correctly, it must be launched on the server. Note that running the HTML file directly will not work. Please make sure you are using a server environment.

You need to add the URL of your server's root directory to the Developer Tools section of DocSpace:

  1. Go to the DocSpace settings.
  2. Navigate to the Developer Tools section.
  3. On the JavaScript SDK tab, in the Enter the address of DocSpace to embed field, add the URL of your server's root directory.

Step 2. Creating the HTML file

Create the target HTML file which must include a placeholder div tag, where all the information about DocSpace parameters will be passed:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>DocSpace JavaScript SDK</title>
        <script src="{PORTAL_SRC}/static/scripts/sdk/1.0.0/api.js"></script>
    </head>
    <body>
        <div id="ds-frame"></div>
    </body>
</html>

The API JavaScript file can normally be found in the following DocSpace folder:

{PORTAL\_SRC}/static/scripts/sdk/1.0.0/api.js

where {PORTAL_SRC} is the name of the server with the ONLYOFFICE DocSpace installed.

Step 3. Getting the base class

When the API JavaScript is connected to the page, get the base class that provides all the basic functionality of api.js:

| Class | Description | | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------- | | DocSpace.SDK | Defines the DocSpace document manager and allows you to perform operations with rooms, folders, and documents within the DocSpace portal. |

Step 4. Authorizing

api.js uses the active DocSpace application sessions to authenticate users. If the user is logged in to the DocSpace portal that the SDK will connect to, then api.js recognizes and uses that active session.

If the users are not authenticated, they will see a page asking them to sign in to DocSpace the first time they use it. Authentication is also possible through the SDK methods.

Step 5. Initializing

Please note that when working via HTTPS, it is necessary to set the "SameSite": "none" parameter in appsettings.json to avoid blocking the work with cookies during cross-domain requests.

Initialize DocSpace frame using the initFrame method with the SDK config passed to it:

const docSpace = DocSpace.SDK.initFrame({
  frameId: "frameId",
  showMenu: true,
})

You can use other available methods to initialize DocSpace.

The full list of config parameters can be found here.

Step 6. Using

After initialization, the current SDK instance can be accessed by using its frameId. The list of current SDK instances is available in the DocSpace.SDK.frames array. To get the specific SDK instance, use the following string:

DocSpace.SDK.frames[frameId]