@web-ppt/edit-core 0.5.0-beta.1

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.
Files changed (179) hide show
  1. package/CHANGELOG.md +274 -0
  2. package/LICENSE +21 -0
  3. package/README.md +474 -0
  4. package/dist/animation-catalog.d.ts +21 -0
  5. package/dist/body-properties.d.ts +8 -0
  6. package/dist/body-property-schema.d.ts +3 -0
  7. package/dist/change-classification.d.ts +10 -0
  8. package/dist/clipboard-binary.d.ts +4 -0
  9. package/dist/clipboard-links.d.ts +11 -0
  10. package/dist/clipboard-source.d.ts +23 -0
  11. package/dist/clipboard.d.ts +4 -0
  12. package/dist/commands/add-image.d.ts +4 -0
  13. package/dist/commands/add-shape.d.ts +4 -0
  14. package/dist/commands/add-slide-identity.d.ts +8 -0
  15. package/dist/commands/add-slide-template.d.ts +9 -0
  16. package/dist/commands/add-slide.d.ts +3 -0
  17. package/dist/commands/add-table.d.ts +4 -0
  18. package/dist/commands/align-elements.d.ts +4 -0
  19. package/dist/commands/apply-format.d.ts +4 -0
  20. package/dist/commands/clipboard-types.d.ts +91 -0
  21. package/dist/commands/direct-format-patches.d.ts +8 -0
  22. package/dist/commands/dispatch.d.ts +7 -0
  23. package/dist/commands/duplicate-slide.d.ts +3 -0
  24. package/dist/commands/edit-text.d.ts +3 -0
  25. package/dist/commands/element-effects.d.ts +5 -0
  26. package/dist/commands/element-fill.d.ts +5 -0
  27. package/dist/commands/element-image-content.d.ts +17 -0
  28. package/dist/commands/element-interaction.d.ts +11 -0
  29. package/dist/commands/element-link.d.ts +5 -0
  30. package/dist/commands/element-name.d.ts +8 -0
  31. package/dist/commands/element-order.d.ts +7 -0
  32. package/dist/commands/element-stroke.d.ts +5 -0
  33. package/dist/commands/element-text.d.ts +6 -0
  34. package/dist/commands/element-transform.d.ts +5 -0
  35. package/dist/commands/element-tree.d.ts +8 -0
  36. package/dist/commands/fit-text-shape.d.ts +3 -0
  37. package/dist/commands/format-painter-types.d.ts +17 -0
  38. package/dist/commands/image-format.d.ts +7 -0
  39. package/dist/commands/image-resource.d.ts +4 -0
  40. package/dist/commands/insert-row.d.ts +3 -0
  41. package/dist/commands/insertion-rect.d.ts +9 -0
  42. package/dist/commands/paste-elements.d.ts +4 -0
  43. package/dist/commands/paste-resources.d.ts +18 -0
  44. package/dist/commands/patch.d.ts +6 -0
  45. package/dist/commands/remove-slide.d.ts +3 -0
  46. package/dist/commands/replace-image.d.ts +3 -0
  47. package/dist/commands/replace-text.d.ts +5 -0
  48. package/dist/commands/set-animations.d.ts +3 -0
  49. package/dist/commands/set-body-props.d.ts +3 -0
  50. package/dist/commands/set-crop.d.ts +3 -0
  51. package/dist/commands/set-effects.d.ts +3 -0
  52. package/dist/commands/set-fill.d.ts +3 -0
  53. package/dist/commands/set-flip.d.ts +4 -0
  54. package/dist/commands/set-link.d.ts +3 -0
  55. package/dist/commands/set-para-props.d.ts +3 -0
  56. package/dist/commands/set-run-props.d.ts +3 -0
  57. package/dist/commands/set-slide-properties.d.ts +7 -0
  58. package/dist/commands/set-stroke.d.ts +3 -0
  59. package/dist/commands/set-xfrm.d.ts +3 -0
  60. package/dist/commands/set-z.d.ts +5 -0
  61. package/dist/commands/slide-image.d.ts +4 -0
  62. package/dist/commands/slide-layout.d.ts +8 -0
  63. package/dist/commands/slide-notes.d.ts +8 -0
  64. package/dist/commands/slide-order.d.ts +7 -0
  65. package/dist/commands/slide-property-types.d.ts +135 -0
  66. package/dist/commands/slide-property.d.ts +20 -0
  67. package/dist/commands/slide-tree.d.ts +6 -0
  68. package/dist/commands/spid.d.ts +4 -0
  69. package/dist/commands/table-row.d.ts +5 -0
  70. package/dist/commands/text-target.d.ts +25 -0
  71. package/dist/commands/types.d.ts +509 -0
  72. package/dist/commands/xfrm.d.ts +8 -0
  73. package/dist/data-validation.d.ts +7 -0
  74. package/dist/document.d.ts +17 -0
  75. package/dist/dynamic-slide-fields.d.ts +6 -0
  76. package/dist/edit-core.js +5321 -0
  77. package/dist/editor.d.ts +38 -0
  78. package/dist/element-ancestry.d.ts +3 -0
  79. package/dist/element-name.d.ts +4 -0
  80. package/dist/element-order.d.ts +7 -0
  81. package/dist/field-text.d.ts +3 -0
  82. package/dist/fractional-index.d.ts +10 -0
  83. package/dist/history.d.ts +50 -0
  84. package/dist/hyperlink.d.ts +10 -0
  85. package/dist/image-content.d.ts +7 -0
  86. package/dist/image-resource-history.d.ts +6 -0
  87. package/dist/index-D4ZTaYOa.js +706 -0
  88. package/dist/index.d.ts +46 -0
  89. package/dist/insertion-DabLme_U.js +5471 -0
  90. package/dist/insertion-invariants.d.ts +5 -0
  91. package/dist/layout-assets.d.ts +10 -0
  92. package/dist/layout-projection.d.ts +24 -0
  93. package/dist/layout-text-rebase.d.ts +3 -0
  94. package/dist/model-invariants.d.ts +5 -0
  95. package/dist/notes-part.d.ts +2 -0
  96. package/dist/opc/bytes.d.ts +1 -0
  97. package/dist/opc/crc32.d.ts +1 -0
  98. package/dist/opc/index.d.ts +3 -0
  99. package/dist/opc/package-owner.d.ts +4 -0
  100. package/dist/opc/patch.d.ts +6 -0
  101. package/dist/opc/types.d.ts +12 -0
  102. package/dist/opc/zip.d.ts +28 -0
  103. package/dist/opc-owner-protocol.d.ts +5 -0
  104. package/dist/opc.js +5 -0
  105. package/dist/paragraph-properties.d.ts +4 -0
  106. package/dist/paragraph-property-schema.d.ts +4 -0
  107. package/dist/patch-DO8497wO.js +322 -0
  108. package/dist/projection.d.ts +19 -0
  109. package/dist/recovery-identity.d.ts +35 -0
  110. package/dist/recovery-types.d.ts +30 -0
  111. package/dist/recovery.d.ts +28 -0
  112. package/dist/run-links.d.ts +3 -0
  113. package/dist/run-properties.d.ts +4 -0
  114. package/dist/run-property-schema.d.ts +3 -0
  115. package/dist/save/animation.d.ts +6 -0
  116. package/dist/save/background-image.d.ts +8 -0
  117. package/dist/save/clipboard-parts.d.ts +11 -0
  118. package/dist/save/drawing-color.d.ts +2 -0
  119. package/dist/save/duplicate-slide-parts.d.ts +15 -0
  120. package/dist/save/effects.d.ts +6 -0
  121. package/dist/save/hyperlink.d.ts +18 -0
  122. package/dist/save/image-content.d.ts +4 -0
  123. package/dist/save/index.d.ts +5 -0
  124. package/dist/save/insertion.d.ts +14 -0
  125. package/dist/save/layout-fallback-source.d.ts +4 -0
  126. package/dist/save/layout-fallback.d.ts +7 -0
  127. package/dist/save/materialize.d.ts +5 -0
  128. package/dist/save/name.d.ts +5 -0
  129. package/dist/save/notes.d.ts +12 -0
  130. package/dist/save/order.d.ts +5 -0
  131. package/dist/save/remove-element.d.ts +4 -0
  132. package/dist/save/remove-slide-parts.d.ts +11 -0
  133. package/dist/save/shape-format.d.ts +14 -0
  134. package/dist/save/slide-parts.d.ts +11 -0
  135. package/dist/save/slide-properties.d.ts +4 -0
  136. package/dist/save/table.d.ts +7 -0
  137. package/dist/save/text-body.d.ts +4 -0
  138. package/dist/save/text.d.ts +6 -0
  139. package/dist/save/transition.d.ts +4 -0
  140. package/dist/save/xfrm.d.ts +22 -0
  141. package/dist/save/xml-element.d.ts +3 -0
  142. package/dist/save.js +1559 -0
  143. package/dist/selection-pane.d.ts +18 -0
  144. package/dist/selection.d.ts +11 -0
  145. package/dist/session-assets.d.ts +20 -0
  146. package/dist/shape-effects.d.ts +6 -0
  147. package/dist/shape-fill.d.ts +12 -0
  148. package/dist/shape-stroke.d.ts +9 -0
  149. package/dist/slide-animation.d.ts +15 -0
  150. package/dist/slide-background-source.d.ts +13 -0
  151. package/dist/slide-notes.d.ts +2 -0
  152. package/dist/slide-properties.d.ts +4 -0
  153. package/dist/slide-transition.d.ts +19 -0
  154. package/dist/space.d.ts +47 -0
  155. package/dist/table-cell.d.ts +10 -0
  156. package/dist/table-direct-markup.d.ts +3 -0
  157. package/dist/table-insertion-policy.d.ts +5 -0
  158. package/dist/table-row-append-validation.d.ts +3 -0
  159. package/dist/table-rows.d.ts +12 -0
  160. package/dist/text-model.d.ts +28 -0
  161. package/dist/text-override-projection.d.ts +8 -0
  162. package/dist/text-override-validation.d.ts +7 -0
  163. package/dist/text-position.d.ts +8 -0
  164. package/dist/text-search-types.d.ts +46 -0
  165. package/dist/text-search.d.ts +5 -0
  166. package/dist/transaction-validation.d.ts +5 -0
  167. package/dist/types.d.ts +519 -0
  168. package/dist/xml/index.d.ts +9 -0
  169. package/dist/xml/mutate.d.ts +7 -0
  170. package/dist/xml/namespace.d.ts +5 -0
  171. package/dist/xml/nodes.d.ts +22 -0
  172. package/dist/xml/order.d.ts +15 -0
  173. package/dist/xml/qname.d.ts +15 -0
  174. package/dist/xml/query.d.ts +10 -0
  175. package/dist/xml/state.d.ts +30 -0
  176. package/dist/xml/tree.d.ts +8 -0
  177. package/dist/xml/types.d.ts +46 -0
  178. package/dist/xml.js +19 -0
  179. package/package.json +67 -0
