8 New ONLYOFFICE Apps Samples: Approval Workflows, Sidebar Pages, and Ready-to-Use Plugins
Eight new samples just landed in the ONLYOFFICE Apps developer docs, and they cover both SDKs you use to extend the platform:
- Embed SDK: a document approval workflow built on rooms, access levels and tags.
- Plugins SDK (advanced): an article navigation plugin that adds your own React pages to the sidebar.
- Plugins SDK (ready-to-use): Book reader, CodeMirror, Convert to markdown, Image editor, URL and ZIP archives.
This post covers what each sample does, the APIs behind it, and the gotchas worth knowing before you copy it into your project.
✅ Document approval workflow (Embed SDK)
An author submits a document. The sample creates a custom room tagged Pending review and gives the reviewer Review access. Approve switches the reviewer to Read access and the tag to Approved. Request changes swaps the tag to Changes requested. Both roles run in one browser session to keep the demo short.
The building blocks:
- Embedding:
DocSpace.SDK.initManager(config)withframeId,src,heightand anonAppReadyevent. - Room setup:
createRoom()andcreateFile(). - Status tracking:
createTag(),addTagsToRoom(),removeTagsFromRoom(). - Access:
PUT /api/2.0/files/rooms/{roomId}/share, plusGET /api/2.0/peoplefor the reviewer list.
The magic numbers are declared up front:
const CUSTOM_ROOM = 5
const REVIEW_ACCESS = 5
const READ_ACCESS = 2
Submitting a document:
async function createApprovalRequest() {
const title = document.getElementById("documentTitle").value
if (!title) return alert("Please enter a document title")
const button = document.getElementById("createRequestBtn")
button.disabled = true
const room = await docSpace.createRoom(`Approval: ${title}`, CUSTOM_ROOM)
if (!room?.id) {
button.disabled = false
return alert(`Error creating room: ${room?.message ?? "unknown error"}`)
}
roomId = room.id
try {
const file = await docSpace.createFile(roomId, `${title}.docx`, "{PUBLIC_DOCX_ID}")
// A portal without API_ERROR support resolves errors instead of rejecting
if (!file?.id) throw new Error(file?.message ?? "unknown error")
await docSpace.createTag("Pending review")
await docSpace.addTagsToRoom(roomId, ["Pending review"])
} catch (error) {
console.error(error)
button.disabled = false
return alert(`Error preparing the room: ${error.message}`)
}
document.getElementById("createStep").classList.add("hidden")
document.getElementById("reviewerStep").classList.remove("hidden")
}
Note the room?.id and file?.id checks: a portal without API_ERROR support resolves errors instead of rejecting, so the sample checks the result explicitly.
💡 Tip: Use a custom room (type 5). Collaboration rooms (type 2) reject Review access with HTTP 403. And run the sample as an ONLYOFFICE Apps admin or room admin, because only those roles can create tags.
Full walkthrough: Document approval workflow sample.
🧩 Article navigation plugin (Plugins SDK)
This one adds two sidebar entries with the ArticleNavigation scope. Sample files shows up in Files for every user type. Sample settings shows up in Settings for owners and full admins only. Each entry opens a full page rendered from a React component built with @onlyoffice/apps-ui-kit, so it picks up the portal theme.
The plugin class implements IPlugin and IArticleNavigationPlugin, and registers its items in onLoadCallback (not the constructor), when the portal is ready:
import { Section, UserRole, type IArticleNavigationItem } from "@onlyoffice/docspace-plugin-sdk";
const filesItem: IArticleNavigationItem = {
key: "article-navigation-sample-files",
label: "Sample files",
icon: "plugin-icon.svg",
component: FilesPage,
appears: [Section.Files],
};
const settingsItem: IArticleNavigationItem = {
key: "article-navigation-sample-settings",
label: "Sample settings",
icon: "plugin-icon.svg",
component: SettingsPage,
appears: [Section.Settings],
usersTypes: [UserRole.owner, UserRole.fullAdmin],
};
Inside the pages, useCurrentUser gives you the profile and usePluginActions gives you showToast. useCurrentFile returns null here, since there's no file on a sidebar page.
The gotcha that will bite you: import the UI kit only from the package root.
// ✅ Correct
import { Button } from "@onlyoffice/apps-ui-kit";
// ❌ Wrong - the portal cannot load this
import { Button } from "@onlyoffice/apps-ui-kit/components/button";
The portal substitutes only the exact specifier, so subpath imports fail at load time.
You'll need ONLYOFFICE Apps 4.0.0 or later, Node.js and npm. npm run build outputs dist/plugin.zip. Steps: Article navigation plugin sample.
🛠️ Six ready-to-use plugins
These are finished plugins, available by default in ONLYOFFICE Apps cloud and installable as system plugins elsewhere (how to enable system plugins). They're also good references for combining plugin interfaces:
| Plugin | What it does | Interfaces it combines |
|---|---|---|
| Book reader | Reads .epub, .fb2 and ZIPs containing them |
IContextMenuPlugin, IFilePlugin |
| CodeMirror | Views and edits code with syntax highlighting | IApiPlugin, ISettingsPlugin, IContextMenuPlugin, IMainButtonPlugin, IFilePlugin |
| Convert to markdown | Turns .docx, .txt, .html into a new .md file |
IApiPlugin, IContextMenuPlugin |
| Image editor | Resize, crop, rotate, draw and add text to images | IApiPlugin, IContextMenuPlugin |
| URL | Stores links as .url files that open in a new tab |
IApiPlugin, ISettingsPlugin, IMainButtonPlugin, IContextMenuPlugin, IFilePlugin |
| ZIP archives | Opens, extracts and creates ZIP archives | IApiPlugin, IContextMenuPlugin, IFilePlugin |
Every plugin also implements IPlugin.
One limitation to know: Convert to markdown can't process files in rooms with Add watermarks to documents enabled.
The source for all six lives in one repo: ONLYOFFICE / docspace-plugins
ONLYOFFICE DocSpace plugins ONLYOFFICE Apps plugins This repository comprises plugins which allow extending the functionality of ONLYOFFICE Apps.
- Codemirror
- ConvertToMarkdown
- draw.io
- Markdown
- ImageEditor
- PDFConverter
- Reader
- SpeechToText
- URL
- ZIP Archives
User feedback and support To ask questions and share feedback, use Issues in this repository. Alternatively, you can contact ONLYOFFICE team via community.onlyoffice.com or feedback.onlyoffice.com.
🚀 Start building
- Read the Plugins SDK get started guide or the Embed SDK get started guide.
- Pick the sample closest to your use case.
- Fork it, swap in your logic, and upload it to your portal.
Grab a sample and start testing it in your integration today. We'd love to hear what you build. Drop your questions or feedback in the comments! 👇
Comments
No comments yet. Start the discussion.