roosterjs-content-model-types 9.4.1 → 9.5.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.
Files changed (71) hide show
  1. package/README.md +10 -10
  2. package/lib/contentModel/format/metadata/ImageMetadataFormat.d.ts +14 -1
  3. package/lib/contentModel/format/metadata/ImageMetadataFormat.js.map +1 -1
  4. package/lib/context/DarkColorHandler.d.ts +4 -0
  5. package/lib/context/DarkColorHandler.js.map +1 -1
  6. package/lib/context/EditorContext.d.ts +4 -0
  7. package/lib/context/EditorContext.js.map +1 -1
  8. package/lib/editor/EditorCore.d.ts +4 -0
  9. package/lib/editor/EditorCore.js.map +1 -1
  10. package/lib/editor/EditorOptions.d.ts +79 -42
  11. package/lib/editor/EditorOptions.js.map +1 -1
  12. package/lib/editor/ExperimentalFeature.d.ts +11 -0
  13. package/lib/editor/ExperimentalFeature.js +3 -0
  14. package/lib/editor/ExperimentalFeature.js.map +1 -0
  15. package/lib/editor/IEditor.d.ts +6 -0
  16. package/lib/editor/IEditor.js.map +1 -1
  17. package/lib/event/BeforePasteEvent.d.ts +2 -2
  18. package/lib/event/BeforePasteEvent.js.map +1 -1
  19. package/lib/index.d.ts +3 -2
  20. package/lib/index.js.map +1 -1
  21. package/lib/parameter/FormatContentModelOptions.d.ts +2 -2
  22. package/lib/parameter/FormatContentModelOptions.js.map +1 -1
  23. package/lib/parameter/ImageEditor.d.ts +5 -1
  24. package/lib/parameter/ImageEditor.js.map +1 -1
  25. package/lib-amd/contentModel/format/metadata/ImageMetadataFormat.d.ts +14 -1
  26. package/lib-amd/contentModel/format/metadata/ImageMetadataFormat.js.map +1 -1
  27. package/lib-amd/context/DarkColorHandler.d.ts +4 -0
  28. package/lib-amd/context/DarkColorHandler.js.map +1 -1
  29. package/lib-amd/context/EditorContext.d.ts +4 -0
  30. package/lib-amd/context/EditorContext.js.map +1 -1
  31. package/lib-amd/editor/EditorCore.d.ts +4 -0
  32. package/lib-amd/editor/EditorCore.js.map +1 -1
  33. package/lib-amd/editor/EditorOptions.d.ts +79 -42
  34. package/lib-amd/editor/EditorOptions.js.map +1 -1
  35. package/lib-amd/editor/ExperimentalFeature.d.ts +11 -0
  36. package/lib-amd/editor/ExperimentalFeature.js +5 -0
  37. package/lib-amd/editor/ExperimentalFeature.js.map +1 -0
  38. package/lib-amd/editor/IEditor.d.ts +6 -0
  39. package/lib-amd/editor/IEditor.js.map +1 -1
  40. package/lib-amd/event/BeforePasteEvent.d.ts +2 -2
  41. package/lib-amd/event/BeforePasteEvent.js.map +1 -1
  42. package/lib-amd/index.d.ts +3 -2
  43. package/lib-amd/index.js.map +1 -1
  44. package/lib-amd/parameter/FormatContentModelOptions.d.ts +2 -2
  45. package/lib-amd/parameter/FormatContentModelOptions.js.map +1 -1
  46. package/lib-amd/parameter/ImageEditor.d.ts +5 -1
  47. package/lib-amd/parameter/ImageEditor.js.map +1 -1
  48. package/lib-mjs/contentModel/format/metadata/ImageMetadataFormat.d.ts +14 -1
  49. package/lib-mjs/contentModel/format/metadata/ImageMetadataFormat.js.map +1 -1
  50. package/lib-mjs/context/DarkColorHandler.d.ts +4 -0
  51. package/lib-mjs/context/DarkColorHandler.js.map +1 -1
  52. package/lib-mjs/context/EditorContext.d.ts +4 -0
  53. package/lib-mjs/context/EditorContext.js.map +1 -1
  54. package/lib-mjs/editor/EditorCore.d.ts +4 -0
  55. package/lib-mjs/editor/EditorCore.js.map +1 -1
  56. package/lib-mjs/editor/EditorOptions.d.ts +79 -42
  57. package/lib-mjs/editor/EditorOptions.js.map +1 -1
  58. package/lib-mjs/editor/ExperimentalFeature.d.ts +11 -0
  59. package/lib-mjs/editor/ExperimentalFeature.js +2 -0
  60. package/lib-mjs/editor/ExperimentalFeature.js.map +1 -0
  61. package/lib-mjs/editor/IEditor.d.ts +6 -0
  62. package/lib-mjs/editor/IEditor.js.map +1 -1
  63. package/lib-mjs/event/BeforePasteEvent.d.ts +2 -2
  64. package/lib-mjs/event/BeforePasteEvent.js.map +1 -1
  65. package/lib-mjs/index.d.ts +3 -2
  66. package/lib-mjs/index.js.map +1 -1
  67. package/lib-mjs/parameter/FormatContentModelOptions.d.ts +2 -2
  68. package/lib-mjs/parameter/FormatContentModelOptions.js.map +1 -1
  69. package/lib-mjs/parameter/ImageEditor.d.ts +5 -1
  70. package/lib-mjs/parameter/ImageEditor.js.map +1 -1
  71. package/package.json +1 -1
package/README.md CHANGED
@@ -51,22 +51,22 @@ There are also some extension packages to provide additional functionalities.
51
51
  1. [roosterjs-color-utils](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_color_utils.html):
52
52
  Provide color transformation utility to make editor work under dark mode.
53
53
 
54
- 2. [roosterjs-react](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_react.html):
55
- Provide a React wrapper of roosterjs so it can be easily used with React.
56
-
57
54
  To be compatible with old (8.\*) versions, you can use `EditorAdapter` class from the following package which can act as a 8.\* Editor:
58
55
 
59
56
  1. [roosterjs-editor-adapter](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_adapter.html):
