roosterjs 9.32.0 → 9.34.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.
@@ -1,4 +1,4 @@
1
- // Type definitions for roosterjs (Version 9.32.0)
1
+ // Type definitions for roosterjs (Version 9.34.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -40,7 +40,7 @@ export interface ReadonlyContentModelWithFormat<T extends ContentModelFormatBase
40
40
  /**
41
41
  * Format of Table
42
42
  */
43
- export type ContentModelTableFormat = ContentModelBlockFormat & IdFormat & AriaFormat & BorderFormat & BorderBoxFormat & SpacingFormat & MarginFormat & DisplayFormat & TableLayoutFormat & SizeFormat;
43
+ export type ContentModelTableFormat = ContentModelBlockFormat & IdFormat & AriaFormat & BorderFormat & BorderBoxFormat & DirectionFormat & SpacingFormat & MarginFormat & DisplayFormat & TableLayoutFormat & SizeFormat;
44
44
 
45
45
  /**
46
46
  * Represents base format of an element that supports dataset and/or metadata
@@ -2559,6 +2559,33 @@ export interface ModelToDomSettings {
2559
2559
  * Map of metadata appliers
2560
2560
  */
2561
2561
  metadataAppliers: MetadataAppliers;
2562
+ /**
2563
+ * Default format for each tag name used for generating DOM tree from content model.
2564
+ *
2565
+ * This map defines the default implicit formats for specific HTML tag names. It is used during
2566
+ * the conversion of a content model to a DOM tree to ensure that elements are styled correctly
2567
+ * based on their tag name. Each entry in the map associates a tag name (in lowercase) with a
2568
+ * combination of segment and block formats.
2569
+ *
2570
+ * Example:
2571
+ * {
2572
+ * "p": {
2573
+ * fontSize: "12px",
2574
+ * lineHeight: "1.5",
2575
+ * marginTop: "10px",
2576
+ * marginBottom: "10px"
2577
+ * },
2578
+ * "h1": {
2579
+ * fontSize: "24px",
2580
+ * fontWeight: "bold",
2581
+ * marginTop: "20px",
2582
+ * marginBottom: "20px"
2583
+ * }
2584
+ * }
2585
+ */
2586
+ defaultContentModelFormatMap: {
2587
+ [tagName: string]: ContentModelSegmentFormat & ContentModelBlockFormat;
2588
+ };
2562
2589
  /**
2563
2590
  * Default Content Model to DOM handlers before overriding.
2564
2591
  * This provides a way to call original handler from an overridden handler function
@@ -2731,6 +2758,10 @@ export interface DomToModelSettings {
2731
2758
  * This provides a way to call original format parser from an overridden parser function
2732
2759
  */
2733
2760
  defaultFormatParsers: Readonly<FormatParsers>;
2761
+ /**
2762
+ * If true elements that has display:none style will be processed
2763
+ */
2764
+ processNonVisibleElements?: boolean;
2734
2765
  }
2735
2766
 
2736
2767
  /**
@@ -3069,6 +3100,10 @@ export interface DomToModelOption {
3069
3100
  * Provide additional format parsers for each format type
3070
3101
  */
3071
3102
  additionalFormatParsers?: Partial<FormatParsersPerCategory>;
3103
+ /**
3104
+ * If true elements that has display:none style will be processed
3105
+ */
3106
+ processNonVisibleElements?: boolean;
3072
3107
  }
3073
3108
 
3074
3109
  /**
@@ -3136,6 +3171,31 @@ export interface ModelToDomOption {
3136
3171
  * When set to true, selection from content model will not be applied
3137
3172
  */
3138
3173
  ignoreSelection?: boolean;
