roosterjs 9.48.0 → 9.50.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.48.0)
1
+ // Type definitions for roosterjs (Version 9.50.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -3158,6 +3158,12 @@ export interface ModelToDomListContext {
3158
3158
  * A stack of current list element chain, start from the parent node of top level list
3159
3159
  */
3160
3160
  nodeStack: ModelToDomListStackItem[];
3161
+ /**
3162
+ * Current level of list item being processed, start from 0
3163
+ * This is used by metadata applier to determine which level of list item is being processed,
3164
+ * so it can apply correct list style for that level. It will be updated by list handler before processing each list item, and reset to 0 when processing a new list.
3165
+ */
3166
+ currentLevel: number;
3161
3167
  }
3162
3168
 
3163
3169
  /**
@@ -6255,6 +6261,12 @@ export interface BeforeCutCopyEvent extends BasePluginDomEvent<'beforeCutCopy',
6255
6261
  export interface BeforeDisposeEvent extends BasePluginEvent<'beforeDispose'> {
6256
6262
  }
6257
6263
 
6264
+ /**
6265
+ * Data of BeforeDropEvent
6266
+ */
6267
+ export interface BeforeDropEvent extends BasePluginDomEvent<'beforeDrop', DragEvent> {
6268
+ }
6269
+
6258
6270
  /**
6259
6271
  * Provides a chance for plugin to change the content before it is copied from editor.
6260
6272
  */
@@ -6609,7 +6621,7 @@ export interface DoubleClickEvent extends BasePluginDomEvent<'doubleClick', Mous
6609
6621
  /**
6610
6622
  * Editor plugin event interface
6611
6623
  */
6612
- export type PluginEvent = BeforeAddUndoSnapshotEvent | BeforeCutCopyEvent | BeforeDisposeEvent | BeforeKeyboardEditingEvent | BeforeLogicalRootChangeEvent | BeforePasteEvent | BeforeSetContentEvent | CompositionEndEvent | ContentChangedEvent | ContextMenuEvent | RewriteFromModelEvent | EditImageEvent | EditorReadyEvent | EnterShadowEditEvent | EntityOperationEvent | ExtractContentWithDomEvent | EditorInputEvent | KeyDownEvent | KeyPressEvent | KeyUpEvent | LeaveShadowEditEvent | LogicalRootChangedEvent | MouseDownEvent | MouseUpEvent | ScrollEvent | SelectionChangedEvent | ZoomChangedEvent | PointerDownEvent | PointerUpEvent | DoubleClickEvent | FindResultChangedEvent;
6624
+ export type PluginEvent = BeforeAddUndoSnapshotEvent | BeforeCutCopyEvent | BeforeDisposeEvent | BeforeDropEvent | BeforeKeyboardEditingEvent | BeforeLogicalRootChangeEvent | BeforePasteEvent | BeforeSetContentEvent | CompositionEndEvent | ContentChangedEvent | ContextMenuEvent | RewriteFromModelEvent | EditImageEvent | EditorReadyEvent | EnterShadowEditEvent | EntityOperationEvent | ExtractContentWithDomEvent | EditorInputEvent | KeyDownEvent | KeyPressEvent | KeyUpEvent | LeaveShadowEditEvent | LogicalRootChangedEvent | MouseDownEvent | MouseUpEvent | ScrollEvent | SelectionChangedEvent | ZoomChangedEvent | PointerDownEvent | PointerUpEvent | DoubleClickEvent | FindResultChangedEvent;
6613
6625
 
6614
6626
  /**
6615
6627
  * A type to extract data part of a plugin event type. Data part is the plugin event without eventType field.
@@ -6770,7 +6782,11 @@ export type PluginEventType = /**
6770
6782
  /**
6771
6783
  * Find result changed event
6772
6784
  */
6773
- | 'findResultChanged';
6785
+ | 'findResultChanged'
6786
+ /**
6787
+ * Let plugin know when a content will be dropped
6788
+ */
6789
+ | 'beforeDrop';
6774
6790
 
6775
6791
  /**
6776
6792
  * This interface represents a PluginEvent wrapping native scroll event
@@ -7408,6 +7424,15 @@ export function normalizeParagraph(paragraph: ReadonlyContentModelParagraph): vo
7408
7424
  */
7409
7425
  export function normalizeContentModel(group: ReadonlyContentModelBlockGroup): void;
7410
7426
 
7427
+ /**
7428
+ * Strip invisible Unicode characters from all text and link hrefs in a content model.
7429
+ * This sanitizes the model at initialization time to prevent hidden content in links
7430
+ * or text (e.g. zero-width chars, bidirectional marks, Unicode Tags).
7431
+ * For General segments, all Text nodes under the element are also sanitized.
7432
+ * @param model The content model document to sanitize in-place
7433
+ */
7434
+ export function sanitizeInvisibleUnicode(model: ContentModelDocument): void;
7435
+
7411
7436
  /**
7412
7437
  * Check if the given block group is a general segment
7413
7438
  * @param group The group to check
@@ -7725,6 +7750,19 @@ export function isSpace(char: string): boolean;
7725
7750
  */
