@web-ppt/editor 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.
- package/CHANGELOG.md +274 -0
- package/LICENSE +21 -0
- package/README.md +473 -0
- package/dist/adapter-format-painter.d.ts +15 -0
- package/dist/adapter-link.d.ts +3 -0
- package/dist/adapter-options.d.ts +6 -0
- package/dist/adapter-recovery.d.ts +14 -0
- package/dist/adapter-selection-pane.d.ts +22 -0
- package/dist/adapter-text-search.d.ts +28 -0
- package/dist/animation-preview.d.ts +26 -0
- package/dist/dom-identity.d.ts +17 -0
- package/dist/dom-patch.d.ts +9 -0
- package/dist/editor-keyboard.d.ts +13 -0
- package/dist/editor.js +6332 -0
- package/dist/element-clipboard.d.ts +23 -0
- package/dist/format-painter-types.d.ts +32 -0
- package/dist/format-painter-view.d.ts +17 -0
- package/dist/format-painter.d.ts +21 -0
- package/dist/framework-adapter-binding.d.ts +4 -0
- package/dist/framework-adapter-state.d.ts +9 -0
- package/dist/framework-adapter-types.d.ts +114 -0
- package/dist/framework-adapter.d.ts +2 -0
- package/dist/image-crop-gesture.d.ts +40 -0
- package/dist/image-insertion.d.ts +46 -0
- package/dist/index.d.ts +28 -0
- package/dist/indexeddb-recovery-store.d.ts +30 -0
- package/dist/keyboard-context.d.ts +8 -0
- package/dist/keyboard-delete.d.ts +7 -0
- package/dist/keyboard-history.d.ts +7 -0
- package/dist/keyboard-layer.d.ts +7 -0
- package/dist/keyboard-nudge.d.ts +10 -0
- package/dist/keyboard-owner.d.ts +5 -0
- package/dist/marquee-gesture.d.ts +31 -0
- package/dist/move-gesture.d.ts +34 -0
- package/dist/placeholder-overlay.d.ts +3 -0
- package/dist/pointer-gesture.d.ts +37 -0
- package/dist/recovery-session.d.ts +24 -0
- package/dist/recovery-store.d.ts +64 -0
- package/dist/resize-geometry.d.ts +19 -0
- package/dist/resize-gesture.d.ts +30 -0
- package/dist/rotation-geometry.d.ts +9 -0
- package/dist/rotation-gesture.d.ts +33 -0
- package/dist/selection-body-properties.d.ts +3 -0
- package/dist/selection-combine.d.ts +10 -0
- package/dist/selection-handles.d.ts +3 -0
- package/dist/selection-hit.d.ts +8 -0
- package/dist/selection-overlay.d.ts +13 -0
- package/dist/selection-pane-types.d.ts +18 -0
- package/dist/selection-pane.d.ts +3 -0
- package/dist/session-state.d.ts +20 -0
- package/dist/session.d.ts +24 -0
- package/dist/slide-dom-renderer.d.ts +22 -0
- package/dist/slide-dom-update.d.ts +13 -0
- package/dist/slide-editor-commands.d.ts +76 -0
- package/dist/slide-editor-dom.d.ts +2 -0
- package/dist/slide-editor-events.d.ts +20 -0
- package/dist/slide-editor-keyboard-events.d.ts +39 -0
- package/dist/slide-editor-types.d.ts +90 -0
- package/dist/slide-editor.d.ts +3 -0
- package/dist/slide-link-controller.d.ts +26 -0
- package/dist/slide-pointer-controller.d.ts +43 -0
- package/dist/snap-guides.d.ts +3 -0
- package/dist/snap.d.ts +60 -0
- package/dist/source-fingerprint.d.ts +9 -0
- package/dist/table-insertion.d.ts +7 -0
- package/dist/text-autofit.d.ts +18 -0
- package/dist/text-clipboard-controller.d.ts +32 -0
- package/dist/text-clipboard.d.ts +7 -0
- package/dist/text-dom.d.ts +30 -0
- package/dist/text-editor-context.d.ts +13 -0
- package/dist/text-editor-target.d.ts +10 -0
- package/dist/text-editor-types.d.ts +30 -0
- package/dist/text-editor-view.d.ts +4 -0
- package/dist/text-editor.d.ts +51 -0
- package/dist/text-input-plan.d.ts +20 -0
- package/dist/text-search-highlight.d.ts +18 -0
- package/dist/text-search-index.d.ts +11 -0
- package/dist/text-search-types.d.ts +41 -0
- package/dist/text-search-view.d.ts +33 -0
- package/dist/text-search.d.ts +46 -0
- package/dist/transform-frame.d.ts +14 -0
- package/dist/transition-preview.d.ts +24 -0
- package/package.json +54 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Editor, ElementId, SlideId } from '@web-ppt/edit-core';
|
|
2
|
+
export declare const ELEMENT_CLIPBOARD_MIME = "application/x-web-ppt-elements+json";
|
|
3
|
+
interface ElementClipboardOptions {
|
|
4
|
+
editor: Editor;
|
|
5
|
+
slideId(): SlideId;
|
|
6
|
+
editable(): boolean;
|
|
7
|
+
gestureActive(): boolean;
|
|
8
|
+
insertImage(file: File): Promise<ElementId>;
|
|
9
|
+
}
|
|
10
|
+
export declare class ElementClipboardController {
|
|
11
|
+
private readonly options;
|
|
12
|
+
constructor(options: ElementClipboardOptions);
|
|
13
|
+
copy(event: ClipboardEvent): void;
|
|
14
|
+
cut(event: ClipboardEvent): void;
|
|
15
|
+
paste(event: ClipboardEvent): void;
|
|
16
|
+
duplicate(event: KeyboardEvent): boolean;
|
|
17
|
+
private shouldYield;
|
|
18
|
+
private shouldYieldBase;
|
|
19
|
+
private selectedRoots;
|
|
20
|
+
private write;
|
|
21
|
+
private pastePayload;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ElementId, FormatMaskField, TableCellAddress, TextRange } from '@web-ppt/edit-core';
|
|
2
|
+
export interface FormatPainterStartOptions {
|
|
3
|
+
/** false/undefined 表示成功一次后自动退出。 */
|
|
4
|
+
readonly continuous?: boolean;
|
|
5
|
+
/** 省略时根据当前元素或文字选区选择安全默认值。 */
|
|
6
|
+
readonly mask?: readonly FormatMaskField[];
|
|
7
|
+
}
|
|
8
|
+
export interface FormatPainterSource {
|
|
9
|
+
readonly id: ElementId;
|
|
10
|
+
readonly cell?: TableCellAddress;
|
|
11
|
+
readonly range?: TextRange;
|
|
12
|
+
readonly mask: readonly FormatMaskField[];
|
|
13
|
+
}
|
|
14
|
+
export interface FormatPainterTarget {
|
|
15
|
+
readonly id: ElementId;
|
|
16
|
+
readonly cell?: TableCellAddress;
|
|
17
|
+
readonly range?: TextRange;
|
|
18
|
+
}
|
|
19
|
+
export interface FormatPainterSnapshot {
|
|
20
|
+
readonly active: boolean;
|
|
21
|
+
readonly mode: 'inactive' | 'single' | 'continuous';
|
|
22
|
+
readonly source: FormatPainterSource | null;
|
|
23
|
+
}
|
|
24
|
+
export type FormatPainterSubscriber = (snapshot: FormatPainterSnapshot) => void;
|
|
25
|
+
export interface FormatPainter {
|
|
26
|
+
readonly snapshot: FormatPainterSnapshot;
|
|
27
|
+
readonly disposed: boolean;
|
|
28
|
+
start(options?: FormatPainterStartOptions): boolean;
|
|
29
|
+
apply(target: FormatPainterTarget): boolean;
|
|
30
|
+
cancel(): void;
|
|
31
|
+
subscribe(subscriber: FormatPainterSubscriber): () => void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FormatPainter } from './format-painter-types';
|
|
2
|
+
import type { FormatPainterStartOptions, FormatPainterTarget } from './format-painter-types';
|
|
3
|
+
/** 视图绑定只投影状态与错误;格式真相仍完全属于会话控制器。 */
|
|
4
|
+
export declare class FormatPainterViewBinding {
|
|
5
|
+
private readonly root;
|
|
6
|
+
private readonly painter;
|
|
7
|
+
private readonly onError?;
|
|
8
|
+
private readonly unsubscribe;
|
|
9
|
+
constructor(root: HTMLElement, painter: FormatPainter, onError?: ((error: unknown) => void) | undefined);
|
|
10
|
+
get active(): boolean;
|
|
11
|
+
start(options: FormatPainterStartOptions): boolean;
|
|
12
|
+
apply(target: FormatPainterTarget): boolean;
|
|
13
|
+
cancel(): void;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
report(error: unknown): void;
|
|
16
|
+
private sync;
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Editor } from '@web-ppt/edit-core';
|
|
2
|
+
import type { FormatPainter, FormatPainterSnapshot, FormatPainterStartOptions, FormatPainterSubscriber, FormatPainterTarget } from './format-painter-types';
|
|
3
|
+
/** 会话状态只保留稳定模型身份,不持有 DOM 或某个框架实例。 */
|
|
4
|
+
export declare class SessionFormatPainter implements FormatPainter {
|
|
5
|
+
private readonly editor;
|
|
6
|
+
private current;
|
|
7
|
+
private readonly subscribers;
|
|
8
|
+
private readonly unsubscribeEditor;
|
|
9
|
+
private isDisposed;
|
|
10
|
+
constructor(editor: Editor);
|
|
11
|
+
get snapshot(): FormatPainterSnapshot;
|
|
12
|
+
get disposed(): boolean;
|
|
13
|
+
start(options?: FormatPainterStartOptions): boolean;
|
|
14
|
+
apply(target: FormatPainterTarget): boolean;
|
|
15
|
+
cancel(): void;
|
|
16
|
+
subscribe(subscriber: FormatPainterSubscriber): () => void;
|
|
17
|
+
dispose(): void;
|
|
18
|
+
private normalizedRange;
|
|
19
|
+
private emit;
|
|
20
|
+
private assertActive;
|
|
21
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EditorSession } from './session';
|
|
2
|
+
import type { WebPptAdapter, WebPptAdapterBinding } from './framework-adapter-types';
|
|
3
|
+
/** React/Vue/Svelte/Web Component 只需把受控 props 映射到这一处。 */
|
|
4
|
+
export declare function applyWebPptAdapterBinding(adapter: WebPptAdapter, binding: WebPptAdapterBinding): Promise<EditorSession | null>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WebPptAdapterSnapshot } from './framework-adapter-types';
|
|
2
|
+
export declare const DEFAULT_WEB_PPT_VIEW: Readonly<{
|
|
3
|
+
mode: "edit";
|
|
4
|
+
zoom: 1;
|
|
5
|
+
textMode: "auto";
|
|
6
|
+
snapping: true;
|
|
7
|
+
}>;
|
|
8
|
+
/** 空态也是完整受控状态,宿主首帧无需判空后再补默认值。 */
|
|
9
|
+
export declare const WEB_PPT_IDLE_SNAPSHOT: WebPptAdapterSnapshot;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { EditAnimationStep, EditorChange, SlideAnimationState, SlideId, SlideTransitionInput, SlideTransitionState, TextSearchMatch } from '@web-ppt/edit-core';
|
|
2
|
+
import type { RecoveryCandidate, RecoveryDecision } from './recovery-store';
|
|
3
|
+
import type { EditorSession, OpenEditorOptions } from './session';
|
|
4
|
+
import type { SelectionPane } from './selection-pane-types';
|
|
5
|
+
import type { EditorMode, LinkFollowHandler, SlideEditor, SlideEditorOptions } from './slide-editor-types';
|
|
6
|
+
import type { WebPptSource } from './source-fingerprint';
|
|
7
|
+
import type { FormatPainterSnapshot, FormatPainterStartOptions } from './format-painter-types';
|
|
8
|
+
import type { TextSearchOpenOptions, TextSearchOptions, TextSearchSnapshot } from './text-search-types';
|
|
9
|
+
export type WebPptDocument = {
|
|
10
|
+
readonly source: WebPptSource;
|
|
11
|
+
readonly openOptions?: OpenEditorOptions;
|
|
12
|
+
readonly session?: never;
|
|
13
|
+
readonly ownership?: never;
|
|
14
|
+
} | {
|
|
15
|
+
readonly session: EditorSession;
|
|
16
|
+
readonly ownership: 'external';
|
|
17
|
+
readonly source?: never;
|
|
18
|
+
readonly openOptions?: never;
|
|
19
|
+
};
|
|
20
|
+
export interface WebPptViewOptions {
|
|
21
|
+
readonly mode?: EditorMode;
|
|
22
|
+
readonly slideId?: SlideId;
|
|
23
|
+
readonly zoom?: number;
|
|
24
|
+
readonly textMode?: SlideEditorOptions['textMode'];
|
|
25
|
+
readonly snapping?: boolean;
|
|
26
|
+
readonly snapMargins?: SlideEditorOptions['snapMargins'];
|
|
27
|
+
readonly onLinkFollow?: LinkFollowHandler;
|
|
28
|
+
}
|
|
29
|
+
export interface WebPptAdapterProgress {
|
|
30
|
+
readonly phase: 'opening' | 'recovering' | 'ready';
|
|
31
|
+
readonly ratio: 0 | 1;
|
|
32
|
+
}
|
|
33
|
+
export interface WebPptViewState {
|
|
34
|
+
readonly mode: EditorMode;
|
|
35
|
+
readonly slideId: SlideId | null;
|
|
36
|
+
readonly zoom: number;
|
|
37
|
+
readonly snapping: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface WebPptFormatPainterState extends FormatPainterSnapshot {
|
|
40
|
+
/** 文档未就绪、只读或当前为查看模式时为 true。 */
|
|
41
|
+
readonly readonly: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface WebPptTextSearchState extends TextSearchSnapshot {
|
|
44
|
+
/** 只有文档就绪、来源可写且当前为编辑模式时为 true;查找与导航不受此值限制。 */
|
|
45
|
+
readonly canReplace: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface WebPptAdapterCallbacks {
|
|
48
|
+
readonly onReady?: (session: EditorSession) => void;
|
|
49
|
+
readonly onError?: (error: unknown) => void;
|
|
50
|
+
readonly onProgress?: (progress: WebPptAdapterProgress) => void;
|
|
51
|
+
readonly onChange?: (change: EditorChange) => void;
|
|
52
|
+
readonly onViewChange?: (state: WebPptViewState) => void;
|
|
53
|
+
readonly onRecovery?: (candidate: RecoveryCandidate) => RecoveryDecision | Promise<RecoveryDecision>;
|
|
54
|
+
}
|
|
55
|
+
export type WebPptAdapterBinding = WebPptViewOptions & WebPptAdapterCallbacks & ({
|
|
56
|
+
readonly source: WebPptSource;
|
|
57
|
+
readonly openOptions?: OpenEditorOptions;
|
|
58
|
+
readonly session?: never;
|
|
59
|
+
readonly sessionOwnership?: never;
|
|
60
|
+
} | {
|
|
61
|
+
readonly session: EditorSession;
|
|
62
|
+
readonly sessionOwnership: 'external';
|
|
63
|
+
readonly source?: never;
|
|
64
|
+
readonly openOptions?: never;
|
|
65
|
+
} | {
|
|
66
|
+
readonly source?: null;
|
|
67
|
+
readonly session?: null;
|
|
68
|
+
readonly sessionOwnership?: never;
|
|
69
|
+
readonly openOptions?: OpenEditorOptions;
|
|
70
|
+
});
|
|
71
|
+
export interface WebPptAdapterSnapshot extends WebPptViewState {
|
|
72
|
+
readonly status: 'idle' | 'opening' | 'recovering' | 'ready' | 'error' | 'disposed';
|
|
73
|
+
readonly progress: number;
|
|
74
|
+
readonly error: unknown | null;
|
|
75
|
+
readonly session: EditorSession | null;
|
|
76
|
+
readonly view: SlideEditor | null;
|
|
77
|
+
readonly selectionPane: SelectionPane | null;
|
|
78
|
+
readonly recovery: RecoveryCandidate | null;
|
|
79
|
+
readonly formatPainter: WebPptFormatPainterState;
|
|
80
|
+
readonly textSearch: WebPptTextSearchState;
|
|
81
|
+
}
|
|
82
|
+
export type WebPptAdapterSubscriber = (snapshot: WebPptAdapterSnapshot) => void;
|
|
83
|
+
export interface WebPptAdapter {
|
|
84
|
+
readonly snapshot: WebPptAdapterSnapshot;
|
|
85
|
+
readonly disposed: boolean;
|
|
86
|
+
subscribe(subscriber: WebPptAdapterSubscriber): () => void;
|
|
87
|
+
setCallbacks(callbacks: WebPptAdapterCallbacks): void;
|
|
88
|
+
applyBinding(binding: WebPptAdapterBinding): Promise<EditorSession | null>;
|
|
89
|
+
attach(container: HTMLElement | null): void;
|
|
90
|
+
attachSelectionPane(container: HTMLElement | null): void;
|
|
91
|
+
setView(options: WebPptViewOptions): void;
|
|
92
|
+
setDocument(document: WebPptDocument | null): Promise<EditorSession | null>;
|
|
93
|
+
save(): Promise<Uint8Array>;
|
|
94
|
+
undo(): EditorChange | null;
|
|
95
|
+
redo(): EditorChange | null;
|
|
96
|
+
startFormatPainter(options?: FormatPainterStartOptions): boolean;
|
|
97
|
+
cancelFormatPainter(): void;
|
|
98
|
+
openTextSearch(options?: TextSearchOpenOptions): void;
|
|
99
|
+
closeTextSearch(): void;
|
|
100
|
+
setTextSearchQuery(query: string): void;
|
|
101
|
+
setTextSearchReplacement(replacement: string): void;
|
|
102
|
+
setTextSearchOptions(options: Partial<TextSearchOptions>): void;
|
|
103
|
+
nextTextSearch(): TextSearchMatch | null;
|
|
104
|
+
previousTextSearch(): TextSearchMatch | null;
|
|
105
|
+
replaceCurrentText(): boolean;
|
|
106
|
+
replaceAllText(): number;
|
|
107
|
+
queryTransition(): SlideTransitionState | null;
|
|
108
|
+
setTransition(value: SlideTransitionInput | null): boolean;
|
|
109
|
+
previewTransition(value?: SlideTransitionInput): Promise<boolean>;
|
|
110
|
+
queryAnimations(): SlideAnimationState | null;
|
|
111
|
+
setAnimations(value: readonly EditAnimationStep[] | null): boolean;
|
|
112
|
+
previewAnimations(value?: readonly EditAnimationStep[]): Promise<boolean>;
|
|
113
|
+
dispose(): void;
|
|
114
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Editor, ElementId, Selection, SlideId } from '@web-ppt/edit-core';
|
|
2
|
+
import type { ResizeHandle } from './resize-geometry';
|
|
3
|
+
interface ImageCropGestureOptions {
|
|
4
|
+
root: HTMLElement;
|
|
5
|
+
stage: HTMLElement;
|
|
6
|
+
interactionLayer: SVGSVGElement;
|
|
7
|
+
editor: Editor;
|
|
8
|
+
editable(): boolean;
|
|
9
|
+
slideId(): SlideId;
|
|
10
|
+
zoom(): number;
|
|
11
|
+
renderSelection(): void;
|
|
12
|
+
}
|
|
13
|
+
/** 双矩形裁剪模式独占 interaction 层;静态图片只在模型提交后增量换代。 */
|
|
14
|
+
export declare class ImageCropGestureController {
|
|
15
|
+
private readonly options;
|
|
16
|
+
private readonly lifecycle;
|
|
17
|
+
private currentId;
|
|
18
|
+
constructor(options: ImageCropGestureOptions);
|
|
19
|
+
get activeId(): ElementId | null;
|
|
20
|
+
get isGestureActive(): boolean;
|
|
21
|
+
enter(id: ElementId): boolean;
|
|
22
|
+
exit(): void;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
cancelGesture(): void;
|
|
25
|
+
commitGesture(): boolean;
|
|
26
|
+
sync(selection: Selection): void;
|
|
27
|
+
handleAt(target: EventTarget | null): ResizeHandle | null;
|
|
28
|
+
begin(event: PointerEvent, handle: ResizeHandle): void;
|
|
29
|
+
move(event: PointerEvent): void;
|
|
30
|
+
finish(event: PointerEvent): void;
|
|
31
|
+
cancelPointer(event: PointerEvent): void;
|
|
32
|
+
private toLocal;
|
|
33
|
+
private proposal;
|
|
34
|
+
private preview;
|
|
35
|
+
private commit;
|
|
36
|
+
private render;
|
|
37
|
+
private renderCrop;
|
|
38
|
+
private removeOverlay;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AddImageCommand, Editor, ElementId, SetBackgroundImageCommand, SlideId } from '@web-ppt/edit-core';
|
|
2
|
+
export interface ImageInsertOptions {
|
|
3
|
+
readonly rect?: AddImageCommand['rect'];
|
|
4
|
+
/** 默认 5MB:留足默认 8MB 历史预算所需的 Base64 开销,保证插入后仍可撤销。 */
|
|
5
|
+
readonly maxBytes?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ImageReplaceOptions {
|
|
8
|
+
/** 默认使用当前单选图片。 */
|
|
9
|
+
readonly id?: ElementId;
|
|
10
|
+
readonly maxBytes?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ImageBackgroundOptions {
|
|
13
|
+
readonly crop?: SetBackgroundImageCommand['crop'];
|
|
14
|
+
readonly alpha?: SetBackgroundImageCommand['alpha'];
|
|
15
|
+
readonly tile?: SetBackgroundImageCommand['tile'];
|
|
16
|
+
readonly maxBytes?: number;
|
|
17
|
+
}
|
|
18
|
+
interface InternalImageInsertOptions extends ImageInsertOptions {
|
|
19
|
+
readonly placeholderId?: ElementId;
|
|
20
|
+
}
|
|
21
|
+
interface ImageInsertionControllerOptions {
|
|
22
|
+
readonly editor: Editor;
|
|
23
|
+
readonly root: HTMLElement;
|
|
24
|
+
slideId(): SlideId;
|
|
25
|
+
editable(): boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare class ImageInsertionController {
|
|
28
|
+
private readonly options;
|
|
29
|
+
private cancelChooser;
|
|
30
|
+
private activeReads;
|
|
31
|
+
private destroyed;
|
|
32
|
+
constructor(options: ImageInsertionControllerOptions);
|
|
33
|
+
private withImageBytes;
|
|
34
|
+
insert(blob: Blob, options?: InternalImageInsertOptions): Promise<ElementId>;
|
|
35
|
+
replace(id: ElementId, blob: Blob, options?: ImageReplaceOptions): Promise<ElementId>;
|
|
36
|
+
choose(options?: InternalImageInsertOptions): Promise<ElementId | null>;
|
|
37
|
+
chooseReplacement(id: ElementId, options?: ImageReplaceOptions): Promise<ElementId | null>;
|
|
38
|
+
setBackground(blob: Blob, options?: ImageBackgroundOptions): Promise<SlideId>;
|
|
39
|
+
chooseBackground(options?: ImageBackgroundOptions): Promise<SlideId | null>;
|
|
40
|
+
private chooseFile;
|
|
41
|
+
destroy(): void;
|
|
42
|
+
private setReading;
|
|
43
|
+
private report;
|
|
44
|
+
private assertContext;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { openEditor } from './session';
|
|
2
|
+
export { createSelectionPane } from './selection-pane';
|
|
3
|
+
export { fingerprintSource } from './source-fingerprint';
|
|
4
|
+
export { RecoveryOpenCancelledError } from './recovery-store';
|
|
5
|
+
export { createIndexedDbRecoveryStore } from './indexeddb-recovery-store';
|
|
6
|
+
export { createWebPptAdapter, } from './framework-adapter';
|
|
7
|
+
export { applyWebPptAdapterBinding } from './framework-adapter-binding';
|
|
8
|
+
export { WEB_PPT_IDLE_SNAPSHOT } from './framework-adapter-state';
|
|
9
|
+
export { ELEMENT_CLIPBOARD_MIME } from './element-clipboard';
|
|
10
|
+
export { elementFrameToSlideMatrix, elementFrameToSlidePoint, elementParentToSlideMatrix, elementParentToSlidePoint, invertSpaceMatrix, screenToSlidePoint, slideToElementFramePoint, slideToElementParentPoint, slideToScreenPoint, transformSpacePoint, queryElementCrop, queryElementEffects, queryElementFill, queryElementLink, queryElementStroke, queryRunLink, querySlideBackground, querySlideHidden, querySlideLayout, querySlideNotes, querySlideAnimations, querySlideTransition, ANIMATION_EFFECTS, MAX_ANIMATION_STEPS, animationDirections, animationEffectsForKind, SHAPE_PATTERN_PRESETS, SLIDE_TRANSITION_TYPES, transitionDirections, } from '@web-ppt/edit-core';
|
|
11
|
+
export type { EditorSession, OpenEditorOptions } from './session';
|
|
12
|
+
export type { FormatPainter, FormatPainterSnapshot, FormatPainterSource, FormatPainterStartOptions, FormatPainterSubscriber, FormatPainterTarget, } from './format-painter-types';
|
|
13
|
+
export type { TextSearch, TextSearchMode, TextSearchOpenOptions, TextSearchOptions, TextSearchSnapshot, TextSearchSubscriber, } from './text-search-types';
|
|
14
|
+
export type { SelectionPane, SelectionPaneOptions } from './selection-pane-types';
|
|
15
|
+
export type { WebPptSourceIdentity } from './source-fingerprint';
|
|
16
|
+
export type { EditorRecovery, RecoveryCandidate, RecoveryDecision, RecoveryDecisionHandler, RecoveryOptions, RecoveryStore, RecoveryStoreAppend, RecoveryStoreJournal, RecoveryStoreReset, } from './recovery-store';
|
|
17
|
+
export type { IndexedDbRecoveryStore, IndexedDbRecoveryStoreOptions, RecoveryCleanupResult, RecoveryStoreStats, } from './indexeddb-recovery-store';
|
|
18
|
+
export type { WebPptAdapter, WebPptAdapterBinding, WebPptAdapterCallbacks, WebPptAdapterProgress, WebPptAdapterSnapshot, WebPptAdapterSubscriber, WebPptDocument, WebPptFormatPainterState, WebPptTextSearchState, WebPptViewOptions, WebPptViewState, } from './framework-adapter-types';
|
|
19
|
+
export type { WebPptSource } from './source-fingerprint';
|
|
20
|
+
export type { EditorMode, LinkFollowContext, LinkFollowHandler, LinkFollowSource, SlideEditor, SlideEditorOptions, } from './slide-editor-types';
|
|
21
|
+
export type { ImageInsertOptions } from './image-insertion';
|
|
22
|
+
export type { ImageBackgroundOptions, ImageReplaceOptions } from './image-insertion';
|
|
23
|
+
export type { TableInsertOptions } from './table-insertion';
|
|
24
|
+
export type { AddImageCommand, AddShapeCommand, AddTableCommand, EditAnimationStep, ElementClipboardPayload, ElementCropState, ElementEffectsState, ElementFillState, ElementLinkState, ElementStrokeState, ImageCrop, LinkOverride, LinkSourceValue, LinkTarget, ParagraphProperties, ParagraphPropertiesState, ParagraphPropertyOverrides, SlideAnimationState, SlideBackgroundState, SlideHiddenState, SlideLayoutState, RunLinkState, RunPropertiesState, RunPropertyOverrides, SlideNotesState, SlideTransitionInput, SlideTransitionState, TextBodyAutoFit, TextBodyProperties, TextBodyPropertyOverrides, ReplaceImageCommand, SetAnimationsCommand, SetBackgroundCommand, SetBackgroundCropCommand, SetBackgroundImageCommand, SetCropCommand, SetEffectsCommand, SetFillCommand, SetHiddenCommand, SetTransitionCommand, SetLayoutCommand, SetLinkCommand, SetStrokeCommand, StrokeCommandValue, VectorFill, FormatMaskField, } from '@web-ppt/edit-core';
|
|
25
|
+
export type { EditorChange, FindTextRequest, ReplaceTextCommand, ReplaceTextScope, SlideId, TextSearchMatch, TextSearchScope, TextSearchTarget, } from '@web-ppt/edit-core';
|
|
26
|
+
export type { SelectionPaneItem } from '@web-ppt/edit-core';
|
|
27
|
+
export type { SnapMargins } from './snap';
|
|
28
|
+
export type { AffineMatrix, SlideViewport, SpacePoint } from '@web-ppt/edit-core';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RecoveryStore } from './recovery-store';
|
|
2
|
+
import type { WebPptSourceIdentity } from './source-fingerprint';
|
|
3
|
+
export interface IndexedDbRecoveryStoreOptions {
|
|
4
|
+
readonly databaseName?: string;
|
|
5
|
+
readonly namespace?: string;
|
|
6
|
+
readonly compactAfterChunks?: number;
|
|
7
|
+
readonly compactToChunks?: number;
|
|
8
|
+
readonly maxJournals?: number;
|
|
9
|
+
readonly maxBytes?: number;
|
|
10
|
+
readonly retentionMs?: number;
|
|
11
|
+
/** 允许 Worker、测试或受控环境注入 IDBFactory;模块导入本身不读取 indexedDB。 */
|
|
12
|
+
readonly factory?: IDBFactory;
|
|
13
|
+
readonly now?: () => number;
|
|
14
|
+
}
|
|
15
|
+
export interface RecoveryStoreStats {
|
|
16
|
+
readonly journalCount: number;
|
|
17
|
+
readonly chunkCount: number;
|
|
18
|
+
readonly frameCount: number;
|
|
19
|
+
readonly estimatedBytes: number;
|
|
20
|
+
}
|
|
21
|
+
export interface RecoveryCleanupResult {
|
|
22
|
+
readonly journalsRemoved: number;
|
|
23
|
+
readonly estimatedBytesRemoved: number;
|
|
24
|
+
}
|
|
25
|
+
export interface IndexedDbRecoveryStore extends RecoveryStore {
|
|
26
|
+
stats(): Promise<RecoveryStoreStats>;
|
|
27
|
+
cleanup(preserveFingerprint?: WebPptSourceIdentity['fingerprint']): Promise<RecoveryCleanupResult>;
|
|
28
|
+
close(): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export declare function createIndexedDbRecoveryStore(options?: IndexedDbRecoveryStoreOptions): IndexedDbRecoveryStore;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { KeyboardControllerOptions } from './keyboard-context';
|
|
2
|
+
/** 删除键只组合公开命令;占位符清空与递归删除语义由 headless RemoveElement 决定。 */
|
|
3
|
+
export declare class DeleteKeyboardController {
|
|
4
|
+
private readonly options;
|
|
5
|
+
constructor(options: KeyboardControllerOptions);
|
|
6
|
+
keyDown(event: KeyboardEvent): boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { KeyboardControllerOptions } from './keyboard-context';
|
|
2
|
+
/** 历史快捷键只负责把画布事件路由到公开 Editor;历史语义仍由 headless 内核拥有。 */
|
|
3
|
+
export declare class HistoryKeyboardController {
|
|
4
|
+
private readonly options;
|
|
5
|
+
constructor(options: KeyboardControllerOptions);
|
|
6
|
+
keyDown(event: KeyboardEvent): boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { KeyboardControllerOptions } from './keyboard-context';
|
|
2
|
+
/** PowerPoint 层级快捷键只编排公开 SetZ;排序规则属于选区语义,不泄漏进 DOM。 */
|
|
3
|
+
export declare class LayerKeyboardController {
|
|
4
|
+
private readonly options;
|
|
5
|
+
constructor(options: KeyboardControllerOptions);
|
|
6
|
+
keyDown(event: KeyboardEvent): boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { KeyboardControllerOptions } from './keyboard-context';
|
|
2
|
+
export declare class KeyboardNudgeController {
|
|
3
|
+
private readonly options;
|
|
4
|
+
private readonly activeHolds;
|
|
5
|
+
private nextHold;
|
|
6
|
+
constructor(options: KeyboardControllerOptions);
|
|
7
|
+
keyDown(event: KeyboardEvent): boolean;
|
|
8
|
+
keyUp(event: KeyboardEvent): boolean;
|
|
9
|
+
breakSequence(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** closed Shadow 会隐藏真实目标;画布只拥有直接发往视图根的键盘事件,全部后代都应让位。 */
|
|
2
|
+
export declare function shouldYieldKeyboardEvent(event: KeyboardEvent): boolean;
|
|
3
|
+
/** SVG 舞台属于画布;closed Shadow 隐藏内部表单时用焦点重定向识别宿主。 */
|
|
4
|
+
export declare function shouldYieldClipboardEvent(event: ClipboardEvent): boolean;
|
|
5
|
+
export declare function shouldYieldPointerEvent(event: PointerEvent): boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Editor, ElementId } from '@web-ppt/edit-core';
|
|
2
|
+
interface MarqueeGestureOptions {
|
|
3
|
+
root: HTMLElement;
|
|
4
|
+
stage: HTMLElement;
|
|
5
|
+
interactionLayer: SVGSVGElement;
|
|
6
|
+
editor: Editor;
|
|
7
|
+
zoom(): number;
|
|
8
|
+
candidateIds(enteredGroup: ElementId | null): ElementId[];
|
|
9
|
+
}
|
|
10
|
+
export declare class MarqueeGestureController {
|
|
11
|
+
private readonly options;
|
|
12
|
+
private readonly lifecycle;
|
|
13
|
+
private session;
|
|
14
|
+
constructor(options: MarqueeGestureOptions);
|
|
15
|
+
get isActive(): boolean;
|
|
16
|
+
begin(event: PointerEvent, enteredGroup: ElementId | null): void;
|
|
17
|
+
move(event: PointerEvent): void;
|
|
18
|
+
modifier(event: KeyboardEvent): boolean;
|
|
19
|
+
finish(event: PointerEvent): void;
|
|
20
|
+
cancel(): void;
|
|
21
|
+
cancelPointer(event: PointerEvent): void;
|
|
22
|
+
private toSlide;
|
|
23
|
+
private startPreview;
|
|
24
|
+
private rectangle;
|
|
25
|
+
private selectionAt;
|
|
26
|
+
private applyFrame;
|
|
27
|
+
private commit;
|
|
28
|
+
private combinedSelectionAt;
|
|
29
|
+
private clearPreview;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Editor, ElementId } from '@web-ppt/edit-core';
|
|
2
|
+
import type { SnapMargins } from './snap';
|
|
3
|
+
interface MoveGestureOptions {
|
|
4
|
+
root: HTMLElement;
|
|
5
|
+
stage: HTMLElement;
|
|
6
|
+
staticLayer: HTMLElement;
|
|
7
|
+
interactionLayer: SVGSVGElement;
|
|
8
|
+
editor: Editor;
|
|
9
|
+
zoom: () => number;
|
|
10
|
+
snapping: () => boolean;
|
|
11
|
+
margins: () => SnapMargins | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare class MoveGestureController {
|
|
14
|
+
private readonly options;
|
|
15
|
+
private readonly lifecycle;
|
|
16
|
+
constructor(options: MoveGestureOptions);
|
|
17
|
+
get isActive(): boolean;
|
|
18
|
+
begin(event: PointerEvent, ids: readonly ElementId[]): void;
|
|
19
|
+
move(event: PointerEvent): void;
|
|
20
|
+
finish(event: PointerEvent): void;
|
|
21
|
+
modifier(event: KeyboardEvent): boolean;
|
|
22
|
+
cancel(): void;
|
|
23
|
+
cancelPointer(event: PointerEvent): void;
|
|
24
|
+
private toSlide;
|
|
25
|
+
private positions;
|
|
26
|
+
private startPreview;
|
|
27
|
+
private proposal;
|
|
28
|
+
private applyFrame;
|
|
29
|
+
private commit;
|
|
30
|
+
private clearPreview;
|
|
31
|
+
private selectionBounds;
|
|
32
|
+
private siblingTargets;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { SpacePoint } from '@web-ppt/edit-core';
|
|
2
|
+
export interface PointerGestureSnapshot {
|
|
3
|
+
screen: SpacePoint;
|
|
4
|
+
altKey: boolean;
|
|
5
|
+
ctrlKey: boolean;
|
|
6
|
+
metaKey: boolean;
|
|
7
|
+
shiftKey: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface PointerGesture {
|
|
10
|
+
cursor: string;
|
|
11
|
+
dataset: {
|
|
12
|
+
name: string;
|
|
13
|
+
value: string;
|
|
14
|
+
};
|
|
15
|
+
start(): void;
|
|
16
|
+
observePointer?(snapshot: PointerGestureSnapshot): void;
|
|
17
|
+
frame(snapshot: PointerGestureSnapshot): void;
|
|
18
|
+
finish(snapshot: PointerGestureSnapshot): (() => void) | null;
|
|
19
|
+
clear(): void;
|
|
20
|
+
}
|
|
21
|
+
export declare class PointerGestureLifecycle {
|
|
22
|
+
private readonly root;
|
|
23
|
+
private active;
|
|
24
|
+
constructor(root: HTMLElement);
|
|
25
|
+
get isActive(): boolean;
|
|
26
|
+
begin(event: PointerEvent, gesture: PointerGesture): void;
|
|
27
|
+
move(event: PointerEvent): void;
|
|
28
|
+
finish(event: PointerEvent): 'ignored' | 'click' | 'gesture';
|
|
29
|
+
/** 键盘确认使用最后一次指针快照;先清理 capture/rAF,再执行提交,避免订阅回调重入活动手势。 */
|
|
30
|
+
commit(): boolean;
|
|
31
|
+
modifier(event: KeyboardEvent): boolean;
|
|
32
|
+
cancel(): void;
|
|
33
|
+
cancelPointer(event: PointerEvent): void;
|
|
34
|
+
private updateSnapshot;
|
|
35
|
+
private scheduleFrame;
|
|
36
|
+
private clear;
|
|
37
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Editor } from '@web-ppt/edit-core';
|
|
2
|
+
import type { EditorRecovery, RecoveryOptions } from './recovery-store';
|
|
3
|
+
import type { WebPptSourceIdentity } from './source-fingerprint';
|
|
4
|
+
/** 编辑提交只入内存队列;IndexedDB 等慢存储始终在 microtask 后串行执行。 */
|
|
5
|
+
export declare class RecoverySessionController implements EditorRecovery {
|
|
6
|
+
readonly source: WebPptSourceIdentity;
|
|
7
|
+
private readonly options;
|
|
8
|
+
private readonly idPrefix;
|
|
9
|
+
private readonly epoch;
|
|
10
|
+
private readonly unsubscribe;
|
|
11
|
+
private queued;
|
|
12
|
+
private tail;
|
|
13
|
+
private scheduled;
|
|
14
|
+
private failure;
|
|
15
|
+
private stopped;
|
|
16
|
+
private pendingFrames;
|
|
17
|
+
constructor(editor: Editor, source: WebPptSourceIdentity, options: RecoveryOptions, epoch: string);
|
|
18
|
+
get pending(): number;
|
|
19
|
+
get error(): unknown | null;
|
|
20
|
+
flush(): Promise<void>;
|
|
21
|
+
dispose(): void;
|
|
22
|
+
private enqueue;
|
|
23
|
+
private drain;
|
|
24
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { RecoveryFrame } from '@web-ppt/edit-core';
|
|
2
|
+
import type { WebPptSourceIdentity } from './source-fingerprint';
|
|
3
|
+
export interface RecoveryStoreJournal {
|
|
4
|
+
readonly version: 1;
|
|
5
|
+
readonly source: WebPptSourceIdentity;
|
|
6
|
+
readonly idPrefix: string;
|
|
7
|
+
readonly epoch: string;
|
|
8
|
+
readonly createdAt: number;
|
|
9
|
+
readonly updatedAt: number;
|
|
10
|
+
readonly estimatedBytes: number;
|
|
11
|
+
readonly frames: readonly RecoveryFrame[];
|
|
12
|
+
}
|
|
13
|
+
export interface RecoveryStoreAppend {
|
|
14
|
+
readonly source: WebPptSourceIdentity;
|
|
15
|
+
readonly idPrefix: string;
|
|
16
|
+
readonly epoch: string;
|
|
17
|
+
readonly frames: readonly RecoveryFrame[];
|
|
18
|
+
}
|
|
19
|
+
export interface RecoveryStoreReset {
|
|
20
|
+
readonly source: WebPptSourceIdentity;
|
|
21
|
+
readonly idPrefix: string;
|
|
22
|
+
/** 每次放弃/清理旧链都会换代,使旧页面的晚到追加必然失败。 */
|
|
23
|
+
readonly epoch: string;
|
|
24
|
+
/** store 必须在原子提交前响应取消,避免过期打开覆盖新会话代际。 */
|
|
25
|
+
readonly signal?: AbortSignal;
|
|
26
|
+
}
|
|
27
|
+
/** 宿主可替换此 seam;存储实现必须在 append Promise 完成前原子提交整批帧。 */
|
|
28
|
+
export interface RecoveryStore {
|
|
29
|
+
load(source: WebPptSourceIdentity): Promise<RecoveryStoreJournal | null>;
|
|
30
|
+
reset(request: RecoveryStoreReset): Promise<void>;
|
|
31
|
+
append(request: RecoveryStoreAppend): Promise<void>;
|
|
32
|
+
remove(source: WebPptSourceIdentity): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export interface RecoveryCandidate {
|
|
35
|
+
readonly fingerprint: WebPptSourceIdentity['fingerprint'];
|
|
36
|
+
readonly sourceByteLength: number;
|
|
37
|
+
readonly idPrefix: string;
|
|
38
|
+
readonly frameCount: number;
|
|
39
|
+
readonly estimatedBytes: number;
|
|
40
|
+
readonly createdAt: number;
|
|
41
|
+
readonly updatedAt: number;
|
|
42
|
+
readonly dirty: true;
|
|
43
|
+
readonly latestLabel: string;
|
|
44
|
+
}
|
|
45
|
+
export type RecoveryDecision = 'restore' | 'discard' | 'cancel';
|
|
46
|
+
export type RecoveryDecisionHandler = (candidate: RecoveryCandidate) => RecoveryDecision | Promise<RecoveryDecision>;
|
|
47
|
+
export interface RecoveryOptions {
|
|
48
|
+
readonly store: RecoveryStore;
|
|
49
|
+
/** adapter 可改由 onRecovery 提供;直接 openEditor 在发现候选时必须提供。 */
|
|
50
|
+
readonly decide?: RecoveryDecisionHandler;
|
|
51
|
+
readonly onError?: (error: unknown) => void;
|
|
52
|
+
/** 框架适配器用它取消过期候选与占位;宿主也可直接控制打开流程。 */
|
|
53
|
+
readonly signal?: AbortSignal;
|
|
54
|
+
}
|
|
55
|
+
export interface EditorRecovery {
|
|
56
|
+
readonly source: WebPptSourceIdentity;
|
|
57
|
+
readonly pending: number;
|
|
58
|
+
readonly error: unknown | null;
|
|
59
|
+
flush(): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export declare class RecoveryOpenCancelledError extends Error {
|
|
62
|
+
readonly candidate: RecoveryCandidate;
|
|
63
|
+
constructor(candidate: RecoveryCandidate);
|
|
64
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { EditDoc, ElementId, SpacePoint } from '@web-ppt/edit-core';
|
|
2
|
+
import type { TransformFrame } from './transform-frame';
|
|
3
|
+
export declare const RESIZE_HANDLES: readonly ["nw", "n", "ne", "e", "se", "s", "sw", "w"];
|
|
4
|
+
export type ResizeHandle = typeof RESIZE_HANDLES[number];
|
|
5
|
+
export declare function isResizeHandle(value: string | undefined): value is ResizeHandle;
|
|
6
|
+
export interface ResizeModifiers {
|
|
7
|
+
altKey: boolean;
|
|
8
|
+
shiftKey: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const MIN_RESIZE_SIZE: number;
|
|
11
|
+
export declare const RESIZE_HANDLE_AXES: Record<ResizeHandle, readonly [number, number]>;
|
|
12
|
+
export declare function resizeHandleAfterFlip(handle: ResizeHandle, horizontal: boolean, vertical: boolean): ResizeHandle;
|
|
13
|
+
export declare function resizeElementFrame(source: TransformFrame, handle: ResizeHandle, pointerInParent: SpacePoint, modifiers?: ResizeModifiers): TransformFrame;
|
|
14
|
+
interface MultiResizeTarget {
|
|
15
|
+
id: ElementId;
|
|
16
|
+
source: TransformFrame;
|
|
17
|
+
}
|
|
18
|
+
export declare function resizeMultiElementFrames(doc: EditDoc, targets: readonly MultiResizeTarget[], selectionSource: TransformFrame, selectionNext: TransformFrame): TransformFrame[];
|
|
19
|
+
export {};
|