roosterjs 8.55.0 → 8.57.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 8.55.0)
1
+ // Type definitions for roosterjs (Version 8.57.0)
2
2
  // Generated by dts tool from roosterjs
3
3
  // Project: https://github.com/Microsoft/roosterjs
4
4
 
@@ -1308,6 +1308,22 @@ class VListChain {
1308
1308
  private getLists;
1309
1309
  }
1310
1310
 
1311
+ /**
1312
+ * Convert decimal numbers into english alphabet letters
1313
+ * @param decimal The decimal number that needs to be converted
1314
+ * @param isLowerCase if true the roman value will appear in lower case
1315
+ * @returns
1316
+ */
1317
+ function convertDecimalsToAlpha(decimal: number, isLowerCase?: boolean): string;
1318
+
1319
+ /**
1320
+ * Convert decimal numbers into roman numbers
1321
+ * @param decimal The decimal number that needs to be converted
1322
+ * @param isLowerCase if true the roman value will appear in lower case
1323
+ * @returns
1324
+ */
1325
+ function convertDecimalsToRoman(decimal: number, isLowerCase?: boolean): string;
1326
+
1311
1327
  /**
1312
1328
  * Set the Style of a List Item provided, with the styles that the inline child elements have
1313
1329
  * If the child inline elements have different styles, it will not modify the styles of the list item
@@ -2957,6 +2973,10 @@ interface DOMEventPluginState {
2957
2973
  * Image selection range
2958
2974
  */
2959
2975
  imageSelectionRange: ImageSelectionRange | null;
2976
+ /**
2977
+ * When set to true, onFocus event will not trigger reselect cached range
2978
+ */
2979
+ skipReselectOnFocus?: boolean;
2960
2980
  }
2961
2981
 
2962
2982
  /**
@@ -3102,6 +3122,29 @@ interface CopyPastePluginState {
3102
3122
  allowedCustomPasteType: string[];
3103
3123
  }
3104
3124
 
3125
+ /**
3126
+ * Known announce strings
3127
+ */
3128
+ const enum KnownAnnounceStrings {
3129
+ /**
3130
+ * String announced for a list item in a OL List
3131
+ * @example
3132
+ * Auto corrected, {0}
3133
+ * Where &lcub0&rcub is the new list item bullet
3134
+ */
3135
+ AnnounceListItemNumbering = 1,
3136
+ /**
3137
+ * String announced for a list item in a UL List
3138
+ * @example
3139
+ * Auto corrected bullet
3140
+ */
3141
+ AnnounceListItemBullet = 2,
3142
+ /**
3143
+ * String announced when cursor is moved to the last cell in a table
3144
+ */
3145
+ AnnounceOnFocusLastCell = 3
3146
+ }
3147
+
3105
3148
  /**
3106
3149
  * Command strings for Document.execCommand() API
3107
3150
  * https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand
@@ -3846,13 +3889,24 @@ const enum ExperimentalFeatures {
3846
3889
  */
3847
3890
  EditWithContentModel = "EditWithContentModel",
3848
3891
  /**
3849
- * Provide additional Tab Key Features. Requires Text Features Content Editable Features
3850
- */
3851
- TabKeyTextFeatures = "TabKeyTextFeatures",
3852
- /**
3892
+ * @deprecated This feature is always enabled
3853
3893
  * Trigger formatting by a especial characters. Ex: (A), 1. i).
3854
3894
  */
3855
3895
  AutoFormatList = "AutoFormatList",
3896
+ /**
3897
+ * @deprecated This feature is always enabled
3898
+ * Add entities around a Read Only Inline entity to prevent cursor to be hidden when cursor is next of it.
3899
+ */
3900
+ InlineEntityReadOnlyDelimiters = "InlineEntityReadOnlyDelimiters",
3901
+ /**
3902
+ * @deprecated This feature is always enabled
3903
+ * Paste with Content model
3904
+ */
3905
+ ContentModelPaste = "ContentModelPaste",
3906
+ /**
3907
+ * Provide additional Tab Key Features. Requires Text Features Content Editable Features
3908
+ */
3909
+ TabKeyTextFeatures = "TabKeyTextFeatures",
3856
3910
  /**
3857
3911
  * With this feature enabled, when writing back a list item we will re-use all
3858
3912
  * ancestor list elements, even if they don't match the types currently in the
@@ -3864,14 +3918,6 @@ const enum ExperimentalFeatures {
3864
3918
  * Delete table with Backspace key with the whole was selected with table selector
3865
3919
  */
3866
3920
  DeleteTableWithBackspace = "DeleteTableWithBackspace",
3867
- /**
3868
- * Add entities around a Read Only Inline entity to prevent cursor to be hidden when cursor is next of it.
3869
- */
3870
- InlineEntityReadOnlyDelimiters = "InlineEntityReadOnlyDelimiters",
3871
- /**
3872
- * Paste with Content model
3873
- */
3874
- ContentModelPaste = "ContentModelPaste",
3875
3921
  /**
3876
3922
  * Disable list chain functionality
3877
3923
  */
