@pptx-glimpse/editor 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 hirokisakabe
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,66 @@
1
+ # @pptx-glimpse/editor
2
+
3
+ UI framework に依存しない `PptxSourceModel` の編集層です。`@pptx-glimpse/document`
4
+ で PPTX を読み書きし、この package で command の検証・適用、selection、undo / redo、
5
+ warning の取得を行います。
6
+
7
+ `@pptx-glimpse/editor` は 0.x です。API は独立して利用できますが、command と結果型は
8
+ 1.0 までに変更される可能性があります。
9
+
10
+ ## インストール
11
+
12
+ ```sh
13
+ npm install @pptx-glimpse/document @pptx-glimpse/editor
14
+ ```
15
+
16
+ ## 最小例
17
+
18
+ ```ts
19
+ import { readPptx, writePptx } from "@pptx-glimpse/document";
20
+ import { createEditorSession } from "@pptx-glimpse/editor";
21
+
22
+ const source = readPptx(input);
23
+ const run = source.slides[0]?.shapes
24
+ .find((shape) => shape.kind === "shape")
25
+ ?.textBody?.paragraphs[0]?.runs[0];
26
+
27
+ if (run?.handle === undefined) {
28
+ throw new Error("editable text run not found");
29
+ }
30
+
31
+ const session = createEditorSession(source);
32
+ const result = session.apply({
33
+ kind: "replaceTextRunPlainText",
34
+ handle: run.handle,
35
+ text: "Edited",
36
+ });
37
+ if (!result.ok) {
38
+ throw new Error(result.message);
39
+ }
40
+
41
+ const output = writePptx(session.document);
42
+ ```
43
+
44
+ 複数 command は `session.applyAll(commands)` で一つの undo 履歴として適用できます。
45
+ `selectShape()` / `deselectShape()`、`undo()` / `redo()`、`canUndo` / `canRedo` も
46
+ session から利用できます。
47
+
48
+ ## 対応 command
49
+
50
+ - text: `replaceTextRunPlainText`, `replaceParagraphPlainText`,
51
+ `setTextRunProperties`, `clearTextRunProperties`, `setParagraphProperties`,
52
+ `clearParagraphProperties`
53
+ - shape: `moveShape`, `resizeShape`, `setShapeTransform`, `setShapeFill`,
54
+ `setShapeOutline`, `addTextBox`, `addConnector`, `deleteShape`
55
+ - media: `replaceImage`
56
+ - slide: `addEmptySlideFromLayout`, `duplicateSlide`, `moveSlide`, `deleteSlide`
57
+
58
+ ## 既知の制約
59
+
60
+ - source handle がない要素や、document 層が安全に保持できない編集は
61
+ `invalid-command` として拒否されます。
62
+ - table、chart、SmartArt の新規編集 command はありません。
63
+ - `replaceImage` が共有 media part を更新する場合、参照する複数画像が同時に変わるため
64
+ `shared-media-part` warning を返します。
65
+ - DOM、React、ProseMirror、renderer は含みません。描画を伴う browser editor facade は
66
+ `pptx-glimpse` の browser entry を利用してください。