@dajiaoai/algeo-sdk 2.8.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -9
- package/dist/algeo-sdk.cjs.js +12 -1
- package/dist/algeo-sdk.esm.js +12 -1
- package/dist/algeo-sdk.umd.js +12 -1
- package/dist/index.d.ts +1 -1
- package/dist/shared.d.ts +16 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -77,6 +77,9 @@ presentation
|
|
|
77
77
|
.getSlideCount()
|
|
78
78
|
.then(({ count }) => console.log('画板数量:', count));
|
|
79
79
|
presentation.switchSlide(1).then(() => console.log('切换画板'));
|
|
80
|
+
presentation.mode
|
|
81
|
+
.setMasterTemplate(masterTemplateContent)
|
|
82
|
+
.then(() => console.log('母版风格已更新'));
|
|
80
83
|
|
|
81
84
|
// 销毁
|
|
82
85
|
// presentation.destroy();
|
|
@@ -134,6 +137,8 @@ editor.on('slideChange', (event) => {
|
|
|
134
137
|
console.log('用户切换后的最新画板索引', event.index);
|
|
135
138
|
});
|
|
136
139
|
|
|
140
|
+
await editor.mode.setMasterTemplate(masterTemplateContent);
|
|
141
|
+
|
|
137
142
|
editor.on('save', async (event) => {
|
|
138
143
|
if (event.stage === 'request') {
|
|
139
144
|
const response = await fetch('/api/geometry-doc/save', {
|
|
@@ -185,6 +190,15 @@ editor.on('aiRequest', async ({ payload, signal }) => {
|
|
|
185
190
|
editor.on('aiCancel', ({ runId, reason }) => {
|
|
186
191
|
console.log('用户取消 AI 生成', runId, reason);
|
|
187
192
|
});
|
|
193
|
+
|
|
194
|
+
await editor.ai.setDraft({
|
|
195
|
+
text: '请根据这张图生成一道几何题',
|
|
196
|
+
images: ['https://example.com/figure.png'],
|
|
197
|
+
openPanel: true,
|
|
198
|
+
focus: true,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
await editor.ai.clearDraft();
|
|
188
202
|
```
|
|
189
203
|
|
|
190
204
|
编辑器内嵌页点击保存按钮时,会触发 `editor.on('save', listener)` 的请求阶段监听器。只有宿主返回 `{ status: 'success' }` 后,iframe 才会展示成功态,并向外触发 `save` 的成功阶段事件。
|
|
@@ -358,10 +372,11 @@ const presentation = await create(container, {
|
|
|
358
372
|
|
|
359
373
|
##### `presentation.mode`
|
|
360
374
|
|
|
361
|
-
| 方法
|
|
362
|
-
|
|
|
363
|
-
| `getUiConfig()`
|
|
364
|
-
| `setUiConfig(config)`
|
|
375
|
+
| 方法 | 说明 |
|
|
376
|
+
| ----------------------------- | ---------------- |
|
|
377
|
+
| `getUiConfig()` | 获取当前 UI 配置 |
|
|
378
|
+
| `setUiConfig(config)` | 更新 UI 配置 |
|
|
379
|
+
| `setMasterTemplate(template)` | 设置母版风格 |
|
|
365
380
|
|
|
366
381
|
##### `presentation.loadShareById(id: string): Promise<LoadShareByIdResult>`
|
|
367
382
|
|
|
@@ -476,7 +491,7 @@ interface FileContent {
|
|
|
476
491
|
| `remove(index)` | 删除指定画板 |
|
|
477
492
|
| `duplicate(index, targetIndex?)` | 复制画板 |
|
|
478
493
|
| `reorder(fromIndex, toIndex)` | 重排画板 |
|
|
479
|
-
| `exportImage(options?)` |
|
|
494
|
+
| `exportImage(options?)` | 导出画板为图片或可编辑排版内容,返回 `ExportedSlideImage[]`,每项含 `index`、`blob`、`format`、`width`、`height`。可选参数 `slideIndices`(1-based,不传则导出全部)、`format`(`'png'`/`'jpg'`/`'svg'`/`'latex'`)、`width`、`height`、`quality`(0~1,仅 jpg)、`autoFit`、`padding` |
|
|
480
495
|
|
|
481
496
|
#### `editor.history`
|
|
482
497
|
|
|
@@ -493,15 +508,18 @@ interface FileContent {
|
|
|
493
508
|
|
|
494
509
|
#### `editor.mode`
|
|
495
510
|
|
|
496
|
-
| 方法
|
|
497
|
-
|
|
|
498
|
-
| `getUiConfig()`
|
|
499
|
-
| `setUiConfig(config)`
|
|
511
|
+
| 方法 | 说明 |
|
|
512
|
+
| ----------------------------- | ---------------- |
|
|
513
|
+
| `getUiConfig()` | 获取当前 UI 配置 |
|
|
514
|
+
| `setUiConfig(config)` | 更新 UI 配置 |
|
|
515
|
+
| `setMasterTemplate(template)` | 设置母版风格 |
|
|
500
516
|
|
|
501
517
|
#### `editor.ai`
|
|
502
518
|
|
|
503
519
|
| 方法 | 说明 |
|
|
504
520
|
| ------------------- | ------------------------------------------------------------------- |
|
|
521
|
+
| `setDraft()` | 设置 AI 对话框草稿,支持 `text`、`images`、`openPanel`、`focus` |
|
|
522
|
+
| `clearDraft()` | 清空 AI 对话框草稿文本与图片 |
|
|
505
523
|
| `consumeStream()` | 消费接入方后端返回的大角几何标准 SSE 流,并实时转发给 iframe |
|
|
506
524
|
| `pushStreamEvent()` | 高级接口;接入方已自行解析 SSE 或使用非标准传输时,手动推送流式事件 |
|
|
507
525
|
|
package/dist/algeo-sdk.cjs.js
CHANGED
|
@@ -4011,7 +4011,7 @@ function convertToLatest(content) {
|
|
|
4011
4011
|
}
|
|
4012
4012
|
|
|
4013
4013
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
4014
|
-
const VERSION = '2.
|
|
4014
|
+
const VERSION = '2.9.0';
|
|
4015
4015
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
4016
4016
|
const DEFAULT_PRESENTATION_PATH = '/e';
|
|
4017
4017
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4325,6 +4325,10 @@ class EmbeddedPresentation extends EmbeddedTarget {
|
|
|
4325
4325
|
...config,
|
|
4326
4326
|
};
|
|
4327
4327
|
},
|
|
4328
|
+
setMasterTemplate: (template) => {
|
|
4329
|
+
this.ensureWhitelistAccess('setMasterTemplate');
|
|
4330
|
+
return this.post('setMasterTemplate', { template });
|
|
4331
|
+
},
|
|
4328
4332
|
};
|
|
4329
4333
|
}
|
|
4330
4334
|
async initialize(options = {}, baseUrl) {
|
|
@@ -4466,8 +4470,15 @@ class EmbeddedEditor extends EmbeddedTarget {
|
|
|
4466
4470
|
...config,
|
|
4467
4471
|
};
|
|
4468
4472
|
},
|
|
4473
|
+
setMasterTemplate: (template) => this.post('setMasterTemplate', { template }),
|
|
4469
4474
|
};
|
|
4470
4475
|
this.ai = {
|
|
4476
|
+
setDraft: async (draft) => {
|
|
4477
|
+
await this.post('setAiDraft', { draft });
|
|
4478
|
+
},
|
|
4479
|
+
clearDraft: async () => {
|
|
4480
|
+
await this.post('clearAiDraft', {});
|
|
4481
|
+
},
|
|
4471
4482
|
consumeStream: async ({ stream, signal }) => {
|
|
4472
4483
|
await this.consumeAiStream(stream, signal);
|
|
4473
4484
|
},
|
package/dist/algeo-sdk.esm.js
CHANGED
|
@@ -4009,7 +4009,7 @@ function convertToLatest(content) {
|
|
|
4009
4009
|
}
|
|
4010
4010
|
|
|
4011
4011
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
4012
|
-
const VERSION = '2.
|
|
4012
|
+
const VERSION = '2.9.0';
|
|
4013
4013
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
4014
4014
|
const DEFAULT_PRESENTATION_PATH = '/e';
|
|
4015
4015
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4323,6 +4323,10 @@ class EmbeddedPresentation extends EmbeddedTarget {
|
|
|
4323
4323
|
...config,
|
|
4324
4324
|
};
|
|
4325
4325
|
},
|
|
4326
|
+
setMasterTemplate: (template) => {
|
|
4327
|
+
this.ensureWhitelistAccess('setMasterTemplate');
|
|
4328
|
+
return this.post('setMasterTemplate', { template });
|
|
4329
|
+
},
|
|
4326
4330
|
};
|
|
4327
4331
|
}
|
|
4328
4332
|
async initialize(options = {}, baseUrl) {
|
|
@@ -4464,8 +4468,15 @@ class EmbeddedEditor extends EmbeddedTarget {
|
|
|
4464
4468
|
...config,
|
|
4465
4469
|
};
|
|
4466
4470
|
},
|
|
4471
|
+
setMasterTemplate: (template) => this.post('setMasterTemplate', { template }),
|
|
4467
4472
|
};
|
|
4468
4473
|
this.ai = {
|
|
4474
|
+
setDraft: async (draft) => {
|
|
4475
|
+
await this.post('setAiDraft', { draft });
|
|
4476
|
+
},
|
|
4477
|
+
clearDraft: async () => {
|
|
4478
|
+
await this.post('clearAiDraft', {});
|
|
4479
|
+
},
|
|
4469
4480
|
consumeStream: async ({ stream, signal }) => {
|
|
4470
4481
|
await this.consumeAiStream(stream, signal);
|
|
4471
4482
|
},
|
package/dist/algeo-sdk.umd.js
CHANGED
|
@@ -4015,7 +4015,7 @@
|
|
|
4015
4015
|
}
|
|
4016
4016
|
|
|
4017
4017
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
4018
|
-
const VERSION = '2.
|
|
4018
|
+
const VERSION = '2.9.0';
|
|
4019
4019
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
4020
4020
|
const DEFAULT_PRESENTATION_PATH = '/e';
|
|
4021
4021
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4329,6 +4329,10 @@
|
|
|
4329
4329
|
...config,
|
|
4330
4330
|
};
|
|
4331
4331
|
},
|
|
4332
|
+
setMasterTemplate: (template) => {
|
|
4333
|
+
this.ensureWhitelistAccess('setMasterTemplate');
|
|
4334
|
+
return this.post('setMasterTemplate', { template });
|
|
4335
|
+
},
|
|
4332
4336
|
};
|
|
4333
4337
|
}
|
|
4334
4338
|
async initialize(options = {}, baseUrl) {
|
|
@@ -4470,8 +4474,15 @@
|
|
|
4470
4474
|
...config,
|
|
4471
4475
|
};
|
|
4472
4476
|
},
|
|
4477
|
+
setMasterTemplate: (template) => this.post('setMasterTemplate', { template }),
|
|
4473
4478
|
};
|
|
4474
4479
|
this.ai = {
|
|
4480
|
+
setDraft: async (draft) => {
|
|
4481
|
+
await this.post('setAiDraft', { draft });
|
|
4482
|
+
},
|
|
4483
|
+
clearDraft: async () => {
|
|
4484
|
+
await this.post('clearAiDraft', {});
|
|
4485
|
+
},
|
|
4475
4486
|
consumeStream: async ({ stream, signal }) => {
|
|
4476
4487
|
await this.consumeAiStream(stream, signal);
|
|
4477
4488
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AlgeoError, EMBED_ERROR_CODES, VERSION } from './shared';
|
|
2
2
|
export type { FileContentLatest } from '@dajiaoai/algeo-protocol';
|
|
3
3
|
export { convertToLatest } from '@dajiaoai/algeo-protocol';
|
|
4
|
-
export type { AiApi, AiCancelEvent, AiRawSseEventV1, AiRequestEvent, AiRunPayloadV1, AiStreamEventV1, AlgeoCreateOptions, AlgeoEditorAuthOptions, AlgeoEditorCreateOptions, AlgeoEditorSaveResult, AlgeoEditorUiConfig, AlgeoEmbedMode, AlgeoErrorPayload, AlgeoPresentationCreateOptions, AlgeoPresentationUiConfig, ContentChangeEvent, DocumentApi, EmbeddedEditorEventListenerMap, EmbeddedEditorEventMap, EmbeddedEditorEventName, EmbeddedPresentationEventListenerMap, EmbeddedPresentationEventMap, EmbeddedPresentationEventName, ExportSlideImageOptions, ExportedSlideImage, ExportSlideImageResult, GetContentResult, GetSlideCountResult, HistoryApi, LoadFileResult, LoadShareByIdResult, ModeApi, PresentationModeApi, ReadyEvent, ReplResult, SlideChangeEvent, SlideIndexResult, SlidesApi, SwitchSlideResult, SaveEvent, } from './shared';
|
|
4
|
+
export type { AiApi, AiCancelEvent, AiRawSseEventV1, AiRequestEvent, AiRunPayloadV1, AiStreamEventV1, AlgeoCreateOptions, AlgeoEditorAuthOptions, AlgeoEditorCreateOptions, AlgeoEditorSaveResult, AlgeoEditorUiConfig, AlgeoEmbedMode, AlgeoErrorPayload, AlgeoPresentationCreateOptions, AlgeoPresentationUiConfig, ContentChangeEvent, DocumentApi, EmbeddedEditorEventListenerMap, EmbeddedEditorEventMap, EmbeddedEditorEventName, EmbeddedPresentationEventListenerMap, EmbeddedPresentationEventMap, EmbeddedPresentationEventName, ExportImageFormat, ExportSlideImageOptions, ExportedSlideImage, ExportSlideImageResult, GetContentResult, GetSlideCountResult, HistoryApi, LoadFileResult, LoadShareByIdResult, ModeApi, PresentationModeApi, ReadyEvent, ReplResult, SlideChangeEvent, SlideIndexResult, SlidesApi, SwitchSlideResult, SaveEvent, } from './shared';
|
|
5
5
|
export { EmbeddedPresentation } from './embedded-presentation';
|
|
6
6
|
export { EmbeddedEditor } from './embedded-editor';
|
|
7
7
|
export { AlgeoSdk, create, createEditor, createPresentation, type EmbeddedInstance, } from './sdk';
|
package/dist/shared.d.ts
CHANGED
|
@@ -88,12 +88,20 @@ export interface SaveRequestMessage {
|
|
|
88
88
|
content: FileContentLatest;
|
|
89
89
|
}
|
|
90
90
|
export interface AiApi {
|
|
91
|
+
setDraft(draft: AiDraftPayloadV1): Promise<void>;
|
|
92
|
+
clearDraft(): Promise<void>;
|
|
91
93
|
consumeStream(input: {
|
|
92
94
|
stream: ReadableStream<Uint8Array>;
|
|
93
95
|
signal?: AbortSignal;
|
|
94
96
|
}): Promise<void>;
|
|
95
97
|
pushStreamEvent(event: AiStreamEventV1): void;
|
|
96
98
|
}
|
|
99
|
+
export interface AiDraftPayloadV1 {
|
|
100
|
+
text?: string;
|
|
101
|
+
images?: string[];
|
|
102
|
+
openPanel?: boolean;
|
|
103
|
+
focus?: boolean;
|
|
104
|
+
}
|
|
97
105
|
export interface AiRequestEvent {
|
|
98
106
|
type: 'aiRequest';
|
|
99
107
|
payload: AiRunPayloadV1;
|
|
@@ -139,6 +147,9 @@ export interface LoadShareByIdResult {
|
|
|
139
147
|
export interface LoadFileResult {
|
|
140
148
|
success: true;
|
|
141
149
|
}
|
|
150
|
+
export interface SetMasterTemplateResult {
|
|
151
|
+
success: true;
|
|
152
|
+
}
|
|
142
153
|
export interface SwitchSlideResult {
|
|
143
154
|
success: true;
|
|
144
155
|
}
|
|
@@ -151,9 +162,10 @@ export interface ReplResult {
|
|
|
151
162
|
export interface SlideIndexResult {
|
|
152
163
|
index: number;
|
|
153
164
|
}
|
|
165
|
+
export type ExportImageFormat = 'png' | 'jpg' | 'svg' | 'latex';
|
|
154
166
|
export interface ExportSlideImageOptions {
|
|
155
167
|
slideIndices?: number[];
|
|
156
|
-
format?:
|
|
168
|
+
format?: ExportImageFormat;
|
|
157
169
|
width?: number;
|
|
158
170
|
height?: number;
|
|
159
171
|
quality?: number;
|
|
@@ -163,7 +175,7 @@ export interface ExportSlideImageOptions {
|
|
|
163
175
|
export interface ExportedSlideImage {
|
|
164
176
|
index: number;
|
|
165
177
|
blob: Blob;
|
|
166
|
-
format:
|
|
178
|
+
format: ExportImageFormat;
|
|
167
179
|
width: number;
|
|
168
180
|
height: number;
|
|
169
181
|
}
|
|
@@ -207,10 +219,12 @@ export interface HistoryApi {
|
|
|
207
219
|
export interface ModeApi {
|
|
208
220
|
getUiConfig(): AlgeoEditorUiConfig;
|
|
209
221
|
setUiConfig(config: Partial<AlgeoEditorUiConfig>): Promise<void>;
|
|
222
|
+
setMasterTemplate(template: string): Promise<SetMasterTemplateResult>;
|
|
210
223
|
}
|
|
211
224
|
export interface PresentationModeApi {
|
|
212
225
|
getUiConfig(): AlgeoPresentationUiConfig;
|
|
213
226
|
setUiConfig(config: Partial<AlgeoPresentationUiConfig>): Promise<void>;
|
|
227
|
+
setMasterTemplate(template: string): Promise<SetMasterTemplateResult>;
|
|
214
228
|
}
|
|
215
229
|
export declare function generateRequestId(): string;
|
|
216
230
|
export declare function isResponseMessage(msg: unknown): msg is EmbedResponseMessage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dajiaoai/algeo-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "大角几何内嵌画板 SDK,支持 iframe 挂载与 postMessage 通信",
|
|
5
5
|
"main": "dist/algeo-sdk.cjs.js",
|
|
6
6
|
"module": "dist/algeo-sdk.esm.js",
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"typescript": "^5.9.3"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@dajiaoai/algeo-protocol": "^1.5.
|
|
45
|
+
"@dajiaoai/algeo-protocol": "^1.5.2"
|
|
46
46
|
}
|
|
47
47
|
}
|