modern-text 1.0.2 → 1.0.3

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/dist/index.cjs CHANGED
@@ -512,6 +512,10 @@ function definePlugin(options) {
512
512
  }
513
513
 
514
514
  class Measurer {
515
+ static notZeroStyles = /* @__PURE__ */ new Set([
516
+ "width",
517
+ "height"
518
+ ]);
515
519
  static pxStyles = /* @__PURE__ */ new Set([
516
520
  "width",
517
521
  "height",
@@ -532,12 +536,13 @@ class Measurer {
532
536
  "paddingBottom"
533
537
  ]);
534
538
  _styleToDomStyle(style) {
535
- const _style = { ...style };
539
+ const _style = {};
536
540
  for (const key in style) {
537
- if (Measurer.pxStyles.has(key)) {
538
- _style[key] = `${style[key]}px`;
541
+ const value = style[key];
542
+ if (Measurer.notZeroStyles.has(key) && !value) ; else if (Measurer.pxStyles.has(key)) {
543
+ _style[key] = `${value}px`;
539
544
  } else {
540
- _style[key] = style[key];
545
+ _style[key] = value;
541
546
  }
542
547
  }
543
548
  return _style;
@@ -1482,7 +1487,7 @@ function textDecoration() {
1482
1487
  });
1483
1488
  }
1484
1489
 
1485
- const defaultTextStyles = modernIdoc.getDefaultTextStyle();
1490
+ const textDefaultStyle = modernIdoc.getDefaultStyle();
1486
1491
  class Text extends EventEmitter {
1487
1492
  debug;
1488
1493
  content;
@@ -1490,7 +1495,7 @@ class Text extends EventEmitter {
1490
1495
  effects;
1491
1496
  measureDom;
1492
1497
  needsUpdate = true;
1493
- computedStyle = { ...defaultTextStyles };
1498
+ computedStyle = { ...textDefaultStyle };
1494
1499
  paragraphs = [];
1495
1500
  lineBox = new modernPath2d.BoundingBox();
1496
1501
  rawGlyphBox = new modernPath2d.BoundingBox();
@@ -1538,7 +1543,7 @@ class Text extends EventEmitter {
1538
1543
  await Promise.all(Array.from(this.plugins.values()).map((p) => p.load?.(this)));
1539
1544
  }
1540
1545
  updateParagraphs() {
1541
- this.computedStyle = { ...defaultTextStyles, ...this.style };
1546
+ this.computedStyle = { ...textDefaultStyle, ...this.style };
1542
1547
  let { content, computedStyle: style } = this;
1543
1548
  const paragraphs = [];
1544
1549
  if (typeof content === "string") {
@@ -1726,7 +1731,6 @@ exports.Fragment = Fragment;
1726
1731
  exports.Measurer = Measurer;
1727
1732
  exports.Paragraph = Paragraph;
1728
1733
  exports.Text = Text;
1729
- exports.defaultTextStyles = defaultTextStyles;
1730
1734
  exports.definePlugin = definePlugin;
1731
1735
  exports.drawPath = drawPath;
1732
1736
  exports.filterEmpty = filterEmpty;
@@ -1747,5 +1751,6 @@ exports.render = render;
1747
1751
  exports.renderText = renderText;
1748
1752
  exports.setupView = setupView;
1749
1753
  exports.textDecoration = textDecoration;
1754
+ exports.textDefaultStyle = textDefaultStyle;
1750
1755
  exports.uploadColor = uploadColor;
1751
1756
  exports.uploadColors = uploadColors;
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { ITextStyle, IText, ITextContent, Highlight } from 'modern-idoc';
1
+ import { IDOCStyleDeclaration, IDOCTextDeclaration, IDOCTextContent, IDOCHighlightDeclaration } from 'modern-idoc';
2
2
  import { BoundingBox, Path2D, Vector2, VectorLike, Matrix3 } from 'modern-path2d';
3
3
  import { Fonts, Sfnt } from 'modern-font';
4
4
 
5
5
  declare function parseColor(ctx: CanvasRenderingContext2D, source: string | CanvasGradient | CanvasPattern, box: BoundingBox): string | CanvasGradient | CanvasPattern;
6
- declare function uploadColor(style: Partial<ITextStyle>, box: BoundingBox, ctx: CanvasRenderingContext2D): void;
6
+ declare function uploadColor(style: Partial<IDOCStyleDeclaration>, box: BoundingBox, ctx: CanvasRenderingContext2D): void;
7
7
  interface LinearGradient {
8
8
  x0: number;
9
9
  y0: number;
@@ -15,7 +15,7 @@ interface LinearGradient {
15
15
  }[];
16
16
  }
17
17
 
18
- interface DrawShapePathsOptions extends Partial<ITextStyle> {
18
+ interface DrawShapePathsOptions extends Partial<IDOCStyleDeclaration> {
19
19
  ctx: CanvasRenderingContext2D;
20
20
  path: Path2D;
21
21
  fontSize: number;
@@ -27,13 +27,13 @@ declare function setupView(ctx: CanvasRenderingContext2D, pixelRatio: number, bo
27
27
 
28
28
  declare class Fragment {
29
29
  content: string;
30
- style: Partial<ITextStyle>;
30
+ style: Partial<IDOCStyleDeclaration>;
31
31
  parent: Paragraph;
32
32
  inlineBox: BoundingBox;
33
33
  characters: Character[];
34
- computedStyle: ITextStyle;
34
+ computedStyle: IDOCStyleDeclaration;
35
35
  get computedContent(): string;
36
- constructor(content: string, style: Partial<ITextStyle> | undefined, parent: Paragraph);
36
+ constructor(content: string, style: Partial<IDOCStyleDeclaration> | undefined, parent: Paragraph);
37
37
  updateComputedStyle(): this;
38
38
  initCharacters(): this;
39
39
  }
@@ -65,7 +65,7 @@ declare class Character {
65
65
  centerDiviation: number;
66
66
  fontStyle?: 'bold' | 'italic';
67
67
  get center(): Vector2 | undefined;
68
- get computedStyle(): ITextStyle;
68
+ get computedStyle(): IDOCStyleDeclaration;
69
69
  get isVertical(): boolean;
70
70
  get fontSize(): number;
71
71
  get fontHeight(): number;
@@ -79,18 +79,18 @@ declare class Character {
79
79
  max: Vector2;
80
80
  } | undefined;
81
81
  getGlyphBoundingBox(withStyle?: boolean): BoundingBox | undefined;
82
- drawTo(ctx: CanvasRenderingContext2D, config?: Partial<ITextStyle>): void;
82
+ drawTo(ctx: CanvasRenderingContext2D, config?: Partial<IDOCStyleDeclaration>): void;
83
83
  }
84
84
 
85
85
  declare class Paragraph {
86
- style: Partial<ITextStyle>;
87
- parentStyle: ITextStyle;
86
+ style: Partial<IDOCStyleDeclaration>;
87
+ parentStyle: IDOCStyleDeclaration;
88
88
  lineBox: BoundingBox;
89
89
  fragments: Fragment[];
90
- computedStyle: ITextStyle;
91
- constructor(style: Partial<ITextStyle>, parentStyle: ITextStyle);
90
+ computedStyle: IDOCStyleDeclaration;
91
+ constructor(style: Partial<IDOCStyleDeclaration>, parentStyle: IDOCStyleDeclaration);
92
92
  updateComputedStyle(): this;
93
- addFragment(content: string, style?: Partial<ITextStyle>): Fragment;
93
+ addFragment(content: string, style?: Partial<IDOCStyleDeclaration>): Fragment;
94
94
  }
95
95
 
96
96
  interface TextPlugin {
@@ -103,7 +103,8 @@ interface TextPlugin {
103
103
  renderOrder?: number;
104
104
  load?: (text: Text$1) => Promise<void>;
105
105
  }
106
- interface TextOptions extends Partial<Omit<IText, 'type'>> {
106
+ interface TextOptions extends Partial<IDOCTextDeclaration> {
107
+ style?: IDOCStyleDeclaration;
107
108
  debug?: boolean;
108
109
  measureDom?: HTMLElement;
109
110
  fonts?: Fonts;
@@ -161,6 +162,7 @@ interface MeasureDomResult {
161
162
  boundingBox: BoundingBox;
162
163
  }
163
164
  declare class Measurer {
165
+ static notZeroStyles: Set<string>;
164
166
  static pxStyles: Set<string>;
165
167
  protected _styleToDomStyle(style: Record<string, any>): Record<string, any>;
166
168
  /**
@@ -173,7 +175,7 @@ declare class Measurer {
173
175
  * </ul>
174
176
  * </section>
175
177
  */
176
- createParagraphDom(paragraphs: Paragraph[], rootStyle: ITextStyle): {
178
+ createParagraphDom(paragraphs: Paragraph[], rootStyle: IDOCStyleDeclaration): {
177
179
  dom: HTMLElement;
178
180
  destory: () => void;
179
181
  };
@@ -190,7 +192,7 @@ declare class Measurer {
190
192
  characters: MeasuredCharacter[];
191
193
  };
192
194
  measureParagraphDom(paragraphs: Paragraph[], dom: HTMLElement): MeasureDomResult;
193
- measure(paragraphs: Paragraph[], rootStyle: ITextStyle, dom?: HTMLElement): MeasureDomResult;
195
+ measure(paragraphs: Paragraph[], rootStyle: IDOCStyleDeclaration, dom?: HTMLElement): MeasureDomResult;
194
196
  }
195
197
 
196
198
  interface TextRenderOptions {
@@ -205,7 +207,7 @@ interface MeasureResult {
205
207
  pathBox: BoundingBox;
206
208
  boundingBox: BoundingBox;
207
209
  }
208
- declare const defaultTextStyles: ITextStyle;
210
+ declare const textDefaultStyle: IDOCStyleDeclaration;
209
211
  interface TextEventMap {
210
212
  update: {
211
213
  text: Text$1;
@@ -222,12 +224,12 @@ interface TextEventMap {
222
224
  }
223
225
  declare class Text$1 extends EventEmitter<TextEventMap> {
224
226
  debug: boolean;
225
- content: ITextContent;
226
- style: Partial<ITextStyle>;
227
- effects?: Partial<ITextStyle>[];
227
+ content: IDOCTextContent;
228
+ style: Partial<IDOCStyleDeclaration>;
229
+ effects?: Partial<IDOCStyleDeclaration>[];
228
230
  measureDom?: HTMLElement;
229
231
  needsUpdate: boolean;
230
- computedStyle: ITextStyle;
232
+ computedStyle: IDOCStyleDeclaration;
231
233
  paragraphs: Paragraph[];
232
234
  lineBox: BoundingBox;
233
235
  rawGlyphBox: BoundingBox;
@@ -277,13 +279,13 @@ declare function renderText(options: RenderTextOptions & {
277
279
  load?: false;
278
280
  }): void;
279
281
 
280
- declare function getHighlightStyle(style: ITextStyle): Highlight;
282
+ declare function getHighlightStyle(style: IDOCStyleDeclaration): IDOCHighlightDeclaration;
281
283
  declare function highlight(): TextPlugin;
282
284
 
283
285
  declare function listStyle(): TextPlugin;
284
286
 
285
287
  declare function render(): TextPlugin;
286
- declare function getTransform2D(text: Text$1, style: Partial<ITextStyle>): Matrix3;
288
+ declare function getTransform2D(text: Text$1, style: Partial<IDOCStyleDeclaration>): Matrix3;
287
289
 
288
290
  declare function textDecoration(): TextPlugin;
289
291
 
@@ -300,4 +302,4 @@ declare function hexToRgb(hex: string): string | null;
300
302
  declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
301
303
  declare function needsFetch(source: string): boolean;
302
304
 
303
- export { Character, type DrawShapePathsOptions, Fragment, type LinearGradient, type MeasureDomResult, type MeasureResult, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, Measurer, Paragraph, type RenderTextOptions, Text$1 as Text, type TextEventMap, type TextOptions, type TextPlugin, type TextRenderOptions, defaultTextStyles, definePlugin, drawPath, filterEmpty, getHighlightStyle, getTransform2D, hexToRgb, highlight, isEqualObject, isEqualValue, isNone, listStyle, measureText, needsFetch, parseColor, parseColormap, parseValueNumber, render, renderText, setupView, textDecoration, uploadColor, uploadColors };
305
+ export { Character, type DrawShapePathsOptions, Fragment, type LinearGradient, type MeasureDomResult, type MeasureResult, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, Measurer, Paragraph, type RenderTextOptions, Text$1 as Text, type TextEventMap, type TextOptions, type TextPlugin, type TextRenderOptions, definePlugin, drawPath, filterEmpty, getHighlightStyle, getTransform2D, hexToRgb, highlight, isEqualObject, isEqualValue, isNone, listStyle, measureText, needsFetch, parseColor, parseColormap, parseValueNumber, render, renderText, setupView, textDecoration, textDefaultStyle, uploadColor, uploadColors };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import { ITextStyle, IText, ITextContent, Highlight } from 'modern-idoc';
1
+ import { IDOCStyleDeclaration, IDOCTextDeclaration, IDOCTextContent, IDOCHighlightDeclaration } from 'modern-idoc';
2
2
  import { BoundingBox, Path2D, Vector2, VectorLike, Matrix3 } from 'modern-path2d';
3
3
  import { Fonts, Sfnt } from 'modern-font';
4
4
 
5
5
  declare function parseColor(ctx: CanvasRenderingContext2D, source: string | CanvasGradient | CanvasPattern, box: BoundingBox): string | CanvasGradient | CanvasPattern;
6
- declare function uploadColor(style: Partial<ITextStyle>, box: BoundingBox, ctx: CanvasRenderingContext2D): void;
6
+ declare function uploadColor(style: Partial<IDOCStyleDeclaration>, box: BoundingBox, ctx: CanvasRenderingContext2D): void;
7
7
  interface LinearGradient {
8
8
  x0: number;
9
9
  y0: number;
@@ -15,7 +15,7 @@ interface LinearGradient {
15
15
  }[];
16
16
  }
17
17
 
18
- interface DrawShapePathsOptions extends Partial<ITextStyle> {
18
+ interface DrawShapePathsOptions extends Partial<IDOCStyleDeclaration> {
19
19
  ctx: CanvasRenderingContext2D;
20
20
  path: Path2D;
21
21
  fontSize: number;
@@ -27,13 +27,13 @@ declare function setupView(ctx: CanvasRenderingContext2D, pixelRatio: number, bo
27
27
 
28
28
  declare class Fragment {
29
29
  content: string;
30
- style: Partial<ITextStyle>;
30
+ style: Partial<IDOCStyleDeclaration>;
31
31
  parent: Paragraph;
32
32
  inlineBox: BoundingBox;
33
33
  characters: Character[];
34
- computedStyle: ITextStyle;
34
+ computedStyle: IDOCStyleDeclaration;
35
35
  get computedContent(): string;
36
- constructor(content: string, style: Partial<ITextStyle> | undefined, parent: Paragraph);
36
+ constructor(content: string, style: Partial<IDOCStyleDeclaration> | undefined, parent: Paragraph);
37
37
  updateComputedStyle(): this;
38
38
  initCharacters(): this;
39
39
  }
@@ -65,7 +65,7 @@ declare class Character {
65
65
  centerDiviation: number;
66
66
  fontStyle?: 'bold' | 'italic';
67
67
  get center(): Vector2 | undefined;
68
- get computedStyle(): ITextStyle;
68
+ get computedStyle(): IDOCStyleDeclaration;
69
69
  get isVertical(): boolean;
70
70
  get fontSize(): number;
71
71
  get fontHeight(): number;
@@ -79,18 +79,18 @@ declare class Character {
79
79
  max: Vector2;
80
80
  } | undefined;
81
81
  getGlyphBoundingBox(withStyle?: boolean): BoundingBox | undefined;
82
- drawTo(ctx: CanvasRenderingContext2D, config?: Partial<ITextStyle>): void;
82
+ drawTo(ctx: CanvasRenderingContext2D, config?: Partial<IDOCStyleDeclaration>): void;
83
83
  }
84
84
 
85
85
  declare class Paragraph {
86
- style: Partial<ITextStyle>;
87
- parentStyle: ITextStyle;
86
+ style: Partial<IDOCStyleDeclaration>;
87
+ parentStyle: IDOCStyleDeclaration;
88
88
  lineBox: BoundingBox;
89
89
  fragments: Fragment[];
90
- computedStyle: ITextStyle;
91
- constructor(style: Partial<ITextStyle>, parentStyle: ITextStyle);
90
+ computedStyle: IDOCStyleDeclaration;
91
+ constructor(style: Partial<IDOCStyleDeclaration>, parentStyle: IDOCStyleDeclaration);
92
92
  updateComputedStyle(): this;
93
- addFragment(content: string, style?: Partial<ITextStyle>): Fragment;
93
+ addFragment(content: string, style?: Partial<IDOCStyleDeclaration>): Fragment;
94
94
  }
95
95
 
96
96
  interface TextPlugin {
@@ -103,7 +103,8 @@ interface TextPlugin {
103
103
  renderOrder?: number;
104
104
  load?: (text: Text$1) => Promise<void>;
105
105
  }
106
- interface TextOptions extends Partial<Omit<IText, 'type'>> {
106
+ interface TextOptions extends Partial<IDOCTextDeclaration> {
107
+ style?: IDOCStyleDeclaration;
107
108
  debug?: boolean;
108
109
  measureDom?: HTMLElement;
109
110
  fonts?: Fonts;
@@ -161,6 +162,7 @@ interface MeasureDomResult {
161
162
  boundingBox: BoundingBox;
162
163
  }
163
164
  declare class Measurer {
165
+ static notZeroStyles: Set<string>;
164
166
  static pxStyles: Set<string>;
165
167
  protected _styleToDomStyle(style: Record<string, any>): Record<string, any>;
166
168
  /**
@@ -173,7 +175,7 @@ declare class Measurer {
173
175
  * </ul>
174
176
  * </section>
175
177
  */
176
- createParagraphDom(paragraphs: Paragraph[], rootStyle: ITextStyle): {
178
+ createParagraphDom(paragraphs: Paragraph[], rootStyle: IDOCStyleDeclaration): {
177
179
  dom: HTMLElement;
178
180
  destory: () => void;
179
181
  };
@@ -190,7 +192,7 @@ declare class Measurer {
190
192
  characters: MeasuredCharacter[];
191
193
  };
192
194
  measureParagraphDom(paragraphs: Paragraph[], dom: HTMLElement): MeasureDomResult;
193
- measure(paragraphs: Paragraph[], rootStyle: ITextStyle, dom?: HTMLElement): MeasureDomResult;
195
+ measure(paragraphs: Paragraph[], rootStyle: IDOCStyleDeclaration, dom?: HTMLElement): MeasureDomResult;
194
196
  }
195
197
 
196
198
  interface TextRenderOptions {
@@ -205,7 +207,7 @@ interface MeasureResult {
205
207
  pathBox: BoundingBox;
206
208
  boundingBox: BoundingBox;
207
209
  }
208
- declare const defaultTextStyles: ITextStyle;
210
+ declare const textDefaultStyle: IDOCStyleDeclaration;
209
211
  interface TextEventMap {
210
212
  update: {
211
213
  text: Text$1;
@@ -222,12 +224,12 @@ interface TextEventMap {
222
224
  }
223
225
  declare class Text$1 extends EventEmitter<TextEventMap> {
224
226
  debug: boolean;
225
- content: ITextContent;
226
- style: Partial<ITextStyle>;
227
- effects?: Partial<ITextStyle>[];
227
+ content: IDOCTextContent;
228
+ style: Partial<IDOCStyleDeclaration>;
229
+ effects?: Partial<IDOCStyleDeclaration>[];
228
230
  measureDom?: HTMLElement;
229
231
  needsUpdate: boolean;
230
- computedStyle: ITextStyle;
232
+ computedStyle: IDOCStyleDeclaration;
231
233
  paragraphs: Paragraph[];
232
234
  lineBox: BoundingBox;
233
235
  rawGlyphBox: BoundingBox;
@@ -277,13 +279,13 @@ declare function renderText(options: RenderTextOptions & {
277
279
  load?: false;
278
280
  }): void;
279
281
 
280
- declare function getHighlightStyle(style: ITextStyle): Highlight;
282
+ declare function getHighlightStyle(style: IDOCStyleDeclaration): IDOCHighlightDeclaration;
281
283
  declare function highlight(): TextPlugin;
282
284
 
283
285
  declare function listStyle(): TextPlugin;
284
286
 
285
287
  declare function render(): TextPlugin;
286
- declare function getTransform2D(text: Text$1, style: Partial<ITextStyle>): Matrix3;
288
+ declare function getTransform2D(text: Text$1, style: Partial<IDOCStyleDeclaration>): Matrix3;
287
289
 
288
290
  declare function textDecoration(): TextPlugin;
289
291
 
@@ -300,4 +302,4 @@ declare function hexToRgb(hex: string): string | null;
300
302
  declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
301
303
  declare function needsFetch(source: string): boolean;
302
304
 
303
- export { Character, type DrawShapePathsOptions, Fragment, type LinearGradient, type MeasureDomResult, type MeasureResult, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, Measurer, Paragraph, type RenderTextOptions, Text$1 as Text, type TextEventMap, type TextOptions, type TextPlugin, type TextRenderOptions, defaultTextStyles, definePlugin, drawPath, filterEmpty, getHighlightStyle, getTransform2D, hexToRgb, highlight, isEqualObject, isEqualValue, isNone, listStyle, measureText, needsFetch, parseColor, parseColormap, parseValueNumber, render, renderText, setupView, textDecoration, uploadColor, uploadColors };
305
+ export { Character, type DrawShapePathsOptions, Fragment, type LinearGradient, type MeasureDomResult, type MeasureResult, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, Measurer, Paragraph, type RenderTextOptions, Text$1 as Text, type TextEventMap, type TextOptions, type TextPlugin, type TextRenderOptions, definePlugin, drawPath, filterEmpty, getHighlightStyle, getTransform2D, hexToRgb, highlight, isEqualObject, isEqualValue, isNone, listStyle, measureText, needsFetch, parseColor, parseColormap, parseValueNumber, render, renderText, setupView, textDecoration, textDefaultStyle, uploadColor, uploadColors };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { ITextStyle, IText, ITextContent, Highlight } from 'modern-idoc';
1
+ import { IDOCStyleDeclaration, IDOCTextDeclaration, IDOCTextContent, IDOCHighlightDeclaration } from 'modern-idoc';
2
2
  import { BoundingBox, Path2D, Vector2, VectorLike, Matrix3 } from 'modern-path2d';
3
3
  import { Fonts, Sfnt } from 'modern-font';
4
4
 
5
5
  declare function parseColor(ctx: CanvasRenderingContext2D, source: string | CanvasGradient | CanvasPattern, box: BoundingBox): string | CanvasGradient | CanvasPattern;
6
- declare function uploadColor(style: Partial<ITextStyle>, box: BoundingBox, ctx: CanvasRenderingContext2D): void;
6
+ declare function uploadColor(style: Partial<IDOCStyleDeclaration>, box: BoundingBox, ctx: CanvasRenderingContext2D): void;
7
7
  interface LinearGradient {
8
8
  x0: number;
9
9
  y0: number;
@@ -15,7 +15,7 @@ interface LinearGradient {
15
15
  }[];
16
16
  }
17
17
 
18
- interface DrawShapePathsOptions extends Partial<ITextStyle> {
18
+ interface DrawShapePathsOptions extends Partial<IDOCStyleDeclaration> {
19
19
  ctx: CanvasRenderingContext2D;
20
20
  path: Path2D;
21
21
  fontSize: number;
@@ -27,13 +27,13 @@ declare function setupView(ctx: CanvasRenderingContext2D, pixelRatio: number, bo
27
27
 
28
28
  declare class Fragment {
29
29
  content: string;
30
- style: Partial<ITextStyle>;
30
+ style: Partial<IDOCStyleDeclaration>;
31
31
  parent: Paragraph;
32
32
  inlineBox: BoundingBox;
33
33
  characters: Character[];
34
- computedStyle: ITextStyle;
34
+ computedStyle: IDOCStyleDeclaration;
35
35
  get computedContent(): string;
36
- constructor(content: string, style: Partial<ITextStyle> | undefined, parent: Paragraph);
36
+ constructor(content: string, style: Partial<IDOCStyleDeclaration> | undefined, parent: Paragraph);
37
37
  updateComputedStyle(): this;
38
38
  initCharacters(): this;
39
39
  }
@@ -65,7 +65,7 @@ declare class Character {
65
65
  centerDiviation: number;
66
66
  fontStyle?: 'bold' | 'italic';
67
67
  get center(): Vector2 | undefined;
68
- get computedStyle(): ITextStyle;
68
+ get computedStyle(): IDOCStyleDeclaration;
69
69
  get isVertical(): boolean;
70
70
  get fontSize(): number;
71
71
  get fontHeight(): number;
@@ -79,18 +79,18 @@ declare class Character {
79
79
  max: Vector2;
80
80
  } | undefined;
81
81
  getGlyphBoundingBox(withStyle?: boolean): BoundingBox | undefined;
82
- drawTo(ctx: CanvasRenderingContext2D, config?: Partial<ITextStyle>): void;
82
+ drawTo(ctx: CanvasRenderingContext2D, config?: Partial<IDOCStyleDeclaration>): void;
83
83
  }
84
84
 
85
85
  declare class Paragraph {
86
- style: Partial<ITextStyle>;
87
- parentStyle: ITextStyle;
86
+ style: Partial<IDOCStyleDeclaration>;
87
+ parentStyle: IDOCStyleDeclaration;
88
88
  lineBox: BoundingBox;
89
89
  fragments: Fragment[];
90
- computedStyle: ITextStyle;
91
- constructor(style: Partial<ITextStyle>, parentStyle: ITextStyle);
90
+ computedStyle: IDOCStyleDeclaration;
91
+ constructor(style: Partial<IDOCStyleDeclaration>, parentStyle: IDOCStyleDeclaration);
92
92
  updateComputedStyle(): this;
93
- addFragment(content: string, style?: Partial<ITextStyle>): Fragment;
93
+ addFragment(content: string, style?: Partial<IDOCStyleDeclaration>): Fragment;
94
94
  }
95
95
 
96
96
  interface TextPlugin {
@@ -103,7 +103,8 @@ interface TextPlugin {
103
103
  renderOrder?: number;
104
104
  load?: (text: Text$1) => Promise<void>;
105
105
  }
106
- interface TextOptions extends Partial<Omit<IText, 'type'>> {
106
+ interface TextOptions extends Partial<IDOCTextDeclaration> {
107
+ style?: IDOCStyleDeclaration;
107
108
  debug?: boolean;
108
109
  measureDom?: HTMLElement;
109
110
  fonts?: Fonts;
@@ -161,6 +162,7 @@ interface MeasureDomResult {
161
162
  boundingBox: BoundingBox;
162
163
  }
163
164
  declare class Measurer {
165
+ static notZeroStyles: Set<string>;
164
166
  static pxStyles: Set<string>;
165
167
  protected _styleToDomStyle(style: Record<string, any>): Record<string, any>;
166
168
  /**
@@ -173,7 +175,7 @@ declare class Measurer {
173
175
  * </ul>
174
176
  * </section>
175
177
  */
176
- createParagraphDom(paragraphs: Paragraph[], rootStyle: ITextStyle): {
178
+ createParagraphDom(paragraphs: Paragraph[], rootStyle: IDOCStyleDeclaration): {
177
179
  dom: HTMLElement;
178
180
  destory: () => void;
179
181
  };
@@ -190,7 +192,7 @@ declare class Measurer {
190
192
  characters: MeasuredCharacter[];
191
193
  };
192
194
  measureParagraphDom(paragraphs: Paragraph[], dom: HTMLElement): MeasureDomResult;
193
- measure(paragraphs: Paragraph[], rootStyle: ITextStyle, dom?: HTMLElement): MeasureDomResult;
195
+ measure(paragraphs: Paragraph[], rootStyle: IDOCStyleDeclaration, dom?: HTMLElement): MeasureDomResult;
194
196
  }
195
197
 
196
198
  interface TextRenderOptions {
@@ -205,7 +207,7 @@ interface MeasureResult {
205
207
  pathBox: BoundingBox;
206
208
  boundingBox: BoundingBox;
207
209
  }
208
- declare const defaultTextStyles: ITextStyle;
210
+ declare const textDefaultStyle: IDOCStyleDeclaration;
209
211
  interface TextEventMap {
210
212
  update: {
211
213
  text: Text$1;
@@ -222,12 +224,12 @@ interface TextEventMap {
222
224
  }
223
225
  declare class Text$1 extends EventEmitter<TextEventMap> {
224
226
  debug: boolean;
225
- content: ITextContent;
226
- style: Partial<ITextStyle>;
227
- effects?: Partial<ITextStyle>[];
227
+ content: IDOCTextContent;
228
+ style: Partial<IDOCStyleDeclaration>;
229
+ effects?: Partial<IDOCStyleDeclaration>[];
228
230
  measureDom?: HTMLElement;
229
231
  needsUpdate: boolean;
230
- computedStyle: ITextStyle;
232
+ computedStyle: IDOCStyleDeclaration;
231
233
  paragraphs: Paragraph[];
232
234
  lineBox: BoundingBox;
233
235
  rawGlyphBox: BoundingBox;
@@ -277,13 +279,13 @@ declare function renderText(options: RenderTextOptions & {
277
279
  load?: false;
278
280
  }): void;
279
281
 
280
- declare function getHighlightStyle(style: ITextStyle): Highlight;
282
+ declare function getHighlightStyle(style: IDOCStyleDeclaration): IDOCHighlightDeclaration;
281
283
  declare function highlight(): TextPlugin;
282
284
 
283
285
  declare function listStyle(): TextPlugin;
284
286
 
285
287
  declare function render(): TextPlugin;
286
- declare function getTransform2D(text: Text$1, style: Partial<ITextStyle>): Matrix3;
288
+ declare function getTransform2D(text: Text$1, style: Partial<IDOCStyleDeclaration>): Matrix3;
287
289
 
288
290
  declare function textDecoration(): TextPlugin;
289
291
 
@@ -300,4 +302,4 @@ declare function hexToRgb(hex: string): string | null;
300
302
  declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
301
303
  declare function needsFetch(source: string): boolean;
302
304
 
303
- export { Character, type DrawShapePathsOptions, Fragment, type LinearGradient, type MeasureDomResult, type MeasureResult, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, Measurer, Paragraph, type RenderTextOptions, Text$1 as Text, type TextEventMap, type TextOptions, type TextPlugin, type TextRenderOptions, defaultTextStyles, definePlugin, drawPath, filterEmpty, getHighlightStyle, getTransform2D, hexToRgb, highlight, isEqualObject, isEqualValue, isNone, listStyle, measureText, needsFetch, parseColor, parseColormap, parseValueNumber, render, renderText, setupView, textDecoration, uploadColor, uploadColors };
305
+ export { Character, type DrawShapePathsOptions, Fragment, type LinearGradient, type MeasureDomResult, type MeasureResult, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, Measurer, Paragraph, type RenderTextOptions, Text$1 as Text, type TextEventMap, type TextOptions, type TextPlugin, type TextRenderOptions, definePlugin, drawPath, filterEmpty, getHighlightStyle, getTransform2D, hexToRgb, highlight, isEqualObject, isEqualValue, isNone, listStyle, measureText, needsFetch, parseColor, parseColormap, parseValueNumber, render, renderText, setupView, textDecoration, textDefaultStyle, uploadColor, uploadColors };