roosterjs 8.40.2 → 8.42.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 8.40.2)
1
+ // Type definitions for roosterjs (Version 8.42.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -394,8 +394,10 @@ export function getBrowserInfo(userAgent: string, appVersion: string, vendor?: s
394
394
  * Apply format to an HTML element
395
395
  * @param element The HTML element to apply format to
396
396
  * @param format The format to apply
397
+ * @param isDarkMode Whether the content should be formatted in dark mode
398
+ * @param darkColorHandler An optional dark color handler object. When it is passed, we will use this handler to do variable-based dark color instead of original dataset base dark color
397
399
  */
398
- export function applyFormat(element: HTMLElement, format: DefaultFormat, isDarkMode?: boolean): void;
400
+ export function applyFormat(element: HTMLElement, format: DefaultFormat, isDarkMode?: boolean, darkColorHandler?: DarkColorHandler | null): void;
399
401
 
400
402
  /**
401
403
  * Change tag of an HTML Element to a new one, and replace it from DOM tree
@@ -683,9 +685,9 @@ export function getInnerHTML(node: HTMLElement | DocumentFragment): string;
683
685
  * @param isBackgroundColor Whether set background color or text color
684
686
  * @param isDarkMode Whether current mode is dark mode. @default false
685
687
  * @param shouldAdaptTheFontColor Whether the font color needs to be adapted to be visible in a dark or bright background color. @default false
686
- * @param defaultFontColor Set the default colors that needs to be set to the to be visible.
688
+ * @param darkColorHandler An optional dark color handler object. When it is passed, we will use this handler to do variable-based dark color instead of original dataset base dark color
687
689
  */
688
- export function setColor(element: HTMLElement, color: string | ModeIndependentColor, isBackgroundColor: boolean, isDarkMode?: boolean, shouldAdaptTheFontColor?: boolean): void;
690
+ export function setColor(element: HTMLElement, color: string | ModeIndependentColor, isBackgroundColor: boolean, isDarkMode?: boolean, shouldAdaptTheFontColor?: boolean, darkColorHandler?: DarkColorHandler | null): void;
689
691
 
690
692
  /**
691
693
  * A wrapper function of Element.matches
@@ -2236,6 +2238,10 @@ export class Editor implements IEditor {
2236
2238
  * @param node The node to transform
2237
2239
  */
2238
2240
  transformToDarkColor(node: Node): void;
2241
+ /**
2242
+ * Get a darkColorHandler object for this editor. It will return null if experimental feature "VariableBasedDarkColor" is not enabled
2243
+ */
2244
+ getDarkColorHandler(): DarkColorHandler | null;
2239
2245
  /**
2240
2246
  * Make the editor in "Shadow Edit" mode.
2241
2247
  * In Shadow Edit mode, all format change will finally be ignored.
@@ -2291,7 +2297,7 @@ export class Editor implements IEditor {
2291
2297
  * @returns the current EditorCore object
2292
2298
  * @throws a standard Error if there's no core object
2293
2299
  */
2294
- private getCore;
2300
+ protected getCore(): EditorCore;
2295
2301
  }
2296
2302
 
2297
2303
  /**
@@ -2377,19 +2383,10 @@ export function insertEntity(editor: IEditor, type: string, contentNode: Node, i
2377
2383
  /**
2378
2384
  * Insert an image to editor at current selection
2379
2385
  * @param editor The editor instance
2380
- * @param imageFile The image file. There are at least 3 ways to obtain the file object:
2381
- * From local file, from clipboard data, from drag-and-drop
2386
+ * @param imageFileOrSrc Either the image file blob or source string of the image.
2382
2387
  * @param attributes Optional image element attributes
2383
2388
  */
2384
- export function insertImage(editor: IEditor, imageFile: File, attributes?: Record<string, string>): void;
2385
-
2386
- /**
2387
- * Insert an image to editor at current selection
2388
- * @param editor The editor instance
2389
- * @param url The image link
2390
- * @param attributes Optional image element attributes
2391
- */
2392
- export function insertImage(editor: IEditor, url: string, attributes?: Record<string, string>): void;
2389
+ export function insertImage(editor: IEditor, imageFileOrSrc: File | string, attributes?: Record<string, string>): void;
2393
2390
 
2394
2391
  /**
2395
2392
  * Insert table into editor at current selection
@@ -3685,7 +3682,13 @@ export const enum ExperimentalFeatures {
3685
3682
  * When apply default format when initialize or user type, apply the format on a SPAN element rather than
3686
3683
  * the block element (In most case, the DIV element) so keep the block element clean.
3687
3684
  */
3688
- DefaultFormatInSpan = "DefaultFormatInSpan"
3685
+ DefaultFormatInSpan = "DefaultFormatInSpan",
3686
+ /**
3687
+ * Use variable-based dark mode solution rather than dataset-based solution.
3688
+ * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
3689
+ * if you need them work for dark mode
3690
+ */
3691
+ VariableBasedDarkColor = "VariableBasedDarkColor"
3689
3692
  }
3690
3693
 
3691
3694
  /**
@@ -5285,6 +5288,10 @@ export interface ElementBasedFormatState {
5285
5288
  * Whether the text is in block quote
5286
5289
  */
5287
5290
  isBlockQuote?: boolean;
5291
+ /**
5292
+ * Whether the text is in Code block
5293
+ */
5294
+ isCodeBlock?: boolean;
5288
5295
  /**
5289
5296
  * Whether unlink command can be called to the text
5290
5297
  */
@@ -5313,6 +5320,10 @@ export interface ElementBasedFormatState {
5313
5320
  * If there is a table, whether the table has header row
5314
5321
  */
5315
5322
  tableHasHeader?: boolean;
5323
+ /**
5324
+ * Whether we can execute table cell merge operation
5325
+ */
5326
+ canMergeTableCell?: boolean;
5316
5327
  }
