@gct-paas/word 0.2.1 → 0.2.2

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.
@@ -8,4 +8,5 @@ import { CommandPayloadMap } from '../types';
8
8
  export declare class SetBold extends SetStyleBase<'setBold'> {
9
9
  constructor(doc: Doc, payload?: CommandPayloadMap['setBold']);
10
10
  protected applyStyle(run: WrText): void;
11
+ protected execute(): Promise<import('../base/CommandBase').PostCommandContext>;
11
12
  }
@@ -8,4 +8,5 @@ import { CommandPayloadMap } from '../types';
8
8
  export declare class SetFont extends SetStyleBase<'setFont'> {
9
9
  constructor(doc: Doc, payload: CommandPayloadMap['setFont']);
10
10
  protected applyStyle(run: WrText): void;
11
+ protected execute(): Promise<import('../base/CommandBase').PostCommandContext>;
11
12
  }
@@ -8,6 +8,7 @@ import { Woverlays } from './overlays/Woverlays';
8
8
  import { Wr } from './document/Wp';
9
9
  import { Section } from '../view/Section';
10
10
  import { Child } from './document/Wbody';
11
+ import { ModelFontUsage } from './font-usage';
11
12
  /**
12
13
  * Word 文档模型
13
14
  * 包含文档的所有组件(document、styles、images 等)
@@ -36,6 +37,8 @@ export declare class DocModel {
36
37
  images: Wimages;
37
38
  settings: Wsettings;
38
39
  overlays: Woverlays;
40
+ /** 运行时字体使用索引;不参与文档 JSON 序列化。 */
41
+ fontUsage: ModelFontUsage;
39
42
  constructor(options: DocModelOptions);
40
43
  /**
41
44
  * 从原始 DOCX JSON 转换为 DocModel 实例
@@ -15,7 +15,7 @@ import { TextStyle } from '../types/style';
15
15
  * - 有效样式合并(由 TextStyleResolver 处理)
16
16
  */
17
17
  export declare class WrPr extends ModelNode {
18
- name: 'w:rPr';
18
+ name: "w:rPr";
19
19
  type: "element";
20
20
  elements: RawElement[];
21
21
  constructor(options: ModelNodeOptions & {
@@ -8,7 +8,7 @@ type IElement = ModelNode | RawElement;
8
8
  * 文本块实例类
9
9
  */
10
10
  export declare class WrText extends ModelNode {
11
- name: 'w:r';
11
+ name: "w:r";
12
12
  type: "element";
13
13
  handler: "text";
14
14
  /** 父节点引用 */
@@ -0,0 +1,22 @@
1
+ export interface ModelFontUsage {
2
+ fontFamilies: string[];
3
+ hasBold: boolean;
4
+ }
5
+ type FontStyleLike = {
6
+ rFonts?: Record<string, string | undefined>;
7
+ b?: boolean;
8
+ };
9
+ type ModelFontUsageOwner = {
10
+ fontUsage: ModelFontUsage;
11
+ };
12
+ /**
13
+ * ModelConverter.toModel 是同步转换;用作用域收集器避免把 context 逐层传给所有 fromXmlJson。
14
+ * 收集结果最终写入 DocModel.fontUsage,由 DocModel.toXmlJson 明确排除。
15
+ */
16
+ export declare function collectModelFontUsage<T>(factory: () => T): {
17
+ value: T;
18
+ usage: ModelFontUsage;
19
+ };
20
+ /** 转换阶段写入当前 collector;模型编辑阶段增量写入指定 DocModel。 */
21
+ export declare function recordModelFontStyle(style: FontStyleLike, model?: ModelFontUsageOwner | null): void;
22
+ export {};
@@ -16,11 +16,5 @@ export declare class ModelConverter {
16
16
  * @returns 原始 JSON 格式 (可用于 xml2js 反向转换)
17
17
  */
18
18
  static toRaw(model: DocModel): any;
19
- /**
20
- * 测试往返转换是否无损
21
- * @param rawJson 原始 JSON
22
- * @returns 是否转换无损
23
- */
24
- static testRoundtrip(rawJson: any): boolean;
25
19
  }
26
20
  export { DocModel } from './DocModel';