@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 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 and the
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 document: the slides on the left
145
- (drag to reorder), the selected slide's title, date and text in the
146
- middle, and the player on the right showing it as it changes, with undo
147
- and redo and the format's validation as you go. It edits the document;
148
- opening and saving files is up to you (the Story Editor page uses the File
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} files={story.files} resolveMedia={resolveMedia} onChange={(doc) => (latest = 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, story.files);
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`) and its
179
- editing functions (`addSlide`, `moveSlide`, `updateSlide`, undo history,
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