roosterjs-editor-adapter 0.28.0 → 8.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -37
- package/lib/corePlugins/BridgePlugin.js +7 -4
- package/lib/corePlugins/BridgePlugin.js.map +1 -1
- package/lib/editor/EditorAdapter.d.ts +0 -1
- package/lib/editor/EditorAdapter.js +13 -10
- package/lib/editor/EditorAdapter.js.map +1 -1
- package/lib/editor/IgnoredPluginNames.d.ts +5 -0
- package/lib/editor/IgnoredPluginNames.js +11 -0
- package/lib/editor/IgnoredPluginNames.js.map +1 -0
- package/lib/editor/utils/createTableRanges.d.ts +8 -0
- package/lib/editor/utils/createTableRanges.js +29 -0
- package/lib/editor/utils/createTableRanges.js.map +1 -0
- package/lib/editor/utils/eventConverter.js +16 -9
- package/lib/editor/utils/eventConverter.js.map +1 -1
- package/lib/editor/utils/selectionConverter.js +2 -2
- package/lib/editor/utils/selectionConverter.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib-amd/corePlugins/BridgePlugin.js +6 -4
- package/lib-amd/corePlugins/BridgePlugin.js.map +1 -1
- package/lib-amd/editor/EditorAdapter.d.ts +0 -1
- package/lib-amd/editor/EditorAdapter.js +13 -10
- package/lib-amd/editor/EditorAdapter.js.map +1 -1
- package/lib-amd/editor/IgnoredPluginNames.d.ts +5 -0
- package/lib-amd/editor/IgnoredPluginNames.js +13 -0
- package/lib-amd/editor/IgnoredPluginNames.js.map +1 -0
- package/lib-amd/editor/utils/createTableRanges.d.ts +8 -0
- package/lib-amd/editor/utils/createTableRanges.js +30 -0
- package/lib-amd/editor/utils/createTableRanges.js.map +1 -0
- package/lib-amd/editor/utils/eventConverter.js +16 -9
- package/lib-amd/editor/utils/eventConverter.js.map +1 -1
- package/lib-amd/editor/utils/selectionConverter.js +2 -2
- package/lib-amd/editor/utils/selectionConverter.js.map +1 -1
- package/lib-amd/index.d.ts +1 -0
- package/lib-amd/index.js +3 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-mjs/corePlugins/BridgePlugin.js +5 -2
- package/lib-mjs/corePlugins/BridgePlugin.js.map +1 -1
- package/lib-mjs/editor/EditorAdapter.d.ts +0 -1
- package/lib-mjs/editor/EditorAdapter.js +10 -7
- package/lib-mjs/editor/EditorAdapter.js.map +1 -1
- package/lib-mjs/editor/IgnoredPluginNames.d.ts +5 -0
- package/lib-mjs/editor/IgnoredPluginNames.js +8 -0
- package/lib-mjs/editor/IgnoredPluginNames.js.map +1 -0
- package/lib-mjs/editor/utils/createTableRanges.d.ts +8 -0
- package/lib-mjs/editor/utils/createTableRanges.js +25 -0
- package/lib-mjs/editor/utils/createTableRanges.js.map +1 -0
- package/lib-mjs/editor/utils/eventConverter.js +16 -9
- package/lib-mjs/editor/utils/eventConverter.js.map +1 -1
- package/lib-mjs/editor/utils/selectionConverter.js +1 -1
- package/lib-mjs/editor/utils/selectionConverter.js.map +1 -1
- package/lib-mjs/index.d.ts +1 -0
- package/lib-mjs/index.js +1 -0
- package/lib-mjs/index.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -6,13 +6,17 @@ Rooster is a framework-independent JavaScript rich-text editor neatly nested
|
|
|
6
6
|
inside one HTML `<div>` element. Editing operations performed by end users are
|
|
7
7
|
handled in simple ways to generate the final HTML.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Rooster is working on top of a middle layer data structure called "Content Model".
|
|
10
|
+
All format API and editing operation are using this Content Model layer as content format,
|
|
11
|
+
and finally convert to HTML and show it in editor.
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
To view the demo site, please click the link below:
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
[RoosterJs Demo Site](https://microsoft.github.io/roosterjs/index.html).
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
## Upgrade from RoosterJs 8.\*
|
|
18
|
+
|
|
19
|
+
Please see [here](https://github.com/microsoft/roosterjs/wiki/RoosterJs-9).
|
|
16
20
|
|
|
17
21
|
## Features
|
|
18
22
|
|
|
@@ -25,24 +29,22 @@ Rooster contains 6 basic packages.
|
|
|
25
29
|
`createEditor()` function in roosterjs to create an editor with default
|
|
26
30
|
configurations.
|
|
27
31
|
|
|
28
|
-
2. [roosterjs-
|
|
29
|
-
Defines the core editor and plugin infrastructure. Use `roosterjs-
|
|
32
|
+
2. [roosterjs-content-model-core](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_content_model_core.html):
|
|
33
|
+
Defines the core editor and plugin infrastructure. Use `roosterjs-content-model-core`
|
|
30
34
|
instead of `roosterjs` to build and customize your own editor.
|
|
31
35
|
|
|
32
|
-
3. [roosterjs-
|
|
36
|
+
3. [roosterjs-content-model-api](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_content_model_api.html):
|
|
33
37
|
Defines APIs for editor operations. Use these APIs to modify content and
|
|
34
|
-
formatting in the editor you built using `roosterjs-
|
|
38
|
+
formatting in the editor you built using `roosterjs-content-model-core`.
|
|
35
39
|
|
|
36
|
-
4. [roosterjs-
|
|
37
|
-
Defines APIs for DOM operations.
|
|
38
|
-
you want to access DOM API directly.
|
|
40
|
+
4. [roosterjs-content-model-dom](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_content_model_dom.html):
|
|
41
|
+
Defines APIs for Content Model and DOM operations. This package do conversion between DOM tree and roosterjs Content Model.
|
|
39
42
|
|
|
40
|
-
5. [roosterjs-
|
|
41
|
-
Defines basic plugins for common features.
|
|
42
|
-
pasting HTML content, inserting inline images.
|
|
43
|
+
5. [roosterjs-content-model-plugins](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_content_model_plugins.html):
|
|
44
|
+
Defines basic plugins for common features.
|
|
43
45
|
|
|
44
|
-
6. [roosterjs-
|
|
45
|
-
Defines public interfaces and enumerations.
|
|
46
|
+
6. [roosterjs-content-model-types](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_content_model_types.html):
|
|
47
|
+
Defines public interfaces and enumerations, including Content Model types, API parameters and other types.
|
|
46
48
|
|
|
47
49
|
There are also some extension packages to provide additional functionalities.
|
|
48
50
|
|
|
@@ -52,30 +54,38 @@ There are also some extension packages to provide additional functionalities.
|
|
|
52
54
|
2. [roosterjs-react](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_react.html):
|
|
53
55
|
Provide a React wrapper of roosterjs so it can be easily used with React.
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
To be compatible with old (8.\*) versions, you can use `EditorAdapter` class from the following package which can act as a 8.\* Editor:
|
|
58
|
+
|
|
59
|
+
1. [roosterjs-editor-adapter](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_adapter.html):
|
|
60
|
+
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
|
+
|
|
62
|
+
And the following packages are for old (8.\*) compatibility:
|
|
63
|
+
|
|
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):
|
|
59
70
|
|
|
60
71
|
### APIs
|
|
61
72
|
|
|
62
|
-
Rooster provides
|
|
63
|
-
(in `roosterjs-
|
|
73
|
+
Rooster provides Content Model level APIs (in `roosterjs-content-model-dom`), core APIs (in `roosterjs-content-model-core`), and formatting APIs
|
|
74
|
+
(in `roosterjs-content-modelapi`) to perform editing operations.
|
|
64
75
|
|
|
65
|
-
`roosterjs-
|
|
76
|
+
`roosterjs-content-model-dom` provides several levels of Content Model operations:
|
|
66
77
|
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
ContentTraverser API.
|
|
78
|
+
- Create Content Model elements
|
|
79
|
+
- Convert DOM tree to Content Model
|
|
80
|
+
- Convert Content Model to DOM tree
|
|
81
|
+
- Format handlers
|
|
82
|
+
- A few DOM level API
|
|
73
83
|
|
|
74
|
-
`roosterjs-
|
|
75
|
-
APIs to perform basic editor operations. These APIs
|
|
84
|
+
`roosterjs-content-model-core` provides APIs for editor core. Editor class will call such
|
|
85
|
+
APIs to perform basic editor operations. These APIs can be overridden by specifying
|
|
76
86
|
API overrides in Editor options when creating the editor.
|
|
77
87
|
|
|
78
|
-
`roosterjs-
|
|
88
|
+
`roosterjs-content-model-api` provides APIs for scenario-based operations triggered by
|
|
79
89
|
user interaction.
|
|
80
90
|
|
|
81
91
|
## Plugins
|
|
@@ -99,7 +109,7 @@ class HelloRooster implements EditorPlugin {
|
|
|
99
109
|
dispose() {}
|
|
100
110
|
|
|
101
111
|
onPluginEvent(e: PluginEvent) {
|
|
102
|
-
if (e.eventType ==
|
|
112
|
+
if (e.eventType == 'input' && e.rawEvent.which == 65) {
|
|
103
113
|
alert('Hello Rooster');
|
|
104
114
|
}
|
|
105
115
|
}
|
|
@@ -114,9 +124,9 @@ Install via NPM or Yarn:
|
|
|
114
124
|
|
|
115
125
|
You can also install sub packages separately:
|
|
116
126
|
|
|
117
|
-
`yarn add roosterjs-
|
|
127
|
+
`yarn add roosterjs-content-model-core`
|
|
118
128
|
|
|
119
|
-
`yarn add roosterjs-
|
|
129
|
+
`yarn add roosterjs-content-model-api`
|
|
120
130
|
|
|
121
131
|
`...`
|
|
122
132
|
|
|
@@ -161,9 +171,9 @@ In order to run the code below, you may also need to install [webpack](https://w
|
|
|
161
171
|
|
|
162
172
|
## Sample code
|
|
163
173
|
|
|
164
|
-
To view the
|
|
174
|
+
To view the demo site, please click [here](https://microsoft.github.io/roosterjs/index.html).
|
|
165
175
|
|
|
166
|
-
To build the
|
|
176
|
+
To build the demo site code yourself, follow these instructions:
|
|
167
177
|
|
|
168
178
|
1. Get dependencies using [yarn](https://yarnpkg.com) or [npm](https://www.npmjs.com/):
|
|
169
179
|
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSizeTransformer = exports.BridgePlugin = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var
|
|
5
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
6
6
|
var DarkColorHandlerImpl_1 = require("../editor/DarkColorHandlerImpl");
|
|
7
7
|
var EditPlugin_1 = require("./EditPlugin");
|
|
8
|
+
var IgnoredPluginNames_1 = require("../editor/IgnoredPluginNames");
|
|
8
9
|
var eventConverter_1 = require("../editor/utils/eventConverter");
|
|
9
10
|
var ExclusivelyHandleEventPluginKey = '__ExclusivelyHandleEventPlugin';
|
|
10
11
|
var OldEventKey = '__OldEventFromNewEvent';
|
|
@@ -19,7 +20,9 @@ var BridgePlugin = /** @class */ (function () {
|
|
|
19
20
|
this.onInitialize = onInitialize;
|
|
20
21
|
this.experimentalFeatures = experimentalFeatures;
|
|
21
22
|
var editPlugin = (0, EditPlugin_1.createEditPlugin)();
|
|
22
|
-
this.legacyPlugins = (0, tslib_1.__spreadArray)([
|
|
23
|
+
this.legacyPlugins = (0, tslib_1.__spreadArray)([
|
|
24
|
+
editPlugin
|
|
25
|
+
], (0, tslib_1.__read)(legacyPlugins.filter(function (x) { return !!x && IgnoredPluginNames_1.IgnoredPluginNames.indexOf(x.getName()) < 0; })), false);
|
|
23
26
|
this.edit = editPlugin.getState();
|
|
24
27
|
this.contextMenuProviders = this.legacyPlugins.filter(isContextMenuProvider);
|
|
25
28
|
this.checkExclusivelyHandling = this.legacyPlugins.some(function (plugin) { return plugin.willHandleEventExclusively; });
|
|
@@ -85,7 +88,7 @@ var BridgePlugin = /** @class */ (function () {
|
|
|
85
88
|
};
|
|
86
89
|
BridgePlugin.prototype.cacheGetExclusivelyHandlePlugin = function (event) {
|
|
87
90
|
var _this = this;
|
|
88
|
-
return (0,
|
|
91
|
+
return (0, roosterjs_content_model_dom_1.cacheGetEventData)(event, ExclusivelyHandleEventPluginKey, function (event) {
|
|
89
92
|
var _a;
|
|
90
93
|
var oldEvent = _this.cacheGetOldEvent(event);
|
|
91
94
|
if (oldEvent) {
|
|
@@ -100,7 +103,7 @@ var BridgePlugin = /** @class */ (function () {
|
|
|
100
103
|
});
|
|
101
104
|
};
|
|
102
105
|
BridgePlugin.prototype.cacheGetOldEvent = function (event) {
|
|
103
|
-
return (0,
|
|
106
|
+
return (0, roosterjs_content_model_dom_1.cacheGetEventData)(event, OldEventKey, eventConverter_1.newEventToOldEvent);
|
|
104
107
|
};
|
|
105
108
|
BridgePlugin.prototype.createEditorCore = function (editor) {
|
|
106
109
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BridgePlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-editor-adapter/lib/corePlugins/BridgePlugin.ts"],"names":[],"mappings":";;;;AAAA,6EAAiE;AACjE,uEAAwE;AACxE,2CAAgD;AAChD,iEAAwF;AAaxF,IAAM,+BAA+B,GAAG,gCAAgC,CAAC;AACzE,IAAM,WAAW,GAAG,wBAAwB,CAAC;AAuC7C;;;GAGG;AACH;IAMI,sBACY,YAAwD,EAChE,aAAwC,EAChC,oBAAiD;QADzD,8BAAA,EAAA,kBAAwC;QAChC,qCAAA,EAAA,yBAAiD;QAFjD,iBAAY,GAAZ,YAAY,CAA4C;QAExD,yBA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,CAAC;AAFD,sDAEC;AAED,SAAS,qBAAqB,CAC1B,MAA0B;;IAE1B,OAAO,CAAC,CAAC,CAAA,MAAiC,MAAO,0CAAE,mBAAmB,CAAA,CAAC;AAC3E,CAAC","sourcesContent":["import { cacheGetEventData } from 'roosterjs-content-model-core';\nimport { createDarkColorHandler } from '../editor/DarkColorHandlerImpl';\nimport { createEditPlugin } from './EditPlugin';\nimport { newEventToOldEvent, oldEventToNewEvent } from '../editor/utils/eventConverter';\nimport type {\n EditorPlugin as LegacyEditorPlugin,\n ContextMenuProvider as LegacyContextMenuProvider,\n IEditor as ILegacyEditor,\n ExperimentalFeatures,\n SizeTransformer,\n EditPluginState,\n CustomData,\n DarkColorHandler,\n} from 'roosterjs-editor-types';\nimport type { ContextMenuProvider, IEditor, PluginEvent } from 'roosterjs-content-model-types';\n\nconst ExclusivelyHandleEventPluginKey = '__ExclusivelyHandleEventPlugin';\nconst OldEventKey = '__OldEventFromNewEvent';\n\n/**\n * @internal\n * Represents the core data structure of a editor adapter\n */\nexport interface EditorAdapterCore {\n /**\n * Custom data of this editor\n */\n readonly customData: Record<string, CustomData>;\n\n /**\n * Enabled experimental features\n */\n readonly experimentalFeatures: ExperimentalFeatures[];\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 * Plugin state of EditPlugin\n */\n readonly edit: EditPluginState;\n\n /**\n * Context Menu providers\n */\n readonly contextMenuProviders: LegacyContextMenuProvider<any>[];\n\n /**\n * @deprecated Use zoomScale instead\n */\n readonly sizeTransformer: SizeTransformer;\n}\n\n/**\n * @internal\n * Act as a bridge between Standalone editor and Content Model editor, translate Standalone editor event type to legacy event type\n */\nexport class BridgePlugin implements ContextMenuProvider<any> {\n private legacyPlugins: LegacyEditorPlugin[];\n private edit: EditPluginState;\n private contextMenuProviders: LegacyContextMenuProvider<any>[];\n private checkExclusivelyHandling: boolean;\n\n constructor(\n private onInitialize: (core: EditorAdapterCore) => ILegacyEditor,\n legacyPlugins: LegacyEditorPlugin[] = [],\n private experimentalFeatures: ExperimentalFeatures[] = []\n ) {\n const editPlugin = createEditPlugin();\n\n this.legacyPlugins = [editPlugin, ...legacyPlugins.filter(x => !!x)];\n this.edit = editPlugin.getState();\n this.contextMenuProviders = this.legacyPlugins.filter(isContextMenuProvider);\n this.checkExclusivelyHandling = this.legacyPlugins.some(\n plugin => plugin.willHandleEventExclusively\n );\n }\n\n /**\n * Get a friendly name of this plugin\n */\n getName() {\n return 'Bridge';\n }\n\n /**\n * Initialize this plugin. This should only be called from Editor\n * @param editor Editor instance\n */\n initialize(editor: IEditor) {\n const outerEditor = this.onInitialize(this.createEditorCore(editor));\n\n this.legacyPlugins.forEach(plugin => plugin.initialize(outerEditor));\n }\n\n /**\n * Dispose this plugin\n */\n dispose() {\n for (let i = this.legacyPlugins.length - 1; i >= 0; i--) {\n const plugin = this.legacyPlugins[i];\n\n plugin.dispose();\n }\n }\n\n willHandleEventExclusively(event: PluginEvent) {\n return this.checkExclusivelyHandling && !!this.cacheGetExclusivelyHandlePlugin(event);\n }\n\n onPluginEvent(event: PluginEvent) {\n const oldEvent = this.cacheGetOldEvent(event);\n\n if (oldEvent) {\n const exclusivelyHandleEventPlugin = this.cacheGetExclusivelyHandlePlugin(event);\n\n if (exclusivelyHandleEventPlugin) {\n exclusivelyHandleEventPlugin.onPluginEvent?.(oldEvent);\n } else {\n this.legacyPlugins.forEach(plugin => plugin.onPluginEvent?.(oldEvent));\n }\n\n Object.assign(event, oldEventToNewEvent(oldEvent, event));\n }\n }\n\n /**\n * A callback to return context menu items\n * @param target Target node that triggered a ContextMenu event\n * @returns An array of context menu items, or null means no items needed\n */\n getContextMenuItems(target: Node): any[] {\n const allItems: any[] = [];\n\n this.contextMenuProviders.forEach(provider => {\n const items = provider.getContextMenuItems(target) ?? [];\n if (items?.length > 0) {\n if (allItems.length > 0) {\n allItems.push(null);\n }\n\n allItems.push(...items);\n }\n });\n\n return allItems;\n }\n\n private cacheGetExclusivelyHandlePlugin(event: PluginEvent) {\n return cacheGetEventData(event, ExclusivelyHandleEventPluginKey, event => {\n const oldEvent = this.cacheGetOldEvent(event);\n\n if (oldEvent) {\n for (let i = 0; i < this.legacyPlugins.length; i++) {\n const plugin = this.legacyPlugins[i];\n\n if (plugin.willHandleEventExclusively?.(oldEvent)) {\n return plugin;\n }\n }\n }\n\n return null;\n });\n }\n\n private cacheGetOldEvent(event: PluginEvent) {\n return cacheGetEventData(event, OldEventKey, newEventToOldEvent);\n }\n\n private createEditorCore(editor: IEditor): EditorAdapterCore {\n return {\n customData: {},\n experimentalFeatures: this.experimentalFeatures ?? [],\n sizeTransformer: createSizeTransformer(editor),\n darkColorHandler: createDarkColorHandler(editor.getColorManager()),\n edit: this.edit,\n contextMenuProviders: this.contextMenuProviders,\n };\n }\n}\n\n/**\n * @internal Export for test only. This function is only used for compatibility from older build\n\n */\nexport function createSizeTransformer(editor: IEditor): SizeTransformer {\n return size => size / editor.getDOMHelper().calculateZoomScale();\n}\n\nfunction isContextMenuProvider(\n source: LegacyEditorPlugin\n): source is LegacyContextMenuProvider<any> {\n return !!(<LegacyContextMenuProvider<any>>source)?.getContextMenuItems;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BridgePlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-editor-adapter/lib/corePlugins/BridgePlugin.ts"],"names":[],"mappings":";;;;AAAA,2EAAgE;AAChE,uEAAwE;AACxE,2CAAgD;AAChD,mEAAkE;AAClE,iEAAwF;AAaxF,IAAM,+BAA+B,GAAG,gCAAgC,CAAC;AACzE,IAAM,WAAW,GAAG,wBAAwB,CAAC;AAuC7C;;;GAGG;AACH;IAMI,sBACY,YAAwD,EAChE,aAAwC,EAChC,oBAAiD;QADzD,8BAAA,EAAA,kBAAwC;QAChC,qCAAA,EAAA,yBAAiD;QAFjD,iBAAY,GAAZ,YAAY,CAA4C;QAExD,yBAAoB,GAApB,oBAA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AAY,EAAE,CAAC,kBAAkB,EAAE,EAAjD,CAAiD,CAAC;AACrE,CAAC;AAFD,sDAEC;AAED,SAAS,qBAAqB,CAC1B,MAA0B;;IAE1B,OAAO,CAAC,CAAC,CAAA,MAAiC,MAAO,0CAAE,mBAAmB,CAAA,CAAC;AAC3E,CAAC","sourcesContent":["import { cacheGetEventData } from 'roosterjs-content-model-dom';\nimport { createDarkColorHandler } from '../editor/DarkColorHandlerImpl';\nimport { createEditPlugin } from './EditPlugin';\nimport { IgnoredPluginNames } from '../editor/IgnoredPluginNames';\nimport { newEventToOldEvent, oldEventToNewEvent } from '../editor/utils/eventConverter';\nimport type {\n EditorPlugin as LegacyEditorPlugin,\n ContextMenuProvider as LegacyContextMenuProvider,\n IEditor as ILegacyEditor,\n ExperimentalFeatures,\n SizeTransformer,\n EditPluginState,\n CustomData,\n DarkColorHandler,\n} from 'roosterjs-editor-types';\nimport type { ContextMenuProvider, IEditor, PluginEvent } from 'roosterjs-content-model-types';\n\nconst ExclusivelyHandleEventPluginKey = '__ExclusivelyHandleEventPlugin';\nconst OldEventKey = '__OldEventFromNewEvent';\n\n/**\n * @internal\n * Represents the core data structure of a editor adapter\n */\nexport interface EditorAdapterCore {\n /**\n * Custom data of this editor\n */\n readonly customData: Record<string, CustomData>;\n\n /**\n * Enabled experimental features\n */\n readonly experimentalFeatures: ExperimentalFeatures[];\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 * Plugin state of EditPlugin\n */\n readonly edit: EditPluginState;\n\n /**\n * Context Menu providers\n */\n readonly contextMenuProviders: LegacyContextMenuProvider<any>[];\n\n /**\n * @deprecated Use zoomScale instead\n */\n readonly sizeTransformer: SizeTransformer;\n}\n\n/**\n * @internal\n * Act as a bridge between Standalone editor and Content Model editor, translate Standalone editor event type to legacy event type\n */\nexport class BridgePlugin implements ContextMenuProvider<any> {\n private legacyPlugins: LegacyEditorPlugin[];\n private edit: EditPluginState;\n private contextMenuProviders: LegacyContextMenuProvider<any>[];\n private checkExclusivelyHandling: boolean;\n\n constructor(\n private onInitialize: (core: EditorAdapterCore) => ILegacyEditor,\n legacyPlugins: LegacyEditorPlugin[] = [],\n private experimentalFeatures: ExperimentalFeatures[] = []\n ) {\n const editPlugin = createEditPlugin();\n\n this.legacyPlugins = [\n editPlugin,\n ...legacyPlugins.filter(x => !!x && IgnoredPluginNames.indexOf(x.getName()) < 0),\n ];\n this.edit = editPlugin.getState();\n this.contextMenuProviders = this.legacyPlugins.filter(isContextMenuProvider);\n this.checkExclusivelyHandling = this.legacyPlugins.some(\n plugin => plugin.willHandleEventExclusively\n );\n }\n\n /**\n * Get a friendly name of this plugin\n */\n getName() {\n return 'Bridge';\n }\n\n /**\n * Initialize this plugin. This should only be called from Editor\n * @param editor Editor instance\n */\n initialize(editor: IEditor) {\n const outerEditor = this.onInitialize(this.createEditorCore(editor));\n\n this.legacyPlugins.forEach(plugin => plugin.initialize(outerEditor));\n }\n\n /**\n * Dispose this plugin\n */\n dispose() {\n for (let i = this.legacyPlugins.length - 1; i >= 0; i--) {\n const plugin = this.legacyPlugins[i];\n\n plugin.dispose();\n }\n }\n\n willHandleEventExclusively(event: PluginEvent) {\n return this.checkExclusivelyHandling && !!this.cacheGetExclusivelyHandlePlugin(event);\n }\n\n onPluginEvent(event: PluginEvent) {\n const oldEvent = this.cacheGetOldEvent(event);\n\n if (oldEvent) {\n const exclusivelyHandleEventPlugin = this.cacheGetExclusivelyHandlePlugin(event);\n\n if (exclusivelyHandleEventPlugin) {\n exclusivelyHandleEventPlugin.onPluginEvent?.(oldEvent);\n } else {\n this.legacyPlugins.forEach(plugin => plugin.onPluginEvent?.(oldEvent));\n }\n\n Object.assign(event, oldEventToNewEvent(oldEvent, event));\n }\n }\n\n /**\n * A callback to return context menu items\n * @param target Target node that triggered a ContextMenu event\n * @returns An array of context menu items, or null means no items needed\n */\n getContextMenuItems(target: Node): any[] {\n const allItems: any[] = [];\n\n this.contextMenuProviders.forEach(provider => {\n const items = provider.getContextMenuItems(target) ?? [];\n if (items?.length > 0) {\n if (allItems.length > 0) {\n allItems.push(null);\n }\n\n allItems.push(...items);\n }\n });\n\n return allItems;\n }\n\n private cacheGetExclusivelyHandlePlugin(event: PluginEvent) {\n return cacheGetEventData(event, ExclusivelyHandleEventPluginKey, event => {\n const oldEvent = this.cacheGetOldEvent(event);\n\n if (oldEvent) {\n for (let i = 0; i < this.legacyPlugins.length; i++) {\n const plugin = this.legacyPlugins[i];\n\n if (plugin.willHandleEventExclusively?.(oldEvent)) {\n return plugin;\n }\n }\n }\n\n return null;\n });\n }\n\n private cacheGetOldEvent(event: PluginEvent) {\n return cacheGetEventData(event, OldEventKey, newEventToOldEvent);\n }\n\n private createEditorCore(editor: IEditor): EditorAdapterCore {\n return {\n customData: {},\n experimentalFeatures: this.experimentalFeatures ?? [],\n sizeTransformer: createSizeTransformer(editor),\n darkColorHandler: createDarkColorHandler(editor.getColorManager()),\n edit: this.edit,\n contextMenuProviders: this.contextMenuProviders,\n };\n }\n}\n\n/**\n * @internal Export for test only. This function is only used for compatibility from older build\n\n */\nexport function createSizeTransformer(editor: IEditor): SizeTransformer {\n return size => size / editor.getDOMHelper().calculateZoomScale();\n}\n\nfunction isContextMenuProvider(\n source: LegacyEditorPlugin\n): source is LegacyContextMenuProvider<any> {\n return !!(<LegacyContextMenuProvider<any>>source)?.getContextMenuItems;\n}\n"]}
|
|
@@ -6,7 +6,6 @@ import type { EditorAdapterOptions } from '../publicTypes/EditorAdapterOptions';
|
|
|
6
6
|
import type { IEditor } from 'roosterjs-content-model-types';
|
|
7
7
|
/**
|
|
8
8
|
* Editor for Content Model.
|
|
9
|
-
* (This class is still under development, and may still be changed in the future with some breaking changes)
|
|
10
9
|
*/
|
|
11
10
|
export declare class EditorAdapter extends Editor implements ILegacyEditor {
|
|
12
11
|
private contentModelEditorCore;
|
|
@@ -5,8 +5,8 @@ exports.EditorAdapter = void 0;
|
|
|
5
5
|
var tslib_1 = require("tslib");
|
|
6
6
|
var BridgePlugin_1 = require("../corePlugins/BridgePlugin");
|
|
7
7
|
var buildRangeEx_1 = require("./utils/buildRangeEx");
|
|
8
|
-
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
9
8
|
var insertNode_1 = require("./utils/insertNode");
|
|
9
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
10
10
|
var eventConverter_1 = require("./utils/eventConverter");
|
|
11
11
|
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
12
12
|
var selectionConverter_1 = require("./utils/selectionConverter");
|
|
@@ -20,7 +20,6 @@ var GetContentModeMap = (_a = {},
|
|
|
20
20
|
_a);
|
|
21
21
|
/**
|
|
22
22
|
* Editor for Content Model.
|
|
23
|
-
* (This class is still under development, and may still be changed in the future with some breaking changes)
|
|
24
23
|
*/
|
|
25
24
|
var EditorAdapter = /** @class */ (function (_super) {
|
|
26
25
|
(0, tslib_1.__extends)(EditorAdapter, _super);
|
|
@@ -99,7 +98,7 @@ var EditorAdapter = /** @class */ (function (_super) {
|
|
|
99
98
|
}
|
|
100
99
|
else {
|
|
101
100
|
if (this.isDarkMode()) {
|
|
102
|
-
(0,
|
|
101
|
+
(0, roosterjs_content_model_dom_1.transformColor)(node, true /*includeSelf*/, 'lightToDark', this.getColorManager());
|
|
103
102
|
}
|
|
104
103
|
var selection = (0, insertNode_1.insertNode)(physicalRoot, this.getDOMSelection(), node, option);
|
|
105
104
|
if (selection && option.updateCursor) {
|
|
@@ -231,7 +230,7 @@ var EditorAdapter = /** @class */ (function (_super) {
|
|
|
231
230
|
}, false /*broadcast*/);
|
|
232
231
|
}
|
|
233
232
|
else if (lifecycle.isDarkMode) {
|
|
234
|
-
(0,
|
|
233
|
+
(0, roosterjs_content_model_dom_1.transformColor)(physicalRoot, false /*includeSelf*/, 'lightToDark', darkColorHandler);
|
|
235
234
|
}
|
|
236
235
|
};
|
|
237
236
|
/**
|
|
@@ -529,8 +528,10 @@ var EditorAdapter = /** @class */ (function (_super) {
|
|
|
529
528
|
var selection = core.api.getDOMSelection(core);
|
|
530
529
|
if ((selection === null || selection === void 0 ? void 0 : selection.type) == 'range') {
|
|
531
530
|
core.undo.snapshotsManager.hasNewContent = false;
|
|
532
|
-
core.undo.
|
|
533
|
-
|
|
531
|
+
core.undo.autoCompleteInsertPoint = {
|
|
532
|
+
node: selection.range.startContainer,
|
|
533
|
+
offset: selection.range.startOffset,
|
|
534
|
+
};
|
|
534
535
|
}
|
|
535
536
|
}
|
|
536
537
|
};
|
|
@@ -568,7 +569,7 @@ var EditorAdapter = /** @class */ (function (_super) {
|
|
|
568
569
|
EditorAdapter.prototype.getDefaultFormat = function () {
|
|
569
570
|
var format = this.getCore().format.defaultFormat;
|
|
570
571
|
return {
|
|
571
|
-
bold: (0,
|
|
572
|
+
bold: (0, roosterjs_content_model_dom_1.isBold)(format.fontWeight),
|
|
572
573
|
italic: format.italic,
|
|
573
574
|
underline: format.underline,
|
|
574
575
|
fontFamily: format.fontFamily,
|
|
@@ -764,7 +765,7 @@ var EditorAdapter = /** @class */ (function (_super) {
|
|
|
764
765
|
if (direction === void 0) { direction = 0 /* LightToDark */; }
|
|
765
766
|
var core = this.getCore();
|
|
766
767
|
if (core.lifecycle.isDarkMode) {
|
|
767
|
-
(0,
|
|
768
|
+
(0, roosterjs_content_model_dom_1.transformColor)(node, true /*includeSelf*/, direction == 1 /* DarkToLight */ ? 'darkToLight' : 'lightToDark', core.darkColorHandler);
|
|
768
769
|
}
|
|
769
770
|
};
|
|
770
771
|
/**
|
|
@@ -822,8 +823,10 @@ var EditorAdapter = /** @class */ (function (_super) {
|
|
|
822
823
|
EditorAdapter.prototype.retrieveFormatState = function () {
|
|
823
824
|
var pendingFormat = this.getPendingFormat();
|
|
824
825
|
var result = {};
|
|
825
|
-
|
|
826
|
-
|
|
826
|
+
this.formatContentModel(function (model) {
|
|
827
|
+
(0, roosterjs_content_model_dom_1.retrieveModelFormatState)(model, pendingFormat, result);
|
|
828
|
+
return false;
|
|
829
|
+
});
|
|
827
830
|
return result;
|
|
828
831
|
};
|
|
829
832
|
/**
|