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