5317
5328
 
5318
5329
  /**
@@ -5343,6 +5354,18 @@ export interface StyleBasedFormatState {
5343
5354
  * Mode independent background color for dark mode
5344
5355
  */
5345
5356
  textColors?: ModeIndependentColor;
5357
+ /**
5358
+ * Line height
5359
+ */
5360
+ lineHeight?: string;
5361
+ /**
5362
+ * Margin Top
5363
+ */
5364
+ marginTop?: string;
5365
+ /**
5366
+ * Margin Bottom
5367
+ */
5368
+ marginBottom?: string;
5346
5369
  }
5347
5370
 
5348
5371
  /**
@@ -6535,6 +6558,10 @@ export interface IEditor {
6535
6558
  * @param node The node to transform
6536
6559
  */
6537
6560
  transformToDarkColor(node: Node): void;
6561
+ /**
6562
+ * Get a darkColorHandler object for this editor. It will return null if experimental feature "VariableBasedDarkColor" is not enabled
6563
+ */
6564
+ getDarkColorHandler(): DarkColorHandler | null;
6538
6565
  /**
6539
6566
  * Make the editor in "Shadow Edit" mode.
6540
6567
  * In Shadow Edit mode, all format change will finally be ignored.
@@ -6587,6 +6614,48 @@ export interface IEditor {
6587
6614
  getVisibleViewport(): Rect | null;
6588
6615
  }
6589
6616
 
6617
+ /**
6618
+ * A handler object for dark color, used for variable-based dark color solution
6619
+ */
6620
+ export interface DarkColorHandler {
6621
+ /**
6622
+ * Given a light mode color value and an optional dark mode color value, register this color
6623
+ * so that editor can handle it, then return the CSS color value for current color mode.
6624
+ * @param lightModeColor Light mode color value
6625
+ * @param isDarkMode Whether current color mode is dark mode
6626
+ * @param darkModeColor Optional dark mode color value. If not passed, we will calculate one.
6627
+ */
6628
+ registerColor(lightModeColor: string, isDarkMode: boolean, darkModeColor?: string): string;
6629
+ /**
6630
+ * Reset known color record, clean up registered color variables.
6631
+ */
6632
+ reset(): void;
6633
+ /**
6634
+ * Parse an existing color value, if it is in variable-based color format, extract color key,
6635
+ * light color and query related dark color if any
6636
+ * @param color The color string to parse
6637
+ */
6638
+ parseColorValue(color: string | null | undefined): ColorKeyAndValue;
6639
+ }
6640
+
6641
+ /**
6642
+ * Represents a combination of color key, light color and dark color, parsed from existing color value
6643
+ */
6644
+ export interface ColorKeyAndValue {
6645
+ /**
6646
+ * Key of color, if found, otherwise undefined
6647
+ */
6648
+ key?: string;
6649
+ /**
6650
+ * Light mode color value
6651
+ */
6652
+ lightModeColor: string;
6653
+ /**
6654
+ * Dark mode color value, if found, otherwise undefined
6655
+ */
6656
+ darkModeColor?: string;
6657
+ }
6658
+
6590
6659
  /**
6591
6660
  * ContentEditFeature interface that handles keyboard event
6592
6661
  */
@@ -6810,6 +6879,11 @@ export interface EditorCore extends PluginState {
6810
6879
  * Color of the border of a selectedImage. Default color: '#DB626C'
6811
6880
  */
6812
6881
  imageSelectionBorderColor?: string;
6882
+ /**
6883
+ * Dark model handler for the editor, used for variable-based solution.
6884
+ * If keep it null, editor will still use original dataset-based dark mode solution.
6885
+ */
6886
+ darkColorHandler?: DarkColorHandler;
6813
6887
  }
6814
6888
 
6815
6889
  /**
@@ -8138,7 +8212,13 @@ export enum CompatibleExperimentalFeatures {
8138
8212
  * When apply default format when initialize or user type, apply the format on a SPAN element rather than
8139
8213
  * the block element (In most case, the DIV element) so keep the block element clean.
8140
8214
  */
8141
- DefaultFormatInSpan = "DefaultFormatInSpan"
8215
+ DefaultFormatInSpan = "DefaultFormatInSpan",
8216
+ /**
8217
+ * Use variable-based dark mode solution rather than dataset-based solution.
8218
+ * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
8219
+ * if you need them work for dark mode
8220
+ */
8221
+ VariableBasedDarkColor = "VariableBasedDarkColor"
8142
8222
  }
8143
8223
 
8144
8224
  /**
@@ -9748,9 +9828,13 @@ export class ImageEdit implements EditorPlugin {
9748
9828
  */
9749
9829
  private wasResized;
9750
9830
  /**
9751
- * Editor zoom scale
9831
+ * The span element that wraps the image and opens shadow dom
9832
+ */
9833
+ private shadowSpan;
9834
+ /**
9835
+ * The span element that wraps the image and opens shadow dom
9752
9836
  */
9753
- private zoomWrapper;
9837
+ private isCropping;
9754
9838
  /**
9755
9839
  * Create a new instance of ImageEdit
9756
9840
  * @param options Image editing options
@@ -9805,7 +9889,6 @@ export class ImageEdit implements EditorPlugin {
9805
9889
  * Create editing wrapper for the image
9806
9890
  */
9807
9891
  private createWrapper;
9808
- private toggleImageVisibility;
9809
9892
  private insertImageWrapper;
9810
9893
  /**
9811
9894
  * Remove the temp wrapper of the image