@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 +21 -0
- package/README.md +66 -0
- package/dist/index.cjs +719 -0
- package/dist/index.d.cts +149 -0
- package/dist/index.d.ts +149 -0
- package/dist/index.js +712 -0
- package/package.json +51 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { AddConnectorInput, SourceHandle, AddEmptySlideFromLayoutInput, AddTextBoxInput, EditableParagraphProperty, EditableTextRunProperty, PptxSourceModel, EditableTextRunProperties, EditableParagraphProperties, Emu, EditableShapeFill, EditableShapeOutline, MoveSlideInput } from '@pptx-glimpse/document';
|
|
2
|
+
|
|
3
|
+
interface ReplaceTextRunPlainTextCommand {
|
|
4
|
+
readonly kind: "replaceTextRunPlainText";
|
|
5
|
+
readonly handle: SourceHandle;
|
|
6
|
+
readonly text: string;
|
|
7
|
+
}
|
|
8
|
+
interface ReplaceParagraphPlainTextCommand {
|
|
9
|
+
readonly kind: "replaceParagraphPlainText";
|
|
10
|
+
readonly handle: SourceHandle;
|
|
11
|
+
readonly text: string;
|
|
12
|
+
}
|
|
13
|
+
interface SetTextRunPropertiesCommand {
|
|
14
|
+
readonly kind: "setTextRunProperties";
|
|
15
|
+
readonly handle: SourceHandle;
|
|
16
|
+
readonly properties: EditableTextRunProperties;
|
|
17
|
+
}
|
|
18
|
+
interface ClearTextRunPropertiesCommand {
|
|
19
|
+
readonly kind: "clearTextRunProperties";
|
|
20
|
+
readonly handle: SourceHandle;
|
|
21
|
+
readonly properties: readonly EditableTextRunProperty[];
|
|
22
|
+
}
|
|
23
|
+
interface SetParagraphPropertiesCommand {
|
|
24
|
+
readonly kind: "setParagraphProperties";
|
|
25
|
+
readonly handle: SourceHandle;
|
|
26
|
+
readonly properties: EditableParagraphProperties;
|
|
27
|
+
}
|
|
28
|
+
interface ClearParagraphPropertiesCommand {
|
|
29
|
+
readonly kind: "clearParagraphProperties";
|
|
30
|
+
readonly handle: SourceHandle;
|
|
31
|
+
readonly properties: readonly EditableParagraphProperty[];
|
|
32
|
+
}
|
|
33
|
+
interface MoveShapeCommand {
|
|
34
|
+
readonly kind: "moveShape";
|
|
35
|
+
readonly handle: SourceHandle;
|
|
36
|
+
readonly offsetX: Emu;
|
|
37
|
+
readonly offsetY: Emu;
|
|
38
|
+
}
|
|
39
|
+
interface ResizeShapeCommand {
|
|
40
|
+
readonly kind: "resizeShape";
|
|
41
|
+
readonly handle: SourceHandle;
|
|
42
|
+
readonly width: Emu;
|
|
43
|
+
readonly height: Emu;
|
|
44
|
+
}
|
|
45
|
+
interface SetShapeTransformCommand {
|
|
46
|
+
readonly kind: "setShapeTransform";
|
|
47
|
+
readonly handle: SourceHandle;
|
|
48
|
+
readonly offsetX: Emu;
|
|
49
|
+
readonly offsetY: Emu;
|
|
50
|
+
readonly width: Emu;
|
|
51
|
+
readonly height: Emu;
|
|
52
|
+
}
|
|
53
|
+
interface SetShapeFillCommand {
|
|
54
|
+
readonly kind: "setShapeFill";
|
|
55
|
+
readonly handle: SourceHandle;
|
|
56
|
+
readonly fill: EditableShapeFill;
|
|
57
|
+
}
|
|
58
|
+
interface SetShapeOutlineCommand {
|
|
59
|
+
readonly kind: "setShapeOutline";
|
|
60
|
+
readonly handle: SourceHandle;
|
|
61
|
+
readonly outline: EditableShapeOutline;
|
|
62
|
+
}
|
|
63
|
+
interface AddTextBoxCommand extends AddTextBoxInput {
|
|
64
|
+
readonly kind: "addTextBox";
|
|
65
|
+
readonly slideHandle: SourceHandle;
|
|
66
|
+
}
|
|
67
|
+
interface AddConnectorCommand extends AddConnectorInput {
|
|
68
|
+
readonly kind: "addConnector";
|
|
69
|
+
readonly slideHandle: SourceHandle;
|
|
70
|
+
}
|
|
71
|
+
interface DeleteShapeCommand {
|
|
72
|
+
readonly kind: "deleteShape";
|
|
73
|
+
readonly handle: SourceHandle;
|
|
74
|
+
}
|
|
75
|
+
interface ReplaceImageCommand {
|
|
76
|
+
readonly kind: "replaceImage";
|
|
77
|
+
readonly handle: SourceHandle;
|
|
78
|
+
readonly bytes: Uint8Array;
|
|
79
|
+
}
|
|
80
|
+
interface AddEmptySlideFromLayoutCommand extends AddEmptySlideFromLayoutInput {
|
|
81
|
+
readonly kind: "addEmptySlideFromLayout";
|
|
82
|
+
}
|
|
83
|
+
interface DuplicateSlideCommand {
|
|
84
|
+
readonly kind: "duplicateSlide";
|
|
85
|
+
readonly handle: SourceHandle;
|
|
86
|
+
}
|
|
87
|
+
interface MoveSlideCommand extends MoveSlideInput {
|
|
88
|
+
readonly kind: "moveSlide";
|
|
89
|
+
readonly handle: SourceHandle;
|
|
90
|
+
}
|
|
91
|
+
interface DeleteSlideCommand {
|
|
92
|
+
readonly kind: "deleteSlide";
|
|
93
|
+
readonly handle: SourceHandle;
|
|
94
|
+
}
|
|
95
|
+
type EditorCommand = ReplaceTextRunPlainTextCommand | ReplaceParagraphPlainTextCommand | SetTextRunPropertiesCommand | ClearTextRunPropertiesCommand | SetParagraphPropertiesCommand | ClearParagraphPropertiesCommand | MoveShapeCommand | ResizeShapeCommand | SetShapeTransformCommand | SetShapeFillCommand | SetShapeOutlineCommand | AddTextBoxCommand | AddConnectorCommand | DeleteShapeCommand | ReplaceImageCommand | AddEmptySlideFromLayoutCommand | DuplicateSlideCommand | MoveSlideCommand | DeleteSlideCommand;
|
|
96
|
+
type EditorApplyCommandResult = {
|
|
97
|
+
readonly ok: true;
|
|
98
|
+
readonly document: PptxSourceModel;
|
|
99
|
+
readonly warnings?: readonly EditorCommandWarning[];
|
|
100
|
+
} | {
|
|
101
|
+
readonly ok: false;
|
|
102
|
+
readonly code: "invalid-command";
|
|
103
|
+
readonly message: string;
|
|
104
|
+
readonly cause?: unknown;
|
|
105
|
+
};
|
|
106
|
+
interface EditorCommandWarning {
|
|
107
|
+
readonly code: "shared-media-part";
|
|
108
|
+
readonly message: string;
|
|
109
|
+
readonly mediaPartPath: string;
|
|
110
|
+
readonly referenceCount: number;
|
|
111
|
+
}
|
|
112
|
+
type EditorHistoryResult = {
|
|
113
|
+
readonly ok: true;
|
|
114
|
+
readonly document: PptxSourceModel;
|
|
115
|
+
} | {
|
|
116
|
+
readonly ok: false;
|
|
117
|
+
readonly reason: "empty-undo-stack" | "empty-redo-stack";
|
|
118
|
+
};
|
|
119
|
+
interface EditorSelection {
|
|
120
|
+
readonly shapeHandle: SourceHandle;
|
|
121
|
+
}
|
|
122
|
+
type EditorSelectShapeResult = {
|
|
123
|
+
readonly ok: true;
|
|
124
|
+
readonly selection: EditorSelection;
|
|
125
|
+
} | {
|
|
126
|
+
readonly ok: false;
|
|
127
|
+
readonly code: "invalid-selection";
|
|
128
|
+
readonly message: string;
|
|
129
|
+
};
|
|
130
|
+
declare class EditorSession {
|
|
131
|
+
#private;
|
|
132
|
+
constructor(document: PptxSourceModel);
|
|
133
|
+
get document(): PptxSourceModel;
|
|
134
|
+
get selection(): EditorSelection | undefined;
|
|
135
|
+
get canUndo(): boolean;
|
|
136
|
+
get canRedo(): boolean;
|
|
137
|
+
get undoDepth(): number;
|
|
138
|
+
get redoDepth(): number;
|
|
139
|
+
selectShape(handle: SourceHandle): EditorSelectShapeResult;
|
|
140
|
+
deselectShape(): void;
|
|
141
|
+
apply(command: EditorCommand): EditorApplyCommandResult;
|
|
142
|
+
applyAll(commands: readonly EditorCommand[]): EditorApplyCommandResult;
|
|
143
|
+
undo(): EditorHistoryResult;
|
|
144
|
+
redo(): EditorHistoryResult;
|
|
145
|
+
private reconcileSelectionAfterDocumentChange;
|
|
146
|
+
}
|
|
147
|
+
declare function createEditorSession(document: PptxSourceModel): EditorSession;
|
|
148
|
+
|
|
149
|
+
export { type AddConnectorCommand, type AddEmptySlideFromLayoutCommand, type AddTextBoxCommand, type ClearParagraphPropertiesCommand, type ClearTextRunPropertiesCommand, type DeleteShapeCommand, type DeleteSlideCommand, type DuplicateSlideCommand, type EditorApplyCommandResult, type EditorCommand, type EditorCommandWarning, type EditorHistoryResult, type EditorSelectShapeResult, type EditorSelection, EditorSession, type MoveShapeCommand, type MoveSlideCommand, type ReplaceImageCommand, type ReplaceParagraphPlainTextCommand, type ReplaceTextRunPlainTextCommand, type ResizeShapeCommand, type SetParagraphPropertiesCommand, type SetShapeFillCommand, type SetShapeOutlineCommand, type SetShapeTransformCommand, type SetTextRunPropertiesCommand, createEditorSession };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { AddConnectorInput, SourceHandle, AddEmptySlideFromLayoutInput, AddTextBoxInput, EditableParagraphProperty, EditableTextRunProperty, PptxSourceModel, EditableTextRunProperties, EditableParagraphProperties, Emu, EditableShapeFill, EditableShapeOutline, MoveSlideInput } from '@pptx-glimpse/document';
|
|
2
|
+
|
|
3
|
+
interface ReplaceTextRunPlainTextCommand {
|
|
4
|
+
readonly kind: "replaceTextRunPlainText";
|
|
5
|
+
readonly handle: SourceHandle;
|
|
6
|
+
readonly text: string;
|
|
7
|
+
}
|
|
8
|
+
interface ReplaceParagraphPlainTextCommand {
|
|
9
|
+
readonly kind: "replaceParagraphPlainText";
|
|
10
|
+
readonly handle: SourceHandle;
|
|
11
|
+
readonly text: string;
|
|
12
|
+
}
|
|
13
|
+
interface SetTextRunPropertiesCommand {
|
|
14
|
+
readonly kind: "setTextRunProperties";
|
|
15
|
+
readonly handle: SourceHandle;
|
|
16
|
+
readonly properties: EditableTextRunProperties;
|
|
17
|
+
}
|
|
18
|
+
interface ClearTextRunPropertiesCommand {
|
|
19
|
+
readonly kind: "clearTextRunProperties";
|
|
20
|
+
readonly handle: SourceHandle;
|
|
21
|
+
readonly properties: readonly EditableTextRunProperty[];
|
|
22
|
+
}
|
|
23
|
+
interface SetParagraphPropertiesCommand {
|
|
24
|
+
readonly kind: "setParagraphProperties";
|
|
25
|
+
readonly handle: SourceHandle;
|
|
26
|
+
readonly properties: EditableParagraphProperties;
|
|
27
|
+
}
|
|
28
|
+
interface ClearParagraphPropertiesCommand {
|
|
29
|
+
readonly kind: "clearParagraphProperties";
|
|
30
|
+
readonly handle: SourceHandle;
|
|
31
|
+
readonly properties: readonly EditableParagraphProperty[];
|
|
32
|
+
}
|
|
33
|
+
interface MoveShapeCommand {
|
|
34
|
+
readonly kind: "moveShape";
|
|
35
|
+
readonly handle: SourceHandle;
|
|
36
|
+
readonly offsetX: Emu;
|
|
37
|
+
readonly offsetY: Emu;
|
|
38
|
+
}
|
|
39
|
+
interface ResizeShapeCommand {
|
|
40
|
+
readonly kind: "resizeShape";
|
|
41
|
+
readonly handle: SourceHandle;
|
|
42
|
+
readonly width: Emu;
|
|
43
|
+
readonly height: Emu;
|
|
44
|
+
}
|
|
45
|
+
interface SetShapeTransformCommand {
|
|
46
|
+
readonly kind: "setShapeTransform";
|
|
47
|
+
readonly handle: SourceHandle;
|
|
48
|
+
readonly offsetX: Emu;
|
|
49
|
+
readonly offsetY: Emu;
|
|
50
|
+
readonly width: Emu;
|
|
51
|
+
readonly height: Emu;
|
|
52
|
+
}
|
|
53
|
+
interface SetShapeFillCommand {
|
|
54
|
+
readonly kind: "setShapeFill";
|
|
55
|
+
readonly handle: SourceHandle;
|
|
56
|
+
readonly fill: EditableShapeFill;
|
|
57
|
+
}
|
|
58
|
+
interface SetShapeOutlineCommand {
|
|
59
|
+
readonly kind: "setShapeOutline";
|
|
60
|
+
readonly handle: SourceHandle;
|
|
61
|
+
readonly outline: EditableShapeOutline;
|
|
62
|
+
}
|
|
63
|
+
interface AddTextBoxCommand extends AddTextBoxInput {
|
|
64
|
+
readonly kind: "addTextBox";
|
|
65
|
+
readonly slideHandle: SourceHandle;
|
|
66
|
+
}
|
|
67
|
+
interface AddConnectorCommand extends AddConnectorInput {
|
|
68
|
+
readonly kind: "addConnector";
|
|
69
|
+
readonly slideHandle: SourceHandle;
|
|
70
|
+
}
|
|
71
|
+
interface DeleteShapeCommand {
|
|
72
|
+
readonly kind: "deleteShape";
|
|
73
|
+
readonly handle: SourceHandle;
|
|
74
|
+
}
|
|
75
|
+
interface ReplaceImageCommand {
|
|
76
|
+
readonly kind: "replaceImage";
|
|
77
|
+
readonly handle: SourceHandle;
|
|
78
|
+
readonly bytes: Uint8Array;
|
|
79
|
+
}
|
|
80
|
+
interface AddEmptySlideFromLayoutCommand extends AddEmptySlideFromLayoutInput {
|
|
81
|
+
readonly kind: "addEmptySlideFromLayout";
|
|
82
|
+
}
|
|
83
|
+
interface DuplicateSlideCommand {
|
|
84
|
+
readonly kind: "duplicateSlide";
|
|
85
|
+
readonly handle: SourceHandle;
|
|
86
|
+
}
|
|
87
|
+
interface MoveSlideCommand extends MoveSlideInput {
|
|
88
|
+
readonly kind: "moveSlide";
|
|
89
|
+
readonly handle: SourceHandle;
|
|
90
|
+
}
|
|
91
|
+
interface DeleteSlideCommand {
|
|
92
|
+
readonly kind: "deleteSlide";
|
|
93
|
+
readonly handle: SourceHandle;
|
|
94
|
+
}
|
|
95
|
+
type EditorCommand = ReplaceTextRunPlainTextCommand | ReplaceParagraphPlainTextCommand | SetTextRunPropertiesCommand | ClearTextRunPropertiesCommand | SetParagraphPropertiesCommand | ClearParagraphPropertiesCommand | MoveShapeCommand | ResizeShapeCommand | SetShapeTransformCommand | SetShapeFillCommand | SetShapeOutlineCommand | AddTextBoxCommand | AddConnectorCommand | DeleteShapeCommand | ReplaceImageCommand | AddEmptySlideFromLayoutCommand | DuplicateSlideCommand | MoveSlideCommand | DeleteSlideCommand;
|
|
96
|
+
type EditorApplyCommandResult = {
|
|
97
|
+
readonly ok: true;
|
|
98
|
+
readonly document: PptxSourceModel;
|
|
99
|
+
readonly warnings?: readonly EditorCommandWarning[];
|
|
100
|
+
} | {
|
|
101
|
+
readonly ok: false;
|
|
102
|
+
readonly code: "invalid-command";
|
|
103
|
+
readonly message: string;
|
|
104
|
+
readonly cause?: unknown;
|
|
105
|
+
};
|
|
106
|
+
interface EditorCommandWarning {
|
|
107
|
+
readonly code: "shared-media-part";
|
|
108
|
+
readonly message: string;
|
|
109
|
+
readonly mediaPartPath: string;
|
|
110
|
+
readonly referenceCount: number;
|
|
111
|
+
}
|
|
112
|
+
type EditorHistoryResult = {
|
|
113
|
+
readonly ok: true;
|
|
114
|
+
readonly document: PptxSourceModel;
|
|
115
|
+
} | {
|
|
116
|
+
readonly ok: false;
|
|
117
|
+
readonly reason: "empty-undo-stack" | "empty-redo-stack";
|
|
118
|
+
};
|
|
119
|
+
interface EditorSelection {
|
|
120
|
+
readonly shapeHandle: SourceHandle;
|
|
121
|
+
}
|
|
122
|
+
type EditorSelectShapeResult = {
|
|
123
|
+
readonly ok: true;
|
|
124
|
+
readonly selection: EditorSelection;
|
|
125
|
+
} | {
|
|
126
|
+
readonly ok: false;
|
|
127
|
+
readonly code: "invalid-selection";
|
|
128
|
+
readonly message: string;
|
|
129
|
+
};
|
|
130
|
+
declare class EditorSession {
|
|
131
|
+
#private;
|
|
132
|
+
constructor(document: PptxSourceModel);
|
|
133
|
+
get document(): PptxSourceModel;
|
|
134
|
+
get selection(): EditorSelection | undefined;
|
|
135
|
+
get canUndo(): boolean;
|
|
136
|
+
get canRedo(): boolean;
|
|
137
|
+
get undoDepth(): number;
|
|
138
|
+
get redoDepth(): number;
|
|
139
|
+
selectShape(handle: SourceHandle): EditorSelectShapeResult;
|
|
140
|
+
deselectShape(): void;
|
|
141
|
+
apply(command: EditorCommand): EditorApplyCommandResult;
|
|
142
|
+
applyAll(commands: readonly EditorCommand[]): EditorApplyCommandResult;
|
|
143
|
+
undo(): EditorHistoryResult;
|
|
144
|
+
redo(): EditorHistoryResult;
|
|
145
|
+
private reconcileSelectionAfterDocumentChange;
|
|
146
|
+
}
|
|
147
|
+
declare function createEditorSession(document: PptxSourceModel): EditorSession;
|
|
148
|
+
|
|
149
|
+
export { type AddConnectorCommand, type AddEmptySlideFromLayoutCommand, type AddTextBoxCommand, type ClearParagraphPropertiesCommand, type ClearTextRunPropertiesCommand, type DeleteShapeCommand, type DeleteSlideCommand, type DuplicateSlideCommand, type EditorApplyCommandResult, type EditorCommand, type EditorCommandWarning, type EditorHistoryResult, type EditorSelectShapeResult, type EditorSelection, EditorSession, type MoveShapeCommand, type MoveSlideCommand, type ReplaceImageCommand, type ReplaceParagraphPlainTextCommand, type ReplaceTextRunPlainTextCommand, type ResizeShapeCommand, type SetParagraphPropertiesCommand, type SetShapeFillCommand, type SetShapeOutlineCommand, type SetShapeTransformCommand, type SetTextRunPropertiesCommand, createEditorSession };
|