@dajiaoai/algeo-sdk 2.11.0 → 2.12.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 CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  大角几何内嵌画板 SDK,支持在任意网页中嵌入几何画板,通过 postMessage 与内嵌页通信。
4
4
 
5
+ ## 交流与支持
6
+
7
+ 欢迎扫描下方二维码加入微信群,与我们交流 SDK 接入问题、使用反馈和功能建议。
8
+
9
+ ![扫码加入大角几何微信群](./assets/wechat-community-banner.jpg)
10
+
5
11
  ## 安装
6
12
 
7
13
  ### npm
@@ -309,6 +315,7 @@ type AlgeoCreateOptions =
309
315
  | `shareId` | `string` | `''` | 编辑模式初始分享 ID,会映射到 `/embed/edit/:appId/:id` |
310
316
  | `initialContent` | `FileContentLatest` | - | 初始化后自动注入的文件内容 |
311
317
  | `ui` | `Partial<AlgeoEditorUiConfig>` | - | 编辑器 UI 开关配置 |
318
+ | `fonts` | `AlgeoFontConfig` | - | 字体资源、字体选择器列表及默认字体配置 |
312
319
 
313
320
  **AlgeoEditorUiConfig:**
314
321
 
@@ -329,6 +336,7 @@ type AlgeoCreateOptions =
329
336
  | `auth` | `{ appId: string }` | - | 演示模式鉴权参数,`appId` 用于路由及白名单校验 |
330
337
  | `shareId` | `string` | `''` | 演示模式初始分享 ID,会映射到 `/embed/present/:appId/:id` |
331
338
  | `ui` | `Partial<AlgeoPresentationUiConfig>` | - | 演示模式 UI 配置 |
339
+ | `fonts` | `AlgeoFontConfig` | - | 字体资源及默认字体配置 |
332
340
 
333
341
  **AlgeoPresentationUiConfig:**
334
342
 
@@ -339,6 +347,58 @@ type AlgeoCreateOptions =
339
347
  | `pencilToolbar` | `boolean` | `true` | 是否展示教具栏 |
340
348
  | `zoomControl` | `boolean` | `true` | 是否展示缩放栏 |
341
349
 
350
+ **AlgeoFontConfig:**
351
+
352
+ 编辑和演示模式使用同一套字体协议。SDK 在 iframe ready 后、其他初始化操作前发送字体配置。通常使用 URL 加载字体;字体 URL 无法满足跨域要求时,可以传入 base64。
353
+
354
+ ```typescript
355
+ interface AlgeoFontConfig {
356
+ resources?: AlgeoFontResource[];
357
+ catalog?: AlgeoFontOption[];
358
+ defaultFont?: string;
359
+ }
360
+
361
+ interface AlgeoFontResource {
362
+ key: string;
363
+ source:
364
+ | { type: 'url'; url: string; format?: AlgeoFontFormat }
365
+ | {
366
+ type: 'base64';
367
+ data: string;
368
+ mimeType?: string;
369
+ format?: AlgeoFontFormat;
370
+ };
371
+ }
372
+
373
+ interface AlgeoFontOption {
374
+ key: string;
375
+ name: string;
376
+ type?: 'custom' | 'system';
377
+ }
378
+ ```
379
+
380
+ `key` 同时作为 FontFace family、CSS `font-family` 和文档字体标识。字重、字号、斜体等属于文档排版内容,不在字体配置中传递。
381
+
382
+ ```javascript
383
+ const fonts = {
384
+ resources: [
385
+ {
386
+ key: 'brand-sans',
387
+ source: {
388
+ type: 'url',
389
+ url: 'https://cdn.example.com/brand-sans.woff2',
390
+ format: 'woff2',
391
+ },
392
+ },
393
+ ],
394
+ catalog: [
395
+ { key: 'brand-sans', name: '品牌字体' },
396
+ { key: 'sans-serif', name: '系统非衬线字体', type: 'system' },
397
+ ],
398
+ defaultFont: 'brand-sans',
399
+ };
400
+ ```
401
+
342
402
  默认路径规则:
