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