weifuwu 0.85.0 → 0.86.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.
Files changed (41) hide show
  1. package/README.md +5 -5
  2. package/dist/components/Editor/Editor.d.ts +8 -7
  3. package/dist/components/Editor/edit-events.d.ts +27 -0
  4. package/dist/components/Editor/model/apply.d.ts +23 -0
  5. package/dist/components/Editor/model/diff.d.ts +25 -0
  6. package/dist/components/Editor/model/dom.d.ts +27 -0
  7. package/dist/components/Editor/model/history.d.ts +21 -0
  8. package/dist/components/Editor/model/html.d.ts +16 -0
  9. package/dist/components/Editor/model/inverse.d.ts +20 -0
  10. package/dist/components/Editor/model/types.d.ts +116 -0
  11. package/dist/components/Editor/tools/table.d.ts +5 -2
  12. package/dist/components/Editor/tools/toolbar.d.ts +1 -1
  13. package/dist/components/Editor/tools/types.d.ts +25 -0
  14. package/dist/components/FilePreview/FilePreview.d.ts +42 -0
  15. package/dist/components/FilePreview/markdown.d.ts +23 -0
  16. package/dist/components/OfficeEditor/ai/ai-bridge.d.ts +39 -0
  17. package/dist/components/OfficeEditor/model/apply.d.ts +25 -0
  18. package/dist/components/OfficeEditor/model/types.d.ts +224 -0
  19. package/dist/components/SheetGrid/SheetGrid.d.ts +30 -0
  20. package/dist/components/SlideCanvas/SlideCanvas.d.ts +28 -0
  21. package/dist/components/index.d.ts +7 -0
  22. package/dist/components/index.js +54 -14
  23. package/dist/components/style.css +679 -4
  24. package/dist/index.js +38 -11
  25. package/dist/office/docx.d.ts +33 -0
  26. package/dist/office/pptx.d.ts +24 -0
  27. package/dist/office/xlsx.d.ts +25 -0
  28. package/dist/office/xml-serialize.d.ts +18 -0
  29. package/dist/office/xml.d.ts +21 -0
  30. package/dist/office/zip.d.ts +21 -0
  31. package/dist/ui-dom/index.js +7 -7
  32. package/dist/ui-dom/locale/en_US.d.ts +14 -0
  33. package/dist/ui-dom/locale/zh_CN.d.ts +14 -0
  34. package/dist/ui-dom/testing.js +5 -5
  35. package/dist/ui-dom/types.d.ts +3 -1
  36. package/dist/ui-dom/vdom3/delegate.d.ts +5 -0
  37. package/dist/ui-dom/vdom3.js +7 -7
  38. package/docs/components-map.md +12 -0
  39. package/docs/components.md +124 -2
  40. package/package.json +1 -1
  41. package/dist/components/Editor/tools/format.d.ts +0 -11