343
403
 
344
404
  - `mode: 'presentation'` -> `/embed/present/:appId`,若传 `presentation.shareId` 则生成 `/embed/present/:appId/:id`
@@ -3865,12 +3865,6 @@ var AlgeoError = class extends Error {
3865
3865
  this.name = "AlgeoError";
3866
3866
  }
3867
3867
  };
3868
- objectType({
3869
- text: stringType().optional(),
3870
- images: arrayType(stringType().trim().min(1)).optional(),
3871
- openPanel: booleanType().optional(),
3872
- focus: booleanType().optional()
3873
- }).passthrough();
3874
3868
  var openAiChatMessageV1Schema = objectType({
3875
3869
  role: stringType(),
3876
3870
  content: unionType([
@@ -3884,23 +3878,9 @@ var openAiChatMessageV1Schema = objectType({
3884
3878
  name: stringType().optional()
3885
3879
  }).passthrough();
3886
3880
  objectType({
3887
- model: stringType().trim().min(1),
3888
- input: unionType([
3889
- stringType(),
3890
- arrayType(unionType([openAiChatMessageV1Schema, recordType(unknownType())]))
3891
- ]).optional(),
3892
- previous_response_id: stringType().trim().min(1).optional(),
3893
- instructions: stringType().optional(),
3894
- temperature: numberType().min(0).max(2).optional(),
3895
- max_output_tokens: numberType().int().positive().optional(),
3896
- metadata: recordType(unknownType()).optional()
3897
- }).passthrough().superRefine((value, ctx) => {
3898
- if (!("input" in value) && !("previous_response_id" in value)) {
3899
- ctx.addIssue({
3900
- code: ZodIssueCode.custom,
3901
- message: "input or previous_response_id is required."
3902
- });
3903
- }
3881
+ model_id: stringType(),
3882
+ messages: arrayType(unionType([openAiChatMessageV1Schema, recordType(unknownType())])),
3883
+ extra_openai_params: recordType(unknownType()).optional()
3904
3884
  });
3905
3885
  objectType({
3906
3886
  id: stringType(),
@@ -4031,7 +4011,7 @@ function convertToLatest(content) {
4031
4011
  }
4032
4012
 
4033
4013
  /** SDK 版本号,构建时由 rollup 注入 */
4034
- const VERSION = '2.11.0';
4014
+ const VERSION = '2.12.0';
4035
4015
  const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
4036
4016
  const DEFAULT_PRESENTATION_PATH = '/embed/present';
4037
4017
  const DEFAULT_EDITOR_PATH = '/embed/edit';
@@ -4040,6 +4020,31 @@ let requestIdCounter = 0;
4040
4020
  function generateRequestId() {
4041
4021
  return `req-${Date.now()}-${++requestIdCounter}`;
4042
4022
  }
4023
+ function validateFontConfig(config) {
4024
+ const resourceKeys = new Set();
4025
+ for (const resource of config.resources ?? []) {
4026
+ const key = resource.key.trim();
4027
+ if (!key) {
4028
+ throw new AlgeoError('fonts.resources[].key 不能为空。', EMBED_ERROR_CODES.BAD_REQUEST);
4029
+ }
4030
+ resourceKeys.add(key);
4031
+ }
4032
+ const catalogKeys = new Set();
4033
+ for (const option of config.catalog ?? []) {
4034
+ const key = option.key.trim();
4035
+ if (!key || !option.name.trim()) {
4036
+ throw new AlgeoError('fonts.catalog[] 的 key 和 name 不能为空。', EMBED_ERROR_CODES.BAD_REQUEST);
4037
+ }
4038
+ if ((option.type ?? 'custom') === 'custom' && !resourceKeys.has(key)) {
4039
+ throw new AlgeoError(`自定义字体 ${key} 未提供对应的字体资源。`, EMBED_ERROR_CODES.BAD_REQUEST);
4040
+ }
4041
+ catalogKeys.add(key);
4042
+ }
4043
+ const defaultFont = config.defaultFont?.trim();
4044
+ if (defaultFont && config.catalog && !catalogKeys.has(defaultFont)) {
4045
+ throw new AlgeoError(`默认字体 ${defaultFont} 不在 fonts.catalog 中。`, EMBED_ERROR_CODES.BAD_REQUEST);
4046
+ }
4047
+ }
4043
4048
  function isResponseMessage(msg) {
4044
4049
  return (typeof msg === 'object' &&
4045
4050
  msg !== null &&
@@ -4422,11 +4427,17 @@ class EmbeddedPresentation extends EmbeddedTarget {
4422
4427
  zoomControl: true,
4423
4428
  ...options.ui,
4424
4429
  };
4430
+ if (options.fonts) {
4431
+ validateFontConfig(options.fonts);
4432
+ }
4425
4433
  await this.init({
4426
4434
  baseUrl,
4427
4435
  auth: options.auth,
4428
4436
  initialId: options.shareId,
4429
4437
  });
4438
+ if (options.fonts) {
4439
+ await this.post('setFontConfig', { config: options.fonts });
4440
+ }
4430
4441
  await this.mode.setUiConfig(this.uiConfig);
4431
4442
  }
4432
4443
  acceptsEventMessage() {
@@ -4588,11 +4599,17 @@ class EmbeddedEditor extends EmbeddedTarget {
4588
4599
  }
4589
4600
  this.uiConfig = options.ui ? { ...options.ui } : {};
4590
4601
  this.resourceLibrary = options.resourceLibrary;
4602
+ if (options.fonts) {
4603
+ validateFontConfig(options.fonts);
4604
+ }
4591
4605
  await this.init({
4592
4606
  baseUrl,
4593
4607
  auth: options.auth,
4594
4608
  initialId: options.shareId,
4595
4609
  });
4610
+ if (options.fonts) {
4611
+ await this.post('setFontConfig', { config: options.fonts });
4612
+ }
4596
4613
  await this.post('setResourceLibraryAvailability', {
4597
4614
  available: Boolean(this.resourceLibrary),
4598
4615
  });
@@ -3863,12 +3863,6 @@ var AlgeoError = class extends Error {
3863
3863
  this.name = "AlgeoError";
3864
3864
  }
3865
3865
  };
3866
- objectType({
3867
- text: stringType().optional(),
3868
- images: arrayType(stringType().trim().min(1)).optional(),
3869
- openPanel: booleanType().optional(),
3870
- focus: booleanType().optional()
3871
- }).passthrough();
3872
3866
  var openAiChatMessageV1Schema = objectType({
3873
3867
  role: stringType(),
3874
3868
  content: unionType([
@@ -3882,23 +3876,9 @@ var openAiChatMessageV1Schema = objectType({
3882
3876
  name: stringType().optional()
3883
3877
  }).passthrough();
3884
3878
  objectType({
3885
- model: stringType().trim().min(1),
3886
- input: unionType([
3887
- stringType(),
3888
- arrayType(unionType([openAiChatMessageV1Schema, recordType(unknownType())]))
3889
- ]).optional(),
3890
- previous_response_id: stringType().trim().min(1).optional(),
3891
- instructions: stringType().optional(),
3892
- temperature: numberType().min(0).max(2).optional(),
3893
- max_output_tokens: numberType().int().positive().optional(),
3894
- metadata: recordType(unknownType()).optional()
3895
- }).passthrough().superRefine((value, ctx) => {
3896
- if (!("input" in value) && !("previous_response_id" in value)) {
3897
- ctx.addIssue({
3898
- code: ZodIssueCode.custom,
3899
- message: "input or previous_response_id is required."
3900
- });
3901
- }
3879
+ model_id: stringType(),
3880
+ messages: arrayType(unionType([openAiChatMessageV1Schema, recordType(unknownType())])),
3881
+ extra_openai_params: recordType(unknownType()).optional()
3902
3882
  });
3903
3883
  objectType({
3904
3884
  id: stringType(),
@@ -4029,7 +4009,7 @@ function convertToLatest(content) {
4029
4009
  }
4030
4010
 
4031
4011
  /** SDK 版本号,构建时由 rollup 注入 */
4032
- const VERSION = '2.11.0';
4012
+ const VERSION = '2.12.0';
4033
4013
  const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
4034
4014
  const DEFAULT_PRESENTATION_PATH = '/embed/present';
4035
4015
  const DEFAULT_EDITOR_PATH = '/embed/edit';
@@ -4038,6 +4018,31 @@ let requestIdCounter = 0;
4038
4018
  function generateRequestId() {
4039
4019
  return `req-${Date.now()}-${++requestIdCounter}`;
4040
4020
  }
4021
+ function validateFontConfig(config) {
4022
+ const resourceKeys = new Set();
4023
+ for (const resource of config.resources ?? []) {
4024
+ const key = resource.key.trim();
4025
+ if (!key) {
4026
+ throw new AlgeoError('fonts.resources[].key 不能为空。', EMBED_ERROR_CODES.BAD_REQUEST);
4027
+ }
4028
+ resourceKeys.add(key);
4029
+ }
4030
+ const catalogKeys = new Set();
4031
+ for (const option of config.catalog ?? []) {
4032
+ const key = option.key.trim();
4033
+ if (!key || !option.name.trim()) {
4034
+ throw new AlgeoError('fonts.catalog[] 的 key 和 name 不能为空。', EMBED_ERROR_CODES.BAD_REQUEST);
4035
+ }
4036
+ if ((option.type ?? 'custom') === 'custom' && !resourceKeys.has(key)) {
4037
+ throw new AlgeoError(`自定义字体 ${key} 未提供对应的字体资源。`, EMBED_ERROR_CODES.BAD_REQUEST);
4038
+ }
4039
+ catalogKeys.add(key);
4040
+ }
4041
+ const defaultFont = config.defaultFont?.trim();
4042
+ if (defaultFont && config.catalog && !catalogKeys.has(defaultFont)) {
4043
+ throw new AlgeoError(`默认字体 ${defaultFont} 不在 fonts.catalog 中。`, EMBED_ERROR_CODES.BAD_REQUEST);
4044
+ }
4045
+ }
4041
4046
  function isResponseMessage(msg) {
4042
4047
  return (typeof msg === 'object' &&
4043
4048
  msg !== null &&
@@ -4420,11 +4425,17 @@ class EmbeddedPresentation extends EmbeddedTarget {
4420
4425
  zoomControl: true,
4421
4426
  ...options.ui,
4422
4427
  };
4428
+ if (options.fonts) {
4429
+ validateFontConfig(options.fonts);
4430
+ }
4423
4431
  await this.init({
4424
4432
  baseUrl,
4425
4433
  auth: options.auth,
4426
4434
  initialId: options.shareId,
4427
4435
  });
4436
+ if (options.fonts) {
4437
+ await this.post('setFontConfig', { config: options.fonts });
4438
+ }
4428
4439
  await this.mode.setUiConfig(this.uiConfig);
4429
4440
  }
4430
4441
  acceptsEventMessage() {
@@ -4586,11 +4597,17 @@ class EmbeddedEditor extends EmbeddedTarget {
4586
4597
  }
4587
4598
  this.uiConfig = options.ui ? { ...options.ui } : {};
4588
4599
  this.resourceLibrary = options.resourceLibrary;
4600
+ if (options.fonts) {
4601
+ validateFontConfig(options.fonts);
4602
+ }
4589
4603
  await this.init({
4590
4604
  baseUrl,
4591
4605
  auth: options.auth,
4592
4606
  initialId: options.shareId,
4593
4607
  });
4608
+ if (options.fonts) {
4609
+ await this.post('setFontConfig', { config: options.fonts });
4610
+ }
4594
4611
  await this.post('setResourceLibraryAvailability', {
4595
4612
  available: Boolean(this.resourceLibrary),
4596
4613
  });
@@ -3869,12 +3869,6 @@
3869
3869
  this.name = "AlgeoError";
3870
3870
  }
3871
3871
  };
3872
- objectType({
3873
- text: stringType().optional(),
3874
- images: arrayType(stringType().trim().min(1)).optional(),
3875
- openPanel: booleanType().optional(),
3876
- focus: booleanType().optional()
3877
- }).passthrough();
3878
3872
  var openAiChatMessageV1Schema = objectType({
3879
3873
  role: stringType(),
3880
3874
  content: unionType([
@@ -3888,23 +3882,9 @@
3888
3882
  name: stringType().optional()
3889
3883
  }).passthrough();
3890
3884
  objectType({
3891
- model: stringType().trim().min(1),
3892
- input: unionType([
3893
- stringType(),
3894
- arrayType(unionType([openAiChatMessageV1Schema, recordType(unknownType())]))
3895
- ]).optional(),
3896
- previous_response_id: stringType().trim().min(1).optional(),
3897
- instructions: stringType().optional(),
3898
- temperature: numberType().min(0).max(2).optional(),
3899
- max_output_tokens: numberType().int().positive().optional(),
3900
- metadata: recordType(unknownType()).optional()
3901
- }).passthrough().superRefine((value, ctx) => {
3902
- if (!("input" in value) && !("previous_response_id" in value)) {
3903
- ctx.addIssue({
3904
- code: ZodIssueCode.custom,
3905
- message: "input or previous_response_id is required."
3906
- });
3907
- }
3885
+ model_id: stringType(),
3886
+ messages: arrayType(unionType([openAiChatMessageV1Schema, recordType(unknownType())])),
3887
+ extra_openai_params: recordType(unknownType()).optional()
3908
3888
  });
3909
3889
  objectType({
3910
3890
  id: stringType(),
@@ -4035,7 +4015,7 @@
4035
4015
  }
4036
4016
 
4037
4017
  /** SDK 版本号,构建时由 rollup 注入 */
4038
- const VERSION = '2.11.0';
4018
+ const VERSION = '2.12.0';
4039
4019
  const DEFAULT_EMBED_BASE = 'https://dajiaoai.com';
4040
4020
  const DEFAULT_PRESENTATION_PATH = '/embed/present';
4041
4021
  const DEFAULT_EDITOR_PATH = '/embed/edit';
@@ -4044,6 +4024,31 @@
4044
4024
  function generateRequestId() {
4045
4025
  return `req-${Date.now()}-${++requestIdCounter}`;
4046
4026
  }
4027
+ function validateFontConfig(config) {
4028
+ const resourceKeys = new Set();
4029
+ for (const resource of config.resources ?? []) {
4030
+ const key = resource.key.trim();
4031
+ if (!key) {
4032
+ throw new AlgeoError('fonts.resources[].key 不能为空。', EMBED_ERROR_CODES.BAD_REQUEST);
4033
+ }
4034
+ resourceKeys.add(key);
4035
+ }
4036
+ const catalogKeys = new Set();
4037
+ for (const option of config.catalog ?? []) {
4038
+ const key = option.key.trim();
4039
+ if (!key || !option.name.trim()) {
4040
+ throw new AlgeoError('fonts.catalog[] 的 key 和 name 不能为空。', EMBED_ERROR_CODES.BAD_REQUEST);
4041
+ }
4042
+ if ((option.type ?? 'custom') === 'custom' && !resourceKeys.has(key)) {
4043
+ throw new AlgeoError(`自定义字体 ${key} 未提供对应的字体资源。`, EMBED_ERROR_CODES.BAD_REQUEST);
4044
+ }
4045
+ catalogKeys.add(key);
4046
+ }
4047
+ const defaultFont = config.defaultFont?.trim();
4048
+ if (defaultFont && config.catalog && !catalogKeys.has(defaultFont)) {
4049
+ throw new AlgeoError(`默认字体 ${defaultFont} 不在 fonts.catalog 中。`, EMBED_ERROR_CODES.BAD_REQUEST);
4050
+ }
4051
+ }
4047
4052
  function isResponseMessage(msg) {
4048
4053
  return (typeof msg === 'object' &&
4049
4054
  msg !== null &&
@@ -4426,11 +4431,17 @@
4426
4431
  zoomControl: true,
4427
4432
  ...options.ui,
4428
4433
  };
4434
+ if (options.fonts) {
4435
+ validateFontConfig(options.fonts);
4436
+ }
4429
4437
  await this.init({
4430
4438
  baseUrl,
4431
4439
  auth: options.auth,
4432
4440
  initialId: options.shareId,
4433
4441
  });
4442
+ if (options.fonts) {
4443
+ await this.post('setFontConfig', { config: options.fonts });
4444
+ }
4434
4445
  await this.mode.setUiConfig(this.uiConfig);
4435
4446
  }
4436
4447
  acceptsEventMessage() {
@@ -4592,11 +4603,17 @@
4592
4603
  }
4593
4604
  this.uiConfig = options.ui ? { ...options.ui } : {};
4594
4605
  this.resourceLibrary = options.resourceLibrary;
4606
+ if (options.fonts) {
4607
+ validateFontConfig(options.fonts);
4608
+ }
4595
4609
  await this.init({
4596
4610
  baseUrl,
4597
4611
  auth: options.auth,
4598
4612
  initialId: options.shareId,
4599
4613
  });
4614
+ if (options.fonts) {
4615
+ await this.post('setFontConfig', { config: options.fonts });
4616
+ }
4600
4617
  await this.post('setResourceLibraryAvailability', {
4601
4618
  available: Boolean(this.resourceLibrary),
4602
4619
  });
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, ExportImageFormat, ExportImageOptions, ExportImageSizeMode, ExportImageViewMode, ExportImageContainMode, ExportViewBounds, ExportPadding, ExportSlideImageOptions, ExportedSlideImage, ExportSlideImageResult, ExportLatexOptions, ExportedLatex, ExportLatexResult, GetContentResult, GetSlideCountResult, HistoryApi, LoadFileResult, LoadShareByIdResult, ModeApi, PresentationModeApi, ReadyEvent, ResourceLibraryItem, ResourceLibraryPageInfo, ResourceLibraryProvider, ResourceLibraryQuery, ResourceLibraryQueryContext, ResourceLibraryResult, ReplResult, SlideChangeEvent, SlideIndexResult, SlidesApi, SwitchSlideResult, SaveEvent, } from './shared';
4
+ export type { AiApi, AiCancelEvent, AiRawSseEventV1, AiRequestEvent, AiRunPayloadV1, AiStreamEventV1, AlgeoCreateOptions, AlgeoEditorAuthOptions, AlgeoEditorCreateOptions, AlgeoEditorSaveResult, AlgeoEditorUiConfig, AlgeoEmbedMode, AlgeoErrorPayload, AlgeoFontConfig, AlgeoFontFormat, AlgeoFontOption, AlgeoFontResource, AlgeoFontSource, AlgeoPresentationCreateOptions, AlgeoPresentationUiConfig, ContentChangeEvent, DocumentApi, EmbeddedEditorEventListenerMap, EmbeddedEditorEventMap, EmbeddedEditorEventName, EmbeddedPresentationEventListenerMap, EmbeddedPresentationEventMap, EmbeddedPresentationEventName, ExportImageFormat, ExportImageOptions, ExportImageSizeMode, ExportImageViewMode, ExportImageContainMode, ExportViewBounds, ExportPadding, ExportSlideImageOptions, ExportedSlideImage, ExportSlideImageResult, ExportLatexOptions, ExportedLatex, ExportLatexResult, GetContentResult, GetSlideCountResult, HistoryApi, LoadFileResult, LoadShareByIdResult, ModeApi, PresentationModeApi, ReadyEvent, ResourceLibraryItem, ResourceLibraryPageInfo, ResourceLibraryProvider, ResourceLibraryQuery, ResourceLibraryQueryContext, ResourceLibraryResult, 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
@@ -33,6 +33,39 @@ export interface AlgeoPresentationUiConfig {
33
33
  pencilToolbar?: boolean;
34
34
  zoomControl?: boolean;
35
35
  }
36
+ export type AlgeoFontFormat = 'woff2' | 'woff' | 'truetype' | 'opentype';
37
+ export type AlgeoFontSource = {
38
+ type: 'url';
39
+ url: string;
40
+ format?: AlgeoFontFormat;
41
+ } | {
42
+ type: 'base64';
43
+ /** 支持纯 base64 字符串或完整的 data URL。 */
44
+ data: string;
45
+ mimeType?: string;
46
+ format?: AlgeoFontFormat;
47
+ };
48
+ export interface AlgeoFontResource {
49
+ /** 字体标识,同时作为 FontFace family、CSS font-family 和文档字体标识。 */
50
+ key: string;
51
+ source: AlgeoFontSource;
52
+ }
53
+ export interface AlgeoFontOption {
54
+ /** 对应自定义字体资源的 key,或系统 font-family。 */
55
+ key: string;
56
+ /** 字体选择器中的展示名称。 */
57
+ name: string;
58
+ /** 默认 custom;system 类型不要求存在对应字体资源。 */
59
+ type?: 'custom' | 'system';
60
+ }
61
+ export interface AlgeoFontConfig {
62
+ /** 需要在内嵌页面中加载并注册的字体文件。 */
63
+ resources?: AlgeoFontResource[];
64
+ /** 编辑器字体选择器中展示的字体及顺序。 */
65
+ catalog?: AlgeoFontOption[];
66
+ /** 新建文本使用的默认字体 key。 */
67
+ defaultFont?: string;
68
+ }
36
69
  export type AlgeoEditorSaveResult = {
37
70
  status: 'success';
38
71
  } | {
@@ -44,6 +77,8 @@ export interface AlgeoEditorCreateOptions {
44
77
  shareId?: string;
45
78
  initialContent?: FileContentLatest;
46
79
  ui?: AlgeoEditorUiConfig;
80
+ /** 字体资源、字体选择器列表及默认字体配置。 */
81
+ fonts?: AlgeoFontConfig;
47
82
  /** 接入方提供的只读图片资源库。 */
48
83
  resourceLibrary?: ResourceLibraryProvider;
49
84
  }
@@ -85,6 +120,8 @@ export interface AlgeoPresentationCreateOptions {
85
120
  auth?: AlgeoEditorAuthOptions;
86
121
  shareId?: string;
87
122
  ui?: AlgeoPresentationUiConfig;
123
+ /** 字体资源及默认字体配置。 */
124
+ fonts?: AlgeoFontConfig;
88
125
  }
89
126
  export type AlgeoCreateOptions = {
90
127
  baseUrl?: string;
@@ -373,6 +410,7 @@ export interface PresentationModeApi {
373
410
  setMasterTemplate(template: string): Promise<SetMasterTemplateResult>;
374
411
  }
375
412
  export declare function generateRequestId(): string;
413
+ export declare function validateFontConfig(config: AlgeoFontConfig): void;
376
414
  export declare function isResponseMessage(msg: unknown): msg is EmbedResponseMessage;
377
415
  export declare function isReadyMessage(msg: unknown): msg is EmbedReadyMessage;
378
416
  export type EmbedEventMessage = ContentChangeEvent | SlideChangeEvent | SaveSuccessEvent | AiCancelEvent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dajiaoai/algeo-sdk",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
4
4
  "description": "大角几何内嵌画板 SDK,支持 iframe 挂载与 postMessage 通信",
5
5
  "main": "dist/algeo-sdk.cjs.js",
6
6
  "module": "dist/algeo-sdk.esm.js",