roosterjs 9.53.0 → 9.55.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.53.0)
1
+ // Type definitions for roosterjs (Version 9.55.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -1511,7 +1511,11 @@ export type PasteType = /**
1511
1511
  /**
1512
1512
  * If there is a image uri in the clipboard, paste the content as image element
1513
1513
  */
1514
- | 'asImage';
1514
+ | 'asImage'
1515
+ /**
1516
+ * If the editor includes a markdown plugin @see MarkdownPastePlugin, and there is markdown content in the clipboard, paste it as markdown
1517
+ */
1518
+ | 'asMarkdown';
1515
1519
 
1516
1520
  /**
1517
1521
  * All Border operations
@@ -2883,6 +2887,13 @@ export interface DomToModelSettings {
2883
2887
  * If true elements that has display:none style will be processed
2884
2888
  */
2885
2889
  processNonVisibleElements?: boolean;
2890
+ /**
2891
+ * When set to true, if a container element could be represented by a FormatContainer, always keep the
2892
+ * FormatContainer and never fall back to a paragraph, even when it only has a single child.
2893
+ * Set this when the intermediate FormatContainer is persisted during DOM to Content Model conversion
2894
+ * and is later used during formatting.
2895
+ */
2896
+ skipFormatContainerFallbackCheck?: boolean;
2886
2897
  }
2887
2898
 
2888
2899
  /**
@@ -3303,6 +3314,13 @@ export interface DomToModelOptionForCreateModel extends DomToModelOption {
3303
3314
  * When this option is passed, "tryGetFromCache" will be ignored.
3304
3315
  */
3305
3316
  recalculateTableSize?: boolean | 'all' | 'selected' | 'none';
3317
+ /**
3318
+ * When set to true, if a container element could be represented by a FormatContainer, always keep the
3319
+ * FormatContainer and never fall back to a paragraph, even when it only has a single child.
3320
+ * Set this when the intermediate FormatContainer is persisted during DOM to Content Model conversion
3321
+ * and is later used during formatting.
3322
+ */
3323
+ skipFormatContainerFallbackCheck?: boolean;
3306
3324
  }
3307
3325
 
3308
3326
  /**
@@ -3412,6 +3430,14 @@ export interface DomIndexer {
3412
3430
  * @returns True if successfully updated, otherwise false
3413
3431
  */
3414
3432
  reconcileElementId: (element: HTMLElement) => boolean;
3433
+ /**
3434
+ * When src or a data-* attribute is changed on an indexed IMG element, update the related
3435
+ * ContentModelImage (src property or dataset) so the cached model stays valid.
3436
+ * @param element The element that has an attribute changed
3437
+ * @param attributeName The name of the changed attribute
3438
+ * @returns True if successfully updated, otherwise false
3439
+ */
3440
+ reconcileImageAttribute: (element: HTMLElement, attributeName: string) => boolean;
3415
3441
  /**
3416
3442
  * When child list of editor content is changed, we can use this method to do sync the change from editor into content model.
3417
3443
  * This is mostly used when user start to type in an empty line. In that case browser will remove the existing BR node in the empty line if any,
@@ -6335,7 +6361,7 @@ export interface BeforePasteEvent extends BasePluginEvent<'beforePaste'> {
6335
6361
  */
6336
6362
  readonly htmlAttributes: Record<string, string>;
6337
6363
  /**
6338
- * Paste type option (as plain text, merge format, normal, as image)
6364
+ * Paste type option (as plain text, merge format, normal, as image, asMarkdown (@see MarkdownPastePlugin ))
6339
6365
  */
6340
6366
  readonly pasteType: PasteType;
6341
6367
  /**
@@ -7667,7 +7693,7 @@ export function createDomToModelContext(editorContext?: EditorContext, ...option
7667
7693
  * @param config A full config object to define how to convert DOM tree to Content Model
7668
7694
  * @param editorContext Context of editor
7669
7695
  */
7670
- export function createDomToModelContextWithConfig(config: DomToModelSettings, editorContext?: EditorContext): any;
7696
+ export function createDomToModelContextWithConfig(config: DomToModelSettings, editorContext?: EditorContext): DomToModelContext;
7671
7697
 
7672
7698
  /**
7673
7699
  * Create Dom to Content Model Config object
@@ -7845,7 +7871,7 @@ export function normalizeFontFamily(fontFamily: string): string;
7845
7871
  * @param allowedCustomPasteType Allowed custom content type when paste besides text/plain, text/html and images
7846
7872
  Only text types are supported, and do not add "text/" prefix to the type values
7847
7873
  */
7848
- export function extractClipboardItems(items: DataTransferItem[], allowedCustomPasteType?: string[]): Promise<ClipboardData>;
7874
+ export function extractClipboardItems(items: DataTransferItem[], allowedCustomPasteType?: string[], isPasteNative?: boolean): Promise<ClipboardData>;
7849
7875
 