@@ -5301,6 +5347,25 @@ interface BeforeKeyboardEditingData {
5301
5347
  interface CompatibleBeforeKeyboardEditingEvent extends BeforeKeyboardEditingData, BasePluginEvent<CompatiblePluginEventType.BeforeKeyboardEditing> {
5302
5348
  }
5303
5349
 
5350
+ /**
5351
+ * Represents data, that can be used to announce text to screen reader.
5352
+ */
5353
+ interface AnnounceData {
5354
+ /**
5355
+ * @optional Default announce strings built in Rooster
5356
+ */
5357
+ defaultStrings?: KnownAnnounceStrings | CompatibleKnownAnnounceStrings;
5358
+ /**
5359
+ * @optional string to announce from this Content Changed event, will be the fallback value if default string
5360
+ * is not provided or if it is not found in the strings map.
5361
+ */
5362
+ text?: string;
5363
+ /**
5364
+ * @optional if provided, will attempt to replace {n} with each of the values inside of the array.
5365
+ */
5366
+ formatStrings?: string[];
5367
+ }
5368
+
5304
5369
  /**
5305
5370
  * This refers to a "content block" in editor that serves as a content parsing boundary
5306
5371
  * It is most those html block like tags, i.e. &lt;p&gt;, &lt;div&gt;, &lt;li&gt;, &lt;td&gt; etc.
@@ -5431,6 +5496,12 @@ interface ContentChangedData {
5431
5496
  * @returns Related entity state array
5432
5497
  */
5433
5498
  getEntityState?: () => EntityState[];
5499
+ /**
5500
+ * @optional
5501
+ * Get Announce data from this content changed event.
5502
+ * @returns
5503
+ */
5504
+ getAnnounceData?: () => AnnounceData | undefined;
5434
5505
  }
5435
5506
 
5436
5507
  /**
@@ -7236,6 +7307,12 @@ interface EditorCore extends PluginState {
7236
7307
  * If keep it null, editor will still use original dataset-based dark mode solution.
7237
7308
  */
7238
7309
  darkColorHandler: DarkColorHandler;
7310
+ /**
7311
+ * A callback to be invoked when any exception is thrown during disposing editor
7312
+ * @param plugin The plugin that causes exception
7313
+ * @param error The error object we got
7314
+ */
7315
+ disposeErrorHandler?: (plugin: EditorPlugin, error: Error) => void;
7239
7316
  }
7240
7317
 
7241
7318
  /**
@@ -7695,6 +7772,12 @@ interface EditorOptions {
7695
7772
  * Color of the border of a selectedImage. Default color: '#DB626C'
7696
7773
  */
7697
7774
  imageSelectionBorderColor?: string;
7775
+ /**
7776
+ * A callback to be invoked when any exception is thrown during disposing editor
7777
+ * @param plugin The plugin that causes exception
7778
+ * @param error The error object we got
7779
+ */
7780
+ disposeErrorHandler?: (plugin: EditorPlugin, error: Error) => void;
7698
7781
  }
7699
7782
 
7700
7783
  /**
@@ -8661,13 +8744,24 @@ enum CompatibleExperimentalFeatures {
8661
8744
  */
8662
8745
  EditWithContentModel = "EditWithContentModel",
8663
8746
  /**
8664
- * Provide additional Tab Key Features. Requires Text Features Content Editable Features
8665
- */
8666
- TabKeyTextFeatures = "TabKeyTextFeatures",
8667
- /**
8747
+ * @deprecated This feature is always enabled
8668
8748
  * Trigger formatting by a especial characters. Ex: (A), 1. i).
8669
8749
  */
8670
8750
  AutoFormatList = "AutoFormatList",
8751
+ /**
8752
+ * @deprecated This feature is always enabled
8753
+ * Add entities around a Read Only Inline entity to prevent cursor to be hidden when cursor is next of it.
8754
+ */
8755
+ InlineEntityReadOnlyDelimiters = "InlineEntityReadOnlyDelimiters",
8756
+ /**
8757
+ * @deprecated This feature is always enabled
8758
+ * Paste with Content model
8759
+ */
8760
+ ContentModelPaste = "ContentModelPaste",
8761
+ /**
8762
+ * Provide additional Tab Key Features. Requires Text Features Content Editable Features
8763
+ */
8764
+ TabKeyTextFeatures = "TabKeyTextFeatures",
8671
8765
  /**
8672
8766
  * With this feature enabled, when writing back a list item we will re-use all
8673
8767
  * ancestor list elements, even if they don't match the types currently in the
@@ -8679,14 +8773,6 @@ enum CompatibleExperimentalFeatures {
8679
8773
  * Delete table with Backspace key with the whole was selected with table selector
8680
8774
  */
