@dajiaoai/algeo-sdk 2.6.1 → 2.7.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 +28 -15
- package/dist/algeo-sdk.cjs.js +20 -2
- package/dist/algeo-sdk.esm.js +20 -2
- package/dist/algeo-sdk.umd.js +20 -2
- package/dist/embedded-presentation.d.ts +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/shared.d.ts +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
# 安装最新版本
|
|
11
11
|
npm install @dajiaoai/algeo-sdk
|
|
12
12
|
|
|
13
|
-
#
|
|
14
|
-
npm install @dajiaoai/algeo-sdk@2.
|
|
13
|
+
# 安装指定主次版本
|
|
14
|
+
npm install @dajiaoai/algeo-sdk@2.7.0
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
在 `package.json` 中:
|
|
@@ -19,7 +19,7 @@ npm install @dajiaoai/algeo-sdk@2.6.0
|
|
|
19
19
|
```json
|
|
20
20
|
{
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@dajiaoai/algeo-sdk": "2.
|
|
22
|
+
"@dajiaoai/algeo-sdk": "~2.7.0"
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
```
|
|
@@ -29,7 +29,7 @@ npm install @dajiaoai/algeo-sdk@2.6.0
|
|
|
29
29
|
```json
|
|
30
30
|
{
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@dajiaoai/algeo-sdk": "^2.
|
|
32
|
+
"@dajiaoai/algeo-sdk": "^2.7.0" // 兼容 2.x 的更新(升级范围更大)
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
```
|
|
@@ -39,18 +39,18 @@ npm install @dajiaoai/algeo-sdk@2.6.0
|
|
|
39
39
|
**unpkg**:
|
|
40
40
|
|
|
41
41
|
```html
|
|
42
|
-
<script src="https://unpkg.com/@dajiaoai/algeo-sdk@2.
|
|
42
|
+
<script src="https://unpkg.com/@dajiaoai/algeo-sdk@2.7.0/dist/algeo-sdk.umd.min.js"></script>
|
|
43
43
|
<script src="https://unpkg.com/@dajiaoai/algeo-sdk@latest/dist/algeo-sdk.umd.min.js"></script>
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
**jsDelivr**:
|
|
47
47
|
|
|
48
48
|
```html
|
|
49
|
-
<script src="https://cdn.jsdelivr.net/npm/@dajiaoai/algeo-sdk@2.
|
|
49
|
+
<script src="https://cdn.jsdelivr.net/npm/@dajiaoai/algeo-sdk@2.7.0/dist/algeo-sdk.umd.min.js"></script>
|
|
50
50
|
<script src="https://cdn.jsdelivr.net/npm/@dajiaoai/algeo-sdk@latest/dist/algeo-sdk.umd.min.js"></script>
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
>
|
|
53
|
+
> 生产环境建议锁定到 **2.7.x**(如 `~2.7.0`),在兼容边界内自动接收修复版本。
|
|
54
54
|
|
|
55
55
|
## 使用方式
|
|
56
56
|
|
|
@@ -63,6 +63,9 @@ const container = document.getElementById('algeo-container');
|
|
|
63
63
|
const presentation = await createPresentation(container, {
|
|
64
64
|
appId: 'YTVJDQZR',
|
|
65
65
|
shareId: '33TA3484',
|
|
66
|
+
ui: {
|
|
67
|
+
logo: false,
|
|
68
|
+
},
|
|
66
69
|
});
|
|
67
70
|
|
|
68
71
|
presentation.on('ready', (event) => {
|
|
@@ -114,6 +117,7 @@ const editor = await createEditor(document.getElementById('editor-root'), {
|
|
|
114
117
|
toolboxPanel: true,
|
|
115
118
|
algebraPanel: false,
|
|
116
119
|
docPanel: false,
|
|
120
|
+
helpEntry: false,
|
|
117
121
|
},
|
|
118
122
|
});
|
|
119
123
|
|
|
@@ -259,10 +263,11 @@ type AlgeoCreateOptions =
|
|
|
259
263
|
|
|
260
264
|
**AlgeoPresentationCreateOptions:**
|
|
261
265
|
|
|
262
|
-
| 属性 | 类型
|
|
263
|
-
| --------- |
|
|
264
|
-
| `appId` | `string`
|
|
265
|
-
| `shareId` | `string`
|
|
266
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
267
|
+
| --------- | ------------------------------------ | ------ | -------------------------------------------------------- |
|
|
268
|
+
| `appId` | `string` | `''` | 演示模式白名单校验使用的应用标识,SDK 会用它请求校验接口 |
|
|
269
|
+
| `shareId` | `string` | `''` | 演示模式初始分享 ID,会映射到 `/e/:id` |
|
|
270
|
+
| `ui` | `Partial<AlgeoPresentationUiConfig>` | - | 演示模式 UI 配置 |
|
|
266
271
|
|
|
267
272
|
默认路径规则:
|
|
268
273
|
|
|
@@ -289,10 +294,11 @@ const presentation = await create(container, {
|
|
|
289
294
|
|
|
290
295
|
#### 实例属性(只读)
|
|
291
296
|
|
|
292
|
-
| 属性 | 类型
|
|
293
|
-
| --------- |
|
|
294
|
-
| `ready` | `boolean`
|
|
295
|
-
| `version` | `string \| null`
|
|
297
|
+
| 属性 | 类型 | 说明 |
|
|
298
|
+
| --------- | --------------------- | ------------------------------------ |
|
|
299
|
+
| `ready` | `boolean` | 是否已就绪(收到 iframe ready 通知) |
|
|
300
|
+
| `version` | `string \| null` | 内嵌页协议版本 |
|
|
301
|
+
| `mode` | `PresentationModeApi` | 演示模式展示控制能力 |
|
|
296
302
|
|
|
297
303
|
#### 事件订阅
|
|
298
304
|
|
|
@@ -308,6 +314,13 @@ const presentation = await create(container, {
|
|
|
308
314
|
|
|
309
315
|
#### 实例方法
|
|
310
316
|
|
|
317
|
+
##### `presentation.mode`
|
|
318
|
+
|
|
319
|
+
| 方法 | 说明 |
|
|
320
|
+
| --------------------- | ---------------- |
|
|
321
|
+
| `getUiConfig()` | 获取当前 UI 配置 |
|
|
322
|
+
| `setUiConfig(config)` | 更新 UI 配置 |
|
|
323
|
+
|
|
311
324
|
##### `presentation.loadShareById(id: string): Promise<LoadShareByIdResult>`
|
|
312
325
|
|
|
313
326
|
按分享 ID 加载内容。
|
package/dist/algeo-sdk.cjs.js
CHANGED
|
@@ -3978,7 +3978,7 @@ function convertToLatest(content) {
|
|
|
3978
3978
|
}
|
|
3979
3979
|
|
|
3980
3980
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
3981
|
-
const VERSION = '2.
|
|
3981
|
+
const VERSION = '2.7.0';
|
|
3982
3982
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
3983
3983
|
const DEFAULT_PRESENTATION_PATH = '/e';
|
|
3984
3984
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4261,12 +4261,27 @@ class EmbeddedPresentation extends EmbeddedTarget {
|
|
|
4261
4261
|
super(container, 'presentation');
|
|
4262
4262
|
this.currentSlideIndex = 0;
|
|
4263
4263
|
this.slideCount = 0;
|
|
4264
|
+
this.uiConfig = {};
|
|
4265
|
+
this.mode = {
|
|
4266
|
+
getUiConfig: () => ({ ...this.uiConfig }),
|
|
4267
|
+
setUiConfig: async (config) => {
|
|
4268
|
+
await this.post('setUiConfig', { config });
|
|
4269
|
+
this.uiConfig = {
|
|
4270
|
+
...this.uiConfig,
|
|
4271
|
+
...config,
|
|
4272
|
+
};
|
|
4273
|
+
},
|
|
4274
|
+
};
|
|
4264
4275
|
}
|
|
4265
4276
|
async initialize(options = {}, baseUrl) {
|
|
4277
|
+
this.uiConfig = options.ui ? { ...options.ui } : {};
|
|
4266
4278
|
await this.init({
|
|
4267
4279
|
baseUrl,
|
|
4268
4280
|
initialId: options.shareId,
|
|
4269
4281
|
});
|
|
4282
|
+
if (Object.keys(this.uiConfig).length > 0) {
|
|
4283
|
+
await this.mode.setUiConfig(this.uiConfig);
|
|
4284
|
+
}
|
|
4270
4285
|
}
|
|
4271
4286
|
acceptsEventMessage() {
|
|
4272
4287
|
return false;
|
|
@@ -4403,12 +4418,15 @@ class EmbeddedEditor extends EmbeddedTarget {
|
|
|
4403
4418
|
if (!options.auth?.appId?.trim()) {
|
|
4404
4419
|
throw new AlgeoError('编辑模式需要提供 auth.appId。', EMBED_ERROR_CODES.MISSING_APP_ID);
|
|
4405
4420
|
}
|
|
4406
|
-
this.uiConfig = options.ui
|
|
4421
|
+
this.uiConfig = options.ui ? { ...options.ui } : {};
|
|
4407
4422
|
await this.init({
|
|
4408
4423
|
baseUrl,
|
|
4409
4424
|
auth: options.auth,
|
|
4410
4425
|
initialId: options.shareId,
|
|
4411
4426
|
});
|
|
4427
|
+
if (Object.keys(this.uiConfig).length > 0) {
|
|
4428
|
+
await this.mode.setUiConfig(this.uiConfig);
|
|
4429
|
+
}
|
|
4412
4430
|
const content = await this.document.getContent();
|
|
4413
4431
|
this.currentContent = content;
|
|
4414
4432
|
this.slideCount = content.slides.length;
|
package/dist/algeo-sdk.esm.js
CHANGED
|
@@ -3976,7 +3976,7 @@ function convertToLatest(content) {
|
|
|
3976
3976
|
}
|
|
3977
3977
|
|
|
3978
3978
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
3979
|
-
const VERSION = '2.
|
|
3979
|
+
const VERSION = '2.7.0';
|
|
3980
3980
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
3981
3981
|
const DEFAULT_PRESENTATION_PATH = '/e';
|
|
3982
3982
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4259,12 +4259,27 @@ class EmbeddedPresentation extends EmbeddedTarget {
|
|
|
4259
4259
|
super(container, 'presentation');
|
|
4260
4260
|
this.currentSlideIndex = 0;
|
|
4261
4261
|
this.slideCount = 0;
|
|
4262
|
+
this.uiConfig = {};
|
|
4263
|
+
this.mode = {
|
|
4264
|
+
getUiConfig: () => ({ ...this.uiConfig }),
|
|
4265
|
+
setUiConfig: async (config) => {
|
|
4266
|
+
await this.post('setUiConfig', { config });
|
|
4267
|
+
this.uiConfig = {
|
|
4268
|
+
...this.uiConfig,
|
|
4269
|
+
...config,
|
|
4270
|
+
};
|
|
4271
|
+
},
|
|
4272
|
+
};
|
|
4262
4273
|
}
|
|
4263
4274
|
async initialize(options = {}, baseUrl) {
|
|
4275
|
+
this.uiConfig = options.ui ? { ...options.ui } : {};
|
|
4264
4276
|
await this.init({
|
|
4265
4277
|
baseUrl,
|
|
4266
4278
|
initialId: options.shareId,
|
|
4267
4279
|
});
|
|
4280
|
+
if (Object.keys(this.uiConfig).length > 0) {
|
|
4281
|
+
await this.mode.setUiConfig(this.uiConfig);
|
|
4282
|
+
}
|
|
4268
4283
|
}
|
|
4269
4284
|
acceptsEventMessage() {
|
|
4270
4285
|
return false;
|
|
@@ -4401,12 +4416,15 @@ class EmbeddedEditor extends EmbeddedTarget {
|
|
|
4401
4416
|
if (!options.auth?.appId?.trim()) {
|
|
4402
4417
|
throw new AlgeoError('编辑模式需要提供 auth.appId。', EMBED_ERROR_CODES.MISSING_APP_ID);
|
|
4403
4418
|
}
|
|
4404
|
-
this.uiConfig = options.ui
|
|
4419
|
+
this.uiConfig = options.ui ? { ...options.ui } : {};
|
|
4405
4420
|
await this.init({
|
|
4406
4421
|
baseUrl,
|
|
4407
4422
|
auth: options.auth,
|
|
4408
4423
|
initialId: options.shareId,
|
|
4409
4424
|
});
|
|
4425
|
+
if (Object.keys(this.uiConfig).length > 0) {
|
|
4426
|
+
await this.mode.setUiConfig(this.uiConfig);
|
|
4427
|
+
}
|
|
4410
4428
|
const content = await this.document.getContent();
|
|
4411
4429
|
this.currentContent = content;
|
|
4412
4430
|
this.slideCount = content.slides.length;
|
package/dist/algeo-sdk.umd.js
CHANGED
|
@@ -3982,7 +3982,7 @@
|
|
|
3982
3982
|
}
|
|
3983
3983
|
|
|
3984
3984
|
/** SDK 版本号,构建时由 rollup 注入 */
|
|
3985
|
-
const VERSION = '2.
|
|
3985
|
+
const VERSION = '2.7.0';
|
|
3986
3986
|
const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
|
|
3987
3987
|
const DEFAULT_PRESENTATION_PATH = '/e';
|
|
3988
3988
|
const DEFAULT_EDITOR_PATH = '/embed/edit';
|
|
@@ -4265,12 +4265,27 @@
|
|
|
4265
4265
|
super(container, 'presentation');
|
|
4266
4266
|
this.currentSlideIndex = 0;
|
|
4267
4267
|
this.slideCount = 0;
|
|
4268
|
+
this.uiConfig = {};
|
|
4269
|
+
this.mode = {
|
|
4270
|
+
getUiConfig: () => ({ ...this.uiConfig }),
|
|
4271
|
+
setUiConfig: async (config) => {
|
|
4272
|
+
await this.post('setUiConfig', { config });
|
|
4273
|
+
this.uiConfig = {
|
|
4274
|
+
...this.uiConfig,
|
|
4275
|
+
...config,
|
|
4276
|
+
};
|
|
4277
|
+
},
|
|
4278
|
+
};
|
|
4268
4279
|
}
|
|
4269
4280
|
async initialize(options = {}, baseUrl) {
|
|
4281
|
+
this.uiConfig = options.ui ? { ...options.ui } : {};
|
|
4270
4282
|
await this.init({
|
|
4271
4283
|
baseUrl,
|
|
4272
4284
|
initialId: options.shareId,
|
|
4273
4285
|
});
|
|
4286
|
+
if (Object.keys(this.uiConfig).length > 0) {
|
|
4287
|
+
await this.mode.setUiConfig(this.uiConfig);
|
|
4288
|
+
}
|
|
4274
4289
|
}
|
|
4275
4290
|
acceptsEventMessage() {
|
|
4276
4291
|
return false;
|
|
@@ -4407,12 +4422,15 @@
|
|
|
4407
4422
|
if (!options.auth?.appId?.trim()) {
|
|
4408
4423
|
throw new AlgeoError('编辑模式需要提供 auth.appId。', EMBED_ERROR_CODES.MISSING_APP_ID);
|
|
4409
4424
|
}
|
|
4410
|
-
this.uiConfig = options.ui
|
|
4425
|
+
this.uiConfig = options.ui ? { ...options.ui } : {};
|
|
4411
4426
|
await this.init({
|
|
4412
4427
|
baseUrl,
|
|
4413
4428
|
auth: options.auth,
|
|
4414
4429
|
initialId: options.shareId,
|
|
4415
4430
|
});
|
|
4431
|
+
if (Object.keys(this.uiConfig).length > 0) {
|
|
4432
|
+
await this.mode.setUiConfig(this.uiConfig);
|
|
4433
|
+
}
|
|
4416
4434
|
const content = await this.document.getContent();
|
|
4417
4435
|
this.currentContent = content;
|
|
4418
4436
|
this.slideCount = content.slides.length;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { EmbeddedTarget } from './embedded-target';
|
|
2
|
-
import { AlgeoError, type AlgeoPresentationCreateOptions, type EmbeddedPresentationEventListenerMap, type EmbeddedPresentationEventMap, type EmbeddedPresentationEventName, type FileContentLatest, type GetSlideCountResult, type LoadFileResult, type LoadShareByIdResult, type ReplResult, type SwitchSlideResult } from './shared';
|
|
2
|
+
import { AlgeoError, type AlgeoPresentationCreateOptions, type EmbeddedPresentationEventListenerMap, type EmbeddedPresentationEventMap, type EmbeddedPresentationEventName, type FileContentLatest, type GetSlideCountResult, type LoadFileResult, type LoadShareByIdResult, type PresentationModeApi, type ReplResult, type SwitchSlideResult } from './shared';
|
|
3
3
|
export declare class EmbeddedPresentation extends EmbeddedTarget<EmbeddedPresentationEventMap, EmbeddedPresentationEventName, EmbeddedPresentationEventListenerMap> {
|
|
4
|
+
readonly mode: PresentationModeApi;
|
|
4
5
|
private currentContent?;
|
|
5
6
|
private currentSlideIndex;
|
|
6
7
|
private slideCount;
|
|
7
8
|
private whitelistError?;
|
|
9
|
+
private uiConfig;
|
|
8
10
|
constructor(container: HTMLElement);
|
|
9
11
|
initialize(options?: AlgeoPresentationCreateOptions, baseUrl?: string): Promise<void>;
|
|
10
12
|
protected acceptsEventMessage(): boolean;
|
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 { AlgeoCreateOptions, AlgeoEditorAuthOptions, AlgeoEditorCreateOptions, AlgeoEditorSaveResult, AlgeoEditorUiConfig, AlgeoEmbedMode, AlgeoErrorPayload, AlgeoPresentationCreateOptions, ContentChangeEvent, DocumentApi, EmbeddedEditorEventListenerMap, EmbeddedEditorEventMap, EmbeddedEditorEventName, EmbeddedPresentationEventListenerMap, EmbeddedPresentationEventMap, EmbeddedPresentationEventName, ExportSlideImageOptions, ExportedSlideImage, ExportSlideImageResult, GetContentResult, GetSlideCountResult, HistoryApi, LoadFileResult, LoadShareByIdResult, ModeApi, ReadyEvent, ReplResult, SlideChangeEvent, SlideIndexResult, SlidesApi, SwitchSlideResult, SaveEvent, } from './shared';
|
|
4
|
+
export type { 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';
|
|
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
|
@@ -23,6 +23,10 @@ export interface AlgeoEditorUiConfig {
|
|
|
23
23
|
toolboxPanel?: boolean;
|
|
24
24
|
algebraPanel?: boolean;
|
|
25
25
|
docPanel?: boolean;
|
|
26
|
+
helpEntry?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface AlgeoPresentationUiConfig {
|
|
29
|
+
logo?: boolean;
|
|
26
30
|
}
|
|
27
31
|
export type AlgeoEditorSaveResult = {
|
|
28
32
|
status: 'success';
|
|
@@ -39,6 +43,7 @@ export interface AlgeoEditorCreateOptions {
|
|
|
39
43
|
export interface AlgeoPresentationCreateOptions {
|
|
40
44
|
appId?: string;
|
|
41
45
|
shareId?: string;
|
|
46
|
+
ui?: AlgeoPresentationUiConfig;
|
|
42
47
|
}
|
|
43
48
|
export type AlgeoCreateOptions = {
|
|
44
49
|
baseUrl?: string;
|
|
@@ -175,6 +180,10 @@ export interface ModeApi {
|
|
|
175
180
|
getUiConfig(): AlgeoEditorUiConfig;
|
|
176
181
|
setUiConfig(config: Partial<AlgeoEditorUiConfig>): Promise<void>;
|
|
177
182
|
}
|
|
183
|
+
export interface PresentationModeApi {
|
|
184
|
+
getUiConfig(): AlgeoPresentationUiConfig;
|
|
185
|
+
setUiConfig(config: Partial<AlgeoPresentationUiConfig>): Promise<void>;
|
|
186
|
+
}
|
|
178
187
|
export declare function generateRequestId(): string;
|
|
179
188
|
export declare function isResponseMessage(msg: unknown): msg is EmbedResponseMessage;
|
|
180
189
|
export declare function isReadyMessage(msg: unknown): msg is EmbedReadyMessage;
|