3174
+ /**
3175
+ * Overrides the default content model formats for specific HTML tags.
3176
+ *
3177
+ * This property allows you to specify custom formats for both segment and block-level
3178
+ * content models for specific tags. The key is the tag name (e.g., 'div', 'span'),
3179
+ * and the value is an object containing both segment and block format overrides.
3180
+ *
3181
+ * Example:
3182
+ * ```
3183
+ * defaultContentModelFormatOverride: {
3184
+ * div: {
3185
+ * fontSize: '16px',
3186
+ * textAlign: 'center',
3187
+ * backgroundColor: 'lightblue',
3188
+ * },
3189
+ * span: {
3190
+ * fontWeight: 'bold',
3191
+ * color: 'red',
3192
+ * },
3193
+ * }
3194
+ * ```
3195
+ */
3196
+ defaultContentModelFormatOverride?: {
3197
+ [tagName: string]: ContentModelSegmentFormat & ContentModelBlockFormat;
3198
+ };
3139
3199
  }
3140
3200
 
3141
3201
  /**
@@ -3623,7 +3683,11 @@ export type ExperimentalFeature = /**
3623
3683
  * selection marker may be recreated during reconciliation, potentially losing its original formatting. This feature ensures
3624
3684
  * the original formatting of the selection marker is kept to match the pending format.
3625
3685
  */
3626
- | 'KeepSelectionMarkerWhenEnteringTextNode';
3686
+ | 'KeepSelectionMarkerWhenEnteringTextNode'
3687
+ /**
3688
+ * Export editor content as HTML using HTMLFast option
3689
+ */
3690
+ | 'ExportHTMLFast';
3627
3691
 
3628
3692
  /**
3629
3693
  * Options for editor
@@ -5209,6 +5273,10 @@ export interface DOMEventRecord<E = Event> {
5209
5273
  * when correlated DOM event is fired
5210
5274
  */
5211
5275
  beforeDispatch?: DOMEventHandlerFunction<E> | null;
5276
+ /**
5277
+ * Whether the event should be captured in the capturing phase.
5278
+ */
5279
+ capture?: boolean;
5212
5280
  }
5213
5281
 
5214
5282
  /**
@@ -5481,8 +5549,10 @@ export interface DOMHelper {
5481
5549
  getClonedRoot(): HTMLElement;
5482
5550
  /**
5483
5551
  * Get format of the container element
5552
+ * @param isInDarkMode Optional flag to indicate if the environment is in dark mode
5553
+ * @param darkColorHandler Optional DarkColorHandler to retrieve dark mode colors
5484
5554
  */
5485
- getContainerFormat(): ContentModelSegmentFormat;
5555
+ getContainerFormat(isInDarkMode?: boolean, darkColorHandler?: DarkColorHandler): ContentModelSegmentFormat;
5486
5556
  }
5487
5557
 
5488
5558
  /**
@@ -6503,7 +6573,6 @@ export function handleRegularSelection(index: number, context: DomToModelContext
6503
6573
  * @param group The parent block group
6504
6574
  * @param parent Parent DOM node to process
6505
6575
  * @param context DOM to Content Model context
6506
- *
6507
6576
  */
6508
6577
  export function processChildNode(group: ContentModelBlockGroup, child: Node, context: DomToModelContext): void;
6509
6578
 
@@ -7143,8 +7212,9 @@ export const DeprecatedColors: string[];
7143
7212
  * @param isBackground True to get background color, false to get text color
7144
7213
  * @param isDarkMode Whether element is in dark mode now
7145
7214
  * @param darkColorHandler @optional The dark color handler object to help manager dark mode color
7215
+ * @param fallback @optional Fallback color to use if no color is found from the element
7146
7216
  */
7147
- export function getColor(element: HTMLElement, isBackground: boolean, isDarkMode: boolean, darkColorHandler?: DarkColorHandler): string | undefined;
7217
+ export function getColor(element: HTMLElement, isBackground: boolean, isDarkMode: boolean, darkColorHandler?: DarkColorHandler, fallback?: string): string | undefined;
7148
7218
 