@@ -0,0 +1,25 @@
1
+ import type { TextBody } from '@web-ppt/core';
2
+ import type { EditDoc, ElementRecord, TableCellAddress, TableCellRowRef, TextOverride } from '../types';
3
+ import type { ElementTextPatch } from './types';
4
+ export interface TextTarget {
5
+ readonly id: string;
6
+ readonly cell?: TableCellAddress;
7
+ }
8
+ export interface TextTargetContext {
9
+ readonly record: ElementRecord;
10
+ readonly body: TextBody;
11
+ readonly before: TextOverride | undefined;
12
+ readonly patchTarget: TextPatchTarget;
13
+ readonly empty: boolean;
14
+ }
15
+ export interface TextPatchTarget {
16
+ readonly id: string;
17
+ readonly cell?: {
18
+ readonly row: TableCellRowRef;
19
+ readonly c: number;
20
+ };
21
+ }
22
+ export declare function textTargetContextForRecord(record: ElementRecord, target: TextTarget): TextTargetContext;
23
+ export declare function textTargetContext(doc: EditDoc, target: TextTarget): TextTargetContext;
24
+ export declare function setTextPatch(target: TextPatchTarget, value: TextOverride, origin: string): ElementTextPatch;
25
+ export declare function inverseTextPatch(target: TextPatchTarget, before: TextOverride | undefined, origin: string): ElementTextPatch;
@@ -0,0 +1,509 @@
1
+ import type { Effects, Fill, Stroke } from '@web-ppt/core';
2
+ import type { ElementId, ElementImageReplacement, ElementInsertionResource, ElementRecord, ImageCrop, LinkOverride, LinkTarget, ParagraphPropertyOverrides, ProjectionInvalidation, RunPropertyOverrides, SlideId, TextFragment, TextOverride, SlideRecord, TableCellAddress, TextBodyPropertyOverrides } from '../types';
3
+ import type { ElementClipboardPayload } from './clipboard-types';
4
+ import type { SetBackgroundCommand, SetBackgroundCropCommand, SetBackgroundImageCommand, SetHiddenCommand, SetAnimationsCommand, SetTransitionCommand, SetLayoutCommand, SetNotesCommand, SlideLayoutPatch, SlideNotesPatch, SlidePropertyPatch } from './slide-property-types';
5
+ import type { ApplyFormatCommand } from './format-painter-types';
6
+ import type { ReplaceTextCommand } from '../text-search-types';
7
+ export type { ClipboardElementRecord, ClipboardPortableLink, ClipboardRelationship, ClipboardResource, ClipboardTextLink, ClipboardXmlRoot, ElementClipboardPayload, ElementClipboardRecordMeta, } from './clipboard-types';
8
+ export type { SetBackgroundCommand, SetBackgroundCropCommand, SetBackgroundImageCommand, SetHiddenCommand, SetAnimationsCommand, SetTransitionCommand, SetLayoutCommand, SlideAnimationsPatch, SlideBackgroundImagePatch, SlideBackgroundPatch, SlideHiddenPatch, SlideTransitionPatch, SetNotesCommand, SlideLayoutPatch, SlideNotesPatch, SlidePropertyPatch, } from './slide-property-types';
9
+ export type { ApplyFormatCommand, FormatMaskField } from './format-painter-types';
10
+ export type { ReplaceTextCommand, ReplaceTextScope } from '../text-search-types';
11
+ export type NumericXfrmField = 'x' | 'y' | 'w' | 'h' | 'rot';
12
+ export type FlipField = 'flipH' | 'flipV';
13
+ export type XfrmField = NumericXfrmField | FlipField;
14
+ export interface XfrmValueByField {
15
+ x: number;
16
+ y: number;
17
+ w: number;
18
+ h: number;
19
+ rot: number;
20
+ flipH: boolean;
21
+ flipV: boolean;
22
+ }
23
+ export type ElementXfrmPath<F extends XfrmField = XfrmField> = readonly ['elements', ElementId, 'ovr', F];
24
+ export interface SetXfrmCommand {
25
+ readonly type: 'SetXfrm';
26
+ readonly id: ElementId;
27
+ readonly x?: number;
28
+ readonly y?: number;
29
+ readonly w?: number;
30
+ readonly h?: number;
31
+ readonly rot?: number;
32
+ }
33
+ export interface SetFlipCommand {
34
+ readonly type: 'SetFlip';
35
+ readonly id: ElementId;
36
+ readonly h?: boolean;
37
+ readonly v?: boolean;
38
+ }
39
+ export interface RemoveElementCommand {
40
+ readonly type: 'RemoveElement';
41
+ readonly id: ElementId;
42
+ }
43
+ export type ElementLayerTarget = 'front' | 'back' | 'forward' | 'backward';
44
+ export interface SetZCommand {
45
+ readonly type: 'SetZ';
46
+ readonly id: ElementId;
47
+ readonly to: ElementLayerTarget;
48
+ }
49
+ export interface SetNameCommand {
50
+ readonly type: 'SetName';
51
+ readonly id: ElementId;
52
+ /** null 删除本次会话的名称覆盖并恢复来源 cNvPr@name。 */
53
+ readonly name: string | null;
54
+ }
55
+ export interface SetLockedCommand {
56
+ readonly type: 'SetLocked';
57
+ readonly id: ElementId;
58
+ readonly locked: boolean;
59
+ }
60
+ export interface SetElementHiddenCommand {
61
+ readonly type: 'SetElementHidden';
62
+ readonly id: ElementId;
63
+ readonly hidden: boolean;
64
+ }
65
+ export type AlignEdge = 'left' | 'center' | 'right' | 'top' | 'middle' | 'bottom';
66
+ export interface AlignElementsCommand {
67
+ readonly type: 'AlignElements';
68
+ readonly ids: readonly ElementId[];
69
+ readonly edge: AlignEdge;
70
+ }
71
+ export interface PasteElementsCommand {
72
+ readonly type: 'PasteElements';
73
+ readonly payload: ElementClipboardPayload;
74
+ readonly at: {
75
+ readonly parentId: SlideId | ElementId;
76
+ readonly x: number;
77
+ readonly y: number;
78
+ };
79
+ }
80
+ export interface AddShapeCommand {
81
+ readonly type: 'AddShape';
82
+ readonly slideId: SlideId;
83
+ readonly preset: string;
84
+ readonly rect: {
85
+ readonly x: number;
86
+ readonly y: number;
87
+ readonly w: number;
88
+ readonly h: number;
89
+ };
90
+ }
91
+ export interface AddImageCommand {
92
+ readonly type: 'AddImage';
93
+ readonly slideId: SlideId;
94
+ /** 空图片占位符可由同一历史单元原子替换。 */
95
+ readonly placeholderId?: ElementId;
96
+ readonly bytes: Uint8Array;
97
+ readonly mime: 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp';
98
+ readonly rect: {
99
+ readonly x: number;
100
+ readonly y: number;
101
+ readonly w: number;
102
+ readonly h: number;
103
+ };
104
+ }
105
+ export interface ReplaceImageCommand {
106
+ readonly type: 'ReplaceImage';
107
+ readonly id: ElementId;
108
+ readonly bytes: Uint8Array;
109
+ readonly mime: 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp';
110
+ }
111
+ export interface SetCropCommand {
112
+ readonly type: 'SetCrop';
113
+ readonly id: ElementId;
114
+ /** null 恢复来源;全零对象明确写出不裁剪。 */
115
+ readonly crop: ImageCrop | null;
116
+ }
117
+ export interface AddTableCommand {
118
+ readonly type: 'AddTable';
119
+ readonly slideId: SlideId;
120
+ readonly rows: number;
121
+ readonly cols: number;
122
+ readonly rect: {
123
+ readonly x: number;
124
+ readonly y: number;
125
+ readonly w: number;
126
+ readonly h: number;
127
+ };
128
+ /** 空内容占位符可由同一历史单元原子替换。 */
129
+ readonly placeholderId?: ElementId;
130
+ }
131
+ export interface AddSlideCommand {
132
+ readonly type: 'AddSlide';
133
+ readonly layoutId: string;
134
+ /** null 表示插入到第一位;稳定页身份比瞬时数组下标更适合框架与协同边界。 */
135
+ readonly at: {
136
+ readonly after: SlideId | null;
137
+ };
138
+ }
139
+ export interface MoveSlideCommand {
140
+ readonly type: 'MoveSlide';
141
+ readonly id: SlideId;
142
+ /** null 表示置首;稳定身份锚点避免页下标在插入后漂移。 */
143
+ readonly at: {
144
+ readonly after: SlideId | null;
145
+ };
146
+ }
147
+ export interface RemoveSlideCommand {
148
+ readonly type: 'RemoveSlide';
149
+ readonly id: SlideId;
150
+ }
151
+ export interface DuplicateSlideCommand {
152
+ readonly type: 'DuplicateSlide';
153
+ readonly id: SlideId;
154
+ }
155
+ export interface SetFillCommand {
156
+ readonly type: 'SetFill';
157
+ readonly id: ElementId;
158
+ /** null 删除直接覆盖;显式无填充使用 { type: 'none' }。 */
159
+ readonly fill: Exclude<Fill, {
160
+ type: 'image';
161
+ }> | null;
162
+ }
163
+ export interface SetStrokeCommand {
164
+ readonly type: 'SetStroke';
165
+ readonly id: ElementId;
166
+ /** null 恢复来源;{type:'none'} 形成显式无描边。 */
167
+ readonly stroke: Stroke | {
168
+ readonly type: 'none';
169
+ } | null;
170
+ }
171
+ export interface SetEffectsCommand {
172
+ readonly type: 'SetEffects';
173
+ readonly id: ElementId;
174
+ /** null 恢复继承;空对象明确写出无效果。 */
175
+ readonly effects: Effects | null;
176
+ }
177
+ export interface SetLinkCommand {
178
+ readonly type: 'SetLink';
179
+ readonly id: ElementId;
180
+ /** null 恢复来源;{kind:'none'} 明确移除当前元素链接。 */
181
+ readonly target: LinkTarget | {
182
+ readonly kind: 'none';
183
+ } | null;
184
+ }
185
+ export type TextEditOp = {
186
+ readonly type: 'replace';
187
+ readonly from: TextPosition;
188
+ readonly to: TextPosition;
189
+ readonly text: string;
190
+ } | {
191
+ readonly type: 'splitParagraph';
192
+ readonly at: TextPosition;
193
+ } | {
194
+ readonly type: 'insertLineBreak';
195
+ readonly at: TextPosition;
196
+ } | {
197
+ readonly type: 'replaceFragment';
198
+ readonly from: TextPosition;
199
+ readonly to: TextPosition;
200
+ readonly fragment: TextFragment;
201
+ };
202
+ export interface EditTextCommand {
203
+ readonly type: 'EditText';
204
+ readonly id: ElementId;
205
+ readonly cell?: TableCellAddress;
206
+ /** 操作按数组顺序作用于前一个操作的结果,便于 beforeinput 批量提交。 */
207
+ readonly ops: readonly TextEditOp[];
208
+ }
209
+ export interface TextRange {
210
+ readonly from: TextPosition;
211
+ readonly to: TextPosition;
212
+ }
213
+ export interface SetRunPropsCommand {
214
+ readonly type: 'SetRunProps';
215
+ readonly id: ElementId;
216
+ readonly cell?: TableCellAddress;
217
+ readonly range: TextRange;
218
+ readonly props: RunPropertyOverrides;
219
+ }
220
+ export interface SetParaPropsCommand {
221
+ readonly type: 'SetParaProps';
222
+ readonly id: ElementId;
223
+ readonly cell?: TableCellAddress;
224
+ readonly range: TextRange;
225
+ readonly props: ParagraphPropertyOverrides;
226
+ }
227
+ export interface FitTextShapeCommand {
228
+ readonly type: 'FitTextShape';
229
+ readonly id: ElementId;
230
+ }
231
+ export interface SetBodyPropsCommand {
232
+ readonly type: 'SetBodyProps';
233
+ readonly id: ElementId;
234
+ readonly cell?: TableCellAddress;
235
+ readonly props: TextBodyPropertyOverrides;
236
+ }
237
+ /** 当前公开语义是尾部追加;指定位置插行要先解决纵向合并与坐标重基。 */
238
+ export interface InsertRowCommand {
239
+ readonly type: 'InsertRow';
240
+ readonly id: ElementId;
241
+ }
242
+ export type Command = SetXfrmCommand | SetFlipCommand | RemoveElementCommand | SetZCommand | SetNameCommand | SetLockedCommand | SetElementHiddenCommand | ApplyFormatCommand | ReplaceTextCommand | AlignElementsCommand | PasteElementsCommand | AddShapeCommand | AddImageCommand | ReplaceImageCommand | SetCropCommand | AddTableCommand | AddSlideCommand | MoveSlideCommand | RemoveSlideCommand | DuplicateSlideCommand | EditTextCommand | SetRunPropsCommand | SetParaPropsCommand | FitTextShapeCommand | SetBodyPropsCommand | InsertRowCommand | SetFillCommand | SetStrokeCommand | SetEffectsCommand | SetLinkCommand | SetBackgroundCommand | SetBackgroundCropCommand | SetBackgroundImageCommand | SetHiddenCommand | SetTransitionCommand | SetAnimationsCommand | SetLayoutCommand | SetNotesCommand;
243
+ type SetXfrmPatch = {
244
+ [F in XfrmField]: {
245
+ readonly op: 'set';
246
+ readonly path: ElementXfrmPath<F>;
247
+ readonly value: XfrmValueByField[F];
248
+ readonly origin: string;
249
+ };
250
+ }[XfrmField];
251
+ type DeleteXfrmPatch = {
252
+ [F in XfrmField]: {
253
+ readonly op: 'del';
254
+ readonly path: ElementXfrmPath<F>;
255
+ readonly origin: string;
256
+ };
257
+ }[XfrmField];
258
+ export type ElementTransformPatch = SetXfrmPatch | DeleteXfrmPatch;
259
+ export type ElementFillPatch = {
260
+ readonly op: 'set';
261
+ readonly path: readonly ['elements', ElementId, 'ovr', 'fill'];
262
+ readonly value: Exclude<Fill, {
263
+ type: 'image';
264
+ }>;
265
+ readonly origin: string;
266
+ } | {
267
+ readonly op: 'del';
268
+ readonly path: readonly ['elements', ElementId, 'ovr', 'fill'];
269
+ readonly origin: string;
270
+ };
271
+ export type ElementStrokePatch = {
272
+ readonly op: 'set';
273
+ readonly path: readonly ['elements', ElementId, 'ovr', 'stroke'];
274
+ readonly value: Stroke | null;
275
+ readonly origin: string;
276
+ } | {
277
+ readonly op: 'del';
278
+ readonly path: readonly ['elements', ElementId, 'ovr', 'stroke'];
279
+ readonly origin: string;
280
+ };
281
+ export type ElementEffectsPatch = {
282
+ readonly op: 'set';
283
+ readonly path: readonly ['elements', ElementId, 'ovr', 'effects'];
284
+ readonly value: Effects;
285
+ readonly origin: string;
286
+ } | {
287
+ readonly op: 'del';
288
+ readonly path: readonly ['elements', ElementId, 'ovr', 'effects'];
289
+ readonly origin: string;
290
+ };
291
+ export type ElementLinkPatch = {
292
+ readonly op: 'set';
293
+ readonly path: readonly ['elements', ElementId, 'ovr', 'link'];
294
+ readonly value: LinkOverride;
295
+ readonly origin: string;
296
+ } | {
297
+ readonly op: 'del';
298
+ readonly path: readonly ['elements', ElementId, 'ovr', 'link'];
299
+ readonly origin: string;
300
+ };
301
+ export type ElementCropPatch = {
302
+ readonly op: 'set';
303
+ readonly path: readonly ['elements', ElementId, 'ovr', 'crop'];
304
+ readonly value: ImageCrop;
305
+ readonly origin: string;
306
+ } | {
307
+ readonly op: 'del';
308
+ readonly path: readonly ['elements', ElementId, 'ovr', 'crop'];
309
+ readonly origin: string;
310
+ };
311
+ export type ElementImageReplacementPatch = {
312
+ readonly op: 'set';
313
+ readonly path: readonly ['elements', ElementId, 'meta', 'imageReplacement'];
314
+ readonly value: ElementImageReplacement;
315
+ readonly origin: string;
316
+ } | {
317
+ readonly op: 'del';
318
+ readonly path: readonly ['elements', ElementId, 'meta', 'imageReplacement'];
319
+ readonly origin: string;
320
+ };
321
+ export type ImageResourcePatch = {
322
+ readonly op: 'set';
323
+ readonly path: readonly ['imageResources', string];
324
+ readonly value: ElementInsertionResource;
325
+ readonly origin: string;
326
+ } | {
327
+ readonly op: 'del';
328
+ readonly path: readonly ['imageResources', string];
329
+ readonly origin: string;
330
+ };
331
+ export type ElementTextPatch = {
332
+ readonly op: 'set';
333
+ readonly path: readonly ['elements', ElementId, 'ovr', 'text'];
334
+ readonly value: TextOverride;
335
+ readonly origin: string;
336
+ } | {
337
+ readonly op: 'del';
338
+ readonly path: readonly ['elements', ElementId, 'ovr', 'text'];
339
+ readonly origin: string;
340
+ } | {
341
+ readonly op: 'set';
342
+ readonly path: readonly ['elements', ElementId, 'ovr', 'tableCells', import('../types').TableCellRowRef, number, 'text'];
343
+ readonly value: TextOverride;
344
+ readonly origin: string;
345
+ } | {
346
+ readonly op: 'del';
347
+ readonly path: readonly ['elements', ElementId, 'ovr', 'tableCells', import('../types').TableCellRowRef, number, 'text'];
348
+ readonly origin: string;
349
+ };
350
+ export type ElementOrderPatch = {
351
+ readonly op: 'set';
352
+ readonly path: readonly ['elements', ElementId, 'order'];
353
+ readonly value: string;
354
+ readonly origin: string;
355
+ } | {
356
+ readonly op: 'del';
357
+ readonly path: readonly ['elements', ElementId, 'order'];
358
+ readonly origin: string;
359
+ };
360
+ export type ElementNamePatch = {
361
+ readonly op: 'set';
362
+ readonly path: readonly ['elements', ElementId, 'ovr', 'name'];
363
+ readonly value: string;
364
+ readonly origin: string;
365
+ } | {
366
+ readonly op: 'del';
367
+ readonly path: readonly ['elements', ElementId, 'ovr', 'name'];
368
+ readonly origin: string;
369
+ };
370
+ export type ElementInteractionField = 'locked' | 'hiddenByUser';
371
+ export type ElementInteractionPatch = {
372
+ readonly op: 'set';
373
+ readonly path: readonly ['elements', ElementId, 'meta', ElementInteractionField];
374
+ readonly value: true;
375
+ readonly origin: string;
376
+ } | {
377
+ readonly op: 'del';
378
+ readonly path: readonly ['elements', ElementId, 'meta', ElementInteractionField];
379
+ readonly origin: string;
380
+ };
381
+ export interface ElementTreeSnapshot {
382
+ readonly root: ElementId;
383
+ readonly parent: SlideId | ElementId;
384
+ readonly records: Readonly<Record<ElementId, ElementRecord>>;
385
+ }
386
+ export type ElementTreePatch = {
387
+ readonly op: 'remove' | 'insert';
388
+ readonly path: readonly ['elements', ElementId];
389
+ readonly value: ElementTreeSnapshot;
390
+ readonly origin: string;
391
+ };
392
+ export interface SlideTreeSnapshot {
393
+ readonly slide: SlideRecord;
394
+ readonly after: SlideId | null;
395
+ /** 删除视图优先切到原后继;插入 patch 不依赖它定位。 */
396
+ readonly before: SlideId | null;
397
+ readonly records: Readonly<Record<ElementId, ElementRecord>>;
398
+ }
399
+ export type SlideTreePatch = {
400
+ readonly op: 'remove' | 'insert';
401
+ readonly path: readonly ['slides', SlideId];
402
+ readonly value: SlideTreeSnapshot;
403
+ readonly origin: string;
404
+ };
405
+ export type SlideOrderPatch = {
406
+ readonly op: 'move';
407
+ readonly path: readonly ['slideOrder', SlideId];
408
+ readonly value: {
409
+ readonly after: SlideId | null;
410
+ };
411
+ readonly origin: string;
412
+ };
413
+ export type TableRowPatch = {
414
+ readonly op: 'insert' | 'remove';
415
+ readonly path: readonly ['elements', ElementId, 'ovr', 'tableRows', string];
416
+ readonly value: import('../types').TableRowInsertion;
417
+ readonly origin: string;
418
+ };
419
+ export type Patch = ElementTransformPatch | ElementFillPatch | ElementStrokePatch | ElementEffectsPatch | ElementLinkPatch | ElementCropPatch | ElementImageReplacementPatch | ImageResourcePatch | ElementTextPatch | ElementOrderPatch | ElementNamePatch | ElementInteractionPatch | ElementTreePatch | SlideTreePatch | SlideOrderPatch | SlidePropertyPatch | SlideLayoutPatch | SlideNotesPatch | TableRowPatch;
420
+ export interface CommandPatches {
421
+ readonly forward: Patch[];
422
+ readonly inverse: Patch[];
423
+ }
424
+ export interface TextPosition {
425
+ readonly p: number;
426
+ readonly r: number;
427
+ readonly off: number;
428
+ }
429
+ export type Selection = {
430
+ readonly kind: 'none';
431
+ } | {
432
+ readonly kind: 'elements';
433
+ readonly ids: readonly ElementId[];
434
+ readonly enteredGroup: ElementId | null;
435
+ } | {
436
+ readonly kind: 'text';
437
+ readonly id: ElementId;
438
+ readonly cell?: TableCellAddress;
439
+ readonly anchor: TextPosition;
440
+ readonly focus: TextPosition;
441
+ } | {
442
+ readonly kind: 'table';
443
+ readonly id: ElementId;
444
+ readonly cells: readonly {
445
+ r: number;
446
+ c: number;
447
+ }[];
448
+ };
449
+ export interface HistoryEntry extends CommandPatches {
450
+ readonly selectionBefore: Selection;
451
+ readonly selectionAfter: Selection;
452
+ readonly label: string;
453
+ readonly time: number;
454
+ readonly mergeKey?: string;
455
+ readonly affectedSlides: readonly SlideId[];
456
+ }
457
+ export interface History {
458
+ readonly undoCount: number;
459
+ readonly redoCount: number;
460
+ readonly byteSize: number;
461
+ readonly undoEntries: readonly HistoryEntry[];
462
+ readonly redoEntries: readonly HistoryEntry[];
463
+ clear(): void;
464
+ }
465
+ export interface SlideChangeSets {
466
+ readonly createdSlides: Set<SlideId>;
467
+ readonly removedSlides: Set<SlideId>;
468
+ readonly movedSlides: Set<SlideId>;
469
+ readonly notesSlides: Set<SlideId>;
470
+ readonly removedSlideFallbacks: Map<SlideId, SlideId>;
471
+ }
472
+ export interface TransactionResult extends ProjectionInvalidation, CommandPatches, SlideChangeSets {
473
+ readonly selection: Selection;
474
+ readonly renderSlides: Set<SlideId>;
475
+ }
476
+ export interface EditorChange extends ProjectionInvalidation, SlideChangeSets {
477
+ readonly source: 'transaction' | 'undo' | 'redo' | 'selection';
478
+ readonly selection: Selection;
479
+ /** dirtyElements 含投影缓存祖先;DOM 增量分区必须以真正被 patch 的元素为准。 */
480
+ readonly touchedElements: Set<ElementId>;
481
+ /** 需要重新生成 markup/defs 的元素;纯层级 patch 不进入这里。 */
482
+ readonly renderElements: Set<ElementId>;
483
+ /** 页面级视觉属性需要重建整个 SVG;隐藏等纯目录元数据不进入这里。 */
484
+ readonly renderSlides: Set<SlideId>;
485
+ /** bodyPr 有效值变化;活动文字面必须同步刷新被延迟的静态分区。 */
486
+ readonly bodyPropsElements: Set<ElementId>;
487
+ /** 只需移动既有 DOM 分区的元素;可与 renderElements 重叠。 */
488
+ readonly reorderedElements: Set<ElementId>;
489
+ /** 名称与会话交互状态改变;选择窗格只消费这一集合,避免文字输入重建目录 DOM。 */
490
+ readonly paneElements: Set<ElementId>;
491
+ }
492
+ export type EditorSubscriber = (change: EditorChange) => void;
493
+ export interface Transaction {
494
+ exec(...commands: Command[]): void;
495
+ select(selection: Selection): void;
496
+ }
497
+ export interface TransactionOptions {
498
+ readonly origin?: string;
499
+ readonly recordHistory?: boolean;
500
+ readonly mergeKey?: string;
501
+ readonly time?: number;
502
+ }
503
+ export interface EditorOptions {
504
+ readonly origin?: string;
505
+ readonly historyLimit?: number;
506
+ readonly historyByteLimit?: number;
507
+ /** 新解析文档的恢复日志;构造期间原子回放,不进入历史或再次广播。 */
508
+ readonly recoveryFrames?: readonly import('../recovery-types').RecoveryFrame[];
509
+ }
@@ -0,0 +1,8 @@
1
+ import type { FlipField, NumericXfrmField, XfrmField, XfrmValueByField } from './types';
2
+ export declare const NUMERIC_XFRM_FIELDS: readonly NumericXfrmField[];
3
+ export declare const FLIP_FIELDS: readonly FlipField[];
4
+ export declare const XFRM_FIELDS: readonly XfrmField[];
5
+ export declare const XFRM_FIELD_SET: Set<XfrmField>;
6
+ export declare const isFrameXfrmField: (field: XfrmField) => boolean;
7
+ export declare const isFrameSaveXfrmField: (field: XfrmField) => boolean;
8
+ export declare function assertXfrmValue<F extends XfrmField>(field: F, value: unknown, label: string): asserts value is XfrmValueByField[F];
@@ -0,0 +1,7 @@
1
+ import type { TextPosition, TextRange } from './commands/types';
2
+ export declare const own: (object: object, key: PropertyKey) => boolean;
3
+ export declare function assertDataObject(value: unknown, fields: readonly string[], label: string): asserts value is object;
4
+ /** JSON 数组必须稠密且只能拥有索引与 length;否则序列化会吞掉空洞、访问器或附加状态。 */
5
+ export declare function assertDataArray(value: unknown, label: string): asserts value is readonly unknown[];
6
+ export declare function assertTextPosition(value: unknown, label: string): asserts value is TextPosition;
7
+ export declare function assertTextRange(value: unknown, label: string): asserts value is TextRange;
@@ -0,0 +1,17 @@
1
+ import type { Presentation, SlideElement } from '@web-ppt/core';
2
+ import type { CreateDocOptions, EditDoc, EditableKind, ElementId, ElementMeta, SlideId } from './types';
3
+ export declare function elementMetaOf(el: SlideElement, inherited: EditableKind, source: Presentation['source'], writablePart: string | null): ElementMeta;
4
+ export declare function createDoc(pres: Presentation, opts?: CreateDocOptions): EditDoc;
5
+ export declare function createEmptyDoc(opts: {
6
+ width: number;
7
+ height: number;
8
+ idPrefix?: string;
9
+ }): EditDoc;
10
+ export declare function allocateSlideId(doc: EditDoc): SlideId;
11
+ export declare function allocateElementId(doc: EditDoc): ElementId;
12
+ /** 采用外部完整包快照会建立新的保存基线;会话中常规保存应只调用 Editor.save。 */
13
+ export declare function replaceDocPackage(doc: EditDoc, pkg: NonNullable<EditDoc['package']>): void;
14
+ /** 保存模块原子提交包与对应基线,不能拆成两个公开赋值。 */
15
+ export declare function commitSavedPackage(doc: EditDoc, pkg: NonNullable<EditDoc['package']>, baselines: Record<string, Uint8Array>, createdParts: string[]): void;
16
+ /** EditDoc 不内嵌函数,资源释放能力由 WeakMap 关联,因而文档本身仍可结构化克隆。 */
17
+ export declare function disposeDoc(doc: EditDoc): void;
@@ -0,0 +1,6 @@
1
+ import type { SlideElement } from '@web-ppt/core';
2
+ export declare const isDynamicSlideLink: (link: string | undefined) => boolean;
3
+ /** 组后代有独立记录和索引;字段身份来自内容,不依赖可选的页码占位符元数据。 */
4
+ export declare function hasDynamicSlideNumber(element: SlideElement): boolean;
5
+ /** 组后代有独立记录和索引;这里只判断当前记录自身承载的跳转。 */
6
+ export declare function hasDynamicSlideLink(element: SlideElement): boolean;