跳到主要内容

Personal mode

Personal mode embeds the current user's personal space — My Documents, Favorites, Recent, Shared with me, and Trash — without exposing the rest of the portal's rooms.

Initialization​

const docSpace = DocSpace.SDK.initPersonal({
frameId: "ds-frame",
src: "https://your-docspace.com",
});

Only frameId and src are required. All other parameters are optional and have sensible defaults.

For setup instructions (connecting the script, CSP configuration, npm package), see Get started.

Configuration, events, and methods​

initPersonal() accepts the full TFrameConfig configuration object and returns an SDKInstance. It forces mode to Personal and forces noLoader to true (the loading spinner never shows in Personal mode, regardless of that setting). Personal mode has no navigation menu at all — showMenu doesn't apply here; switch sections with navigateSection() at runtime or personalDestination at init.

navigateSection() and upload() both work in Personal mode as well as Forms mode. setCustomActions() also works in Personal mode, alongside Manager and Forms mode. Calling any of the three from an incompatible mode rejects the returned promise with SDKErrorCode.ModeMismatch — none of them throw synchronously.

Personal mode forwards a number of other config fields into the frame's URL beyond what's shown in the examples below: id (open a specific folder instead of the My Documents root), disableActionButton, filter.sortBy/filter.sortOrder/filter.search/filter.count/filter.page, and headerOffset/headerHeight (padding/height overrides for the header, also honored in Forms and Chat mode).

onFileManagerClick, onEditorOpen, and onDownload (with downloadToEvent: true) all fire in Personal mode, same as in Manager and Public room mode — Personal's file list reuses the same underlying component. openEditorInSameTab controls where a file opens from the list when onEditorOpen isn't set — true navigates the host page to the editor, false forces a new tab, and leaving it unset follows the portal's own "Open in the same tab" setting. upload() works the same way it does in Forms mode — resolving with { fileName, fileSize, uploadId } and firing onUploadSuccess/onUploadError with that same payload — see Uploading a file without the picker dialog for the full behavior (timeout, payload shape, error handling). onFilterSearch fires with { search } whenever a visitor changes the file list's search text at runtime (an empty string when they clear it) — see Sorting and filtering the file list below for the matching filter.search config field. See Events and callbacks for the other events' payload shapes.

Personal mode also supports the same file/folder data and content methods as Manager mode — getUserInfo(), getFiles(), getFolders(), getList(), getFolderInfo(), getSelection(), openModal(), createFile(), createFolder(), and setListView(). There are no rooms in Personal mode, so room-level methods (getRooms(), createRoom(), tags) aren't available. Get selection and Set list view are written against initManager(), but neither example does anything room-specific — swap in initPersonal() and the rest carries over unchanged. Create file and Create folder target a room via rootPath/filter.folder, which don't apply in Personal mode — pass the target folder's id directly instead (see Opening a specific folder below); the method calls themselves, createFile(folderId, title) and createFolder(parentFolderId, title), are unchanged.

Use cases​

Opening a specific section on load​

Set personalDestination to skip the default "My Documents" landing section:

const docSpace = DocSpace.SDK.initPersonal({
frameId: "ds-personal",
src: "https://your-docspace.com",
personalDestination: "favorites",
});

Available sections: "my-documents", "favorites", "recent", "shared-with-me", "trash", "settings".

Use navigateSection() on the returned instance instead of reinitializing the frame, and track the active section from the host page with onNavigate:

const docSpace = DocSpace.SDK.initPersonal({
frameId: "ds-personal",
src: "https://your-docspace.com",
events: {
onAppReady: function () {
document.getElementById("trash-button").onclick = () => {
docSpace.navigateSection("trash");
};
},
onNavigate: function (data) {
console.log("Section changed:", data.section);
},
},
});

Opening a specific folder​

Pass id to land on a subfolder within the user's personal space instead of the My Documents root:

const docSpace = DocSpace.SDK.initPersonal({
frameId: "ds-personal",
src: "https://your-docspace.com",
id: "your-folder-id",
});

Adding custom actions​

Works the same way as in Manager mode — file/folder context menu entries and create ("+") menu items, with the same restriction fields. Personal mode has no rooms, so contextMenu.room and roomTypes don't apply here.

const docSpace = DocSpace.SDK.initPersonal({
frameId: "ds-personal",
src: "https://your-docspace.com",
customActions: {
contextMenu: {
file: [{ key: "send-to-crm", label: "Send to CRM", extensions: ["docx", "pdf"] }],
},
createMenu: [{ key: "upload-from-crm", label: "Upload from CRM" }],
},
events: {
onCustomAction: function (data) {
console.log("Action:", data.action, "Item:", data.item);
},
},
});

See Manager mode's reference for the full payload shape and every restriction field.

Sorting and filtering the file list​

Use the filter object to control how the list is sorted and searched on load:

const docSpace = DocSpace.SDK.initPersonal({
frameId: "ds-personal",
src: "https://your-docspace.com",
filter: {
sortBy: "DateAndTime",
sortOrder: "descending",
search: "report",
},
});