modern-text 0.7.2 → 0.7.4

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.d.ts CHANGED
@@ -252,7 +252,24 @@ interface TextLineStyle {
252
252
  listStyleSize: ListStyleSize;
253
253
  listStylePosition: ListStylePosition;
254
254
  }
255
- interface TextInlineStyle {
255
+ interface HighlightStyle {
256
+ image: HighlightImage;
257
+ referImage: HighlightReferImage;
258
+ colormap: HighlightColormap;
259
+ line: HighlightLine;
260
+ size: HighlightSize;
261
+ thickness: HighlightThickness;
262
+ }
263
+ interface TextHighlightStyle {
264
+ highlight?: Partial<HighlightStyle>;
265
+ highlightImage?: HighlightImage;
266
+ highlightReferImage?: HighlightReferImage;
267
+ highlightColormap?: HighlightColormap;
268
+ highlightLine?: HighlightLine;
269
+ highlightSize?: HighlightSize;
270
+ highlightThickness?: HighlightThickness;
271
+ }
272
+ interface TextInlineStyle extends TextHighlightStyle {
256
273
  verticalAlign: VerticalAlign;
257
274
  letterSpacing: number;
258
275
  fontSize: number;
@@ -263,12 +280,6 @@ interface TextInlineStyle {
263
280
  textTransform: TextTransform;
264
281
  textOrientation: TextOrientation;
265
282
  textDecoration: TextDecorationLine;
266
- highlightImage: HighlightImage;
267
- highlightReferImage: HighlightReferImage;
268
- highlightColormap: HighlightColormap;
269
- highlightLine: HighlightLine;
270
- highlightSize: HighlightSize;
271
- highlightThickness: HighlightThickness;
272
283
  }
273
284
  interface TextDrawStyle {
274
285
  color: string | CanvasGradient | CanvasPattern;
@@ -349,10 +360,22 @@ declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text$1): void
349
360
 
350
361
  declare function definePlugin(options: TextPlugin): TextPlugin;
351
362
 
352
- declare function measureText(options: TextOptions): MeasureResult;
363
+ declare function measureText(options: TextOptions & {
364
+ load: true;
365
+ }): Promise<MeasureResult>;
366
+ declare function measureText(options: TextOptions & {
367
+ load?: false;
368
+ }): MeasureResult;
353
369
 
354
- declare function renderText(options: TextOptions & TextRenderOptions): void;
370
+ type RenderTextOptions = TextOptions & TextRenderOptions;
371
+ declare function renderText(options: RenderTextOptions & {
372
+ load: true;
373
+ }): Promise<void>;
374
+ declare function renderText(options: RenderTextOptions & {
375
+ load?: false;
376
+ }): void;
355
377
 
378
+ declare function getHighlightStyle(style: TextStyle): HighlightStyle;
356
379
  declare function highlight(): TextPlugin;
357
380
 
358
381
  declare function listStyle(): TextPlugin;
@@ -375,4 +398,4 @@ declare function hexToRgb(hex: string): string | null;
375
398
  declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
376
399
  declare function needsFetch(source: string): boolean;
377
400
 
378
- export { Character, type DrawShapePathsOptions, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type HighlightColormap, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightThickness, type LinearGradient, type ListStyleColormap, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type MeasureDomResult, type MeasureResult, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, Measurer, Paragraph, type ParagraphContent, type Sizeable, Text$1 as Text, type TextAlign, type TextContent, type TextDecorationLine, type TextDrawStyle, type TextEventMap, type TextInlineStyle, type TextLineStyle, type TextOptions, type TextOrientation, type TextPlugin, type TextRenderOptions, type TextStyle, type TextTransform, type TextWrap, type VerticalAlign, type WritingMode, defaultTextStyles, definePlugin, drawPath, filterEmpty, getTransform2D, hexToRgb, highlight, isEqualObject, isEqualValue, isNone, listStyle, measureText, needsFetch, parseColor, parseColormap, parseValueNumber, render, renderText, setupView, textDecoration, uploadColor, uploadColors };
401
+ export { Character, type DrawShapePathsOptions, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type HighlightColormap, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightStyle, type HighlightThickness, type LinearGradient, type ListStyleColormap, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type MeasureDomResult, type MeasureResult, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, Measurer, Paragraph, type ParagraphContent, type RenderTextOptions, type Sizeable, Text$1 as Text, type TextAlign, type TextContent, type TextDecorationLine, type TextDrawStyle, type TextEventMap, type TextHighlightStyle, type TextInlineStyle, type TextLineStyle, type TextOptions, type TextOrientation, type TextPlugin, type TextRenderOptions, type TextStyle, type TextTransform, type TextWrap, type VerticalAlign, type WritingMode, defaultTextStyles, definePlugin, drawPath, filterEmpty, getHighlightStyle, getTransform2D, hexToRgb, highlight, isEqualObject, isEqualValue, isNone, listStyle, measureText, needsFetch, parseColor, parseColormap, parseValueNumber, render, renderText, setupView, textDecoration, uploadColor, uploadColors };