7149
7219
  /**
7150
7220
  * Set color to given HTML element
@@ -7638,8 +7708,12 @@ export function setTableCellBackgroundColor(cell: ShallowMutableContentModelTabl
7638
7708
  * @param pendingFormat Existing pending format, if any
7639
7709
  * @param formatState Existing format state object, used for receiving the result
7640
7710
  * @param conflictSolution The strategy for handling format conflicts
7711
+ * @param domHelper Optional DOMHelper to retrieve container format
7712
+ * @param isInDarkMode Optional flag to indicate if the environment is in dark mode
7713
+ * @param colorHandler Optional DarkColorHandler to handle dark mode colors
7714
+ *
7641
7715
  */
7642
- export function retrieveModelFormatState(model: ReadonlyContentModelDocument, pendingFormat: ContentModelSegmentFormat | null, formatState: ContentModelFormatState, conflictSolution?: ConflictFormatSolution, domHelper?: DOMHelper): void;
7716
+ export function retrieveModelFormatState(model: ReadonlyContentModelDocument, pendingFormat: ContentModelSegmentFormat | null, formatState: ContentModelFormatState, conflictSolution?: ConflictFormatSolution, domHelper?: DOMHelper, isInDarkMode?: boolean, colorHandler?: DarkColorHandler): void;
7643
7717
 
7644
7718
  /**
7645
7719
  * Gets the list style type that the bullet is part of, using the Constant record
@@ -8246,11 +8320,19 @@ export function createModelFromHtml(html: string, options?: Partial<DomToModelOp
8246
8320
  /**
8247
8321
  * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity
8248
8322
  * @param editor The editor to get content from
8249
- * @param mode Specify HTML to get plain text result. This is the default option
8323
+ * @param mode Specify HTML to get HTML. This is the default option
8250
8324
  * @param options @optional Options for Model to DOM conversion
8251
8325
  */
8252
8326
  export function exportContent(editor: IEditor, mode?: 'HTML', options?: ModelToDomOption): string;
8253
8327
 
8328
+ /**
8329
+ * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity.
8330
+ * This is a fast version, it retrieve HTML content directly from editor without going through content model conversion.
8331
+ * @param editor The editor to get content from
8332
+ * @param mode Specify HTMLFast to get HTML result.
8333
+ */
8334
+ export function exportContent(editor: IEditor, mode: 'HTMLFast'): string;
8335
+
8254
8336
  /**
8255
8337
  * Export plain text content
8256
8338
  * @param editor The editor to get content from
@@ -9785,7 +9867,6 @@ export interface CustomReplace {
9785
9867
  * - Flip image
9786
9868
  */
9787
9869
  export class ImageEditPlugin implements ImageEditor, EditorPlugin {
9788
- protected options: ImageEditOptions;
9789
9870
  protected editor: IEditor | null;
9790
9871
  private shadowSpan;
9791
9872
  private selectedImage;
@@ -9803,6 +9884,7 @@ export class ImageEditPlugin implements ImageEditor, EditorPlugin {
9803
9884
  private zoomScale;
9804
9885
  private disposer;
9805
9886
  protected isEditing: boolean;
9887
+ protected options: ImageEditOptions;
9806
9888
  constructor(options?: ImageEditOptions);
9807
9889
  /**
9808
9890
  * Get name of this plugin
@@ -9843,7 +9925,10 @@ export class ImageEditPlugin implements ImageEditor, EditorPlugin {
9843
9925
  */
9844
9926
  protected applyFormatWithContentModel(editor: IEditor, isCropMode: boolean, shouldSelectImage: boolean, isApiOperation?: boolean): void;
9845
9927
  private startEditing;
9928
+ private updateImageDimensionsIfZero;
9929
+ private startEditingInternal;
9846
9930
  startRotateAndResize(editor: IEditor, image: HTMLImageElement): void;
9931
+ private updateResizeHandleDirection;
9847
9932
  private updateRotateHandleState;
9848
9933
  isOperationAllowed(operation: ImageEditOperation): boolean;
9849
9934
  canRegenerateImage(image: HTMLImageElement): boolean;