@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,38 @@
1
+ import type { Command, EditorChange, EditorOptions, EditorSubscriber, History, Selection, Transaction, TransactionOptions, TransactionResult } from './commands/types';
2
+ import type { OpcPatchResult } from './opc/types';
3
+ import type { RecoverySubscriber } from './recovery-types';
4
+ import type { EditDoc, ElementId, SlideId } from './types';
5
+ export declare class Editor {
6
+ readonly doc: EditDoc;
7
+ readonly history: History;
8
+ private readonly historyStore;
9
+ private readonly origin;
10
+ private readonly subscribers;
11
+ private readonly recoveryJournal;
12
+ private currentSelection;
13
+ private currentState;
14
+ private savedState;
15
+ private nextState;
16
+ private activeImageResources;
17
+ constructor(doc: EditDoc, options?: EditorOptions);
18
+ get selection(): Selection;
19
+ isDirty(): boolean;
20
+ save(): Promise<Uint8Array>;
21
+ saveDetailed(): Promise<OpcPatchResult>;
22
+ markSaved(): void;
23
+ select(selection: Selection): void;
24
+ subscribe(subscriber: EditorSubscriber): () => void;
25
+ subscribeRecovery(subscriber: RecoverySubscriber): () => void;
26
+ exec(...commands: Command[]): TransactionResult;
27
+ transaction(callback: (transaction: Transaction) => void, label: string, options?: TransactionOptions): TransactionResult;
28
+ undo(): EditorChange | null;
29
+ redo(): EditorChange | null;
30
+ toSlide(id: SlideId): import("@web-ppt/core").Slide;
31
+ effectiveElement(id: ElementId): import("@web-ppt/core").SlideElement;
32
+ private commit;
33
+ private emitRecovery;
34
+ private emit;
35
+ private refreshActiveImageResources;
36
+ private historyImageResourceBytes;
37
+ private pruneImageResources;
38
+ }
@@ -0,0 +1,3 @@
1
+ import type { EditDoc, ElementId, ElementRecord } from './types';
2
+ /** 父链是热路径;统一环检测,避免锁定、隐藏与选区各自复制且逐渐分叉。 */
3
+ export declare function elementOrAncestorMatches(doc: EditDoc, id: ElementId, predicate: (record: ElementRecord) => boolean): boolean;
@@ -0,0 +1,4 @@
1
+ import type { ElementRecord } from './types';
2
+ export declare const MAX_ELEMENT_NAME_LENGTH = 255;
3
+ export declare function assertElementName(value: unknown, label?: string): asserts value is string;
4
+ export declare function elementName(record: ElementRecord): string;
@@ -0,0 +1,7 @@
1
+ import type { EditDoc, ElementId, ElementRecord, FractionalIndex } from './types';
2
+ export declare function elementOrder(record: Pick<ElementRecord, 'z' | 'order'>): FractionalIndex;
3
+ export declare function elementParentChildren(doc: EditDoc, parent: string): ElementId[];
4
+ /** 母版/版式与歧义宿主留在固定槽位;层级命令只重排可可靠写回的同 part 直属节点。 */
5
+ export declare function writableLayerSiblingIds(doc: EditDoc, record: ElementRecord): ElementId[];
6
+ /** 同一事务可能改多个键;最后只排序一次,避免多选操作退化成逐元素全量搬移。 */
7
+ export declare function sortElementChildrenByOrder(doc: EditDoc, parent: string): void;
@@ -0,0 +1,3 @@
1
+ import type { TextBody } from '@web-ppt/core';
2
+ /** 字段内容属于页面;版式字段节点上的直设格式只是缓存,克隆时必须回到继承层。 */
3
+ export declare function fieldTextWithoutDirect(source: TextBody): TextBody;
@@ -0,0 +1,10 @@
1
+ import type { FractionalIndex } from './types';
2
+ export declare function assertFractionalIndex(key: string): void;
3
+ /** 初始兄弟顺序留出 61 个直接插槽,避免导入大文档时键长随元素数增长。 */
4
+ export declare function initialFractionalIndex(index: number): FractionalIndex;
5
+ /**
6
+ * `discriminator` 供协同插入传稳定唯一值(通常就是新元素 ULID)。中点本身已在边界的
7
+ * 某一位留出严格间隙,因此追加编码后仍在原开区间内;不同客户端不会占用同一个 z。
8
+ */
9
+ export declare function fractionalIndexBetween(lower: FractionalIndex | null, upper: FractionalIndex | null, discriminator?: string): FractionalIndex;
10
+ export declare function compareFractionalIndex(a: FractionalIndex, b: FractionalIndex): number;
@@ -0,0 +1,50 @@
1
+ import type { History, HistoryEntry, Patch } from './commands/types';
2
+ interface StoredHistoryEntry extends HistoryEntry {
3
+ readonly beforeState: number;
4
+ readonly afterState: number;
5
+ readonly links: readonly StoredPatchLink[];
6
+ }
7
+ interface StoredPatchLink {
8
+ readonly trigger: string;
9
+ readonly related: readonly string[];
10
+ }
11
+ export interface HistoryPatchLink {
12
+ readonly trigger: Patch['path'];
13
+ readonly related: readonly Patch['path'][];
14
+ }
15
+ export interface HistoryStoreHooks {
16
+ /** 不复制进 Patch、但仅因历史可达而常驻的外部资源字节。 */
17
+ readonly externalByteSize?: (entries: readonly HistoryEntry[]) => number;
18
+ /** 历史驱逐/清空后通知资源所有者做可达性回收。 */
19
+ readonly changed?: (entries: readonly HistoryEntry[]) => void;
20
+ }
21
+ export declare function cloneHistoryEntry(entry: HistoryEntry): HistoryEntry;
22
+ export declare class HistoryStore implements History {
23
+ private readonly undoList;
24
+ private readonly redoList;
25
+ private readonly limit;
26
+ private readonly byteLimit;
27
+ private readonly hooks;
28
+ private bytes;
29
+ private externalBytes;
30
+ private mergeBarrier;
31
+ constructor(limit?: number, byteLimit?: number, hooks?: HistoryStoreHooks);
32
+ get undoCount(): number;
33
+ get redoCount(): number;
34
+ get byteSize(): number;
35
+ get undoEntries(): readonly HistoryEntry[];
36
+ get redoEntries(): readonly HistoryEntry[];
37
+ clear(): void;
38
+ breakMerge(): void;
39
+ /** 后到的非记录写入胜出;旧历史只保留未冲突路径,避免撤销覆盖远端或系统改动。 */
40
+ rebaseUnrecorded(patches: readonly Patch[], currentState: number, allocateState: () => number): void;
41
+ push(entry: HistoryEntry, beforeState: number, afterState: number, links?: readonly HistoryPatchLink[]): void;
42
+ peekUndo(): StoredHistoryEntry | null;
43
+ peekRedo(): StoredHistoryEntry | null;
44
+ moveToRedo(): void;
45
+ moveToUndo(): void;
46
+ private entries;
47
+ private rebudget;
48
+ private sizeOf;
49
+ }
50
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { EditDoc, ElementId, ElementLinkState, LinkOverride, LinkSourceValue, LinkTarget } from './types';
2
+ export declare const MAX_EXTERNAL_LINK_LENGTH = 2048;
3
+ export declare function normalizeExternalLinkTarget(href: string): LinkTarget | null;
4
+ export declare function assertLinkOverride(value: unknown, label: string): asserts value is LinkOverride;
5
+ export declare function normalizeLinkTarget(doc: EditDoc, value: LinkOverride, label: string): LinkOverride;
6
+ export declare function sourceLinkValue(doc: EditDoc, link: string | undefined): LinkSourceValue | null;
7
+ export declare function renderLinkTarget(doc: EditDoc, target: LinkTarget): string | undefined;
8
+ export declare function sourceLinkReadonly(value: LinkSourceValue | null): boolean;
9
+ export declare function linkValueFollowable(doc: EditDoc, value: LinkSourceValue | null): boolean;
10
+ export declare function queryElementLink(doc: EditDoc, ids: readonly ElementId[]): ElementLinkState;
@@ -0,0 +1,7 @@
1
+ import type { ImageElement } from '@web-ppt/core';
2
+ import type { EditDoc, ElementCropState, ElementId, ImageCrop } from './types';
3
+ export declare function assertImageCrop(value: unknown, label: string): asserts value is ImageCrop;
4
+ /** srcRect 用十万分数保存;命令入口先收敛,避免保存重开制造脏状态。 */
5
+ export declare function normalizeImageCrop(crop: ImageCrop): ImageCrop;
6
+ export declare function isEditablePicture(element: ImageElement): boolean;
7
+ export declare function queryElementCrop(doc: EditDoc, ids: readonly ElementId[]): ElementCropState;
@@ -0,0 +1,6 @@
1
+ import type { HistoryEntry, Patch } from './commands/types';
2
+ import type { EditDoc } from './types';
3
+ /** 结构历史也可能包住整棵元素快照,因此不能只识别直接 imageReplacement Patch。 */
4
+ export declare function historyImageResourceHashes(entries: readonly HistoryEntry[]): Set<string>;
5
+ export declare function activeImageResourceHashes(doc: EditDoc): Set<string>;
6
+ export declare function imageReachabilityMayChange(patches: readonly Patch[]): boolean;