@textcortex/slidewise 1.0.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/LICENSE +21 -0
- package/README.md +112 -0
- package/dist/__vite-browser-external-DYxpcVy9.js +5 -0
- package/dist/__vite-browser-external-DYxpcVy9.js.map +1 -0
- package/dist/file.svg +1 -0
- package/dist/globe.svg +1 -0
- package/dist/index.mjs +16697 -0
- package/dist/index.mjs.map +1 -0
- package/dist/slidewise.css +1 -0
- package/dist/types/SlidewiseEditor.d.ts +47 -0
- package/dist/types/SlidewiseFileEditor.d.ts +54 -0
- package/dist/types/components/editor/BottomToolbar.d.ts +1 -0
- package/dist/types/components/editor/Canvas.d.ts +1 -0
- package/dist/types/components/editor/Editor.d.ts +8 -0
- package/dist/types/components/editor/ElementView.d.ts +6 -0
- package/dist/types/components/editor/FloatingToolbar.d.ts +6 -0
- package/dist/types/components/editor/GridView.d.ts +1 -0
- package/dist/types/components/editor/PlayMode.d.ts +1 -0
- package/dist/types/components/editor/SelectionFrame.d.ts +8 -0
- package/dist/types/components/editor/SlideRail.d.ts +1 -0
- package/dist/types/components/editor/SlideView.d.ts +5 -0
- package/dist/types/components/editor/TopBar.d.ts +7 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/lib/StoreProvider.d.ts +8 -0
- package/dist/types/lib/fonts.d.ts +9 -0
- package/dist/types/lib/pptx/deckToPptx.d.ts +9 -0
- package/dist/types/lib/pptx/index.d.ts +3 -0
- package/dist/types/lib/pptx/pptxToDeck.d.ts +18 -0
- package/dist/types/lib/pptx/types.d.ts +15 -0
- package/dist/types/lib/pptx/units.d.ts +25 -0
- package/dist/types/lib/schema/migrate.d.ts +25 -0
- package/dist/types/lib/seed.d.ts +2 -0
- package/dist/types/lib/store.d.ts +55 -0
- package/dist/types/lib/types.d.ts +141 -0
- package/dist/window.svg +1 -0
- package/package.json +86 -0
- package/src/App.tsx +261 -0
- package/src/SlidewiseEditor.css +146 -0
- package/src/SlidewiseEditor.tsx +214 -0
- package/src/SlidewiseFileEditor.tsx +242 -0
- package/src/components/editor/BottomToolbar.tsx +216 -0
- package/src/components/editor/Canvas.tsx +467 -0
- package/src/components/editor/Editor.tsx +53 -0
- package/src/components/editor/ElementView.tsx +588 -0
- package/src/components/editor/FloatingToolbar.tsx +729 -0
- package/src/components/editor/GridView.tsx +232 -0
- package/src/components/editor/PlayMode.tsx +260 -0
- package/src/components/editor/SelectionFrame.tsx +241 -0
- package/src/components/editor/SlideRail.tsx +285 -0
- package/src/components/editor/SlideView.tsx +55 -0
- package/src/components/editor/TopBar.tsx +240 -0
- package/src/fonts.css +2 -0
- package/src/index.css +13 -0
- package/src/index.ts +36 -0
- package/src/lib/StoreProvider.tsx +43 -0
- package/src/lib/__tests__/css-scope.test.ts +133 -0
- package/src/lib/fonts.ts +104 -0
- package/src/lib/pptx/__tests__/roundtrip.test.ts +240 -0
- package/src/lib/pptx/deckToPptx.ts +300 -0
- package/src/lib/pptx/index.ts +3 -0
- package/src/lib/pptx/pptxToDeck.ts +1515 -0
- package/src/lib/pptx/types.ts +17 -0
- package/src/lib/pptx/units.ts +32 -0
- package/src/lib/schema/__tests__/migrate.test.ts +70 -0
- package/src/lib/schema/migrate.ts +102 -0
- package/src/lib/seed.ts +777 -0
- package/src/lib/store.ts +384 -0
- package/src/lib/types.ts +185 -0
- package/src/main.tsx +10 -0
- package/src/vite-env.d.ts +3 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TextCortex AI
|
|
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,112 @@
|
|
|
1
|
+
# Slidewise
|
|
2
|
+
|
|
3
|
+
Embeddable React PPTX editor. PPTX import + canvas editor + PPTX export, in
|
|
4
|
+
one component.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
pnpm add @textcortex/slidewise
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Peer dependencies: `react >=19`, `react-dom >=19`.
|
|
11
|
+
|
|
12
|
+
## Quick start
|
|
13
|
+
|
|
14
|
+
`SlidewiseFileEditor` wraps the editor with PPTX load/save plumbing — give it
|
|
15
|
+
async `loadBlob` and `saveBlob` callbacks and it handles parsing, dirty
|
|
16
|
+
tracking, and serialisation.
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import {
|
|
20
|
+
SlidewiseFileEditor,
|
|
21
|
+
type SlidewiseFileEditorApi,
|
|
22
|
+
} from "@textcortex/slidewise";
|
|
23
|
+
import "@textcortex/slidewise/style.css";
|
|
24
|
+
import { useRef } from "react";
|
|
25
|
+
|
|
26
|
+
export function PresentationsRoute({ fileId }: { fileId: string }) {
|
|
27
|
+
const apiRef = useRef<SlidewiseFileEditorApi | null>(null);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<SlidewiseFileEditor
|
|
31
|
+
onEditorApiChange={(api) => (apiRef.current = api)}
|
|
32
|
+
loadBlob={async () => {
|
|
33
|
+
const res = await fetch(`/api/files/${fileId}`);
|
|
34
|
+
return res.blob();
|
|
35
|
+
}}
|
|
36
|
+
saveBlob={async (pptx) => {
|
|
37
|
+
await fetch(`/api/files/${fileId}`, { method: "PUT", body: pptx });
|
|
38
|
+
}}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The host owns transport and conflict detection; Slidewise owns parsing,
|
|
45
|
+
editing, and serialisation. Call `apiRef.current.save()` to trigger a save
|
|
46
|
+
from outside the editor's top bar; call `apiRef.current.isDirty()` to gate
|
|
47
|
+
"unsaved changes" UI.
|
|
48
|
+
|
|
49
|
+
## Lower-level entry point
|
|
50
|
+
|
|
51
|
+
If your host already has a `Deck` in memory (e.g. you're storing the JSON
|
|
52
|
+
shape in your own database rather than `.pptx` blobs), mount
|
|
53
|
+
`SlidewiseEditor` directly:
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { SlidewiseEditor, type Deck } from "@textcortex/slidewise";
|
|
57
|
+
import "@textcortex/slidewise/style.css";
|
|
58
|
+
|
|
59
|
+
<SlidewiseEditor
|
|
60
|
+
deck={deck}
|
|
61
|
+
onChange={(next) => setDeck(next)}
|
|
62
|
+
onSave={(next) => persist(next)}
|
|
63
|
+
/>;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Working with decks programmatically
|
|
67
|
+
|
|
68
|
+
Slidewise persists slides as a versioned JSON `Deck`. The schema is the
|
|
69
|
+
canonical contract — undo/redo, exports, AI features, and persistence all
|
|
70
|
+
key off it.
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import {
|
|
74
|
+
parsePptx,
|
|
75
|
+
serializeDeck,
|
|
76
|
+
migrate,
|
|
77
|
+
CURRENT_DECK_VERSION,
|
|
78
|
+
type Deck,
|
|
79
|
+
} from "@textcortex/slidewise";
|
|
80
|
+
|
|
81
|
+
const deck: Deck = await parsePptx(blob); // import
|
|
82
|
+
const pptx: Blob = await serializeDeck(deck); // export
|
|
83
|
+
const safe: Deck = migrate(unknownDeckJson); // normalise an external deck
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`migrate()` runs every external deck (PPTX import, JSON import, localStorage
|
|
87
|
+
hydration, host props) through the schema migration chain so the rest of the
|
|
88
|
+
editor only sees current-shape decks. It throws if the input was written by a
|
|
89
|
+
newer Slidewise than the host has installed — pin the version range you can
|
|
90
|
+
support.
|
|
91
|
+
|
|
92
|
+
## Releasing
|
|
93
|
+
|
|
94
|
+
Versioning and publishing run through
|
|
95
|
+
[changesets](https://github.com/changesets/changesets).
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pnpm changeset # describe the impact of your change
|
|
99
|
+
pnpm version-packages # bump versions + update CHANGELOG (CI usually does this)
|
|
100
|
+
pnpm release # build + publish (CI does this on merge)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
CI (`.github/workflows/release.yml`) opens a "Version Packages" PR whenever
|
|
104
|
+
there are pending changesets and publishes to npm when that PR merges.
|
|
105
|
+
|
|
106
|
+
## Repo layout
|
|
107
|
+
|
|
108
|
+
- `src/SlidewiseEditor.tsx` / `src/SlidewiseFileEditor.tsx` — public entry components
|
|
109
|
+
- `src/components/editor/` — top bar, slide rail, canvas, panels
|
|
110
|
+
- `src/lib/pptx/` — PPTX import (`pptxToDeck`) and export (`deckToPptx`)
|
|
111
|
+
- `src/lib/schema/` — `Deck` schema versioning + migrator
|
|
112
|
+
- `src/lib/types.ts` — `Deck` / `Slide` / `SlideElement` shapes (the contract)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"__vite-browser-external-DYxpcVy9.js","sources":["../__vite-browser-external"],"sourcesContent":["export default {}"],"names":["__viteBrowserExternal"],"mappings":"AAAA,MAAAA,IAAe,CAAA;"}
|
package/dist/file.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>
|
package/dist/globe.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
|