@gramps-connect/story 0.2.0 → 0.3.0
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 +15 -13
- package/dist/editor.js +490 -119
- package/dist/editor.js.map +4 -4
- package/dist/embed.js +10 -10
- package/dist/player.js +63 -8
- package/dist/player.js.map +2 -2
- package/dist/types/editor/PhotosField.d.ts +16 -0
- package/dist/types/editor/StoryEditor.d.ts +17 -12
- package/dist/types/editor/index.d.ts +3 -2
- package/dist/types/editor/model.d.ts +26 -1
- package/dist/types/editor/strings.d.ts +12 -0
- package/dist/types/player/strings.d.ts +2 -0
- package/package.json +1 -1
- package/src/editor/PhotosField.tsx +134 -0
- package/src/editor/StoryEditor.tsx +119 -29
- package/src/editor/index.ts +5 -3
- package/src/editor/model.ts +63 -1
- package/src/editor/strings.ts +24 -0
- package/src/player/StoryPlayer.tsx +57 -5
- package/src/player/strings.ts +7 -0
package/README.md
CHANGED
|
@@ -15,8 +15,8 @@ writes them and presents them with this package's player.
|
|
|
15
15
|
Everything happens in the browser: an opened story is never uploaded.
|
|
16
16
|
- **Change a story, or make one:** the Story Editor, at
|
|
17
17
|
**https://dsblank.github.io/gramps-connect-stories/edit.html** (or
|
|
18
|
-
**Edit** on an open story in the viewer). Titles, dates, text
|
|
19
|
-
order of slides; it saves a new `.story.zip`, back into the opened file
|
|
18
|
+
**Edit** on an open story in the viewer). Titles, dates, text, photos
|
|
19
|
+
and the order of slides; it saves a new `.story.zip`, back into the opened file
|
|
20
20
|
in Chrome and Edge. Also entirely in the browser.
|
|
21
21
|
- **Put a story on a web page:** the [`<gramps-connect-story>`](#on-any-web-page-gramps-connect-story)
|
|
22
22
|
element.
|
|
@@ -141,11 +141,13 @@ needed only by the player. With TypeScript 6 or later, add `"geojson"` to
|
|
|
141
141
|
|
|
142
142
|
## The editor: `@gramps-connect/story/editor`
|
|
143
143
|
|
|
144
|
-
A React component that edits a story
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
and
|
|
148
|
-
|
|
144
|
+
A React component that edits a story: the slides on the left (drag to
|
|
145
|
+
reorder), the selected slide's title, date, text and photos in the middle,
|
|
146
|
+
and the player on the right showing it as it changes, with undo and redo
|
|
147
|
+
and the format's validation as you go. Photos are added by picking,
|
|
148
|
+
dropping or pasting, prepared in the browser (`optimizeImage`: resized,
|
|
149
|
+
metadata left behind) and stored once however many slides show them. It
|
|
150
|
+
edits the story; opening and saving files is up to you (the Story Editor page uses the File
|
|
149
151
|
System Access API where there is one, a download where not).
|
|
150
152
|
|
|
151
153
|
```tsx
|
|
@@ -154,13 +156,13 @@ import { MantineProvider } from "@mantine/core";
|
|
|
154
156
|
import { StoryEditor, pruneMedia } from "@gramps-connect/story/editor";
|
|
155
157
|
import { writeStoryZip } from "@gramps-connect/story";
|
|
156
158
|
|
|
157
|
-
let latest = story.doc;
|
|
159
|
+
let latest = { doc: story.doc, files: story.files };
|
|
158
160
|
<MantineProvider>
|
|
159
|
-
<StoryEditor initialStory={story.doc}
|
|
161
|
+
<StoryEditor initialStory={story.doc} initialFiles={story.files} onChange={(doc, files) => (latest = { doc, files })} />
|
|
160
162
|
</MantineProvider>
|
|
161
163
|
|
|
162
164
|
// Saving: leave out media nothing uses any more, then zip.
|
|
163
|
-
const saved = pruneMedia(latest,
|
|
165
|
+
const saved = pruneMedia(latest.doc, latest.files);
|
|
164
166
|
const zip = await writeStoryZip(saved.doc, saved.files);
|
|
165
167
|
```
|
|
166
168
|
|
|
@@ -175,9 +177,9 @@ they are, so opening and saving a story never loses anything.
|
|
|
175
177
|
The editor is built with [Mantine](https://mantine.dev) 8 (optional peer
|
|
176
178
|
dependencies `@mantine/core` and `@mantine/hooks`, needed only by the
|
|
177
179
|
editor): wrap it in a `MantineProvider` and load Mantine's stylesheet. The
|
|
178
|
-
pieces it's made of (`SlideList`, `StoryTextField`, `DateField
|
|
179
|
-
editing functions (`addSlide`, `moveSlide`,
|
|
180
|
-
...) are exported too.
|
|
180
|
+
pieces it's made of (`SlideList`, `StoryTextField`, `DateField`,
|
|
181
|
+
`PhotosField`) and its editing functions (`addSlide`, `moveSlide`,
|
|
182
|
+
`updateSlide`, `addImage`, undo history, ...) are exported too.
|
|
181
183
|
|
|
182
184
|
## Writing stories from Python: `python/gramps_connect_story.py`
|
|
183
185
|
|