roosterjs 9.11.2 → 9.13.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.11.2)
1
+ // Type definitions for roosterjs (Version 9.13.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -2852,6 +2852,10 @@ export interface ModelToDomBlockAndSegmentNode {
2852
2852
  * Segment node of this position. When provided, it represents the position right after this node
2853
2853
  */
2854
2854
  segment: Node | null;
2855
+ /**
2856
+ * Offset number of this position. It is only used for Text node, default value is 0
2857
+ */
2858
+ offset?: number;
2855
2859
  }
2856
2860
 
2857
2861
  /**
@@ -3064,6 +3068,14 @@ export interface DomIndexer {
3064
3068
  * @param parent Parent of entity. For block element, this should be the parent block group. For inline entity, this should be the parent paragraph
3065
3069
  */
3066
3070
  onBlockEntity: (entity: ContentModelEntity, group: ContentModelBlockGroup) => void;
3071
+ /**
3072
+ * Invoke when merge two continuous text nodes, we need to merge their indexes as well
3073
+ * @param targetText Target text node to merge into
3074
+ * @param sourceText Source text node to merge from
3075
+ * @example Assume we have two text nodes: Node1="Foo", Node2="Bar", after merge,
3076
+ * Node1 will become "FooBar", Node2 will be removed from DOM tree
3077
+ */
3078
+ onMergeText: (targetText: Text, sourceText: Text) => void;
3067
3079
  /**
3068
3080
  * When document content or selection is changed by user, we need to use this function to update the content model
3069
3081
  * to reflect the latest document. This process can fail since the selected node may not have a related model data structure.
@@ -4359,6 +4371,28 @@ export interface ContextMenuPluginState {
4359
4371
  contextMenuProviders: ContextMenuProvider<any>[];
4360
4372
  }
4361
4373
 
4374
+ /**
4375
+ * Options to customize the Auto link options in Auto Format Plugin
4376
+ */
4377
+ export interface AutoLinkOptions {
4378
+ /**
4379
+ * When press backspace before a link, remove the hyperlink
4380
+ */
4381
+ autoUnlink?: boolean;
4382
+ /**
4383
+ * When paste or type content with a link, create hyperlink for the link
4384
+ */
4385
+ autoLink?: boolean;
4386
+ /**
4387
+ * When paste content or type content with telephone, create hyperlink for the telephone number
4388
+ */
4389
+ autoTel?: boolean;
4390
+ /**
4391
+ * When paste or type a content with mailto, create hyperlink for the content
4392
+ */
4393
+ autoMailto?: boolean;
4394
+ }
4395
+
4362
4396
  /**
4363
4397
  * Current running environment
4364
4398
  */
@@ -5333,14 +5367,16 @@ export interface MergeModelOption {
5333
5367
  insertPosition?: InsertPoint;
5334
5368
  /**
5335
5369
  * Use this to decide whether to change the source model format when doing the merge.
5336
- * 'mergeAll': segment format of the insert position will be merged into the content that is merged into current model.
5370
+ * 'mergeAll': (deprecated) Use PreferSource Instead, segment format of the insert position will be merged into the content that is merged into current model.
5337
5371
  * If the source model already has some format, it will not be overwritten.
5338
5372
  * 'keepSourceEmphasisFormat': format of the insert position will be set into the content that is merged into current model.
5339
5373
  * If the source model already has emphasis format, such as, fontWeight, Italic or underline different than the default style, it will not be overwritten.
5340
5374
  * 'none' the source segment format will not be modified.
5375
+ * 'preferSource' Will merge both formatting, but source will overwrite target
5376
+ * 'preferTarget' Will merge both formatting, but target will overwrite source
5341
5377
  * @default undefined
5342
5378
  */
5343
- mergeFormat?: 'mergeAll' | 'keepSourceEmphasisFormat' | 'none';
5379
+ mergeFormat?: 'mergeAll' | 'keepSourceEmphasisFormat' | 'none' | 'preferSource' | 'preferTarget';
5344
5380
  /**
5345
5381
  * Whether to add a paragraph after the merged content.
5346
5382
  */
@@ -7181,9 +7217,10 @@ export function getListStyleTypeFromString(listType: 'OL' | 'UL', bullet: string
7181
7217
  /**
7182
7218
  * Get the text format of a segment, this function will return only format that is applicable to text
7183
7219
  * @param segment The segment to get format from
7220
+ * @param includingBIU When pass true, also get Bold/Italic/Underline format
7184
7221
  * @returns
7185
7222
  */
7186
- export function getSegmentTextFormat(segment: ReadonlyContentModelSegment): ContentModelSegmentFormat;
7223
+ export function getSegmentTextFormat(segment: ReadonlyContentModelSegment, includingBIU?: boolean): ContentModelSegmentFormat;
7187
7224
 
7188
7225
  /**
7189
7226
  * Get index of closest ancestor block group of the expected block group type. If not found, return -1
@@ -8269,6 +8306,19 @@ export function setModelIndentation(model: ReadonlyContentModelDocument, indenta
8269
8306
  */
8270
8307
  export function matchLink(url: string): LinkData | null;
8271
8308
 
8309
+ /**
8310
+ * Promote the given text segment to a hyper link when the segment text is ending with a valid link format.
8311
+ * When the whole text segment if of a link, promote the whole segment.
8312
+ * When the text segment ends with a link format, split the segment and promote the second part
8313
+ * When link is in middle of the text segment, no action.
8314
+ * This is mainly used for doing auto link when there is a link before cursor
8315
+ * @param segment The text segment to search link text from
8316
+ * @param paragraph Parent paragraph of the segment
8317
+ * @param options Options of auto link
8318
+ * @returns If a link is promoted, return this segment. Otherwise return null
8319
+ */
8320
+ export function promoteLink(segment: ContentModelText, paragraph: ShallowMutableContentModelParagraph, autoLinkOptions: AutoLinkOptions): ContentModelText | null;
8321
+
8272
8322
  /**
8273
8323
  * Get announce data for list item
8274
8324
  * @param path Content model path that include the list item
@@ -8527,28 +8577,6 @@ export interface AutoFormatOptions extends AutoLinkOptions {
8527
8577
  autoOrdinals?: boolean;
8528
8578
  }
8529
8579
 
8530
- /**
8531
- * Options to customize the Auto link options in Auto Format Plugin
8532
- */
8533
- export interface AutoLinkOptions {
8534
- /**
8535
- * When press backspace before a link, remove the hyperlink
8536
- */
8537
- autoUnlink?: boolean;
8538
- /**
8539
- * When paste or type content with a link, create hyperlink for the link
8540
- */
8541
- autoLink?: boolean;
8542
- /**
8543
- * When paste content or type content with telephone, create hyperlink for the telephone number
8544
- */
8545
- autoTel?: boolean;
8546
- /**
8547
- * When paste or type a content with mailto, create hyperlink for the content
8548
- */
8549
- autoMailto?: boolean;
8550
- }
8551
-
8552
8580
  /**
8553
8581
  * Shortcut command for Bold
8554
8582
  * Windows: Ctrl + B