roosterjs 9.2.0 → 9.3.1

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.2.0)
1
+ // Type definitions for roosterjs (Version 9.3.1)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -2710,19 +2710,20 @@ export type ColorTransformFunction = (lightColor: string, baseLValue?: number, c
2710
2710
  * An interface of Editor, built on top of Content Model
2711
2711
  */
2712
2712
  export interface IEditor {
2713
+ /**
2714
+ * @deprecated Use formatContentModel() instead
2715
+ */
2716
+ getContentModelCopy(mode: 'connected'): ContentModelDocument;
2713
2717
  /**
2714
2718
  * Create Content Model from DOM tree in this editor
2715
2719
  * @param mode What kind of Content Model we want. Currently we support the following values:
2716
- * - connected: Returns a connect Content Model object. "Connected" means if there is any entity inside editor, the returned Content Model will
2717
- * contain the same wrapper element for entity. This option should only be used in some special cases. In most cases we should use "disconnected"
2718
- * to get a fully disconnected Content Model so that any change to the model will not impact editor content.
2719
2720
  * - disconnected: Returns a disconnected clone of Content Model from editor which you can do any change on it and it won't impact the editor content.
2720
2721
  * If there is any entity in editor, the returned object will contain cloned copy of entity wrapper element.
2721
2722
  * If editor is in dark mode, the cloned entity will be converted back to light mode.
2722
2723
  * - clean: Similar with disconnected, this will return a disconnected model, the difference is "clean" mode will not include any selection info.
2723
2724
  * This is usually used for exporting content
2724
2725
  */
2725
- getContentModelCopy(mode: 'connected' | 'disconnected' | 'clean'): ContentModelDocument;
2726
+ getContentModelCopy(mode: 'disconnected' | 'clean'): ContentModelDocument;
2726
2727
  /**
2727
2728
  * Get current running environment, such as if editor is running on Mac
2728
2729
  */
@@ -3853,6 +3854,10 @@ export interface FormatContentModelOptions {
3853
3854
  * When specified, use this selection range to override current selection inside editor
3854
3855
  */
3855
3856
  selectionOverride?: DOMSelection;
3857
+ /**
3858
+ * When pass to true, scroll the editing caret into view after write DOM tree if need
3859
+ */
3860
+ scrollCaretIntoView?: boolean;
3856
3861
  }
3857
3862
 
3858
3863
  /**
@@ -4757,6 +4762,60 @@ export type ParsedTable = ParsedTableCell[][];
4757
4762
  */
4758
4763
  export type ParsedTableCell = HTMLTableCellElement | 'spanLeft' | 'spanTop' | 'spanBoth';
4759
4764
 
4765
+ /**
4766
+ * Callback function type for converting a given Content Model object to plain text
4767
+ * @param model The source model object to be converted to plain text
4768
+ */
4769
+ export type ModelToTextCallback<T> = (model: T) => string;
4770
+
4771
+ /**
4772
+ * Callbacks to customize the behavior of contentModelToText function
4773
+ */
4774
+ export interface ModelToTextCallbacks {
4775
+ /**
4776
+ * Customize the behavior of converting entity segment to plain text
4777
+ */
4778
+ onEntitySegment?: ModelToTextCallback<ContentModelEntity>;
4779
+ /**
4780
+ * Customize the behavior of converting entity block to plain text
4781
+ */
4782
+ onEntityBlock?: ModelToTextCallback<ContentModelEntity>;
4783
+ /**
4784
+ * Customize the behavior of converting general segment to plain text
4785
+ */
4786
+ onGeneralSegment?: ModelToTextCallback<ContentModelGeneralSegment>;
4787
+ /**
4788
+ * Customize the behavior of converting text model to plain text
4789
+ */
4790
+ onText?: ModelToTextCallback<ContentModelText>;
4791
+ /**
4792
+ * Customize the behavior of converting image model to plain text
4793
+ */
4794
+ onImage?: ModelToTextCallback<ContentModelImage>;
4795
+ /**
4796
+ * Customize the behavior of converting divider model to plain text
4797
+ */
4798
+ onDivider?: ModelToTextCallback<ContentModelDivider>;
4799
+ /**
4800
+ * Customize the check if we should convert a paragraph model to plain text
4801
+ */
4802
+ onParagraph?: ModelToTextChecker<ContentModelParagraph>;
4803
+ /**
4804
+ * Customize the check if we should convert a table model to plain text
4805
+ */
4806
+ onTable?: ModelToTextChecker<ContentModelTable>;
4807
+ /**
4808
+ * Customize the check if we should convert a block group model to plain text
4809
+ */
4810
+ onBlockGroup?: ModelToTextChecker<ContentModelBlockGroup>;
4811
+ }
4812
+
4813
+ /**
4814
+ * Callback function type for checking if we should convert to text for the given content model object
4815
+ * @param model The source model to check if we should convert it to plain text
4816
+ */
4817
+ export type ModelToTextChecker<T> = (model: T) => boolean;
4818
+
4760
4819
  /**
4761
4820
  * Editor plugin event interface
4762
4821
  */
@@ -5304,8 +5363,9 @@ export function contentModelToDom(doc: Document, root: Node, model: ContentModel
5304
5363
  * Convert Content Model to plain text
5305
5364
  * @param model The source Content Model
5306
5365
  * @param [separator='\r\n'] The separator string used for connect lines
5366
+ * @param callbacks Callbacks to customize the behavior of contentModelToText function
5307
5367
  */
5308
- export function contentModelToText(model: ContentModelDocument, separator?: string): string;
5368
+ export function contentModelToText(model: ContentModelDocument, separator?: string, callbacks?: ModelToTextCallbacks): string;
5309
5369
 
5310
5370
  /**
5311
5371
  * Content Model Element Processor for child elements
@@ -6570,9 +6630,6 @@ export class Editor implements IEditor {
6570
6630
  /**
6571
6631
  * Create Content Model from DOM tree in this editor
6572
6632
  * @param mode What kind of Content Model we want. Currently we support the following values:
6573
- * - connected: Returns a connect Content Model object. "Connected" means if there is any entity inside editor, the returned Content Model will
6574
- * contain the same wrapper element for entity. This option should only be used in some special cases. In most cases we should use "disconnected"
6575
- * to get a fully disconnected Content Model so that any change to the model will not impact editor content.
6576
6633
  * - disconnected: Returns a disconnected clone of Content Model from editor which you can do any change on it and it won't impact the editor content.
6577
6634
  * If there is any entity in editor, the returned object will contain cloned copy of entity wrapper element.
6578
6635
  * If editor is in dark mode, the cloned entity will be converted back to light mode.
@@ -6735,15 +6792,28 @@ export class Editor implements IEditor {
6735
6792
  export function createModelFromHtml(html: string, options?: Partial<DomToModelOptionForSanitizing>, trustedHTMLHandler?: TrustedHTMLHandler, defaultSegmentFormat?: ContentModelSegmentFormat): ContentModelDocument;
6736
6793
 
6737
6794
  /**
6738
- * Export string content of editor
6795
+ * Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity
6796
+ * @param editor The editor to get content from
6797
+ * @param mode Specify HTML to get plain text result. This is the default option
6798
+ * @param options @optional Options for Model to DOM conversion
6799
+ */
6800
+ export function exportContent(editor: IEditor, mode?: 'HTML', options?: ModelToDomOption): string;
6801
+
6802
+ /**
6803
+ * Export plain text content
6804
+ * @param editor The editor to get content from
6805
+ * @param mode Specify PlainText to get plain text result
6806
+ * @param callbacks @optional Callbacks to customize conversion behavior
6807
+ */
6808
+ export function exportContent(editor: IEditor, mode: 'PlainText', callbacks?: ModelToTextCallbacks): string;
6809
+
6810
+ /**
6811
+ * Export plain text using editor's textContent property directly
6739
6812
  * @param editor The editor to get content from
6740
- * @param mode Mode of content to export. It supports:
6741
- * - HTML: Export HTML content. If there are entities, this will cause EntityOperation event with option = 'replaceTemporaryContent' to get a dehydrated entity
6742
- * - PlainText: Export plain text content
6743
- * - PlainTextFast: Export plain text using editor's textContent property directly
6813
+ * @param mode Specify PlainTextFast to get plain text result using textContent property
6744
6814
  * @param options @optional Options for Model to DOM conversion
6745
6815
  */
6746
- export function exportContent(editor: IEditor, mode?: ExportContentMode, options?: ModelToDomOption): string;
6816
+ export function exportContent(editor: IEditor, mode: 'PlainTextFast'): string;
6747
6817
 
6748
6818
  /**
6749
6819
  * Undo to last undo snapshot
@@ -7164,6 +7234,15 @@ export function formatSegmentWithContentModel(editor: IEditor, apiName: string,
7164
7234
  */
7165
7235
  export function formatTextSegmentBeforeSelectionMarker(editor: IEditor, callback: (model: ContentModelDocument, previousSegment: ContentModelText, paragraph: ContentModelParagraph, markerFormat: ContentModelSegmentFormat, context: FormatContentModelContext) => boolean, options?: FormatContentModelOptions): boolean;
7166
7236
 
7237
+ /**
7238
+ * Format content model at a given insert point with a callback function
7239
+ * @param editor The editor object
7240
+ * @param insertPoint The insert point to format
7241
+ * @param callback The callback function to format the content model
7242
+ * @param options Options to control the behavior of the formatting
7243
+ */
7244
+ export function formatInsertPointWithContentModel(editor: IEditor, insertPoint: DOMInsertPoint, callback: (model: ContentModelDocument, context: FormatContentModelContext, insertPoint?: InsertPoint) => void, options?: FormatContentModelOptions): void;
7245
+
7167
7246
  /**
7168
7247
  * Set a list type to content model
7169
7248
  * @param model the model document
@@ -7226,6 +7305,7 @@ export function getListAnnounceData(path: ContentModelBlockGroup[]): AnnounceDat
7226
7305
  export class TableEditPlugin implements EditorPlugin {
7227
7306
  private anchorContainerSelector?;
7228
7307
  private onTableEditorCreated?;
7308
+ private disableFeatures?;
7229
7309
  private editor;
7230
7310
  private onMouseMoveDisposer;
7231
7311
  private tableRectMap;
@@ -7236,8 +7316,9 @@ export class TableEditPlugin implements EditorPlugin {
7236
7316
  * The container must not be affected by transform: scale(), otherwise the position calculation will be wrong.
7237
7317
  * If not specified, the plugin will be inserted in document.body
7238
7318
  * @param onTableEditorCreated An optional callback to customize the Table Editors elements when created.
7319
+ * @param disableFeatures An optional array of TableEditFeatures to disable
7239
7320
  */
7240
- constructor(anchorContainerSelector?: string | undefined, onTableEditorCreated?: OnTableEditorCreatedCallback | undefined);
7321
+ constructor(anchorContainerSelector?: string | undefined, onTableEditorCreated?: OnTableEditorCreatedCallback | undefined, disableFeatures?: TableEditFeatureName[] | undefined);
7241
7322
  /**
7242
7323
  * Get a friendly name of this plugin
7243
7324
  */
@@ -7272,7 +7353,12 @@ export class TableEditPlugin implements EditorPlugin {
7272
7353
  /**
7273
7354
  * Optional callback when creating a TableEditPlugin, allows to customize the Selectors element as required.
7274
7355
  */
7275
- export type OnTableEditorCreatedCallback = (editorType: 'HorizontalTableInserter' | 'VerticalTableInserter' | 'TableMover' | 'TableResizer', element: HTMLElement) => () => void;
7356
+ export type OnTableEditorCreatedCallback = (featureType: TableEditFeatureName, element: HTMLElement) => () => void;
7357
+
7358
+ /**
7359
+ * Names of table edit features
7360
+ */
7361
+ export type TableEditFeatureName = 'HorizontalTableInserter' | 'VerticalTableInserter' | 'TableMover' | 'TableResizer' | 'TableSelector' | 'CellResizer';
7276
7362
 
7277
7363
  /**
7278
7364
  * Paste plugin, handles BeforePaste event and reformat some special content, including:
@@ -7700,7 +7786,7 @@ export interface ContextMenuOptions<T> {
7700
7786
  * A watermark plugin to manage watermark string for roosterjs
7701
7787
  */
7702
7788
  export class WatermarkPlugin implements EditorPlugin {
7703
- private watermark;
7789
+ protected watermark: string;
7704
7790
  private editor;
7705
7791
  private format;
7706
7792
  private isShowing;