@manifest-editor/shell 1.0.0 → 1.0.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 digirati-co-uk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,278 @@
1
+ # Shell
2
+
3
+
4
+ ## App context
5
+
6
+ ### useApps()
7
+
8
+ * Get current app
9
+ * Change app
10
+ * List all apps
11
+
12
+ ```js
13
+ const { currentApp, apps, changeApp } = useApps();
14
+
15
+ // All app information.
16
+ apps['manifest-editor'];
17
+
18
+ // Current app
19
+ currentApp.id;
20
+
21
+ // Change app
22
+ changeApp({ id: 'manifest-editor' });
23
+
24
+ // Change app with argument (launcher)
25
+ changeApp({ id: 'collection-explorer', args: 'https://example.org/collection-123' });
26
+ ```
27
+
28
+ ### useAppState()
29
+ Global app state, currently only used for `canvasId`.
30
+ * Get global state
31
+ * Set global state
32
+
33
+ ```js
34
+ const appState = useAppState();
35
+
36
+ // Setting
37
+ appState.setState({ canvasId: 'https://example.org/canvas-1' })
38
+
39
+ // Getting
40
+ appState.state.canvasId;
41
+
42
+ ```
43
+
44
+ ## Config context
45
+
46
+ ```js
47
+ const config = useConfig();
48
+
49
+
50
+ // Languages for the editor ['en, 'none']
51
+ config.i18n.availableLanguages;
52
+
53
+ // Behaviours string[]
54
+ config.behaviorPresets;
55
+
56
+ // IIIF collection for templates
57
+ config.newTemplates;
58
+
59
+ // List of previews.
60
+ config.previews;
61
+ ```
62
+
63
+ ## Layout
64
+ * Get available layouts in app
65
+ * Get layout state
66
+ * Get layout actions
67
+
68
+
69
+ ### Available layouts
70
+ ```js
71
+ const layouts = useAvailableLayouts();
72
+
73
+ // Loading status, check before listing.
74
+ layouts.loading;
75
+
76
+ // List of left panels.
77
+ layouts.leftPanels;
78
+
79
+ // List of center panels.
80
+ layouts.centerPanels;
81
+
82
+ // List of right panels
83
+ layouts.rightPanels;
84
+ ```
85
+
86
+ ### Get layout state
87
+ ```js
88
+ const {
89
+ leftPanel,
90
+ rightPanel,
91
+ pinnedRightPanel,
92
+ centerPanel,
93
+ } = useLayoutState();
94
+
95
+ // Following are the same for all.
96
+
97
+ // Panel state (defined by app)
98
+ leftPanel.state;
99
+
100
+ // Current identifier for panel
101
+ leftPanel.current;
102
+
103
+ // If the panel is open or not.
104
+ leftPanel.open;
105
+
106
+ // If the panel is minimised (not yet implemented)
107
+ leftPanel.minimised;
108
+
109
+ // Custom width of panel, if set.
110
+ leftPanel.customWidth;
111
+
112
+ // Only for pinned:
113
+
114
+ // Can this be pinned;
115
+ pinnedRightPanel.pinnable;
116
+
117
+ // Is this pinned?
118
+ pinnedRightPanel.pinned;
119
+ ```
120
+
121
+ ### Get layout actions
122
+ ```js
123
+ const actions = useLayoutActions();
124
+
125
+ // Open a panel
126
+ actions.open('manifest-properties');
127
+ actions.open('manifest-properties', { some: 'state' });
128
+
129
+ // Change a panels state (does not open)
130
+ actions.change('canvas-properties', { tab: 2 });
131
+
132
+ // Close panel
133
+ actions.close('canvas-properties');
134
+
135
+ // Toggle panel
136
+ actions.toggle('canvas-properties');
137
+
138
+
139
+ // Same actions as above are available PER panel
140
+ actions.leftPanel;
141
+ actions.rightPanel;
142
+ actions.centerPanel;
143
+
144
+ // And some additional on each:
145
+ actions.leftPanel.resetSize();
146
+ actions.leftPanel.setCustomWidth(450);
147
+ actions.leftPanel.maximise(); // N/A
148
+ actions.leftPanel.minimise(); // N/A
149
+ ```
150
+
151
+
152
+ ## Preview Context
153
+ * Get selected preview
154
+ * Get all activated previews
155
+ * List all configurations and their class handlers
156
+ * Activate, select and focus previews
157
+ * Delete previews from storage
158
+ * Update all existing previews (vault -> external)
159
+
160
+ ```js
161
+ const preview = usePreviewContext();
162
+
163
+ // Which preview is selected.
164
+ preview.selected;
165
+
166
+ // List of active preview ids
167
+ preview.active;
168
+
169
+ // List of all available preview configurations
170
+ preview.configs;
171
+
172
+ // List of all available config classes.
173
+ preview.handlers;
174
+
175
+ // And actions
176
+ preview.actions.activatePreview('universal-viewer');
177
+ preview.actions.selectPreview('universal-viewer');
178
+ preview.actions.deletePreview('universal-viewer');
179
+ preview.actions.focusPreview('universal-viewer');
180
+ preview.actions.updatePreviews();
181
+ ```
182
+
183
+ ## Project context
184
+ * Create project (then select automatically)
185
+ * List all recent projects
186
+ * Select a project to work on
187
+
188
+
189
+ ### useProjectCreators()
190
+ ```js
191
+ const { createProjectFromManifestId, createBlankManifest } = useProjectCreators();
192
+
193
+ // Create and select a blank manifest
194
+ await createBlankManifest();
195
+
196
+ // Create a new project from external manifest id
197
+ await createProjectFromManifestId('https://example.org/manifest');
198
+ ```
199
+
200
+ ### useProjectContext()
201
+ ```js
202
+ const ctx = useProjectContext();
203
+
204
+ // Loading status (projects can be loaded from network)
205
+ ctx.loadingStatus.loading;
206
+ ctx.loadingStatus.loaded;
207
+ ctx.loadingStatus.lastLoaded; // time.
208
+
209
+ // Current proejct details (same for listing)
210
+ ctx.current;
211
+ ctx.current.name;
212
+ ctx.current.thumbnail; // Optional
213
+ ctx.current.previews; // list of previews
214
+ ctx.current.resource.id; // Top level resource {id, type: Manifest}
215
+ ctx.current.storage; // Configured storage for project
216
+ ctx.current.settings; // Unused, future settings
217
+ ctx.current.filename; // File name (unused)
218
+ ctx.current.publications; // Future publish options
219
+ ctx.current.metadata.modified; // Last modified
220
+ ctx.current.metadata.created; // Created at
221
+
222
+ // List of all projects
223
+ ctx.allProjects;
224
+
225
+ // Actions
226
+ ctx.actions.switchProject('some-project-id');
227
+ ctx.actions.createProject({ ... });
228
+ ctx.actions.deselectProject('some-project-id')
229
+ ctx.actions.saveProject({ ... });
230
+ ctx.actions.updateThumbnail('...');
231
+ ctx.actions.updateDetails({name: '..', filename: '..'});
232
+ ctx.actions.updateSettings({ ... });
233
+
234
+ // More internal actions
235
+ ctx.actions.createPublication({ ... }); // unused
236
+ ctx.actions.removePublication('publication-id');
237
+ ctx.actions.updatePublication({ ... });
238
+ ctx.actions.updateStorage({ ... });
239
+ ctx.actions.setLoadingStatus({ ... })
240
+ ctx.actions.load({ ... });
241
+ ```
242
+
243
+ ## Resource editing context
244
+
245
+ Simple Context/hook combo
246
+
247
+ Top level:
248
+
249
+ ```jsx
250
+ const anno = { id: 'https://e.org/anno-1', type: 'Annotation' }
251
+
252
+ <ResourceEditingProvider resource={anno}>
253
+ <MyGenericEditor />
254
+ </ResourceEditingProvider>
255
+ ```
256
+
257
+ And then inside the generic editor
258
+
259
+ ```typescript
260
+ import {
261
+ DescriptiveProperties
262
+ } from "@iiif/presentation-3";
263
+
264
+ function MyGenericEditor() {
265
+
266
+ // You can narrow with typescript
267
+ const resource = useResource<DescriptiveProperties>();
268
+
269
+ // Although technical properties, the "ref" is always
270
+ // merged with the type.
271
+ resource.id
272
+ resource.type
273
+ resource.label
274
+ resource.summary
275
+ // ...
276
+
277
+ }
278
+ ```