7850
7876
  /**
7851
7877
  * Gets the cached event data by cache key from event object if there is already one.
@@ -8082,6 +8108,13 @@ export function setSelection(group: ReadonlyContentModelBlockGroup, start?: Read
8082
8108
  */
8083
8109
  export function cloneModel(model: ReadonlyContentModelDocument, options?: CloneModelOptions): ContentModelDocument;
8084
8110
 
8111
+ /**
8112
+ * Clone a content model for paste operations, ensuring that cached elements are handled appropriately.
8113
+ * @param model The content model to clone
8114
+ * @returns A cloned content model suitable for paste operations
8115
+ */
8116
+ export function cloneModelForPaste(model: ReadonlyContentModelDocument): ContentModelDocument;
8117
+
8085
8118
  /**
8086
8119
  * Merge source model into target mode
8087
8120
  * @param target Target Content Model that will merge content into
@@ -10918,6 +10951,23 @@ export function convertMarkdownToContentModel(text: string, options?: MarkdownTo
10918
10951
  */
10919
10952
  export function convertContentModelToMarkdown(model: ContentModelDocument, newLine?: MarkdownLineBreaks): string;
10920
10953
 
10954
+ /**
10955
+ * Detect whether the given plain text contains any markdown markup.
10956
+ * Recognizes block-level patterns (headings, blockquotes, lists, horizontal rules, tables)
10957
+ * and inline patterns (bold, italic, strikethrough, links, images).
10958
+ * @param text The plain text to check.
10959
+ * @returns True if the text contains any markdown markup, false otherwise.
10960
+ */
10961
+ export function isContentMarkdown(text: string): boolean;
10962
+
10963
+ /**
10964
+ * Detect whether the given clipboard content can be interpreted as markdown.
10965
+ * @param editor The editor instance.
10966
+ * @param clipboardData The clipboard data to check.
10967
+ * @returns True if the content can be interpreted as markdown, false otherwise.
10968
+ */
10969
+ export function isPastedContentMarkdown(editor: IEditor, clipboardData: ClipboardData): boolean;
10970
+
10921
10971
  /**
10922
10972
  * The characters to add line breaks and new lines
10923
10973
  */
@@ -10949,3 +10999,60 @@ export interface MarkdownToModelOptions {
10949
10999
  direction?: 'ltr' | 'rtl' | undefined;
10950
11000
  }
10951
11001
 
11002
+ /**
11003
+ * Markdown paste plugin. Handles the BeforePaste event and, when the pasted content
11004
+ * can be interpreted as markdown, converts the plain text into a Content Model and
11005
+ * pastes it as rich markdown content instead of the original clipboard HTML.
11006
+ */
11007
+ export class MarkdownPastePlugin implements EditorPlugin {
11008
+ private editor;
11009
+ private options;
11010
+ /**
11011
+ * Construct a new instance of MarkdownPastePlugin
11012
+ * @param options Options to control the markdown paste behavior
11013
+ */
11014
+ constructor(options?: MarkdownPasteOptions);
11015
+ /**
11016
+ * Get name of this plugin
11017
+ */
11018
+ getName(): string;
11019
+ /**
11020
+ * The first method that editor will call to a plugin when editor is initializing.
11021
+ * It will pass in the editor instance, plugin should take this chance to save the
11022
+ * editor reference so that it can call to any editor method or format API later.
11023
+ * @param editor The editor object
11024
+ */
11025
+ initialize(editor: IEditor): void;
11026
+ /**
11027
+ * The last method that editor will call to a plugin before it is disposed.
11028
+ * Plugin can take this chance to clear the reference to editor. After this method is
11029
+ * called, plugin should not call to any editor method since it will result in error.
11030
+ */
11031
+ dispose(): void;
11032
+ /**
11033
+ * Core method for a plugin. Once an event happens in editor, editor will call this
11034
+ * method of each plugin to handle the event as long as the event is not handled
11035
+ * exclusively by another plugin.
11036
+ * @param event The event to handle:
11037
+ */
11038
+ onPluginEvent(event: PluginEvent): void;
11039
+ }
11040
+
11041
+ /**
11042
+ * Options for MarkdownPastePlugin
11043
+ */
11044
+ export interface MarkdownPasteOptions {
11045
+ /**
11046
+ * When true, content that can be interpreted as markdown is automatically converted
11047
+ * into rich content on every paste, without requiring an explicit "Paste as Markdown"
11048
+ * command.
11049
+ * @default false
11050
+ */
11051
+ autoConversion: boolean;
11052
+ /**
11053
+ * When true, the plugin will undo the markdown conversion when the user undoes the action.
11054
+ * @default false
11055
+ */
11056
+ undoConversion: boolean;
11057
+ }
11058
+