8681
8775
  DeleteTableWithBackspace = "DeleteTableWithBackspace",
8682
- /**
8683
- * Add entities around a Read Only Inline entity to prevent cursor to be hidden when cursor is next of it.
8684
- */
8685
- InlineEntityReadOnlyDelimiters = "InlineEntityReadOnlyDelimiters",
8686
- /**
8687
- * Paste with Content model
8688
- */
8689
- ContentModelPaste = "ContentModelPaste",
8690
8776
  /**
8691
8777
  * Disable list chain functionality
8692
8778
  */
@@ -8950,6 +9036,29 @@ enum CompatibleEntityOperation {
8950
9036
  UpdateEntityState = 11
8951
9037
  }
8952
9038
 
9039
+ /**
9040
+ * Known announce strings
9041
+ */
9042
+ enum CompatibleKnownAnnounceStrings {
9043
+ /**
9044
+ * String announced for a list item in a OL List
9045
+ * @example
9046
+ * Auto corrected, &lcub;0&rcub;
9047
+ * Where &lcub0&rcub is the new list item bullet
9048
+ */
9049
+ AnnounceListItemNumbering = 1,
9050
+ /**
9051
+ * String announced for a list item in a UL List
9052
+ * @example
9053
+ * Auto corrected bullet
9054
+ */
9055
+ AnnounceListItemBullet = 2,
9056
+ /**
9057
+ * String announced when cursor is moved to the last cell in a table
9058
+ */
9059
+ AnnounceOnFocusLastCell = 3
9060
+ }
9061
+
8953
9062
  /**
8954
9063
  * The position. Mostly used for content insertion and traversing
8955
9064
  * On insertion, we will need to specify where we want the content to be placed (begin, end, selection or outside)
@@ -10636,6 +10745,7 @@ class PickerPlugin<T extends PickerDataProvider = PickerDataProvider> implements
10636
10745
  private shouldHandleKeyUpEvent;
10637
10746
  private onKeyUpDomEvent;
10638
10747
  private onKeyDownEvent;
10748
+ private getParentNodeIfTextNode;
10639
10749
  private onAndroidInputEvent;
10640
10750
  private calcInputLength;
10641
10751
  private tryRemoveNode;
@@ -10785,4 +10895,64 @@ class AutoFormat implements EditorPlugin {
10785
10895
  onPluginEvent(event: PluginEvent): void;
10786
10896
  }
10787
10897
 
10898
+ /**
10899
+ * Announce feature keys
10900
+ */
10901
+ type AnnounceFeatureKey = 'announceNewListItem' | 'announceWarningOnLastTableCell';
10902
+
10903
+ /**
10904
+ * Represents a Announce feature used in Announce Plugin.
10905
+ * If the Should Handle Callback returns announce data, it will be announced by using a aria-live region.
10906
+ */
10907
+ interface AnnounceFeature {
10908
+ /**
10909
+ * Whether to handle this feature, if returns Announce Data, will be announced, otherwise will do nothing.
10910
+ * @returns
10911
+ */
10912
+ shouldHandle: (editor: IEditor, lastFocusedElement: HTMLElement | null) => AnnounceData | false;
10913
+ /**
10914
+ * Keys handled in the current event
10915
+ */
10916
+ keys: number[];
10917
+ }
10918
+
10919
+ /**
10920
+ * Announce messages to screen reader by using aria live element.
10921
+ */
10922
+ class Announce implements EditorPlugin {
10923
+ private stringsMapOrGetter?;
10924
+ private ariaLiveElement;
10925
+ private editor;
10926
+ private features;
10927
+ private lastFocusedElement;
10928
+ constructor(stringsMapOrGetter?: Map<KnownAnnounceStrings | CompatibleKnownAnnounceStrings, string> | ((key: KnownAnnounceStrings | CompatibleKnownAnnounceStrings) => string) | undefined, skipAnnounceFeatures?: AnnounceFeatureKey[], additionalFeatures?: AnnounceFeature[]);
10929
+ /**
10930
+ * Get a friendly name of this plugin
10931
+ */
10932
+ getName(): string;
10933
+ /**
10934
+ * Initialize this plugin
10935
+ * @param editor The editor instance
10936
+ */
10937
+ initialize(editor: IEditor): void;
10938
+ /**
10939
+ * Dispose this plugin
10940
+ */
10941
+ dispose(): void;
10942
+ /**
10943
+ * Handle events triggered from editor
10944
+ * @param event PluginEvent object
10945
+ */
10946
+ onPluginEvent(ev: PluginEvent): void;
10947
+ private handleFeatures;
10948
+ protected announce(announceData: AnnounceData, editor: IEditor): void;
10949
+ private getString;
10950
+ /**
10951
+ * @internal
10952
+ * Public only for unit testing.
10953
+ * @returns
10954
+ */
10955
+ getAriaLiveElement(): HTMLDivElement | undefined;
10956
+ }
10957
+
10788
10958
  }