@shiftengineering/folio 0.0.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +211 -0
- package/dist-embed-component/Folio Tutorial.pdf +0 -0
- package/dist-embed-component/apple-touch-icon-180x180.png +0 -0
- package/dist-embed-component/apple-touch-icon.png +0 -0
- package/dist-embed-component/favicon-96x96.png +0 -0
- package/dist-embed-component/favicon.ico +0 -0
- package/dist-embed-component/favicon.svg +15 -0
- package/dist-embed-component/folio-embed.js +2259 -0
- package/dist-embed-component/folio-embed.umd.cjs +34 -0
- package/dist-embed-component/folio-light.svg +11 -0
- package/dist-embed-component/folio.svg +11 -0
- package/dist-embed-component/logo-dev.svg +6 -0
- package/dist-embed-component/logo.svg +13 -0
- package/dist-embed-component/maskable-icon-512x512.png +0 -0
- package/dist-embed-component/nvidia-10k-2023.pdf +0 -0
- package/dist-embed-component/nvidia-10k-2024.pdf +0 -0
- package/dist-embed-component/pwa-192x192.png +0 -0
- package/dist-embed-component/pwa-512x512.png +0 -0
- package/dist-embed-component/pwa-64x64.png +0 -0
- package/dist-embed-component/shift-text-black.svg +3 -0
- package/dist-embed-component/shift-text-white.svg +3 -0
- package/dist-embed-component/site.webmanifest +21 -0
- package/dist-embed-component/staticwebapp.config.json +6 -0
- package/dist-embed-component/types/embed-component/FolioContext.d.ts +62 -0
- package/dist-embed-component/types/embed-component/FolioEmbed.component.d.ts +28 -0
- package/dist-embed-component/types/embed-component/index.d.ts +3 -0
- package/dist-embed-component/types/embed-component/useFolio.d.ts +32 -0
- package/dist-embed-component/web-app-manifest-192x192.png +0 -0
- package/dist-embed-component/web-app-manifest-512x512.png +0 -0
- package/package.json +204 -0
package/README.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# @shiftengineering/folio
|
|
2
|
+
|
|
3
|
+
A React component library for embedding and interacting with Folio documents, projects, and files in your application.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Using npm
|
|
9
|
+
npm install @shiftengineering/folio
|
|
10
|
+
|
|
11
|
+
# Using yarn
|
|
12
|
+
yarn add @shiftengineering/folio
|
|
13
|
+
|
|
14
|
+
# Using pnpm
|
|
15
|
+
pnpm add @shiftengineering/folio
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
This package exports three main features:
|
|
21
|
+
|
|
22
|
+
1. `FolioProvider` - Context provider for Folio connections
|
|
23
|
+
2. `FolioEmbed` - React component to embed Folio in an iframe
|
|
24
|
+
3. `useFolio` - React hook for interacting with Folio data
|
|
25
|
+
|
|
26
|
+
### Basic Setup
|
|
27
|
+
|
|
28
|
+
First, wrap your application with the `FolioProvider`:
|
|
29
|
+
|
|
30
|
+
```jsx
|
|
31
|
+
import { FolioProvider } from "@shiftengineering/folio";
|
|
32
|
+
import App from "./App";
|
|
33
|
+
|
|
34
|
+
// Optional: custom authentication function
|
|
35
|
+
const getToken = async () => {
|
|
36
|
+
// Fetch or generate your authentication token
|
|
37
|
+
return "your-auth-token";
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
ReactDOM.render(
|
|
41
|
+
<FolioProvider
|
|
42
|
+
host="http://your-folio-server.com"
|
|
43
|
+
port={5174}
|
|
44
|
+
getToken={getToken}
|
|
45
|
+
>
|
|
46
|
+
<App />
|
|
47
|
+
</FolioProvider>,
|
|
48
|
+
document.getElementById("root"),
|
|
49
|
+
);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Embedding Folio
|
|
53
|
+
|
|
54
|
+
Use the `FolioEmbed` component to embed Folio in your application:
|
|
55
|
+
|
|
56
|
+
```jsx
|
|
57
|
+
import { FolioEmbed } from "@shiftengineering/folio";
|
|
58
|
+
|
|
59
|
+
function MyFolioPage() {
|
|
60
|
+
return (
|
|
61
|
+
<div className="folio-page">
|
|
62
|
+
<h1>My Folio Documents</h1>
|
|
63
|
+
<FolioEmbed
|
|
64
|
+
width="100%"
|
|
65
|
+
height="800px"
|
|
66
|
+
className="my-custom-class"
|
|
67
|
+
style={{ border: "1px solid #ccc" }}
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Interacting with Folio Data
|
|
75
|
+
|
|
76
|
+
Use the `useFolio` hook to get and manipulate Folio data:
|
|
77
|
+
|
|
78
|
+
```jsx
|
|
79
|
+
import { useFolio } from "@shiftengineering/folio";
|
|
80
|
+
|
|
81
|
+
function FolioProjectManager() {
|
|
82
|
+
const {
|
|
83
|
+
isLoading,
|
|
84
|
+
error,
|
|
85
|
+
getProjectsForUser,
|
|
86
|
+
addProjectForUser,
|
|
87
|
+
getFilesForProject,
|
|
88
|
+
addFilesToProject,
|
|
89
|
+
} = useFolio();
|
|
90
|
+
const [projects, setProjects] = useState([]);
|
|
91
|
+
const [files, setFiles] = useState([]);
|
|
92
|
+
const [selectedProjectId, setSelectedProjectId] = useState(null);
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
// Load user's projects when component mounts
|
|
96
|
+
const loadProjects = async () => {
|
|
97
|
+
const userProjects = await getProjectsForUser();
|
|
98
|
+
setProjects(userProjects);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
loadProjects();
|
|
102
|
+
}, []);
|
|
103
|
+
|
|
104
|
+
const handleCreateProject = async () => {
|
|
105
|
+
const newProject = await addProjectForUser("My New Project");
|
|
106
|
+
if (newProject) {
|
|
107
|
+
setProjects([...projects, newProject]);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const handleSelectProject = async (projectId) => {
|
|
112
|
+
setSelectedProjectId(projectId);
|
|
113
|
+
const projectFiles = await getFilesForProject(projectId);
|
|
114
|
+
setFiles(projectFiles);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const handleAddFile = async () => {
|
|
118
|
+
if (!selectedProjectId) return;
|
|
119
|
+
|
|
120
|
+
const newFiles = await addFilesToProject(selectedProjectId, [
|
|
121
|
+
{ path: "/path/to/file.pdf", name: "My Document.pdf" },
|
|
122
|
+
]);
|
|
123
|
+
|
|
124
|
+
if (newFiles) {
|
|
125
|
+
setFiles([...files, ...newFiles]);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
if (isLoading) return <div>Loading...</div>;
|
|
130
|
+
if (error) return <div>Error: {error.message}</div>;
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<div>
|
|
134
|
+
<button onClick={handleCreateProject}>Create New Project</button>
|
|
135
|
+
|
|
136
|
+
<h2>Your Projects</h2>
|
|
137
|
+
<ul>
|
|
138
|
+
{projects.map((project) => (
|
|
139
|
+
<li key={project.id} onClick={() => handleSelectProject(project.id)}>
|
|
140
|
+
{project.name}
|
|
141
|
+
</li>
|
|
142
|
+
))}
|
|
143
|
+
</ul>
|
|
144
|
+
|
|
145
|
+
{selectedProjectId && (
|
|
146
|
+
<>
|
|
147
|
+
<h2>Project Files</h2>
|
|
148
|
+
<button onClick={handleAddFile}>Add File</button>
|
|
149
|
+
<ul>
|
|
150
|
+
{files.map((file) => (
|
|
151
|
+
<li key={file.id}>{file.name}</li>
|
|
152
|
+
))}
|
|
153
|
+
</ul>
|
|
154
|
+
</>
|
|
155
|
+
)}
|
|
156
|
+
</div>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## API Reference
|
|
162
|
+
|
|
163
|
+
### FolioProvider
|
|
164
|
+
|
|
165
|
+
Context provider that manages Folio application connection settings.
|
|
166
|
+
|
|
167
|
+
| Prop | Type | Default | Description |
|
|
168
|
+
| ---------- | -------- | ----------------------------------- | --------------------------------------------------------- |
|
|
169
|
+
| `host` | string | `'http://localhost'` | Host for the Folio API and iframe |
|
|
170
|
+
| `port` | number | `5174` | Port for the Folio API and iframe |
|
|
171
|
+
| `getToken` | function | `() => 'dev-jwt-token-for-testing'` | Function to get the authentication token for API requests |
|
|
172
|
+
|
|
173
|
+
### FolioEmbed
|
|
174
|
+
|
|
175
|
+
React component to embed Folio in an iframe.
|
|
176
|
+
|
|
177
|
+
| Prop | Type | Default | Description |
|
|
178
|
+
| ------------- | ---------------- | ------------------------------------------------------------------- | ----------------------------------------------- |
|
|
179
|
+
| `width` | string \| number | `'100%'` | Width of the iframe |
|
|
180
|
+
| `height` | string \| number | `'100vh'` | Height of the iframe |
|
|
181
|
+
| `allow` | string | `'camera; microphone; clipboard-read; clipboard-write; fullscreen'` | Allow attributes for the iframe |
|
|
182
|
+
| `style` | object | `{}` | Additional styles for the iframe container |
|
|
183
|
+
| `className` | string | `''` | Additional class names for the iframe container |
|
|
184
|
+
| `iframeProps` | object | `{}` | Additional props to pass to the iframe |
|
|
185
|
+
|
|
186
|
+
### useFolio
|
|
187
|
+
|
|
188
|
+
Hook for interacting with the Folio application.
|
|
189
|
+
|
|
190
|
+
| Property | Type | Description |
|
|
191
|
+
| -------------------- | ------------- | ---------------------------------------- |
|
|
192
|
+
| `isLoading` | boolean | Indicates if an operation is in progress |
|
|
193
|
+
| `error` | Error \| null | Error from the last operation if any |
|
|
194
|
+
| `getProjectsForUser` | function | Get all projects for the current user |
|
|
195
|
+
| `addProjectForUser` | function | Add a new project for the current user |
|
|
196
|
+
| `addFilesToProject` | function | Add files to an existing project |
|
|
197
|
+
| `getFilesForProject` | function | Get all files for a specific project |
|
|
198
|
+
|
|
199
|
+
## Types
|
|
200
|
+
|
|
201
|
+
The library exports these TypeScript types:
|
|
202
|
+
|
|
203
|
+
| Type | Description |
|
|
204
|
+
| ----------------- | ---------------------------------- |
|
|
205
|
+
| `FolioFile` | Represents a file in Folio |
|
|
206
|
+
| `FolioProject` | Represents a project in Folio |
|
|
207
|
+
| `FolioEmbedProps` | Props for the FolioEmbed component |
|
|
208
|
+
|
|
209
|
+
## License
|
|
210
|
+
|
|
211
|
+
[YOUR LICENSE HERE]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev/svgjs" width="577" height="483"><svg width="577" height="483" viewBox="0 0 577 483" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g clip-path="url(#clip0_7_27)">
|
|
3
|
+
<rect y="88.6035" width="125.465" height="340.807" transform="rotate(-44.9265 0 88.6035)" fill="#1D4ED8"></rect>
|
|
4
|
+
<rect x="239.677" y="152.027" width="125.465" height="340.807" transform="rotate(44.5184 239.677 152.027)" fill="#1D4ED8"></rect>
|
|
5
|
+
<rect x="247" y="88.6035" width="125.465" height="340.807" transform="rotate(-44.9265 247 88.6035)" fill="#1D4ED8"></rect>
|
|
6
|
+
<rect x="486.677" y="152.027" width="125.465" height="340.807" transform="rotate(44.5184 486.677 152.027)" fill="#1D4ED8"></rect>
|
|
7
|
+
</g>
|
|
8
|
+
<defs>
|
|
9
|
+
<clipPath id="SvgjsClipPath1031">
|
|
10
|
+
<rect width="576.509" height="483" fill="white"></rect>
|
|
11
|
+
</clipPath>
|
|
12
|
+
</defs>
|
|
13
|
+
</svg><style>@media (prefers-color-scheme: light) { :root { filter: none; } }
|
|
14
|
+
@media (prefers-color-scheme: dark) { :root { filter: none; } }
|
|
15
|
+
</style></svg>
|