roosterjs 9.41.0 → 9.44.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.41.0)
1
+ // Type definitions for roosterjs (Version 9.44.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -2871,6 +2871,10 @@ export interface EditorContext {
2871
2871
  * When pass true, this cached element will be used to create DOM tree back when convert Content Model to DOM
2872
2872
  */
2873
2873
  allowCacheElement?: boolean;
2874
+ /**
2875
+ * Whether to allow caching list item elements separately.
2876
+ */
2877
+ allowCacheListItem?: boolean;
2874
2878
  /**
2875
2879
  * @optional Indexer for content model, to help build backward relationship from DOM node to Content Model
2876
2880
  */
@@ -2891,6 +2895,11 @@ export interface EditorContext {
2891
2895
  * When set to true, size of table will be recalculated when converting from DOM to Content Model.
2892
2896
  */
2893
2897
  recalculateTableSize?: boolean | 'all' | 'selected' | 'none';
2898
+ /**
2899
+ * Width of the editor's editable area in pixels, excluding padding.
2900
+ * This value is typically used for layout calculations such as constraining pasted image sizes.
2901
+ */
2902
+ editorViewWidth?: number;
2894
2903
  }
2895
2904
 
2896
2905
  /**
@@ -3016,6 +3025,10 @@ export interface ModelToDomListStackItem extends Partial<ContentModelListLevel>
3016
3025
  * DOM node of this list stack
3017
3026
  */
3018
3027
  node: Node;
3028
+ /**
3029
+ * Reference node to insert next list item under this list
3030
+ */
3031
+ refNode: Node | null;
3019
3032
  }
3020
3033
 
3021
3034
  /**
@@ -3675,27 +3688,12 @@ export interface IEditor {
3675
3688
  * By default these features are not enabled. To enable them, pass the feature name into EditorOptions.experimentalFeatures
3676
3689
  * when create editor
3677
3690
  */
3678
- export type ExperimentalFeature = /**
3679
- * @deprecated When this feature is enabled, we will persist a content model in memory as long as we can,
3680
- * and use cached element when write back if it is not changed.
3681
- */
3682
- 'PersistCache'
3683
- /**
3684
- * @deprecated
3685
- * Workaround for the Legacy Image Edit
3686
- */
3687
- | 'LegacyImageSelection'
3691
+ export type ExperimentalFeature = GraduatedExperimentalFeature
3688
3692
  /**
3689
3693
  * @deprecated Please use the shouldHandleEnterKey option of the EditPlugin Options
3690
3694
  * Use Content Model handle ENTER key
3691
3695
  */
3692
3696
  | 'HandleEnterKey'
3693
- /**
3694
- * @deprecated
3695
- * Prevent default browser behavior for copy/cut event,
3696
- * and set the clipboard data with custom implementation.
3697
- */
3698
- | 'CustomCopyCut'
3699
3697
  /**
3700
3698
  * For CJK keyboard input on mobile, if the user toggles bold/italic/underline on an empty div,
3701
3699
  * the pending format will be applied on the selection marker. When typing text, the selection moves to the text node and the
@@ -3711,7 +3709,31 @@ export type ExperimentalFeature = /**
3711
3709
  * Get cloned root element from an independent HTML document instead of current document.
3712
3710
  * So any operation to the cloned root won't trigger network request for resources like images
3713
3711
  */
3714
- | 'CloneIndependentRoot';
3712
+ | 'CloneIndependentRoot'
3713
+ /**
3714
+ * Allow caching list item elements.
3715
+ */
3716
+ | 'CacheList';
3717
+
3718
+ /**
3719
+ * Predefined experiment features (Graduated, only keep them for backward compatibility)
3720
+ */
3721
+ export type GraduatedExperimentalFeature = /**
3722
+ * @deprecated When this feature is enabled, we will persist a content model in memory as long as we can,
3723
+ * and use cached element when write back if it is not changed.
3724
+ */
3725
+ 'PersistCache'
3726
+ /**
3727
+ * @deprecated
3728
+ * Workaround for the Legacy Image Edit
3729
+ */
3730
+ | 'LegacyImageSelection'
3731
+ /**
3732
+ * @deprecated
3733
+ * Prevent default browser behavior for copy/cut event,
3734
+ * and set the clipboard data with custom implementation.
3735
+ */
3736
+ | 'CustomCopyCut';
3715
3737
 
3716
3738
  /**
3717
3739
  * Options for editor
@@ -6026,6 +6048,20 @@ export interface TextAndHtmlContentForCopy {
6026
6048
  textContent: string;
6027
6049
  }
6028
6050
 
6051
+ /**
6052
+ * The link label and href for promoted link
6053
+ */
6054
+ export interface PromotedLink {
6055
+ /**
6056
+ * The label for the promoted link
6057
+ */
6058
+ label: string;
6059
+ /**
6060
+ * The href for the promoted link
6061
+ */
6062
+ href: string;
6063
+ }
6064
+
6029
6065
  /**
6030
6066
  * Editor plugin event interface
6031
6067
  */
@@ -7548,6 +7584,13 @@ export function parseTableCells(table: HTMLTableElement): ParsedTable;
7548
7584
  */
7549
7585
  export function readFile(file: File, callback: (dataUrl: string | null) => void): void;
7550
7586
 
