### Project Setup and Development Commands Source: https://github.com/onlyoffice/docspace-react/blob/master/README.md Essential commands for setting up and developing the ONLYOFFICE DocSpace React project. This includes cloning the repository, installing dependencies, running tests, building the project, and creating a package. ```bash git clone https://github.com/ONLYOFFICE/docspace-react ``` ```bash npm install ``` ```bash npm run test ``` ```bash npm run rollup ``` ```bash npm pack ``` -------------------------------- ### Start React Development Server Source: https://github.com/onlyoffice/docspace-react/blob/master/README.md Command to start the Node.js development server for the React application. This command should be run from the root directory of the React project. ```bash npm run start ``` -------------------------------- ### Serve Static React Build Source: https://github.com/onlyoffice/docspace-react/blob/master/README.md Commands to install and use the 'serve' package to host the static build of the React application. It shows how to serve on a default port and a custom port. ```bash npm install -g serve serve -s build serve -s build -l 4000 ``` -------------------------------- ### Install and Configure ONLYOFFICE DocSpace React Package Source: https://context7.com/onlyoffice/docspace-react/llms.txt Installs the @onlyoffice/docspace-react package using npm or yarn. It also shows a basic setup example for integrating the DocSpace component into a React application, requiring the server URL and configuration options. ```bash # Install the package npm install --save @onlyoffice/docspace-react # Or using yarn yarn add @onlyoffice/docspace-react ``` ```tsx // Basic setup in your React application import React from 'react'; import { DocSpace } from "@onlyoffice/docspace-react"; function App() { return (
>
);
}
```
--------------------------------
### Display File Selector Interface in React
Source: https://context7.com/onlyoffice/docspace-react/llms.txt
Renders a file picker interface for selecting files from DocSpace. This component is ideal for implementing file selection workflows in your application. It requires the DocSpace component and basic configuration with the 'file-selector' mode.
```tsx
import React from 'react';
import { DocSpace } from "@onlyoffice/docspace-react";
function FilePicker() {
return (
console.log("File selector ready"),
onAppError: (e) => console.error("Error:", e),
}
}}
/>
);
}
export default FilePicker;
```
--------------------------------
### Authenticate DocSpace with Password Hash in React
Source: https://context7.com/onlyoffice/docspace-react/llms.txt
Enables automatic login to DocSpace using email and a password hash. The `onRequestPasswordHash` callback is invoked with the email to retrieve the password hash, and `onUnsuccessLogin` handles authentication failures. This requires providing email, `onRequestPasswordHash`, and `onUnsuccessLogin` props to the DocSpace component.
```tsx
import React from 'react';
import { DocSpace } from "@onlyoffice/docspace-react";
function AuthenticatedDocSpace() {
// Return the password hash for the given email
// In production, retrieve this securely from your backend
const onRequestPasswordHash = (email: string): string => {
// Password hash should be obtained securely from your authentication system
return "your-password-hash-here";
};
// Handle failed authentication attempts
const onUnsuccessLogin = () => {
alert("Login failed. Please check your credentials.");
// Redirect to login page or show authentication modal
};
return (
console.log("DocSpace ready"),
onAppError: (e) => console.error("Error:", e),
}
}}
email="user@example.com"
onRequestPasswordHash={onRequestPasswordHash}
onUnsuccessLogin={onUnsuccessLogin}
/>
);
}
export default AuthenticatedDocSpace;
```
--------------------------------
### Open Document in DocSpace Editor
Source: https://context7.com/onlyoffice/docspace-react/llms.txt
Integrates the ONLYOFFICE DocSpace editor to view or edit a specific document. This mode requires a file ID and enables collaborative editing features. It's suitable for direct document interaction within your React application.
```tsx
import React from 'react';
import { DocSpace } from "@onlyoffice/docspace-react";
function DocumentEditor() {
const fileId = 12345; // The DocSpace file ID to open
return (
console.log("Editor ready"),
onAppError: (e) => console.error("Editor error:", e),
}
}}
/>
);
}
export default DocumentEditor;
```
--------------------------------
### Display DocSpace File Manager
Source: https://context7.com/onlyoffice/docspace-react/llms.txt
Renders the full ONLYOFFICE DocSpace file manager interface. This mode allows users to navigate folders, perform file operations like upload, download, delete, and share, and manage rooms. It's the default mode for comprehensive document management.
```tsx
import React from 'react';
import { DocSpace } from "@onlyoffice/docspace-react";
function FileManager() {
return (
console.log("File manager ready"),
onAppError: (e) => console.error("Error:", e),
}
}}
/>
);
}
export default FileManager;
```
--------------------------------
### Display DocSpace Room Selector
Source: https://context7.com/onlyoffice/docspace-react/llms.txt
Renders an interface for selecting ONLYOFFICE DocSpace rooms. This component is useful for workflows that require users to choose a specific room for file operations or navigation within collaborative workspaces.
```tsx
import React from 'react';
import { DocSpace } from "@onlyoffice/docspace-react";
function RoomPicker() {
return (
console.log("Room selector ready"),
onAppError: (e) => console.error("Error:", e),
}
}}
/>
);
}
export default RoomPicker;
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.