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