7587
+ /**
7588
+ * Retrieves metadata from the given document, including HTML attributes and meta tags.
7589
+ * @param doc The document from which to retrieve metadata.
7590
+ * @returns A record containing metadata key-value pairs.
7591
+ */
7592
+ export function retrieveDocumentMetadata(doc: Document): Record<string, string>;
7593
+
7551
7594
  /**
7552
7595
  * Edit and transform color of elements between light mode and dark mode
7553
7596
  * @param rootNode The root DOM node to transform
@@ -8575,10 +8618,10 @@ export function getContentForCopy(editor: IEditor, isCut: boolean, event: Clipbo
8575
8618
  * @param columns Number of columns in table, it also controls the default table cell width:
8576
8619
  * if columns &lt;= 4, width = 120px; if columns &lt;= 6, width = 100px; else width = 70px
8577
8620
  * @param rows Number of rows in table
8578
- * @param format (Optional) The table format. If not passed, the default format will be applied:
8579
- * background color: #FFF; border color: #ABABAB
8621
+ * @param tableMetadataFormat (Optional) The table format that are stored as metadata. If not passed, the default format will be applied: background color: #FFF; border color: #ABABAB
8622
+ * @param format (Optional) The table format used for style attributes
8580
8623
  */
8581
- export function insertTable(editor: IEditor, columns: number, rows: number, format?: Partial<TableMetadataFormat>): void;
8624
+ export function insertTable(editor: IEditor, columns: number, rows: number, tableMetadataFormat?: Partial<TableMetadataFormat>, format?: ContentModelTableFormat): void;
8582
8625
 
8583
8626
  /**
8584
8627
  * Format current focused table with the given format
@@ -9065,6 +9108,14 @@ export function matchLink(url: string): LinkData | null;
9065
9108
  */
9066
9109
  export function promoteLink(segment: ContentModelText, paragraph: ShallowMutableContentModelParagraph, autoLinkOptions: AutoLinkOptions): ContentModelText | null;
9067
9110
 
9111
+ /**
9112
+ * Verify if the link can be promoted
9113
+ * @param segment The text segment to search link text from
9114
+ * @param options Options of auto link
9115
+ * @returns if a link can be promoted
9116
+ */
9117
+ export function getPromoteLink(segment: ContentModelText, autoLinkOptions: AutoLinkOptions): PromotedLink | undefined;
9118
+
9068
9119
  /**
9069
9120
  * Get announce data for list item
9070
9121
  * @param path Content model path that include the list item
@@ -9226,15 +9277,15 @@ export const DefaultSanitizers: Record<string, ValueSanitizer>;
9226
9277
  * 3. Tab Key
9227
9278
  */
9228
9279
  export class EditPlugin implements EditorPlugin {
9229
- private options;
9230
9280
  private editor;
9231
9281
  private disposer;
9232
9282
  private shouldHandleNextInputEvent;
9233
9283
  private selectionAfterDelete;
9234
9284
  private handleNormalEnter;
9285
+ private options;
9235
9286
  /**
9236
9287
  * @param options An optional parameter that takes in an object of type EditOptions, which includes the following properties:
9237
- * handleTabKey: A boolean that enables or disables Tab key handling. Defaults to true.
9288
+ * handleTabKey: A boolean or HandleTabOptions object that controls Tab key handling. When a boolean, true enables all features and false disables all. When an object, individual features can be controlled. Defaults to all enabled.
9238
9289
  */
9239
9290
  constructor(options?: EditOptions);
9240
9291
  private createNormalEnterChecker;
@@ -9282,9 +9333,12 @@ export class EditPlugin implements EditorPlugin {
9282
9333
  */
9283
9334
  export type EditOptions = {
9284
9335
  /**
9285
- * Whether to handle Tab key in keyboard. @default true
9336
+ * Whether to handle Tab key in keyboard, or an object to control specific Tab key behaviors.
9337
+ * When true, all Tab features are enabled. When false, all are disabled.
9338
+ * When an object, individual features can be controlled via HandleTabOptions.
9339
+ * @default true
9286
9340
  */
9287
- handleTabKey?: boolean;
9341
+ handleTabKey?: HandleTabOptions | boolean;
9288
9342
  /**
9289
9343
  * Whether expanded selection within a text node should be handled by CM when pressing Backspace/Delete key.
9290
9344
  * @default true
@@ -9322,6 +9376,37 @@ export type EditOptions = {
9322
9376
  formatsToPreserveOnMerge?: string[];
9323
9377
  };
9324
9378
 
9379
+ /**
9380
+ * Options for handling Tab key in Edit plugin
9381
+ */
9382
+ export interface HandleTabOptions {
9383
+ /**
9384
+ * Whether to indent/outdent multiple selected blocks when Tab/Shift+Tab is pressed and multiple blocks are selected.
9385
+ * @default true
9386
+ */
9387
+ indentMultipleBlocks?: boolean;
9388
+ /**
9389
+ * Whether to indent/outdent table cells when Tab key is pressed and a table is selected
9390
+ * @default true
9391
+ */
9392
+ indentTable?: boolean;
9393
+ /**
9394
+ * Whether to append a new row when Tab key is pressed in the last cell of a table
9395
+ * @default true
9396
+ */
9397
+ appendTableRow?: boolean;
9398
+ /**
9399
+ * Whether to indent/outdent list items when Tab key is pressed
9400
+ * @default true
9401
+ */
9402
+ indentList?: boolean;
9403
+ /**
9404
+ * Whether to indent/outdent paragraph when Tab key is pressed
9405
+ * @default true
9406
+ */
9407
+ indentParagraph?: boolean;
9408
+ }
9409
+
9325
9410
  /**
9326
9411
  * Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.
9327
9412
  * It can be customized with options to enable or disable auto list features.