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