@@ -0,0 +1,224 @@
1
+ /**
2
+ * weifuwu/components/OfficeEditor/model — ODES(office 文档事件流标准)协议层
3
+ *
4
+ * 设计(design/office-events-plan.md):
5
+ * - 文档状态 = fold(事件流)(与 Editor/ai/sandbox 四端同构)
6
+ * - docx 的 IR = Editor DocState(op = EditEvent 全量复用——段落流同构)
7
+ * - xlsx = 网格模型(稀疏 cells Map——`A1` 引用语义)
8
+ * - pptx = 画布模型(slide → shape 集合——几何 + 层叠)
9
+ * - checkpoint = 快照 + tail(导入 = 服务端转换出 snapshot;编辑 append op;
10
+ * 导出 = fold → IR → 服务端渲染 OOXML——前端零依赖)
11
+ */
12
+ import type { DocState, EditEvent } from '../../Editor/model/types.ts';
13
+ export type DocType = 'docx' | 'xlsx' | 'pptx';
14
+ export type CellKind = 's' | 'n' | 'b' | 'f';
15
+ export interface CellStyle {
16
+ bold?: boolean;
17
+ italic?: boolean;
18
+ align?: 'left' | 'center' | 'right';
19
+ bg?: string;
20
+ }
21
+ export interface SheetCell {
22
+ kind: CellKind;
23
+ value: string | number | boolean;
24
+ /** kind='f' 时公式字符串(不计算——服务端导出时重算;裁剪:引用不自动调整) */
25
+ formula?: string;
26
+ style?: CellStyle;
27
+ }
28
+ export interface SheetState {
29
+ name: string;
30
+ /** 已用列数(导出行列范围) */
31
+ cols: number;
32
+ /** 'A1' → cell(稀疏) */
33
+ cells: Map<string, SheetCell>;
34
+ }
35
+ export interface WorkbookState {
36
+ sheets: SheetState[];
37
+ activeSheet: number;
38
+ }
39
+ export type ShapeKind = 'text' | 'image' | 'table' | 'rect' | 'line';
40
+ export interface ShapeProps {
41
+ text?: string;
42
+ fontSize?: number;
43
+ bold?: boolean;
44
+ fill?: string;
45
+ imageUrl?: string;
46
+ }
47
+ export interface SlideShape {
48
+ id: string;
49
+ kind: ShapeKind;
50
+ x: number;
51
+ y: number;
52
+ w: number;
53
+ h: number;
54
+ props?: ShapeProps;
55
+ }
56
+ export interface SlideState {
57
+ shapes: SlideShape[];
58
+ layout?: string;
59
+ }
60
+ export interface DeckState {
61
+ slides: SlideState[];
62
+ activeSlide: number;
63
+ size: {
64
+ w: number;
65
+ h: number;
66
+ };
67
+ }
68
+ /** checkpoint 快照(三模型联合) */
69
+ export type OfficeSnapshot = {
70
+ docType: 'docx';
71
+ doc: DocState;
72
+ } | {
73
+ docType: 'xlsx';
74
+ workbook: WorkbookState;
75
+ } | {
76
+ docType: 'pptx';
77
+ deck: DeckState;
78
+ };
79
+ export type SheetOp = {
80
+ type: 'cell-set';
81
+ sheet: number;
82
+ ref: string;
83
+ cell: SheetCell | null;
84
+ } | {
85
+ type: 'range-style';
86
+ sheet: number;
87
+ ref: string;
88
+ style: CellStyle;
89
+ } | {
90
+ type: 'insert-rows';
91
+ sheet: number;
92
+ at: number;
93
+ count: number;
94
+ } | {
95
+ type: 'delete-rows';
96
+ sheet: number;
97
+ at: number;
98
+ count: number;
99
+ } | {
100
+ type: 'insert-cols';
101
+ sheet: number;
102
+ at: number;
103
+ count: number;
104
+ } | {
105
+ type: 'delete-cols';
106
+ sheet: number;
107
+ at: number;
108
+ count: number;
109
+ } | {
110
+ type: 'sheet-add';
111
+ name: string;
112
+ } | {
113
+ type: 'sheet-rename';
114
+ sheet: number;
115
+ name: string;
116
+ } | {
117
+ type: 'sheet-delete';
118
+ sheet: number;
119
+ } | {
120
+ type: 'sheet-move';
121
+ sheet: number;
122
+ to: number;
123
+ } | {
124
+ type: 'sheet-active';
125
+ sheet: number;
126
+ };
127
+ export type SlideOp = {
128
+ type: 'slide-add';
129
+ at?: number;
130
+ layout?: string;
131
+ } | {
132
+ type: 'slide-delete';
133
+ slide: number;
134
+ } | {
135
+ type: 'slide-move';
136
+ slide: number;
137
+ to: number;
138
+ } | {
139
+ type: 'slide-active';
140
+ slide: number;
141
+ } | {
142
+ type: 'shape-add';
143
+ slide: number;
144
+ shape: SlideShape;
145
+ } | {
146
+ type: 'shape-remove';
147
+ slide: number;
148
+ shapeId: string;
149
+ } | {
150
+ type: 'shape-move';
151
+ slide: number;
152
+ shapeId: string;
153
+ x: number;
154
+ y: number;
155
+ } | {
156
+ type: 'shape-resize';
157
+ slide: number;
158
+ shapeId: string;
159
+ w: number;
160
+ h: number;
161
+ } | {
162
+ type: 'shape-set';
163
+ slide: number;
164
+ shapeId: string;
165
+ props: Partial<ShapeProps>;
166
+ };
167
+ export type OfficeOp = EditEvent | SheetOp | SlideOp;
168
+ /** 事件流外壳(payload 直接进 edit 通道——action: 'office') */
169
+ export interface OfficeStreamPayload {
170
+ docType: DocType;
171
+ /** 编辑操作(AI 拒绝/状态记录时缺省——不产生 op) */
172
+ op?: OfficeOp;
173
+ /** AI 关联(可选——跨端审计:editEvents ↔ aiEvents 一条链——messageId 关联键) */
174
+ ai?: {
175
+ messageId: string;
176
+ status: 'suggested' | 'accepted' | 'rejected';
177
+ };
178
+ }
179
+ /** OfficeEditor 的 AI 协作选项(与 Editor ai prop 同构——SSE wf: 协议) */
180
+ export interface OfficeAiOptions {
181
+ url: string;
182
+ /** 上下文模式(docType 感知默认:docx→text / xlsx→formula / pptx→shape) */
183
+ mode: 'text' | 'formula' | 'shape';
184
+ /** 自定义解析(默认按 mode:公式/值/文本 → OfficeOp[]) */
185
+ parse?: (text: string, ctx: AiContext) => OfficeOp[];
186
+ }
187
+ export interface AiContext {
188
+ docType: DocType;
189
+ /** xlsx:活动单元格 ref(A1)或选区范围(A1:B5) */
190
+ ref?: string;
191
+ /** pptx:选中 shapeId */
192
+ shapeId?: string;
193
+ /** docx:选区文本(原文——提示词输入) */
194
+ selectionText?: string;
195
+ }
196
+ export interface OfficeCommit {
197
+ label: string;
198
+ ops: OfficeOp[];
199
+ /** 操作前快照(undo 精确恢复;可逆 op 由逆操作覆盖——快照兜底) */
200
+ before: OfficeSnapshot;
201
+ ts?: number;
202
+ }
203
+ export interface OfficeCheckpoint {
204
+ docType: DocType;
205
+ /** 当前状态快照(fold 至此的起点) */
206
+ snapshot: OfficeSnapshot;
207
+ /** 快照后增量事件(可裁剪重打包——tail 超阈值 → 重新生成 snapshot) */
208
+ tail: OfficeOp[];
209
+ /** 事件流起点 id(与 edit-events 关联审计) */
210
+ baseEventId?: number;
211
+ }
212
+ export interface ImportWarning {
213
+ path: string;
214
+ issue: string;
215
+ }
216
+ export interface OfficeImportResult {
217
+ docType: DocType;
218
+ snapshot: OfficeSnapshot;
219
+ warnings: ImportWarning[];
220
+ }
221
+ export interface OfficeExportRequest {
222
+ docType: DocType;
223
+ snapshot: OfficeSnapshot;
224
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * weifuwu/components/SheetGrid — xlsx 网格编辑器(ODES 事件流底座)
3
+ *
4
+ * 设计(design/office-events-plan.md):文档 = fold(事件流)——SheetGrid 的每个
5
+ * 编辑操作 = OfficeOp(cell-set/insert-rows/...)→ editEmit('office') → commit
6
+ * (before 快照 + ops——撤销一步)。
7
+ *
8
+ * - 单元格编辑:点击进入编辑 → Enter/Blur 提交 → cell-set op
9
+ * - 行列增删:工具条按钮(作用于活动单元格)→ insert/delete op
10
+ * - 撤销:Ctrl+Z(undo 栈——恢复 before 快照——同 Editor)
11
+ * - AI 公式:选中单元格 → AI(SSE wf:)→ 回复解析(parseFormulaReply——
12
+ * 公式/数字/文本)→ 浮层确认 → cell-set commit(原子撤销;拒绝不落 op)
13
+ * - sheet 标签切换(activeSheet op——只读切换 v1)
14
+ */
15
+ import type { WorkbookState } from '../OfficeEditor/model/types.ts';
16
+ import type { Component } from '../../ui-dom/vdom3/types.ts';
17
+ export interface SheetGridProps {
18
+ /** 受控工作簿(FilePreview 传入——编辑经 onChange 回写) */
19
+ workbook: WorkbookState;
20
+ onChange?: (wb: WorkbookState) => void;
21
+ /** AI 公式(SSE wf: 协议——选中单元格 → 建议 → 接受 commit) */
22
+ ai?: {
23
+ url: string;
24
+ headers?: Record<string, string>;
25
+ };
26
+ height?: string;
27
+ /** 关闭编辑(只读展示) */
28
+ readonly?: boolean;
29
+ }
30
+ export declare const SheetGrid: Component<SheetGridProps>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * weifuwu/components/SlideCanvas — pptx 画布编辑器(ODES 事件流——阶段 3)
3
+ *
4
+ * 设计(design/office-events-plan.md):文档 = fold(事件流)——每个编辑 =
5
+ * OfficeOp(shape-add/remove/move/resize/set)→ editEmit('office') → commit。
6
+ *
7
+ * - 画布:960×540 幻灯片区域(缩放适配容器——scale 因子)
8
+ * - shape:文本(div)/矩形(背景)/图片(占位)/线条
9
+ * - 选中 + 拖动移动(pointer events);右下角 handle 缩放
10
+ * - 双击文本 shape → 编辑文本(textarea——blur/Enter 提交 → shape-set)
11
+ * - 工具条:添加文本/矩形、删除、幻灯片增删、撤销
12
+ * - AI:选中 shape → 文本润色(wf: SSE → usePopup 浮层 → 接受 = shape-set commit)
13
+ * - 事件流:全部操作 → editEmit('office', { docType: 'pptx', op }) + commit
14
+ */
15
+ import type { DeckState } from '../OfficeEditor/model/types.ts';
16
+ import type { Component } from '../../ui-dom/vdom3/types.ts';
17
+ export interface SlideCanvasProps {
18
+ /** 受控 DeckState */
19
+ deck: DeckState;
20
+ onChange?: (deck: DeckState) => void;
21
+ ai?: {
22
+ url: string;
23
+ headers?: Record<string, string>;
24
+ };
25
+ height?: string;
26
+ readonly?: boolean;
27
+ }
28
+ export declare const SlideCanvas: Component<SlideCanvasProps>;
@@ -109,6 +109,13 @@ export type { AuthPageProps } from './AuthPage/AuthPage.ts';
109
109
  export { Markdown } from './Markdown/Markdown.ts';
110
110
  export type { MarkdownProps } from './Markdown/Markdown.ts';
111
111
  export { parseMarkdown, parseInline } from './Markdown/parser.ts';
112
+ export { FilePreview } from './FilePreview/FilePreview.ts';
113
+ export { SheetGrid } from './SheetGrid/SheetGrid.ts';
114
+ export type { SheetGridProps } from './SheetGrid/SheetGrid.ts';
115
+ export { SlideCanvas } from './SlideCanvas/SlideCanvas.ts';
116
+ export type { SlideCanvasProps } from './SlideCanvas/SlideCanvas.ts';
117
+ export type { FilePreviewProps, FileType } from './FilePreview/FilePreview.ts';
118
+ export { markdownToHtml, serializeMarkdown } from './FilePreview/markdown.ts';
112
119
  export { CodeBlock } from './CodeBlock/CodeBlock.ts';
113
120
  export type { CodeBlockProps } from './CodeBlock/CodeBlock.ts';
114
121
  export { Timeline } from './Timeline/Timeline.ts';