7726
7751
  export function normalizeText(txt: string, isForward: boolean): string;
7727
7752
 
7753
+ /**
7754
+ * Strip invisible Unicode characters from a string.
7755
+ * This removes zero-width characters, bidirectional marks, Unicode Tags (U+E0001-U+E00FF),
7756
+ * interlinear annotation anchors, Mongolian free variation selectors,
7757
+ * and other invisible formatting characters that can be used to hide content in links.
7758
+ *
7759
+ * @remarks This function strips ZWJ (U+200D) which may affect emoji sequences.
7760
+ * It should only be applied to href attributes, not to visible text content.
7761
+ * @param value The string to strip invisible characters from
7762
+ * @returns The string with invisible characters removed
7763
+ */
7764
+ export function stripInvisibleUnicode(value: string): string;
7765
+
7728
7766
  /**
7729
7767
  * Parse a table into a two dimensions array of TD elements. For those merged cells, the value will be null.
7730
7768
  * @param table Input HTML Table element
@@ -7909,6 +7947,14 @@ export function getSelectedParagraphs(model: ContentModelDocument): ContentModel
7909
7947
  */
7910
7948
  export function getSelectedParagraphs(model: ReadonlyContentModelDocument, mutate: true): ShallowMutableContentModelParagraph[];
7911
7949
 
7950
+ /**
7951
+ * Get any array of selected paragraphs from a content model, return mutable paragraphs
7952
+ * @param model The Content Model to get selection from
7953
+ * @param mutate Set to true to indicate we will mutate the selected paragraphs
7954
+ * @param removeUnmeaningful True to remove unmeaningful selection like only selection marker is selected, or head/tail paragraph is selected with selection marker at the wrong place
7955
+ */
7956
+ export function getSelectedParagraphs(model: ReadonlyContentModelDocument, mutate: true, removeUnmeaningful: boolean): ShallowMutableContentModelParagraph[];
7957
+
7912
7958
  /**
7913
7959
  * Get any array of selected paragraphs from a content model (Readonly)
7914
7960
  * @param model The Content Model to get selection from
@@ -10767,6 +10813,56 @@ export class AnnouncePlugin implements EditorPlugin {
10767
10813
  onPluginEvent(event: PluginEvent): void;
10768
10814
  }
10769
10815
 
10816
+ /**
10817
+ * DragAndDrop plugin, handles ContentChanged event when change source is "Drop"
10818
+ * to sanitize dropped content, similar to how PastePlugin sanitizes pasted content.
10819
+ */
10820
+ export class DragAndDropPlugin implements EditorPlugin {
10821
+ private editor;
10822
+ private forbiddenElements;
10823
+ private isInternalDragging;
10824
+ private disposer;
10825
+ /**
10826
+ * Construct a new instance of DragAndDropPlugin
10827
+ */
10828
+ constructor(options?: DragAndDropOptions);
10829
+ /**
10830
+ * Get name of this plugin
10831
+ */
10832
+ getName(): string;
10833
+ /**
10834
+ * The first method that editor will call to a plugin when editor is initializing.
10835
+ * It will pass in the editor instance, plugin should take this chance to save the
10836
+ * editor reference so that it can call to any editor method or format API later.
10837
+ * @param editor The editor object
10838
+ */
10839
+ initialize(editor: IEditor): void;
10840
+ /**
10841
+ * The last method that editor will call to a plugin before it is disposed.
10842
+ * Plugin can take this chance to clear the reference to editor. After this method is
10843
+ * called, plugin should not call to any editor method since it will result in error.
10844
+ */
10845
+ dispose(): void;
10846
+ /**
10847
+ * Core method for a plugin. Once an event happens in editor, editor will call this
10848
+ * method of each plugin to handle the event as long as the event is not handled
10849
+ * exclusively by another plugin.
10850
+ * @param event The event to handle:
10851
+ */
10852
+ onPluginEvent(event: PluginEvent): void;
10853
+ }
10854
+
10855
+ /**
10856
+ * Options for DragAndDrop plugin
10857
+ */
10858
+ export interface DragAndDropOptions {
10859
+ /**
10860
+ * Forbidden elements that cannot be dropped in the editor
10861
+ * @default ['iframe']
10862
+ */
10863
+ forbiddenElements?: string[];
10864
+ }
10865
+
10770
10866
  /**
10771
10867
  * Get dark mode color for a given color
10772
10868
  * @param color The color to calculate from