@gramps-connect/story 0.2.0 → 0.4.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 +25 -14
- package/dist/editor.js +851 -181
- 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/PlaceField.d.ts +21 -0
- package/dist/types/editor/PlaceMap.d.ts +12 -0
- package/dist/types/editor/StoryEditor.d.ts +21 -12
- package/dist/types/editor/index.d.ts +5 -2
- package/dist/types/editor/model.d.ts +42 -1
- package/dist/types/editor/placeSearch.d.ts +22 -0
- package/dist/types/editor/strings.d.ts +27 -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/PlaceField.tsx +160 -0
- package/src/editor/PlaceMap.tsx +88 -0
- package/src/editor/StoryEditor.tsx +143 -40
- package/src/editor/index.ts +8 -3
- package/src/editor/model.ts +100 -1
- package/src/editor/placeSearch.ts +61 -0
- package/src/editor/strings.ts +54 -0
- package/src/player/StoryPlayer.tsx +57 -5
- package/src/player/strings.ts +7 -0
package/README.md
CHANGED
|
@@ -15,9 +15,10 @@ 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
|
|
20
|
-
in Chrome and Edge. Also entirely in the browser
|
|
18
|
+
**Edit** on an open story in the viewer). Titles, dates, text, photos,
|
|
19
|
+
places and the order of slides; it saves a new `.story.zip`, back into
|
|
20
|
+
the opened file in Chrome and Edge. Also entirely in the browser, except
|
|
21
|
+
a place search on Wikidata when you ask for one.
|
|
21
22
|
- **Put a story on a web page:** the [`<gramps-connect-story>`](#on-any-web-page-gramps-connect-story)
|
|
22
23
|
element.
|
|
23
24
|
- **Format specification:** [`spec/1.0/README.md`](spec/1.0/README.md)
|
|
@@ -141,11 +142,13 @@ needed only by the player. With TypeScript 6 or later, add `"geojson"` to
|
|
|
141
142
|
|
|
142
143
|
## The editor: `@gramps-connect/story/editor`
|
|
143
144
|
|
|
144
|
-
A React component that edits a story
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
and
|
|
148
|
-
|
|
145
|
+
A React component that edits a story: the slides on the left (drag to
|
|
146
|
+
reorder), the selected slide's title, date, text, place and photos in the middle,
|
|
147
|
+
and the player on the right showing it as it changes, with undo and redo
|
|
148
|
+
and the format's validation as you go. Photos are added by picking,
|
|
149
|
+
dropping or pasting, prepared in the browser (`optimizeImage`: resized,
|
|
150
|
+
metadata left behind) and stored once however many slides show them. It
|
|
151
|
+
edits the story; opening and saving files is up to you (the Story Editor page uses the File
|
|
149
152
|
System Access API where there is one, a download where not).
|
|
150
153
|
|
|
151
154
|
```tsx
|
|
@@ -154,13 +157,13 @@ import { MantineProvider } from "@mantine/core";
|
|
|
154
157
|
import { StoryEditor, pruneMedia } from "@gramps-connect/story/editor";
|
|
155
158
|
import { writeStoryZip } from "@gramps-connect/story";
|
|
156
159
|
|
|
157
|
-
let latest = story.doc;
|
|
160
|
+
let latest = { doc: story.doc, files: story.files };
|
|
158
161
|
<MantineProvider>
|
|
159
|
-
<StoryEditor initialStory={story.doc}
|
|
162
|
+
<StoryEditor initialStory={story.doc} initialFiles={story.files} onChange={(doc, files) => (latest = { doc, files })} />
|
|
160
163
|
</MantineProvider>
|
|
161
164
|
|
|
162
165
|
// Saving: leave out media nothing uses any more, then zip.
|
|
163
|
-
const saved = pruneMedia(latest,
|
|
166
|
+
const saved = pruneMedia(latest.doc, latest.files);
|
|
164
167
|
const zip = await writeStoryZip(saved.doc, saved.files);
|
|
165
168
|
```
|
|
166
169
|
|
|
@@ -172,12 +175,20 @@ Gramps' own date parser, in all of Gramps' languages. Pass
|
|
|
172
175
|
`parseDateText` to use another. Fields the editor doesn't know are kept as
|
|
173
176
|
they are, so opening and saving a story never loses anything.
|
|
174
177
|
|
|
178
|
+
A place is a name and a point: click the map or drag the pin, type the
|
|
179
|
+
coordinates, or pick one of the story's other places to use the very same
|
|
180
|
+
one (its shape and map overlays too). **Find on Wikidata** looks the name
|
|
181
|
+
up and puts the pin there; it's the only thing the editor sends anywhere,
|
|
182
|
+
the name only, and only when clicked. Pass `placeSearch` to use another
|
|
183
|
+
service, or `placeSearch={null}` to leave it out. Shapes and overlays
|
|
184
|
+
aren't edited yet, only kept.
|
|
185
|
+
|
|
175
186
|
The editor is built with [Mantine](https://mantine.dev) 8 (optional peer
|
|
176
187
|
dependencies `@mantine/core` and `@mantine/hooks`, needed only by the
|
|
177
188
|
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.
|
|
189
|
+
pieces it's made of (`SlideList`, `StoryTextField`, `DateField`,
|
|
190
|
+
`PlaceField`, `PhotosField`) and its editing functions (`addSlide`, `moveSlide`,
|
|
191
|
+
`updateSlide`, `addImage`, undo history, ...) are exported too.
|
|
181
192
|
|
|
182
193
|
## Writing stories from Python: `python/gramps_connect_story.py`
|
|
183
194
|
|