roosterjs 8.40.1 → 8.41.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.1)
1
+ // Type definitions for roosterjs (Version 8.41.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.
@@ -3685,7 +3691,13 @@ export const enum ExperimentalFeatures {
3685
3691
  * When apply default format when initialize or user type, apply the format on a SPAN element rather than
3686
3692
  * the block element (In most case, the DIV element) so keep the block element clean.
3687
3693
  */
3688
- DefaultFormatInSpan = "DefaultFormatInSpan"
3694
+ DefaultFormatInSpan = "DefaultFormatInSpan",
3695
+ /**
3696
+ * Use variable-based dark mode solution rather than dataset-based solution.
3697
+ * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
3698
+ * if you need them work for dark mode
3699
+ */
3700
+ VariableBasedDarkColor = "VariableBasedDarkColor"
3689
3701
  }
3690
3702
 
3691
3703
  /**
@@ -5285,6 +5297,10 @@ export interface ElementBasedFormatState {
5285
5297
  * Whether the text is in block quote
5286
5298
  */
5287
5299
  isBlockQuote?: boolean;
5300
+ /**
5301
+ * Whether the text is in Code block
5302
+ */
5303
+ isCodeBlock?: boolean;
5288
5304
  /**
5289
5305
  * Whether unlink command can be called to the text
5290
5306
  */
@@ -5313,6 +5329,10 @@ export interface ElementBasedFormatState {
5313
5329
  * If there is a table, whether the table has header row
5314
5330
  */
5315
5331
  tableHasHeader?: boolean;
5332
+ /**
5333
+ * Whether we can execute table cell merge operation
5334
+ */
5335
+ canMergeTableCell?: boolean;
5316
5336
  }
5317
5337
 
5318
5338
  /**
@@ -6535,6 +6555,10 @@ export interface IEditor {
6535
6555
  * @param node The node to transform
6536
6556
  */
6537
6557
  transformToDarkColor(node: Node): void;
6558
+ /**
6559
+ * Get a darkColorHandler object for this editor. It will return null if experimental feature "VariableBasedDarkColor" is not enabled
6560
+ */
6561
+ getDarkColorHandler(): DarkColorHandler | null;
6538
6562
  /**
6539
6563
  * Make the editor in "Shadow Edit" mode.
6540
6564
  * In Shadow Edit mode, all format change will finally be ignored.
@@ -6587,6 +6611,48 @@ export interface IEditor {
6587
6611
  getVisibleViewport(): Rect | null;
6588
6612
  }
6589
6613
 
6614
+ /**
6615
+ * A handler object for dark color, used for variable-based dark color solution
6616
+ */
6617
+ export interface DarkColorHandler {
6618
+ /**
6619
+ * Given a light mode color value and an optional dark mode color value, register this color
6620
+ * so that editor can handle it, then return the CSS color value for current color mode.
6621
+ * @param lightModeColor Light mode color value
6622
+ * @param isDarkMode Whether current color mode is dark mode
6623
+ * @param darkModeColor Optional dark mode color value. If not passed, we will calculate one.
6624
+ */
6625
+ registerColor(lightModeColor: string, isDarkMode: boolean, darkModeColor?: string): string;
6626
+ /**
6627
+ * Reset known color record, clean up registered color variables.
6628
+ */
6629
+ reset(): void;
6630
+ /**
6631
+ * Parse an existing color value, if it is in variable-based color format, extract color key,
6632
+ * light color and query related dark color if any
6633
+ * @param color The color string to parse
6634
+ */
6635
+ parseColorValue(color: string | null | undefined): ColorKeyAndValue;
6636
+ }
6637
+
6638
+ /**
6639
+ * Represents a combination of color key, light color and dark color, parsed from existing color value
6640
+ */
6641
+ export interface ColorKeyAndValue {
6642
+ /**
6643
+ * Key of color, if found, otherwise undefined
6644
+ */
6645
+ key?: string;
6646
+ /**
6647
+ * Light mode color value
6648
+ */
6649
+ lightModeColor: string;
6650
+ /**
6651
+ * Dark mode color value, if found, otherwise undefined
6652
+ */
6653
+ darkModeColor?: string;
6654
+ }
6655
+
6590
6656
  /**
6591
6657
  * ContentEditFeature interface that handles keyboard event
6592
6658
  */
@@ -6810,6 +6876,11 @@ export interface EditorCore extends PluginState {
6810
6876
  * Color of the border of a selectedImage. Default color: '#DB626C'
6811
6877
  */
6812
6878
  imageSelectionBorderColor?: string;
6879
+ /**
6880
+ * Dark model handler for the editor, used for variable-based solution.
6881
+ * If keep it null, editor will still use original dataset-based dark mode solution.
6882
+ */
6883
+ darkColorHandler?: DarkColorHandler;
6813
6884
  }
6814
6885
 
6815
6886
  /**
@@ -8138,7 +8209,13 @@ export enum CompatibleExperimentalFeatures {
8138
8209
  * When apply default format when initialize or user type, apply the format on a SPAN element rather than
8139
8210
  * the block element (In most case, the DIV element) so keep the block element clean.
8140
8211
  */
8141
- DefaultFormatInSpan = "DefaultFormatInSpan"
8212
+ DefaultFormatInSpan = "DefaultFormatInSpan",
8213
+ /**
8214
+ * Use variable-based dark mode solution rather than dataset-based solution.
8215
+ * When enable this feature, need to pass in a DarkModelHandler object to each call of setColor and applyFormat
8216
+ * if you need them work for dark mode
8217
+ */
8218
+ VariableBasedDarkColor = "VariableBasedDarkColor"
8142
8219
  }
8143
8220
 
8144
8221
  /**
@@ -9748,9 +9825,13 @@ export class ImageEdit implements EditorPlugin {
9748
9825
  */
9749
9826
  private wasResized;
9750
9827
  /**
9751
- * Editor zoom scale
9828
+ * The span element that wraps the image and opens shadow dom
9829
+ */
9830
+ private shadowSpan;
9831
+ /**
9832
+ * The span element that wraps the image and opens shadow dom
9752
9833
  */
9753
- private zoomWrapper;
9834
+ private isCropping;
9754
9835
  /**
9755
9836
  * Create a new instance of ImageEdit
9756
9837
  * @param options Image editing options
@@ -9805,7 +9886,6 @@ export class ImageEdit implements EditorPlugin {
9805
9886
  * Create editing wrapper for the image
9806
9887
  */
9807
9888
  private createWrapper;
9808
- private toggleImageVisibility;
9809
9889
  private insertImageWrapper;
9810
9890
  /**
9811
9891
  * Remove the temp wrapper of the image