60
57
  Provide a adapter class `EditorAdapter` to work with Editor (9.\*) and legacy plugins (via [EditorAdapterOptions.legacyPlugins](https://microsoft.github.io/roosterjs/docs/interfaces/roosterjs_editor_adapter.editoradapteroptions.html#legacyplugins))
61
58
 
62
- And the following packages are for old (8.\*) compatibility:
59
+ All old packages (8.\*) are moved to branch [roosterjsv8](https://github.com/microsoft/roosterjs/tree/roosterjsv8), including
60
+
61
+ 1. roosterjs-editor-core
62
+ 2. roosterjs-editor-api
63
+ 3. roosterjs-editor-dom
64
+ 4. roosterjs-editor-plugins
65
+ 5. roosterjs-editor-types
66
+ 6. roosterjs-editor-types-compatible
67
+ 7. roosterjs-react
63
68
 
64
- 1. [roosterjs-editor-core](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_core.html):
65
- 2. [roosterjs-editor-api](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_api.html):
66
- 3. [roosterjs-editor-dom](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_dom.html):
67
- 4. [roosterjs-editor-plugins](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_plugins.html):
68
- 5. [roosterjs-editor-types](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_types.html):
69
- 6. [roosterjs-editor-types-compatible](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_types_compatible.html):
69
+ We will not update these branches any more unless there are new security bugs.
70
70
 
71
71
  ### APIs
72
72
 
@@ -17,6 +17,19 @@ export declare type ImageResizeMetadataFormat = {
17
17
  */
18
18
  heightPx?: number;
19
19
  };
20
+ /**
21
+ * Metadata for inline image flip
22
+ */
23
+ export interface ImageFlipMetadataFormat {
24
+ /**
25
+ * If true, the image was flipped.
26
+ */
27
+ flippedVertical?: boolean;
28
+ /**
29
+ * If true, the image was flipped.
30
+ */
31
+ flippedHorizontal?: boolean;
32
+ }
20
33
  /**
21
34
  * Metadata for inline image crop
22
35
  */
@@ -55,7 +68,7 @@ export declare type ImageRotateMetadataFormat = {
55
68
  /**
56
69
  * Metadata for inline image
57
70
  */
58
- export declare type ImageMetadataFormat = ImageResizeMetadataFormat & ImageCropMetadataFormat & ImageRotateMetadataFormat & {
71
+ export declare type ImageMetadataFormat = ImageResizeMetadataFormat & ImageCropMetadataFormat & ImageRotateMetadataFormat & ImageFlipMetadataFormat & {
59
72
  /**
60
73
  * Original src of the image. This value will not be changed when edit image. We can always use it
61
74
  * to get the original image so that all editing operation will be on top of the original image.
@@ -1 +1 @@
1
- {"version":3,"file":"ImageMetadataFormat.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-types/lib/contentModel/format/metadata/ImageMetadataFormat.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Metadata for inline image resize\n */\nexport type ImageResizeMetadataFormat = {\n /**\n * Width after resize, in px.\n * If image is cropped, this is the width of visible part\n * If image is rotated, this is the width before rotation\n * @default clientWidth of the image\n */\n widthPx?: number;\n\n /**\n * Height after resize, in px.\n * If image is cropped, this is the height of visible part\n * If image is rotated, this is the height before rotation\n * @default clientHeight of the image\n */\n heightPx?: number;\n};\n\n/**\n * Metadata for inline image crop\n */\nexport type ImageCropMetadataFormat = {\n /**\n * Left cropped percentage. Rotation or resizing won't impact this percentage value\n * @default 0\n */\n leftPercent?: number;\n\n /**\n * Right cropped percentage. Rotation or resizing won't impact this percentage value\n * @default 0\n */\n rightPercent?: number;\n\n /**\n * Top cropped percentage. Rotation or resizing won't impact this percentage value\n * @default 0\n */\n topPercent?: number;\n\n /**\n * Bottom cropped percentage. Rotation or resizing won't impact this percentage value\n * @default 0\n */\n bottomPercent?: number;\n};\n\n/**\n * Metadata for inline image rotate\n */\nexport type ImageRotateMetadataFormat = {\n /**\n * Rotated angle of inline image, in radian. Cropping or resizing won't impact this percentage value\n * @default 0\n */\n angleRad?: number;\n};\n\n/**\n * Metadata for inline image\n */\nexport type ImageMetadataFormat = ImageResizeMetadataFormat &\n ImageCropMetadataFormat &\n ImageRotateMetadataFormat & {\n /**\n * Original src of the image. This value will not be changed when edit image. We can always use it\n * to get the original image so that all editing operation will be on top of the original image.\n */\n readonly src?: string;\n\n /**\n * Natural width of the original image (specified by the src field, may not be the current edited image)\n */\n readonly naturalWidth?: number;\n\n /**\n * Natural height of the original image (specified by the src field, may not be the current edited image)\n */\n readonly naturalHeight?: number;\n };\n"]}
1
+ {"version":3,"file":"ImageMetadataFormat.js","sourceRoot":"","sources":["../../../../../../packages/roosterjs-content-model-types/lib/contentModel/format/metadata/ImageMetadataFormat.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Metadata for inline image resize\n */\nexport type ImageResizeMetadataFormat = {\n /**\n * Width after resize, in px.\n * If image is cropped, this is the width of visible part\n * If image is rotated, this is the width before rotation\n * @default clientWidth of the image\n */\n widthPx?: number;\n\n /**\n * Height after resize, in px.\n * If image is cropped, this is the height of visible part\n * If image is rotated, this is the height before rotation\n * @default clientHeight of the image\n */\n heightPx?: number;\n};\n\n/**\n * Metadata for inline image flip\n */\nexport interface ImageFlipMetadataFormat {\n /**\n * If true, the image was flipped.\n */\n flippedVertical?: boolean;\n /**\n * If true, the image was flipped.\n */\n flippedHorizontal?: boolean;\n}\n\n/**\n * Metadata for inline image crop\n */\nexport type ImageCropMetadataFormat = {\n /**\n * Left cropped percentage. Rotation or resizing won't impact this percentage value\n * @default 0\n */\n leftPercent?: number;\n\n /**\n * Right cropped percentage. Rotation or resizing won't impact this percentage value\n * @default 0\n */\n rightPercent?: number;\n\n /**\n * Top cropped percentage. Rotation or resizing won't impact this percentage value\n * @default 0\n */\n topPercent?: number;\n\n /**\n * Bottom cropped percentage. Rotation or resizing won't impact this percentage value\n * @default 0\n */\n bottomPercent?: number;\n};\n\n/**\n * Metadata for inline image rotate\n */\nexport type ImageRotateMetadataFormat = {\n /**\n * Rotated angle of inline image, in radian. Cropping or resizing won't impact this percentage value\n * @default 0\n */\n angleRad?: number;\n};\n\n/**\n * Metadata for inline image\n */\nexport type ImageMetadataFormat = ImageResizeMetadataFormat &\n ImageCropMetadataFormat &\n ImageRotateMetadataFormat &\n ImageFlipMetadataFormat & {\n /**\n * Original src of the image. This value will not be changed when edit image. We can always use it\n * to get the original image so that all editing operation will be on top of the original image.\n */\n readonly src?: string;\n\n /**\n * Natural width of the original image (specified by the src field, may not be the current edited image)\n */\n readonly naturalWidth?: number;\n\n /**\n * Natural height of the original image (specified by the src field, may not be the current edited image)\n */\n readonly naturalHeight?: number;\n };\n"]}
@@ -49,4 +49,8 @@ export interface DarkColorHandler {
49
49
  * A util function to transform light mode color to dark mode color
50
50
  */
51
51
  getDarkColor: ColorTransformFunction;
52
+ /**
53
+ * Generate color key for dark mode color.
54
+ */
55
+ generateColorKey: ColorTransformFunction;
52
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DarkColorHandler.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/context/DarkColorHandler.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents a combination of color key, light color and dark color, parsed from existing color value\n */\nexport interface Colors {\n /**\n * Light mode color value\n */\n lightModeColor: string;\n\n /**\n * Dark mode color value, if found, otherwise undefined\n */\n darkModeColor: string;\n}\n\n/**\n * A util function type to transform light mode color to dark mode color\n * Default value is to return the original light color\n * @param lightColor Source color string in light mode\n * @param baseLValue Base value of light used for dark value calculation\n * @param colorType @optional Type of color, can be text, background, or border\n * @param element @optional Source HTML element of the color\n */\nexport type ColorTransformFunction = (\n lightColor: string,\n baseLValue?: number,\n colorType?: 'text' | 'background' | 'border',\n element?: HTMLElement\n) => string;\n\n/**\n * A handler object for dark color, used for variable-based dark color solution\n */\nexport interface DarkColorHandler {\n /**\n * Map of known colors\n */\n readonly knownColors: Record<string, Colors>;\n\n /**\n * Update all known colors to root container.\n * @param isDarkMode Whether container is in dark mode. When in dark mode, we add CSS color variables for all known colors.\n * When in light mode, we will remove all those CSS color variables\n */\n updateKnownColor(isDarkMode: boolean): void;\n\n /**\n * Register a known color, and update it to root container via CSS color variable when in dark mode\n * @param isDarkMode Whether container is in dark mode.\n * @param key The key of color, normally it is the name of color variable\n * @param colorPair A pair value of light color and dark color\n */\n updateKnownColor(isDarkMode: boolean, key: string, colorPair: Colors): void;\n\n /**\n * Reset known color record, clean up registered color variables.\n */\n reset(): void;\n\n /**\n * A util function to transform light mode color to dark mode color\n */\n getDarkColor: ColorTransformFunction;\n}\n"]}
1
+ {"version":3,"file":"DarkColorHandler.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/context/DarkColorHandler.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents a combination of color key, light color and dark color, parsed from existing color value\n */\nexport interface Colors {\n /**\n * Light mode color value\n */\n lightModeColor: string;\n\n /**\n * Dark mode color value, if found, otherwise undefined\n */\n darkModeColor: string;\n}\n\n/**\n * A util function type to transform light mode color to dark mode color\n * Default value is to return the original light color\n * @param lightColor Source color string in light mode\n * @param baseLValue Base value of light used for dark value calculation\n * @param colorType @optional Type of color, can be text, background, or border\n * @param element @optional Source HTML element of the color\n */\nexport type ColorTransformFunction = (\n lightColor: string,\n baseLValue?: number,\n colorType?: 'text' | 'background' | 'border',\n element?: HTMLElement\n) => string;\n\n/**\n * A handler object for dark color, used for variable-based dark color solution\n */\nexport interface DarkColorHandler {\n /**\n * Map of known colors\n */\n readonly knownColors: Record<string, Colors>;\n\n /**\n * Update all known colors to root container.\n * @param isDarkMode Whether container is in dark mode. When in dark mode, we add CSS color variables for all known colors.\n * When in light mode, we will remove all those CSS color variables\n */\n updateKnownColor(isDarkMode: boolean): void;\n\n /**\n * Register a known color, and update it to root container via CSS color variable when in dark mode\n * @param isDarkMode Whether container is in dark mode.\n * @param key The key of color, normally it is the name of color variable\n * @param colorPair A pair value of light color and dark color\n */\n updateKnownColor(isDarkMode: boolean, key: string, colorPair: Colors): void;\n\n /**\n * Reset known color record, clean up registered color variables.\n */\n reset(): void;\n\n /**\n * A util function to transform light mode color to dark mode color\n */\n getDarkColor: ColorTransformFunction;\n\n /**\n * Generate color key for dark mode color.\n */\n generateColorKey: ColorTransformFunction;\n}\n"]}
@@ -47,4 +47,8 @@ export interface EditorContext {
47
47
  * Root Font size in Px.
48
48
  */
49
49
  rootFontSize?: number;
50
+ /**
51
+ * Enabled experimental features
52
+ */
53
+ experimentalFeatures?: ReadonlyArray<string>;
50
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EditorContext.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/context/EditorContext.ts"],"names":[],"mappings":"","sourcesContent":["import type { DarkColorHandler } from './DarkColorHandler';\nimport type { DomIndexer } from './DomIndexer';\nimport type { ContentModelSegmentFormat } from '../contentModel/format/ContentModelSegmentFormat';\nimport type { PendingFormat } from '../pluginState/FormatPluginState';\n\n/**\n * An editor context interface used by ContentModel PAI\n */\nexport interface EditorContext {\n /**\n * Whether current content is in dark mode\n */\n isDarkMode?: boolean;\n\n /**\n * Default format of editor\n */\n defaultFormat?: ContentModelSegmentFormat;\n\n /**\n * Pending format if any\n */\n pendingFormat?: PendingFormat;\n\n /**\n * Color manager, to help manager color in dark mode\n */\n darkColorHandler?: DarkColorHandler;\n\n /**\n * Whether to handle delimiters in Content Model\n */\n addDelimiterForEntity?: boolean;\n\n /**\n * Zoom scale number\n */\n zoomScale?: number;\n\n /**\n * Whether the content is in Right-to-left from root level\n */\n isRootRtl?: boolean;\n\n /**\n * Whether put the source element into Content Model when possible.\n * When pass true, this cached element will be used to create DOM tree back when convert Content Model to DOM\n */\n allowCacheElement?: boolean;\n\n /**\n * @optional Indexer for content model, to help build backward relationship from DOM node to Content Model\n */\n domIndexer?: DomIndexer;\n\n /**\n * Root Font size in Px.\n */\n rootFontSize?: number;\n}\n"]}
1
+ {"version":3,"file":"EditorContext.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/context/EditorContext.ts"],"names":[],"mappings":"","sourcesContent":["import type { DarkColorHandler } from './DarkColorHandler';\nimport type { DomIndexer } from './DomIndexer';\nimport type { ContentModelSegmentFormat } from '../contentModel/format/ContentModelSegmentFormat';\nimport type { PendingFormat } from '../pluginState/FormatPluginState';\n\n/**\n * An editor context interface used by ContentModel PAI\n */\nexport interface EditorContext {\n /**\n * Whether current content is in dark mode\n */\n isDarkMode?: boolean;\n\n /**\n * Default format of editor\n */\n defaultFormat?: ContentModelSegmentFormat;\n\n /**\n * Pending format if any\n */\n pendingFormat?: PendingFormat;\n\n /**\n * Color manager, to help manager color in dark mode\n */\n darkColorHandler?: DarkColorHandler;\n\n /**\n * Whether to handle delimiters in Content Model\n */\n addDelimiterForEntity?: boolean;\n\n /**\n * Zoom scale number\n */\n zoomScale?: number;\n\n /**\n * Whether the content is in Right-to-left from root level\n */\n isRootRtl?: boolean;\n\n /**\n * Whether put the source element into Content Model when possible.\n * When pass true, this cached element will be used to create DOM tree back when convert Content Model to DOM\n */\n allowCacheElement?: boolean;\n\n /**\n * @optional Indexer for content model, to help build backward relationship from DOM node to Content Model\n */\n domIndexer?: DomIndexer;\n\n /**\n * Root Font size in Px.\n */\n rootFontSize?: number;\n\n /**\n * Enabled experimental features\n */\n experimentalFeatures?: ReadonlyArray<string>;\n}\n"]}
@@ -293,4 +293,8 @@ export interface EditorCore extends PluginState {
293
293
  * @param error The error object we got
294
294
  */
295
295
  readonly disposeErrorHandler?: (plugin: EditorPlugin, error: Error) => void;
296
+ /**
297
+ * Enabled experimental features
298
+ */
299
+ readonly experimentalFeatures: ReadonlyArray<string>;
296
300
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EditorCore.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/editor/EditorCore.ts"],"names":[],"mappings":"","sourcesContent":["import type { AnnounceData } from '../parameter/AnnounceData';\nimport type { DOMHelper } from '../parameter/DOMHelper';\nimport type { PluginEvent } from '../event/PluginEvent';\nimport type { PluginState } from '../pluginState/PluginState';\nimport type { EditorPlugin } from './EditorPlugin';\nimport type { DOMEventRecord } from '../parameter/DOMEventRecord';\nimport type { Snapshot } from '../parameter/Snapshot';\nimport type { EntityState } from '../parameter/FormatContentModelContext';\nimport type { DarkColorHandler } from '../context/DarkColorHandler';\nimport type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';\nimport type { DOMSelection } from '../selection/DOMSelection';\nimport type { DomToModelOptionForCreateModel } from '../context/DomToModelOption';\nimport type { EditorContext } from '../context/EditorContext';\nimport type { EditorEnvironment } from '../parameter/EditorEnvironment';\nimport type { ModelToDomOption } from '../context/ModelToDomOption';\nimport type { OnNodeCreated } from '../context/ModelToDomSettings';\nimport type { TrustedHTMLHandler } from '../parameter/TrustedHTMLHandler';\nimport type { Rect } from '../parameter/Rect';\nimport type {\n ContentModelFormatter,\n FormatContentModelOptions,\n} from '../parameter/FormatContentModelOptions';\n\n/**\n * Create a EditorContext object used by ContentModel API\n * @param core The EditorCore object\n * @param saveIndex True to allow saving index info into node using domIndexer, otherwise false\n */\nexport type CreateEditorContext = (core: EditorCore, saveIndex: boolean) => EditorContext;\n\n/**\n * Create Content Model from DOM tree in this editor\n * @param core The EditorCore object\n * @param option The option to customize the behavior of DOM to Content Model conversion\n * @param selectionOverride When passed a valid selection, use this selection range instead of current selection in editor.\n * When pass \"none\", it means we don't need a selection in content model\n */\nexport type CreateContentModel = (\n core: EditorCore,\n option?: DomToModelOptionForCreateModel,\n selectionOverride?: DOMSelection | 'none'\n) => ContentModelDocument;\n\n/**\n * Get current DOM selection from editor\n * @param core The EditorCore object\n */\nexport type GetDOMSelection = (core: EditorCore) => DOMSelection | null;\n\n/**\n * Set content with content model. This is the replacement of core API getSelectionRangeEx\n * @param core The EditorCore object\n * @param model The content model to set\n * @param option Additional options to customize the behavior of Content Model to DOM conversion\n * @param onNodeCreated An optional callback that will be called when a DOM node is created\n */\nexport type SetContentModel = (\n core: EditorCore,\n model: ContentModelDocument,\n option?: ModelToDomOption,\n onNodeCreated?: OnNodeCreated\n) => DOMSelection | null;\n\n/**\n * Set current DOM selection from editor. This is the replacement of core API select\n * @param core The EditorCore object\n * @param selection The selection to set\n * @param skipSelectionChangedEvent @param Pass true to skip triggering a SelectionChangedEvent\n */\nexport type SetDOMSelection = (\n core: EditorCore,\n selection: DOMSelection | null,\n skipSelectionChangedEvent?: boolean\n) => void;\n\n/**\n * Set a new logical root (most likely due to focus change)\n * @param core The EditorCore object\n * @param logicalRoot The new logical root (has to be child of physicalRoot or null to use physicalRoot as logical root)\n */\nexport type SetLogicalRoot = (core: EditorCore, logicalRoot: HTMLDivElement | null) => void;\n\n/**\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param core The EditorCore object\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatContentModelOptions\n */\nexport type FormatContentModel = (\n core: EditorCore,\n formatter: ContentModelFormatter,\n options?: FormatContentModelOptions,\n domToModelOptions?: DomToModelOptionForCreateModel\n) => void;\n\n/**\n * Switch the Shadow Edit mode of editor On/Off\n * @param core The EditorCore object\n * @param isOn True to switch On, False to switch Off\n */\nexport type SwitchShadowEdit = (core: EditorCore, isOn: boolean) => void;\n\n/**\n * Trigger a plugin event\n * @param core The EditorCore object\n * @param pluginEvent The event object to trigger\n * @param broadcast Set to true to skip the shouldHandleEventExclusively check\n */\nexport type TriggerEvent = (core: EditorCore, pluginEvent: PluginEvent, broadcast: boolean) => void;\n\n/**\n * Add an undo snapshot to current undo snapshot stack\n * @param core The EditorCore object\n * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).\n * @param entityStates @optional Entity states related to this snapshot.\n * Each entity state will cause an EntityOperation event with operation = EntityOperation.UpdateEntityState\n * when undo/redo to this snapshot\n */\nexport type AddUndoSnapshot = (\n core: EditorCore,\n canUndoByBackspace: boolean,\n entityStates?: EntityState[]\n) => Snapshot | null;\n\n/**\n * Retrieves the rect of the visible viewport of the editor.\n * @param core The EditorCore object\n */\nexport type GetVisibleViewport = (core: EditorCore) => Rect | null;\n\n/**\n * Focus to editor. If there is a cached selection range, use it as current selection\n * @param core The EditorCore object\n */\nexport type Focus = (core: EditorCore) => void;\n\n/**\n * Attach a DOM event to the editor content DIV\n * @param core The EditorCore object\n * @param eventMap A map from event name to its handler\n */\nexport type AttachDomEvent = (\n core: EditorCore,\n eventMap: Record<string, DOMEventRecord>\n) => () => void;\n\n/**\n * Restore an undo snapshot into editor\n * @param core The EditorCore object\n * @param step Steps to move, can be 0, positive or negative\n */\nexport type RestoreUndoSnapshot = (core: EditorCore, snapshot: Snapshot) => void;\n\n/**\n * Add CSS rules for editor\n * @param core The EditorCore object\n * @param key A string to identify the CSS rule type. When set CSS rules with the same key again, existing rules with the same key will be replaced.\n * @param cssRule The CSS rule string, must be a valid CSS rule string, or browser may throw exception. Pass null to remove existing rules\n * @param subSelectors @optional If the rule is used for child element under editor, use this parameter to specify the child elements. Each item will be\n * combined with root selector together to build a separate rule. It also accepts pseudo classes \"before\" and \"after\" to create pseudo class rule \"::before\"\n * and \"::after\" to the editor root element itself\n * @param maxRuleLength @optional Set maximum length for a single rule. This is used by test code only\n */\nexport type SetEditorStyle = (\n core: EditorCore,\n key: string,\n cssRule: string | null,\n subSelectors?: 'before' | 'after' | string[],\n maxRuleLength?: number\n) => void;\n\n/**\n * Announce the given data\n * @param core The EditorCore object\n * @param announceData Data to announce\n */\nexport type Announce = (core: EditorCore, announceData: AnnounceData) => void;\n\n/**\n * The interface for the map of core API for Editor.\n * Editor can call call API from this map under EditorCore object\n */\nexport interface CoreApiMap {\n /**\n * Create Content Model from DOM tree in this editor\n * @param core The EditorCore object\n * @param option The option to customize the behavior of DOM to Content Model conversion\n * @param selectionOverride When passed a valid selection, use this selection range instead of current selection in editor.\n * When pass \"none\", it means we don't need a selection in content model\n */\n createEditorContext: CreateEditorContext;\n\n /**\n * Create Content Model from DOM tree in this editor\n * @param core The EditorCore object\n * @param option The option to customize the behavior of DOM to Content Model conversion\n */\n createContentModel: CreateContentModel;\n\n /**\n * Get current DOM selection from editor\n * @param core The EditorCore object\n */\n getDOMSelection: GetDOMSelection;\n\n /**\n * Set content with content model\n * @param core The EditorCore object\n * @param model The content model to set\n * @param option Additional options to customize the behavior of Content Model to DOM conversion\n */\n setContentModel: SetContentModel;\n\n /**\n * Set current DOM selection from editor. This is the replacement of core API select\n * @param core The EditorCore object\n * @param selection The selection to set\n * @param skipSelectionChangedEvent @param Pass true to skip triggering a SelectionChangedEvent\n */\n setDOMSelection: SetDOMSelection;\n\n /**\n * Set a new logical root (most likely due to focus change)\n * @param core The StandaloneEditorCore object\n * @param logicalRoot The new logical root (has to be child of physicalRoot)\n */\n setLogicalRoot: SetLogicalRoot;\n\n /**\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param core The EditorCore object\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatContentModelOptions\n */\n formatContentModel: FormatContentModel;\n\n /**\n * Switch the Shadow Edit mode of editor On/Off\n * @param core The EditorCore object\n * @param isOn True to switch On, False to switch Off\n */\n switchShadowEdit: SwitchShadowEdit;\n\n /**\n * Retrieves the rect of the visible viewport of the editor.\n * @param core The EditorCore object\n */\n getVisibleViewport: GetVisibleViewport;\n\n /**\n * Focus to editor. If there is a cached selection range, use it as current selection\n * @param core The EditorCore object\n */\n focus: Focus;\n\n /**\n * Add an undo snapshot to current undo snapshot stack\n * @param core The EditorCore object\n * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).\n * @param entityStates @optional Entity states related to this snapshot.\n * Each entity state will cause an EntityOperation event with operation = EntityOperation.UpdateEntityState\n * when undo/redo to this snapshot\n */\n addUndoSnapshot: AddUndoSnapshot;\n\n /**\n * Restore an undo snapshot into editor\n * @param core The editor core object\n * @param step Steps to move, can be 0, positive or negative\n */\n restoreUndoSnapshot: RestoreUndoSnapshot;\n\n /**\n * Attach a DOM event to the editor content DIV\n * @param core The EditorCore object\n * @param eventMap A map from event name to its handler\n */\n attachDomEvent: AttachDomEvent;\n\n /**\n * Trigger a plugin event\n * @param core The EditorCore object\n * @param pluginEvent The event object to trigger\n * @param broadcast Set to true to skip the shouldHandleEventExclusively check\n */\n triggerEvent: TriggerEvent;\n\n /**\n * Add CSS rules for editor\n * @param core The EditorCore object\n * @param key A string to identify the CSS rule type. When set CSS rules with the same key again, existing rules with the same key will be replaced.\n * @param cssRule The CSS rule string, must be a valid CSS rule string, or browser may throw exception\n * @param subSelectors @optional If the rule is used for child element under editor, use this parameter to specify the child elements. Each item will be\n * combined with root selector together to build a separate rule.\n */\n setEditorStyle: SetEditorStyle;\n\n /**\n * Announce the given data\n * @param core The EditorCore object\n * @param announceData Data to announce\n */\n announce: Announce;\n}\n\n/**\n * Represents the core data structure of an editor\n */\nexport interface EditorCore extends PluginState {\n /**\n * The root DIV element of this editor (formerly contentDiv)\n */\n readonly physicalRoot: HTMLDivElement;\n\n /**\n * The content DIV element that operations should be applied to\n * By default, the logical root is the same as the physical root,\n * but if nested editors are used, the logical root changes to that of the inner editor\n */\n logicalRoot: HTMLDivElement;\n\n /**\n * Core API map of this editor\n */\n readonly api: CoreApiMap;\n\n /**\n * Original API map of this editor. Overridden core API can use API from this map to call the original version of core API.\n */\n readonly originalApi: CoreApiMap;\n\n /**\n * An array of editor plugins.\n */\n readonly plugins: EditorPlugin[];\n\n /**\n * Editor running environment\n */\n readonly environment: EditorEnvironment;\n\n /**\n * Dark model handler for the editor, used for variable-based solution.\n * If keep it null, editor will still use original dataset-based dark mode solution.\n */\n readonly darkColorHandler: DarkColorHandler;\n\n /**\n * A handler to convert HTML string to a trust HTML string.\n * By default it will just return the original HTML string directly.\n * To override, pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler\n */\n readonly trustedHTMLHandler: TrustedHTMLHandler;\n\n /**\n * A helper class to provide DOM access APIs\n */\n readonly domHelper: DOMHelper;\n\n /**\n * A callback to be invoked when any exception is thrown during disposing editor\n * @param plugin The plugin that causes exception\n * @param error The error object we got\n */\n readonly disposeErrorHandler?: (plugin: EditorPlugin, error: Error) => void;\n}\n"]}
1
+ {"version":3,"file":"EditorCore.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/editor/EditorCore.ts"],"names":[],"mappings":"","sourcesContent":["import type { AnnounceData } from '../parameter/AnnounceData';\nimport type { DOMHelper } from '../parameter/DOMHelper';\nimport type { PluginEvent } from '../event/PluginEvent';\nimport type { PluginState } from '../pluginState/PluginState';\nimport type { EditorPlugin } from './EditorPlugin';\nimport type { DOMEventRecord } from '../parameter/DOMEventRecord';\nimport type { Snapshot } from '../parameter/Snapshot';\nimport type { EntityState } from '../parameter/FormatContentModelContext';\nimport type { DarkColorHandler } from '../context/DarkColorHandler';\nimport type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';\nimport type { DOMSelection } from '../selection/DOMSelection';\nimport type { DomToModelOptionForCreateModel } from '../context/DomToModelOption';\nimport type { EditorContext } from '../context/EditorContext';\nimport type { EditorEnvironment } from '../parameter/EditorEnvironment';\nimport type { ModelToDomOption } from '../context/ModelToDomOption';\nimport type { OnNodeCreated } from '../context/ModelToDomSettings';\nimport type { TrustedHTMLHandler } from '../parameter/TrustedHTMLHandler';\nimport type { Rect } from '../parameter/Rect';\nimport type {\n ContentModelFormatter,\n FormatContentModelOptions,\n} from '../parameter/FormatContentModelOptions';\n\n/**\n * Create a EditorContext object used by ContentModel API\n * @param core The EditorCore object\n * @param saveIndex True to allow saving index info into node using domIndexer, otherwise false\n */\nexport type CreateEditorContext = (core: EditorCore, saveIndex: boolean) => EditorContext;\n\n/**\n * Create Content Model from DOM tree in this editor\n * @param core The EditorCore object\n * @param option The option to customize the behavior of DOM to Content Model conversion\n * @param selectionOverride When passed a valid selection, use this selection range instead of current selection in editor.\n * When pass \"none\", it means we don't need a selection in content model\n */\nexport type CreateContentModel = (\n core: EditorCore,\n option?: DomToModelOptionForCreateModel,\n selectionOverride?: DOMSelection | 'none'\n) => ContentModelDocument;\n\n/**\n * Get current DOM selection from editor\n * @param core The EditorCore object\n */\nexport type GetDOMSelection = (core: EditorCore) => DOMSelection | null;\n\n/**\n * Set content with content model. This is the replacement of core API getSelectionRangeEx\n * @param core The EditorCore object\n * @param model The content model to set\n * @param option Additional options to customize the behavior of Content Model to DOM conversion\n * @param onNodeCreated An optional callback that will be called when a DOM node is created\n */\nexport type SetContentModel = (\n core: EditorCore,\n model: ContentModelDocument,\n option?: ModelToDomOption,\n onNodeCreated?: OnNodeCreated\n) => DOMSelection | null;\n\n/**\n * Set current DOM selection from editor. This is the replacement of core API select\n * @param core The EditorCore object\n * @param selection The selection to set\n * @param skipSelectionChangedEvent @param Pass true to skip triggering a SelectionChangedEvent\n */\nexport type SetDOMSelection = (\n core: EditorCore,\n selection: DOMSelection | null,\n skipSelectionChangedEvent?: boolean\n) => void;\n\n/**\n * Set a new logical root (most likely due to focus change)\n * @param core The EditorCore object\n * @param logicalRoot The new logical root (has to be child of physicalRoot or null to use physicalRoot as logical root)\n */\nexport type SetLogicalRoot = (core: EditorCore, logicalRoot: HTMLDivElement | null) => void;\n\n/**\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param core The EditorCore object\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatContentModelOptions\n */\nexport type FormatContentModel = (\n core: EditorCore,\n formatter: ContentModelFormatter,\n options?: FormatContentModelOptions,\n domToModelOptions?: DomToModelOptionForCreateModel\n) => void;\n\n/**\n * Switch the Shadow Edit mode of editor On/Off\n * @param core The EditorCore object\n * @param isOn True to switch On, False to switch Off\n */\nexport type SwitchShadowEdit = (core: EditorCore, isOn: boolean) => void;\n\n/**\n * Trigger a plugin event\n * @param core The EditorCore object\n * @param pluginEvent The event object to trigger\n * @param broadcast Set to true to skip the shouldHandleEventExclusively check\n */\nexport type TriggerEvent = (core: EditorCore, pluginEvent: PluginEvent, broadcast: boolean) => void;\n\n/**\n * Add an undo snapshot to current undo snapshot stack\n * @param core The EditorCore object\n * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).\n * @param entityStates @optional Entity states related to this snapshot.\n * Each entity state will cause an EntityOperation event with operation = EntityOperation.UpdateEntityState\n * when undo/redo to this snapshot\n */\nexport type AddUndoSnapshot = (\n core: EditorCore,\n canUndoByBackspace: boolean,\n entityStates?: EntityState[]\n) => Snapshot | null;\n\n/**\n * Retrieves the rect of the visible viewport of the editor.\n * @param core The EditorCore object\n */\nexport type GetVisibleViewport = (core: EditorCore) => Rect | null;\n\n/**\n * Focus to editor. If there is a cached selection range, use it as current selection\n * @param core The EditorCore object\n */\nexport type Focus = (core: EditorCore) => void;\n\n/**\n * Attach a DOM event to the editor content DIV\n * @param core The EditorCore object\n * @param eventMap A map from event name to its handler\n */\nexport type AttachDomEvent = (\n core: EditorCore,\n eventMap: Record<string, DOMEventRecord>\n) => () => void;\n\n/**\n * Restore an undo snapshot into editor\n * @param core The EditorCore object\n * @param step Steps to move, can be 0, positive or negative\n */\nexport type RestoreUndoSnapshot = (core: EditorCore, snapshot: Snapshot) => void;\n\n/**\n * Add CSS rules for editor\n * @param core The EditorCore object\n * @param key A string to identify the CSS rule type. When set CSS rules with the same key again, existing rules with the same key will be replaced.\n * @param cssRule The CSS rule string, must be a valid CSS rule string, or browser may throw exception. Pass null to remove existing rules\n * @param subSelectors @optional If the rule is used for child element under editor, use this parameter to specify the child elements. Each item will be\n * combined with root selector together to build a separate rule. It also accepts pseudo classes \"before\" and \"after\" to create pseudo class rule \"::before\"\n * and \"::after\" to the editor root element itself\n * @param maxRuleLength @optional Set maximum length for a single rule. This is used by test code only\n */\nexport type SetEditorStyle = (\n core: EditorCore,\n key: string,\n cssRule: string | null,\n subSelectors?: 'before' | 'after' | string[],\n maxRuleLength?: number\n) => void;\n\n/**\n * Announce the given data\n * @param core The EditorCore object\n * @param announceData Data to announce\n */\nexport type Announce = (core: EditorCore, announceData: AnnounceData) => void;\n\n/**\n * The interface for the map of core API for Editor.\n * Editor can call call API from this map under EditorCore object\n */\nexport interface CoreApiMap {\n /**\n * Create Content Model from DOM tree in this editor\n * @param core The EditorCore object\n * @param option The option to customize the behavior of DOM to Content Model conversion\n * @param selectionOverride When passed a valid selection, use this selection range instead of current selection in editor.\n * When pass \"none\", it means we don't need a selection in content model\n */\n createEditorContext: CreateEditorContext;\n\n /**\n * Create Content Model from DOM tree in this editor\n * @param core The EditorCore object\n * @param option The option to customize the behavior of DOM to Content Model conversion\n */\n createContentModel: CreateContentModel;\n\n /**\n * Get current DOM selection from editor\n * @param core The EditorCore object\n */\n getDOMSelection: GetDOMSelection;\n\n /**\n * Set content with content model\n * @param core The EditorCore object\n * @param model The content model to set\n * @param option Additional options to customize the behavior of Content Model to DOM conversion\n */\n setContentModel: SetContentModel;\n\n /**\n * Set current DOM selection from editor. This is the replacement of core API select\n * @param core The EditorCore object\n * @param selection The selection to set\n * @param skipSelectionChangedEvent @param Pass true to skip triggering a SelectionChangedEvent\n */\n setDOMSelection: SetDOMSelection;\n\n /**\n * Set a new logical root (most likely due to focus change)\n * @param core The StandaloneEditorCore object\n * @param logicalRoot The new logical root (has to be child of physicalRoot)\n */\n setLogicalRoot: SetLogicalRoot;\n\n /**\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param core The EditorCore object\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatContentModelOptions\n */\n formatContentModel: FormatContentModel;\n\n /**\n * Switch the Shadow Edit mode of editor On/Off\n * @param core The EditorCore object\n * @param isOn True to switch On, False to switch Off\n */\n switchShadowEdit: SwitchShadowEdit;\n\n /**\n * Retrieves the rect of the visible viewport of the editor.\n * @param core The EditorCore object\n */\n getVisibleViewport: GetVisibleViewport;\n\n /**\n * Focus to editor. If there is a cached selection range, use it as current selection\n * @param core The EditorCore object\n */\n focus: Focus;\n\n /**\n * Add an undo snapshot to current undo snapshot stack\n * @param core The EditorCore object\n * @param canUndoByBackspace True if this action can be undone when user press Backspace key (aka Auto Complete).\n * @param entityStates @optional Entity states related to this snapshot.\n * Each entity state will cause an EntityOperation event with operation = EntityOperation.UpdateEntityState\n * when undo/redo to this snapshot\n */\n addUndoSnapshot: AddUndoSnapshot;\n\n /**\n * Restore an undo snapshot into editor\n * @param core The editor core object\n * @param step Steps to move, can be 0, positive or negative\n */\n restoreUndoSnapshot: RestoreUndoSnapshot;\n\n /**\n * Attach a DOM event to the editor content DIV\n * @param core The EditorCore object\n * @param eventMap A map from event name to its handler\n */\n attachDomEvent: AttachDomEvent;\n\n /**\n * Trigger a plugin event\n * @param core The EditorCore object\n * @param pluginEvent The event object to trigger\n * @param broadcast Set to true to skip the shouldHandleEventExclusively check\n */\n triggerEvent: TriggerEvent;\n\n /**\n * Add CSS rules for editor\n * @param core The EditorCore object\n * @param key A string to identify the CSS rule type. When set CSS rules with the same key again, existing rules with the same key will be replaced.\n * @param cssRule The CSS rule string, must be a valid CSS rule string, or browser may throw exception\n * @param subSelectors @optional If the rule is used for child element under editor, use this parameter to specify the child elements. Each item will be\n * combined with root selector together to build a separate rule.\n */\n setEditorStyle: SetEditorStyle;\n\n /**\n * Announce the given data\n * @param core The EditorCore object\n * @param announceData Data to announce\n */\n announce: Announce;\n}\n\n/**\n * Represents the core data structure of an editor\n */\nexport interface EditorCore extends PluginState {\n /**\n * The root DIV element of this editor (formerly contentDiv)\n */\n readonly physicalRoot: HTMLDivElement;\n\n /**\n * The content DIV element that operations should be applied to\n * By default, the logical root is the same as the physical root,\n * but if nested editors are used, the logical root changes to that of the inner editor\n */\n logicalRoot: HTMLDivElement;\n\n /**\n * Core API map of this editor\n */\n readonly api: CoreApiMap;\n\n /**\n * Original API map of this editor. Overridden core API can use API from this map to call the original version of core API.\n */\n readonly originalApi: CoreApiMap;\n\n /**\n * An array of editor plugins.\n */\n readonly plugins: EditorPlugin[];\n\n /**\n * Editor running environment\n */\n readonly environment: EditorEnvironment;\n\n /**\n * Dark model handler for the editor, used for variable-based solution.\n * If keep it null, editor will still use original dataset-based dark mode solution.\n */\n readonly darkColorHandler: DarkColorHandler;\n\n /**\n * A handler to convert HTML string to a trust HTML string.\n * By default it will just return the original HTML string directly.\n * To override, pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler\n */\n readonly trustedHTMLHandler: TrustedHTMLHandler;\n\n /**\n * A helper class to provide DOM access APIs\n */\n readonly domHelper: DOMHelper;\n\n /**\n * A callback to be invoked when any exception is thrown during disposing editor\n * @param plugin The plugin that causes exception\n * @param error The error object we got\n */\n readonly disposeErrorHandler?: (plugin: EditorPlugin, error: Error) => void;\n\n /**\n * Enabled experimental features\n */\n readonly experimentalFeatures: ReadonlyArray<string>;\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { ExperimentalFeature } from './ExperimentalFeature';
1
2
  import type { KnownAnnounceStrings } from '../parameter/AnnounceData';
2
3
  import type { PasteType } from '../enum/PasteType';
3
4
  import type { Colors, ColorTransformFunction } from '../context/DarkColorHandler';
@@ -10,9 +11,40 @@ import type { ContentModelDocument } from '../contentModel/blockGroup/ContentMod
10
11
  import type { Snapshots } from '../parameter/Snapshot';
11
12
  import type { TrustedHTMLHandler } from '../parameter/TrustedHTMLHandler';
12
13
  /**
13
- * Options for editor
14
+ * Options for colors and dark mode
15
+ */
16
+ export interface ColorOptions {
17
+ /**
18
+ * A util function to transform light mode color to dark mode color
19
+ * Default value is to return the original light color
20
+ */
21
+ getDarkColor?: ColorTransformFunction;
22
+ /**
23
+ * A util function to generate color key for dark mode color.
24
+ * By default, the color key is generated from the light mode color. For example,
25
+ * color "#123456" will have the key "--darkColor__123456", and
26
+ * color "rgb(0,0,0)" will have key "--darkColor_rgb_0_0_0_".
27
+ * Pass in this function to customize this behavior.
28
+ * The return value must be a valid CSS variable, starts with "--"
29
+ */
30
+ generateColorKey?: ColorTransformFunction;
31
+ /**
32
+ * Existing known color pairs
33
+ */
34
+ knownColors?: Record<string, Colors>;
35
+ /**
36
+ * Whether to skip the adjust editor process when for light/dark mode
37
+ */
38
+ doNotAdjustEditorColor?: boolean;
39
+ /**
40
+ * If the editor is currently in dark mode
41
+ */
42
+ inDarkMode?: boolean;
43
+ }
44
+ /**
45
+ * Options for Content Model
14
46
  */
15
- export interface EditorOptions {
47
+ export interface ContentModelOptions {
16
48
  /**
17
49
  * Default options used for DOM to Content Model conversion
18
50
  */
@@ -22,43 +54,63 @@ export interface EditorOptions {
22
54
  */
23
55
  defaultModelToDomOptions?: ModelToDomOption;
24
56
  /**
25
- * Whether content model should be cached in order to improve editing performance.
26
- * Pass true to disable the cache.
27
- * @default false
57
+ * Default format of editor content. This will be applied to empty content.
58
+ * If there is already content inside editor, format of existing content will not be changed.
59
+ * Default value is the computed style of editor content DIV
60
+ */
61
+ defaultSegmentFormat?: ContentModelSegmentFormat;
62
+ /**
63
+ * @deprecated
28
64
  */
29
65
  disableCache?: boolean;
66
+ }
67
+ /**
68
+ * Options for selection
69
+ */
70
+ export interface SelectionOptions {
30
71
  /**
31
- * List of plugins.
32
- * The order of plugins here determines in what order each event will be dispatched.
33
- * Plugins not appear in this list will not be added to editor, including built-in plugins.
34
- * Default value is empty array.
72
+ * Color of the border of a selectedImage. Default color: '#DB626C'
35
73
  */
36
- plugins?: EditorPlugin[];
74
+ imageSelectionBorderColor?: string;
37
75
  /**
38
- * Default format of editor content. This will be applied to empty content.
39
- * If there is already content inside editor, format of existing content will not be changed.
40
- * Default value is the computed style of editor content DIV
76
+ * Background color of a selected table cell. Default color: '#C6C6C6'
41
77
  */
42
- defaultSegmentFormat?: ContentModelSegmentFormat;
78
+ tableCellSelectionBackgroundColor?: string;
79
+ }
80
+ /**
81
+ * Options for paste
82
+ */
83
+ export interface PasteOptions {
43
84
  /**
44
85
  * Allowed custom content type when paste besides text/plain, text/html and images
45
86
  * Only text types are supported, and do not add "text/" prefix to the type values
46
87
  */
47
88
  allowedCustomPasteType?: string[];
48
89
  /**
49
- * The scroll container to get scroll event from.
50
- * By default, the scroll container will be the same with editor content DIV
90
+ * Default paste type. By default will use the normal (as-is) paste type.
51
91
  */
52
- scrollContainer?: HTMLElement;
92
+ defaultPasteType?: PasteType;
93
+ }
94
+ /**
95
+ * Options for editor fundamental data structure
96
+ */
97
+ export interface EditorBaseOptions {
53
98
  /**
54
- * A util function to transform light mode color to dark mode color
55
- * Default value is to return the original light color
99
+ * Enabled experimental features
56
100
  */
57
- getDarkColor?: ColorTransformFunction;
101
+ experimentalFeatures?: (ExperimentalFeature | string)[];
58
102
  /**
59
- * Existing known color pairs
103
+ * List of plugins.
104
+ * The order of plugins here determines in what order each event will be dispatched.
105
+ * Plugins not appear in this list will not be added to editor, including built-in plugins.
106
+ * Default value is empty array.
60
107
  */
61
- knownColors?: Record<string, Colors>;
108
+ plugins?: EditorPlugin[];
109
+ /**
110
+ * The scroll container to get scroll event from.
111
+ * By default, the scroll container will be the same with editor content DIV
112
+ */
113
+ scrollContainer?: HTMLElement;
62
114
  /**
63
115
  * Customized trusted type handler used for sanitizing HTML string before assign to DOM tree
64
116
  * This is required when trusted-type Content-Security-Policy (CSP) is enabled.
@@ -70,26 +122,10 @@ export interface EditorOptions {
70
122
  * Default value is null
71
123
  */
72
124
  coreApiOverride?: Partial<CoreApiMap>;
73
- /**
74
- * Color of the border of a selectedImage. Default color: '#DB626C'
75
- */
76
- imageSelectionBorderColor?: string;
77
- /**
78
- * Background color of a selected table cell. Default color: '#C6C6C6'
79
- */
80
- tableCellSelectionBackgroundColor?: string;
81
125
  /**
82
126
  * Initial Content Model
83
127
  */
84
128
  initialModel?: ContentModelDocument;
85
- /**
86
- * Whether to skip the adjust editor process when for light/dark mode
87
- */
88
- doNotAdjustEditorColor?: boolean;
89
- /**
90
- * If the editor is currently in dark mode
91
- */
92
- inDarkMode?: boolean;
93
129
  /**
94
130
  * Undo snapshot. Use this parameter to provide an external storage of undo snapshots
95
131
  */
@@ -100,10 +136,6 @@ export interface EditorOptions {
100
136
  * @param error The error object we got
101
137
  */
102
138
  disposeErrorHandler?: (plugin: EditorPlugin, error: Error) => void;
103
- /**
104
- * Default paste type. By default will use the normal (as-is) paste type.
105
- */
106
- defaultPasteType?: PasteType;
107
139
  /**
108
140
  * A callback to help get string template to announce, used for accessibility
109
141
  * @param key The key of known announce data
@@ -111,3 +143,8 @@ export interface EditorOptions {
111
143
  */
112
144
  announcerStringGetter?: (key: KnownAnnounceStrings) => string;
113
145
  }
146
+ /**
147
+ * Options for editor
148
+ */
149
+ export interface EditorOptions extends EditorBaseOptions, ColorOptions, ContentModelOptions, SelectionOptions, PasteOptions {
150
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"EditorOptions.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/editor/EditorOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { KnownAnnounceStrings } from '../parameter/AnnounceData';\nimport type { PasteType } from '../enum/PasteType';\nimport type { Colors, ColorTransformFunction } from '../context/DarkColorHandler';\nimport type { EditorPlugin } from './EditorPlugin';\nimport type { ContentModelSegmentFormat } from '../contentModel/format/ContentModelSegmentFormat';\nimport type { CoreApiMap } from './EditorCore';\nimport type { DomToModelOption } from '../context/DomToModelOption';\nimport type { ModelToDomOption } from '../context/ModelToDomOption';\nimport type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';\nimport type { Snapshots } from '../parameter/Snapshot';\nimport type { TrustedHTMLHandler } from '../parameter/TrustedHTMLHandler';\n\n/**\n * Options for editor\n */\nexport interface EditorOptions {\n /**\n * Default options used for DOM to Content Model conversion\n */\n defaultDomToModelOptions?: DomToModelOption;\n\n /**\n * Default options used for Content Model to DOM conversion\n */\n defaultModelToDomOptions?: ModelToDomOption;\n\n /**\n * Whether content model should be cached in order to improve editing performance.\n * Pass true to disable the cache.\n * @default false\n */\n disableCache?: boolean;\n\n /**\n * List of plugins.\n * The order of plugins here determines in what order each event will be dispatched.\n * Plugins not appear in this list will not be added to editor, including built-in plugins.\n * Default value is empty array.\n */\n plugins?: EditorPlugin[];\n\n /**\n * Default format of editor content. This will be applied to empty content.\n * If there is already content inside editor, format of existing content will not be changed.\n * Default value is the computed style of editor content DIV\n */\n defaultSegmentFormat?: ContentModelSegmentFormat;\n\n /**\n * Allowed custom content type when paste besides text/plain, text/html and images\n * Only text types are supported, and do not add \"text/\" prefix to the type values\n */\n allowedCustomPasteType?: string[];\n\n /**\n * The scroll container to get scroll event from.\n * By default, the scroll container will be the same with editor content DIV\n */\n scrollContainer?: HTMLElement;\n\n /**\n * A util function to transform light mode color to dark mode color\n * Default value is to return the original light color\n */\n getDarkColor?: ColorTransformFunction;\n\n /**\n * Existing known color pairs\n */\n knownColors?: Record<string, Colors>;\n\n /**\n * Customized trusted type handler used for sanitizing HTML string before assign to DOM tree\n * This is required when trusted-type Content-Security-Policy (CSP) is enabled.\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types\n */\n trustedHTMLHandler?: TrustedHTMLHandler;\n\n /**\n * A function map to override default core API implementation\n * Default value is null\n */\n coreApiOverride?: Partial<CoreApiMap>;\n\n /**\n * Color of the border of a selectedImage. Default color: '#DB626C'\n */\n imageSelectionBorderColor?: string;\n\n /**\n * Background color of a selected table cell. Default color: '#C6C6C6'\n */\n tableCellSelectionBackgroundColor?: string;\n\n /**\n * Initial Content Model\n */\n initialModel?: ContentModelDocument;\n\n /**\n * Whether to skip the adjust editor process when for light/dark mode\n */\n doNotAdjustEditorColor?: boolean;\n\n /**\n * If the editor is currently in dark mode\n */\n inDarkMode?: boolean;\n\n /**\n * Undo snapshot. Use this parameter to provide an external storage of undo snapshots\n */\n snapshots?: Snapshots;\n\n /**\n * A callback to be invoked when any exception is thrown during disposing editor\n * @param plugin The plugin that causes exception\n * @param error The error object we got\n */\n disposeErrorHandler?: (plugin: EditorPlugin, error: Error) => void;\n\n /**\n * Default paste type. By default will use the normal (as-is) paste type.\n */\n defaultPasteType?: PasteType;\n\n /**\n * A callback to help get string template to announce, used for accessibility\n * @param key The key of known announce data\n * @returns A template string to announce, use placeholder such as \"{0}\" for variables if necessary\n */\n announcerStringGetter?: (key: KnownAnnounceStrings) => string;\n}\n"]}
1
+ {"version":3,"file":"EditorOptions.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/editor/EditorOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExperimentalFeature } from './ExperimentalFeature';\nimport type { KnownAnnounceStrings } from '../parameter/AnnounceData';\nimport type { PasteType } from '../enum/PasteType';\nimport type { Colors, ColorTransformFunction } from '../context/DarkColorHandler';\nimport type { EditorPlugin } from './EditorPlugin';\nimport type { ContentModelSegmentFormat } from '../contentModel/format/ContentModelSegmentFormat';\nimport type { CoreApiMap } from './EditorCore';\nimport type { DomToModelOption } from '../context/DomToModelOption';\nimport type { ModelToDomOption } from '../context/ModelToDomOption';\nimport type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';\nimport type { Snapshots } from '../parameter/Snapshot';\nimport type { TrustedHTMLHandler } from '../parameter/TrustedHTMLHandler';\n\n/**\n * Options for colors and dark mode\n */\nexport interface ColorOptions {\n /**\n * A util function to transform light mode color to dark mode color\n * Default value is to return the original light color\n */\n getDarkColor?: ColorTransformFunction;\n\n /**\n * A util function to generate color key for dark mode color.\n * By default, the color key is generated from the light mode color. For example,\n * color \"#123456\" will have the key \"--darkColor__123456\", and\n * color \"rgb(0,0,0)\" will have key \"--darkColor_rgb_0_0_0_\".\n * Pass in this function to customize this behavior.\n * The return value must be a valid CSS variable, starts with \"--\"\n */\n generateColorKey?: ColorTransformFunction;\n\n /**\n * Existing known color pairs\n */\n knownColors?: Record<string, Colors>;\n\n /**\n * Whether to skip the adjust editor process when for light/dark mode\n */\n doNotAdjustEditorColor?: boolean;\n\n /**\n * If the editor is currently in dark mode\n */\n inDarkMode?: boolean;\n}\n\n/**\n * Options for Content Model\n */\nexport interface ContentModelOptions {\n /**\n * Default options used for DOM to Content Model conversion\n */\n defaultDomToModelOptions?: DomToModelOption;\n\n /**\n * Default options used for Content Model to DOM conversion\n */\n defaultModelToDomOptions?: ModelToDomOption;\n\n /**\n * Default format of editor content. This will be applied to empty content.\n * If there is already content inside editor, format of existing content will not be changed.\n * Default value is the computed style of editor content DIV\n */\n defaultSegmentFormat?: ContentModelSegmentFormat;\n\n /**\n * @deprecated\n */\n disableCache?: boolean;\n}\n\n/**\n * Options for selection\n */\nexport interface SelectionOptions {\n /**\n * Color of the border of a selectedImage. Default color: '#DB626C'\n */\n imageSelectionBorderColor?: string;\n\n /**\n * Background color of a selected table cell. Default color: '#C6C6C6'\n */\n tableCellSelectionBackgroundColor?: string;\n}\n\n/**\n * Options for paste\n */\nexport interface PasteOptions {\n /**\n * Allowed custom content type when paste besides text/plain, text/html and images\n * Only text types are supported, and do not add \"text/\" prefix to the type values\n */\n allowedCustomPasteType?: string[];\n\n /**\n * Default paste type. By default will use the normal (as-is) paste type.\n */\n defaultPasteType?: PasteType;\n}\n\n/**\n * Options for editor fundamental data structure\n */\nexport interface EditorBaseOptions {\n /**\n * Enabled experimental features\n */\n experimentalFeatures?: (ExperimentalFeature | string)[];\n\n /**\n * List of plugins.\n * The order of plugins here determines in what order each event will be dispatched.\n * Plugins not appear in this list will not be added to editor, including built-in plugins.\n * Default value is empty array.\n */\n plugins?: EditorPlugin[];\n\n /**\n * The scroll container to get scroll event from.\n * By default, the scroll container will be the same with editor content DIV\n */\n scrollContainer?: HTMLElement;\n\n /**\n * Customized trusted type handler used for sanitizing HTML string before assign to DOM tree\n * This is required when trusted-type Content-Security-Policy (CSP) is enabled.\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types\n */\n trustedHTMLHandler?: TrustedHTMLHandler;\n\n /**\n * A function map to override default core API implementation\n * Default value is null\n */\n coreApiOverride?: Partial<CoreApiMap>;\n\n /**\n * Initial Content Model\n */\n initialModel?: ContentModelDocument;\n\n /**\n * Undo snapshot. Use this parameter to provide an external storage of undo snapshots\n */\n snapshots?: Snapshots;\n\n /**\n * A callback to be invoked when any exception is thrown during disposing editor\n * @param plugin The plugin that causes exception\n * @param error The error object we got\n */\n disposeErrorHandler?: (plugin: EditorPlugin, error: Error) => void;\n\n /**\n * A callback to help get string template to announce, used for accessibility\n * @param key The key of known announce data\n * @returns A template string to announce, use placeholder such as \"{0}\" for variables if necessary\n */\n announcerStringGetter?: (key: KnownAnnounceStrings) => string;\n}\n\n/**\n * Options for editor\n */\nexport interface EditorOptions\n extends EditorBaseOptions,\n ColorOptions,\n ContentModelOptions,\n SelectionOptions,\n PasteOptions {}\n"]}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Predefined experiment features
3
+ * By default these features are not enabled. To enable them, pass the feature name into EditorOptions.experimentalFeatures
4
+ * when create editor
5
+ */
6
+ export declare type ExperimentalFeature =
7
+ /**
8
+ * When this feature is enabled, we will persist a content model in memory as long as we can,
9
+ * and use cached element when write back if it is not changed.
10
+ */
11
+ 'PersistCache';
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ExperimentalFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExperimentalFeature.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/editor/ExperimentalFeature.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Predefined experiment features\n * By default these features are not enabled. To enable them, pass the feature name into EditorOptions.experimentalFeatures\n * when create editor\n */\nexport type ExperimentalFeature =\n /**\n * When this feature is enabled, we will persist a content model in memory as long as we can,\n * and use cached element when write back if it is not changed.\n */\n 'PersistCache';\n"]}
@@ -15,6 +15,7 @@ import type { DarkColorHandler } from '../context/DarkColorHandler';
15
15
  import type { TrustedHTMLHandler } from '../parameter/TrustedHTMLHandler';
16
16
  import type { Rect } from '../parameter/Rect';
17
17
  import type { EntityState } from '../parameter/FormatContentModelContext';
18
+ import type { ExperimentalFeature } from './ExperimentalFeature';
18
19
  /**
19
20
  * An interface of Editor, built on top of Content Model
20
21
  */
@@ -182,4 +183,9 @@ export interface IEditor {
182
183
  * @param announceData Data to announce
183
184
  */
184
185
  announce(announceData: AnnounceData): void;
186
+ /**
187
+ * Check if a given feature is enabled
188
+ * @param featureName The name of feature to check
189
+ */
190
+ isExperimentalFeatureEnabled(featureName: ExperimentalFeature | string): boolean;
185
191
  }
@@ -1 +1 @@
1
- {"version":3,"file":"IEditor.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/editor/IEditor.ts"],"names":[],"mappings":"","sourcesContent":["import type { AnnounceData } from '../parameter/AnnounceData';\nimport type { DomToModelOptionForCreateModel } from '../context/DomToModelOption';\nimport type { DOMHelper } from '../parameter/DOMHelper';\nimport type { PluginEventData, PluginEventFromType } from '../event/PluginEventData';\nimport type { PluginEventType } from '../event/PluginEventType';\nimport type { DOMEventRecord } from '../parameter/DOMEventRecord';\nimport type { SnapshotsManager } from '../parameter/SnapshotsManager';\nimport type { Snapshot } from '../parameter/Snapshot';\nimport type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';\nimport type { ContentModelSegmentFormat } from '../contentModel/format/ContentModelSegmentFormat';\nimport type { DOMSelection } from '../selection/DOMSelection';\nimport type { EditorEnvironment } from '../parameter/EditorEnvironment';\nimport type {\n ContentModelFormatter,\n FormatContentModelOptions,\n} from '../parameter/FormatContentModelOptions';\nimport type { DarkColorHandler } from '../context/DarkColorHandler';\nimport type { TrustedHTMLHandler } from '../parameter/TrustedHTMLHandler';\nimport type { Rect } from '../parameter/Rect';\nimport type { EntityState } from '../parameter/FormatContentModelContext';\n\n/**\n * An interface of Editor, built on top of Content Model\n */\nexport interface IEditor {\n /**\n * @deprecated Use formatContentModel() instead\n */\n getContentModelCopy(mode: 'connected'): ContentModelDocument;\n\n /**\n * Create Content Model from DOM tree in this editor\n * @param mode What kind of Content Model we want. Currently we support the following values:\n * - 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.\n * If there is any entity in editor, the returned object will contain cloned copy of entity wrapper element.\n * If editor is in dark mode, the cloned entity will be converted back to light mode.\n * - clean: Similar with disconnected, this will return a disconnected model, the difference is \"clean\" mode will not include any selection info.\n * This is usually used for exporting content\n */\n getContentModelCopy(mode: 'disconnected' | 'clean'): ContentModelDocument;\n\n /**\n * Get current running environment, such as if editor is running on Mac\n */\n getEnvironment(): EditorEnvironment;\n\n /**\n * Get current DOM selection.\n * This is the replacement of IEditor.getSelectionRangeEx.\n */\n getDOMSelection(): DOMSelection | null;\n\n /**\n * Set DOMSelection into editor content.\n * This is the replacement of IEditor.select.\n * @param selection The selection to set\n */\n setDOMSelection(selection: DOMSelection | null): void;\n\n /**\n * Set a new logical root (most likely due to focus change)\n * @param core The StandaloneEditorCore object\n * @param logicalRoot The new logical root (has to be child of physicalRoot or null to use physicalRoot as logical root)\n */\n setLogicalRoot(logicalRoot: HTMLDivElement | null): void;\n\n /**\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatContentModelOptions\n */\n formatContentModel(\n formatter: ContentModelFormatter,\n options?: FormatContentModelOptions,\n domToModelOption?: DomToModelOptionForCreateModel\n ): void;\n\n /**\n * Get pending format of editor if any, or return null\n */\n getPendingFormat(): ContentModelSegmentFormat | null;\n\n /**\n * Get whether this editor is disposed\n * @returns True if editor is disposed, otherwise false\n */\n isDisposed(): boolean;\n\n /**\n * Get a DOM Helper object to help access DOM tree in editor\n */\n getDOMHelper(): DOMHelper;\n\n /**\n * Get document which contains this editor\n * @returns The HTML document which contains this editor\n */\n getDocument(): Document;\n\n /**\n * Focus to this editor, the selection was restored to where it was before, no unexpected scroll.\n */\n focus(): void;\n\n /**\n * Trigger an event to be dispatched to all plugins\n * @param eventType Type of the event\n * @param data data of the event with given type, this is the rest part of PluginEvent with the given type\n * @param broadcast indicates if the event needs to be dispatched to all plugins\n * True means to all, false means to allow exclusive handling from one plugin unless no one wants that\n * @returns the event object which is really passed into plugins. Some plugin may modify the event object so\n * the result of this function provides a chance to read the modified result\n */\n triggerEvent<T extends PluginEventType>(\n eventType: T,\n data: PluginEventData<T>,\n broadcast?: boolean\n ): PluginEventFromType<T>;\n\n /**\n * Get undo snapshots manager\n */\n getSnapshotsManager(): SnapshotsManager;\n\n /**\n * Check if the editor is in dark mode\n * @returns True if the editor is in dark mode, otherwise false\n */\n isDarkMode(): boolean;\n\n /**\n * Set the dark mode state and transforms the content to match the new state.\n * @param isDarkMode The next status of dark mode. True if the editor should be in dark mode, false if not.\n */\n setDarkModeState(isDarkMode?: boolean): void;\n\n /**\n * Add a single undo snapshot to undo stack\n * @param entityState @optional State for entity if we want to add entity state for this snapshot\n */\n takeSnapshot(entityState?: EntityState): Snapshot | null;\n\n /**\n * Restore an undo snapshot into editor\n * @param snapshot The snapshot to restore\n */\n restoreSnapshot(snapshot: Snapshot): void;\n\n /**\n * Attach a DOM event to the editor content DIV\n * @param eventMap A map from event name to its handler\n */\n attachDomEvent(eventMap: Record<string, DOMEventRecord>): () => void;\n\n /**\n * Check if editor is in Shadow Edit mode\n */\n isInShadowEdit(): boolean;\n\n /**\n * Make the editor in \"Shadow Edit\" mode.\n * In Shadow Edit mode, all format change will finally be ignored.\n * This can be used for building a live preview feature for format button, to allow user\n * see format result without really apply it.\n * This function can be called repeated. If editor is already in shadow edit mode, we can still\n * use this function to do more shadow edit operation.\n */\n startShadowEdit(): void;\n\n /**\n * Leave \"Shadow Edit\" mode, all changes made during shadow edit will be discarded\n */\n stopShadowEdit(): void;\n\n /**\n * Get a darkColorHandler object for this editor.\n */\n getColorManager(): DarkColorHandler;\n\n /**\n * Dispose this editor, dispose all plugins and custom data\n */\n dispose(): void;\n\n /**\n * Check if focus is in editor now\n * @returns true if focus is in editor, otherwise false\n */\n hasFocus(): boolean;\n\n /**\n * Get a function to convert HTML string to trusted HTML string.\n * By default it will just return the input HTML directly. To override this behavior,\n * pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types\n */\n getTrustedHTMLHandler(): TrustedHTMLHandler;\n\n /**\n * Get the scroll container of the editor\n */\n getScrollContainer(): HTMLElement;\n\n /**\n * Retrieves the rect of the visible viewport of the editor.\n */\n getVisibleViewport(): Rect | null;\n\n /**\n * Add CSS rules for editor\n * @param key A string to identify the CSS rule type. When set CSS rules with the same key again, existing rules with the same key will be replaced.\n * @param cssRule The CSS rule string, must be a valid CSS rule string, or browser may throw exception. Pass null to clear existing rules\n * @param subSelectors @optional If the rule is used for child element under editor, use this parameter to specify the child elements. Each item will be\n * combined with root selector together to build a separate rule.\n */\n setEditorStyle(\n key: string,\n cssRule: string | null,\n subSelectors?: 'before' | 'after' | string[]\n ): void;\n\n /**\n * Announce the given data\n * @param announceData Data to announce\n */\n announce(announceData: AnnounceData): void;\n}\n"]}
1
+ {"version":3,"file":"IEditor.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/editor/IEditor.ts"],"names":[],"mappings":"","sourcesContent":["import type { AnnounceData } from '../parameter/AnnounceData';\nimport type { DomToModelOptionForCreateModel } from '../context/DomToModelOption';\nimport type { DOMHelper } from '../parameter/DOMHelper';\nimport type { PluginEventData, PluginEventFromType } from '../event/PluginEventData';\nimport type { PluginEventType } from '../event/PluginEventType';\nimport type { DOMEventRecord } from '../parameter/DOMEventRecord';\nimport type { SnapshotsManager } from '../parameter/SnapshotsManager';\nimport type { Snapshot } from '../parameter/Snapshot';\nimport type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';\nimport type { ContentModelSegmentFormat } from '../contentModel/format/ContentModelSegmentFormat';\nimport type { DOMSelection } from '../selection/DOMSelection';\nimport type { EditorEnvironment } from '../parameter/EditorEnvironment';\nimport type {\n ContentModelFormatter,\n FormatContentModelOptions,\n} from '../parameter/FormatContentModelOptions';\nimport type { DarkColorHandler } from '../context/DarkColorHandler';\nimport type { TrustedHTMLHandler } from '../parameter/TrustedHTMLHandler';\nimport type { Rect } from '../parameter/Rect';\nimport type { EntityState } from '../parameter/FormatContentModelContext';\nimport type { ExperimentalFeature } from './ExperimentalFeature';\n\n/**\n * An interface of Editor, built on top of Content Model\n */\nexport interface IEditor {\n /**\n * @deprecated Use formatContentModel() instead\n */\n getContentModelCopy(mode: 'connected'): ContentModelDocument;\n\n /**\n * Create Content Model from DOM tree in this editor\n * @param mode What kind of Content Model we want. Currently we support the following values:\n * - 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.\n * If there is any entity in editor, the returned object will contain cloned copy of entity wrapper element.\n * If editor is in dark mode, the cloned entity will be converted back to light mode.\n * - clean: Similar with disconnected, this will return a disconnected model, the difference is \"clean\" mode will not include any selection info.\n * This is usually used for exporting content\n */\n getContentModelCopy(mode: 'disconnected' | 'clean'): ContentModelDocument;\n\n /**\n * Get current running environment, such as if editor is running on Mac\n */\n getEnvironment(): EditorEnvironment;\n\n /**\n * Get current DOM selection.\n * This is the replacement of IEditor.getSelectionRangeEx.\n */\n getDOMSelection(): DOMSelection | null;\n\n /**\n * Set DOMSelection into editor content.\n * This is the replacement of IEditor.select.\n * @param selection The selection to set\n */\n setDOMSelection(selection: DOMSelection | null): void;\n\n /**\n * Set a new logical root (most likely due to focus change)\n * @param core The StandaloneEditorCore object\n * @param logicalRoot The new logical root (has to be child of physicalRoot or null to use physicalRoot as logical root)\n */\n setLogicalRoot(logicalRoot: HTMLDivElement | null): void;\n\n /**\n * The general API to do format change with Content Model\n * It will grab a Content Model for current editor content, and invoke a callback function\n * to do format change. Then according to the return value, write back the modified content model into editor.\n * If there is cached model, it will be used and updated.\n * @param formatter Formatter function, see ContentModelFormatter\n * @param options More options, see FormatContentModelOptions\n */\n formatContentModel(\n formatter: ContentModelFormatter,\n options?: FormatContentModelOptions,\n domToModelOption?: DomToModelOptionForCreateModel\n ): void;\n\n /**\n * Get pending format of editor if any, or return null\n */\n getPendingFormat(): ContentModelSegmentFormat | null;\n\n /**\n * Get whether this editor is disposed\n * @returns True if editor is disposed, otherwise false\n */\n isDisposed(): boolean;\n\n /**\n * Get a DOM Helper object to help access DOM tree in editor\n */\n getDOMHelper(): DOMHelper;\n\n /**\n * Get document which contains this editor\n * @returns The HTML document which contains this editor\n */\n getDocument(): Document;\n\n /**\n * Focus to this editor, the selection was restored to where it was before, no unexpected scroll.\n */\n focus(): void;\n\n /**\n * Trigger an event to be dispatched to all plugins\n * @param eventType Type of the event\n * @param data data of the event with given type, this is the rest part of PluginEvent with the given type\n * @param broadcast indicates if the event needs to be dispatched to all plugins\n * True means to all, false means to allow exclusive handling from one plugin unless no one wants that\n * @returns the event object which is really passed into plugins. Some plugin may modify the event object so\n * the result of this function provides a chance to read the modified result\n */\n triggerEvent<T extends PluginEventType>(\n eventType: T,\n data: PluginEventData<T>,\n broadcast?: boolean\n ): PluginEventFromType<T>;\n\n /**\n * Get undo snapshots manager\n */\n getSnapshotsManager(): SnapshotsManager;\n\n /**\n * Check if the editor is in dark mode\n * @returns True if the editor is in dark mode, otherwise false\n */\n isDarkMode(): boolean;\n\n /**\n * Set the dark mode state and transforms the content to match the new state.\n * @param isDarkMode The next status of dark mode. True if the editor should be in dark mode, false if not.\n */\n setDarkModeState(isDarkMode?: boolean): void;\n\n /**\n * Add a single undo snapshot to undo stack\n * @param entityState @optional State for entity if we want to add entity state for this snapshot\n */\n takeSnapshot(entityState?: EntityState): Snapshot | null;\n\n /**\n * Restore an undo snapshot into editor\n * @param snapshot The snapshot to restore\n */\n restoreSnapshot(snapshot: Snapshot): void;\n\n /**\n * Attach a DOM event to the editor content DIV\n * @param eventMap A map from event name to its handler\n */\n attachDomEvent(eventMap: Record<string, DOMEventRecord>): () => void;\n\n /**\n * Check if editor is in Shadow Edit mode\n */\n isInShadowEdit(): boolean;\n\n /**\n * Make the editor in \"Shadow Edit\" mode.\n * In Shadow Edit mode, all format change will finally be ignored.\n * This can be used for building a live preview feature for format button, to allow user\n * see format result without really apply it.\n * This function can be called repeated. If editor is already in shadow edit mode, we can still\n * use this function to do more shadow edit operation.\n */\n startShadowEdit(): void;\n\n /**\n * Leave \"Shadow Edit\" mode, all changes made during shadow edit will be discarded\n */\n stopShadowEdit(): void;\n\n /**\n * Get a darkColorHandler object for this editor.\n */\n getColorManager(): DarkColorHandler;\n\n /**\n * Dispose this editor, dispose all plugins and custom data\n */\n dispose(): void;\n\n /**\n * Check if focus is in editor now\n * @returns true if focus is in editor, otherwise false\n */\n hasFocus(): boolean;\n\n /**\n * Get a function to convert HTML string to trusted HTML string.\n * By default it will just return the input HTML directly. To override this behavior,\n * pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types\n */\n getTrustedHTMLHandler(): TrustedHTMLHandler;\n\n /**\n * Get the scroll container of the editor\n */\n getScrollContainer(): HTMLElement;\n\n /**\n * Retrieves the rect of the visible viewport of the editor.\n */\n getVisibleViewport(): Rect | null;\n\n /**\n * Add CSS rules for editor\n * @param key A string to identify the CSS rule type. When set CSS rules with the same key again, existing rules with the same key will be replaced.\n * @param cssRule The CSS rule string, must be a valid CSS rule string, or browser may throw exception. Pass null to clear existing rules\n * @param subSelectors @optional If the rule is used for child element under editor, use this parameter to specify the child elements. Each item will be\n * combined with root selector together to build a separate rule.\n */\n setEditorStyle(\n key: string,\n cssRule: string | null,\n subSelectors?: 'before' | 'after' | string[]\n ): void;\n\n /**\n * Announce the given data\n * @param announceData Data to announce\n */\n announce(announceData: AnnounceData): void;\n\n /**\n * Check if a given feature is enabled\n * @param featureName The name of feature to check\n */\n isExperimentalFeatureEnabled(featureName: ExperimentalFeature | string): boolean;\n}\n"]}
@@ -2,7 +2,7 @@ import type { DomToModelOptionForSanitizing } from '../context/DomToModelOption'
2
2
  import type { PasteType } from '../enum/PasteType';
3
3
  import type { ClipboardData } from '../parameter/ClipboardData';
4
4
  import type { BasePluginEvent } from './BasePluginEvent';
5
- import type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';
5
+ import type { ContentModelDocument, ShallowMutableContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';
6
6
  import type { InsertPoint } from '../selection/InsertPoint';
7
7
  /**
8
8
  * A function type used by merging pasted content into current Content Model
@@ -10,7 +10,7 @@ import type { InsertPoint } from '../selection/InsertPoint';
10
10
  * @param source Source Content Model to merge from
11
11
  * @returns Insert point after merge
12
12
  */
13
- export declare type MergePastedContentFunc = (target: ContentModelDocument, source: ContentModelDocument) => InsertPoint | null;
13
+ export declare type MergePastedContentFunc = (target: ShallowMutableContentModelDocument, source: ContentModelDocument) => InsertPoint | null;
14
14
  /**
15
15
  * Data of BeforePasteEvent
16
16
  */
@@ -1 +1 @@
1
- {"version":3,"file":"BeforePasteEvent.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/event/BeforePasteEvent.ts"],"names":[],"mappings":"","sourcesContent":["import type { DomToModelOptionForSanitizing } from '../context/DomToModelOption';\nimport type { PasteType } from '../enum/PasteType';\nimport type { ClipboardData } from '../parameter/ClipboardData';\nimport type { BasePluginEvent } from './BasePluginEvent';\nimport type { ContentModelDocument } from '../contentModel/blockGroup/ContentModelDocument';\nimport type { InsertPoint } from '../selection/InsertPoint';\n\n/**\n * A function type used by merging pasted content into current Content Model\n * @param target Target Content Model to merge into\n * @param source Source Content Model to merge from\n * @returns Insert point after merge\n */\nexport type MergePastedContentFunc = (\n target: ContentModelDocument,\n source: ContentModelDocument\n) => InsertPoint | null;\n\n/**\n * Data of BeforePasteEvent\n */\nexport interface BeforePasteEvent extends BasePluginEvent<'beforePaste'> {\n /**\n * An object contains all related data for pasting\n */\n readonly clipboardData: ClipboardData;\n\n /**\n * HTML Document Fragment which will be inserted into content\n */\n readonly fragment: DocumentFragment;\n\n /**\n * Stripped HTML string before \"StartFragment\" comment\n */\n readonly htmlBefore: string;\n\n /**\n * Stripped HTML string after \"EndFragment\" comment\n */\n readonly htmlAfter: string;\n\n /**\n * Attributes of the root \"HTML\" tag\n */\n readonly htmlAttributes: Record<string, string>;\n\n /**\n * Paste type option (as plain text, merge format, normal, as image)\n */\n readonly pasteType: PasteType;\n\n /**\n * domToModel Options to use when creating the content model from the paste fragment\n */\n readonly domToModelOption: DomToModelOptionForSanitizing;\n\n /**\n * customizedMerge Customized merge function to use when merging the paste fragment into the editor\n */\n customizedMerge?: MergePastedContentFunc;\n}\n"]}
1
+ {"version":3,"file":"BeforePasteEvent.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-types/lib/event/BeforePasteEvent.ts"],"names":[],"mappings":"","sourcesContent":["import type { DomToModelOptionForSanitizing } from '../context/DomToModelOption';\nimport type { PasteType } from '../enum/PasteType';\nimport type { ClipboardData } from '../parameter/ClipboardData';\nimport type { BasePluginEvent } from './BasePluginEvent';\nimport type {\n ContentModelDocument,\n ShallowMutableContentModelDocument,\n} from '../contentModel/blockGroup/ContentModelDocument';\nimport type { InsertPoint } from '../selection/InsertPoint';\n\n/**\n * A function type used by merging pasted content into current Content Model\n * @param target Target Content Model to merge into\n * @param source Source Content Model to merge from\n * @returns Insert point after merge\n */\nexport type MergePastedContentFunc = (\n target: ShallowMutableContentModelDocument,\n source: ContentModelDocument\n) => InsertPoint | null;\n\n/**\n * Data of BeforePasteEvent\n */\nexport interface BeforePasteEvent extends BasePluginEvent<'beforePaste'> {\n /**\n * An object contains all related data for pasting\n */\n readonly clipboardData: ClipboardData;\n\n /**\n * HTML Document Fragment which will be inserted into content\n */\n readonly fragment: DocumentFragment;\n\n /**\n * Stripped HTML string before \"StartFragment\" comment\n */\n readonly htmlBefore: string;\n\n /**\n * Stripped HTML string after \"EndFragment\" comment\n */\n readonly htmlAfter: string;\n\n /**\n * Attributes of the root \"HTML\" tag\n */\n readonly htmlAttributes: Record<string, string>;\n\n /**\n * Paste type option (as plain text, merge format, normal, as image)\n */\n readonly pasteType: PasteType;\n\n /**\n * domToModel Options to use when creating the content model from the paste fragment\n */\n readonly domToModelOption: DomToModelOptionForSanitizing;\n\n /**\n * customizedMerge Customized merge function to use when merging the paste fragment into the editor\n */\n customizedMerge?: MergePastedContentFunc;\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -51,7 +51,7 @@ export { EntityInfoFormat } from './contentModel/format/formatParts/EntityInfoFo
51
51
  export { DatasetFormat, ReadonlyDatasetFormat } from './contentModel/format/metadata/DatasetFormat';
52
52
  export { TableMetadataFormat } from './contentModel/format/metadata/TableMetadataFormat';
53
53
  export { ListMetadataFormat } from './contentModel/format/metadata/ListMetadataFormat';
54
- export { ImageResizeMetadataFormat, ImageCropMetadataFormat, ImageMetadataFormat, ImageRotateMetadataFormat, } from './contentModel/format/metadata/ImageMetadataFormat';
54
+ export { ImageResizeMetadataFormat, ImageCropMetadataFormat, ImageMetadataFormat, ImageRotateMetadataFormat, ImageFlipMetadataFormat, } from './contentModel/format/metadata/ImageMetadataFormat';
55
55
  export { TableCellMetadataFormat } from './contentModel/format/metadata/TableCellMetadataFormat';
56
56
  export { ContentModelBlockGroupType } from './contentModel/blockGroup/BlockGroupType';
57
57
  export { ContentModelBlockType } from './contentModel/block/BlockType';
@@ -116,7 +116,8 @@ export { DefinitionType } from './metadata/DefinitionType';
116
116
  export { ArrayItemType, DefinitionBase, StringDefinition, NumberDefinition, BooleanDefinition, ArrayDefinition, ObjectPropertyDefinition, ObjectDefinition, Definition, } from './metadata/Definition';
117
117
  export { DarkColorHandler, Colors, ColorTransformFunction } from './context/DarkColorHandler';
118
118
  export { IEditor } from './editor/IEditor';
119
- export { EditorOptions } from './editor/EditorOptions';
119
+ export { ExperimentalFeature } from './editor/ExperimentalFeature';
120
+ export { EditorOptions, ColorOptions, ContentModelOptions, SelectionOptions, PasteOptions, EditorBaseOptions, } from './editor/EditorOptions';
120
121
  export { CreateContentModel, CreateEditorContext, GetDOMSelection, SetContentModel, SetDOMSelection, SetLogicalRoot, FormatContentModel, CoreApiMap, EditorCore, SwitchShadowEdit, TriggerEvent, AddUndoSnapshot, Focus, AttachDomEvent, RestoreUndoSnapshot, GetVisibleViewport, SetEditorStyle, Announce, } from './editor/EditorCore';
121
122
  export { EditorCorePlugins } from './editor/EditorCorePlugins';
122
123
  export { EditorPlugin } from './editor/EditorPlugin';