roosterjs-content-model-plugins 9.40.0 → 9.42.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/lib/announce/AnnouncePlugin.d.ts +32 -0
- package/lib/announce/AnnouncePlugin.js +66 -0
- package/lib/announce/AnnouncePlugin.js.map +1 -0
- package/lib/announce/tableSelectionUtils.d.ts +17 -0
- package/lib/announce/tableSelectionUtils.js +72 -0
- package/lib/announce/tableSelectionUtils.js.map +1 -0
- package/lib/edit/inputSteps/handleEnterOnList.js +0 -33
- package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib/findReplace/FindReplacePlugin.d.ts +42 -0
- package/lib/findReplace/FindReplacePlugin.js +97 -0
- package/lib/findReplace/FindReplacePlugin.js.map +1 -0
- package/lib/findReplace/createFindReplaceContext.d.ts +8 -0
- package/lib/findReplace/createFindReplaceContext.js +26 -0
- package/lib/findReplace/createFindReplaceContext.js.map +1 -0
- package/lib/findReplace/find.d.ts +11 -0
- package/lib/findReplace/find.js +20 -0
- package/lib/findReplace/find.js.map +1 -0
- package/lib/findReplace/moveHighlight.d.ts +9 -0
- package/lib/findReplace/moveHighlight.js +21 -0
- package/lib/findReplace/moveHighlight.js.map +1 -0
- package/lib/findReplace/replace.d.ts +10 -0
- package/lib/findReplace/replace.js +48 -0
- package/lib/findReplace/replace.js.map +1 -0
- package/lib/findReplace/types/FindReplaceContext.d.ts +38 -0
- package/lib/findReplace/types/FindReplaceContext.js +3 -0
- package/lib/findReplace/types/FindReplaceContext.js.map +1 -0
- package/lib/findReplace/types/FindReplaceHighlightOptions.d.ts +13 -0
- package/lib/findReplace/types/FindReplaceHighlightOptions.js +3 -0
- package/lib/findReplace/types/FindReplaceHighlightOptions.js.map +1 -0
- package/lib/findReplace/types/HighlightHelper.d.ts +23 -0
- package/lib/findReplace/types/HighlightHelper.js +3 -0
- package/lib/findReplace/types/HighlightHelper.js.map +1 -0
- package/lib/findReplace/utils/HighlightHelperImpl.d.ts +9 -0
- package/lib/findReplace/utils/HighlightHelperImpl.js +65 -0
- package/lib/findReplace/utils/HighlightHelperImpl.js.map +1 -0
- package/lib/findReplace/utils/constants.d.ts +28 -0
- package/lib/findReplace/utils/constants.js +32 -0
- package/lib/findReplace/utils/constants.js.map +1 -0
- package/lib/findReplace/utils/replaceTextInRange.d.ts +4 -0
- package/lib/findReplace/utils/replaceTextInRange.js +71 -0
- package/lib/findReplace/utils/replaceTextInRange.js.map +1 -0
- package/lib/findReplace/utils/setMarkedIndex.d.ts +6 -0
- package/lib/findReplace/utils/setMarkedIndex.js +29 -0
- package/lib/findReplace/utils/setMarkedIndex.js.map +1 -0
- package/lib/findReplace/utils/sortRanges.d.ts +5 -0
- package/lib/findReplace/utils/sortRanges.js +23 -0
- package/lib/findReplace/utils/sortRanges.js.map +1 -0
- package/lib/findReplace/utils/updateHighlight.d.ts +6 -0
- package/lib/findReplace/utils/updateHighlight.js +48 -0
- package/lib/findReplace/utils/updateHighlight.js.map +1 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +13 -1
- package/lib/index.js.map +1 -1
- package/lib/paste/PastePlugin.js +8 -32
- package/lib/paste/PastePlugin.js.map +1 -1
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +7 -31
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib/paste/parsers/adjustPercentileLineHeightParser.d.ts +8 -0
- package/lib/paste/parsers/adjustPercentileLineHeightParser.js +26 -0
- package/lib/paste/parsers/adjustPercentileLineHeightParser.js.map +1 -0
- package/lib/paste/parsers/blockElementParser.d.ts +7 -0
- package/lib/paste/parsers/blockElementParser.js +15 -0
- package/lib/paste/parsers/blockElementParser.js.map +1 -0
- package/lib/paste/parsers/imageSizeParser.d.ts +6 -0
- package/lib/paste/parsers/imageSizeParser.js +24 -0
- package/lib/paste/parsers/imageSizeParser.js.map +1 -0
- package/lib/paste/parsers/listLevelParser.d.ts +10 -0
- package/lib/paste/parsers/listLevelParser.js +19 -0
- package/lib/paste/parsers/listLevelParser.js.map +1 -0
- package/lib/paste/parsers/tableBorderParser.d.ts +5 -0
- package/lib/paste/parsers/tableBorderParser.js +28 -0
- package/lib/paste/parsers/tableBorderParser.js.map +1 -0
- package/lib/paste/parsers/wordTableParser.d.ts +8 -0
- package/lib/paste/parsers/wordTableParser.js +20 -0
- package/lib/paste/parsers/wordTableParser.js.map +1 -0
- package/lib/shortcut/shortcuts.js +15 -3
- package/lib/shortcut/shortcuts.js.map +1 -1
- package/lib-amd/announce/AnnouncePlugin.d.ts +32 -0
- package/lib-amd/announce/AnnouncePlugin.js +67 -0
- package/lib-amd/announce/AnnouncePlugin.js.map +1 -0
- package/lib-amd/announce/tableSelectionUtils.d.ts +17 -0
- package/lib-amd/announce/tableSelectionUtils.js +74 -0
- package/lib-amd/announce/tableSelectionUtils.js.map +1 -0
- package/lib-amd/edit/inputSteps/handleEnterOnList.js +0 -33
- package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-amd/findReplace/FindReplacePlugin.d.ts +42 -0
- package/lib-amd/findReplace/FindReplacePlugin.js +96 -0
- package/lib-amd/findReplace/FindReplacePlugin.js.map +1 -0
- package/lib-amd/findReplace/createFindReplaceContext.d.ts +8 -0
- package/lib-amd/findReplace/createFindReplaceContext.js +26 -0
- package/lib-amd/findReplace/createFindReplaceContext.js.map +1 -0
- package/lib-amd/findReplace/find.d.ts +11 -0
- package/lib-amd/findReplace/find.js +21 -0
- package/lib-amd/findReplace/find.js.map +1 -0
- package/lib-amd/findReplace/moveHighlight.d.ts +9 -0
- package/lib-amd/findReplace/moveHighlight.js +22 -0
- package/lib-amd/findReplace/moveHighlight.js.map +1 -0
- package/lib-amd/findReplace/replace.d.ts +10 -0
- package/lib-amd/findReplace/replace.js +47 -0
- package/lib-amd/findReplace/replace.js.map +1 -0
- package/lib-amd/findReplace/types/FindReplaceContext.d.ts +38 -0
- package/lib-amd/findReplace/types/FindReplaceContext.js +5 -0
- package/lib-amd/findReplace/types/FindReplaceContext.js.map +1 -0
- package/lib-amd/findReplace/types/FindReplaceHighlightOptions.d.ts +13 -0
- package/lib-amd/findReplace/types/FindReplaceHighlightOptions.js +5 -0
- package/lib-amd/findReplace/types/FindReplaceHighlightOptions.js.map +1 -0
- package/lib-amd/findReplace/types/HighlightHelper.d.ts +23 -0
- package/lib-amd/findReplace/types/HighlightHelper.js +5 -0
- package/lib-amd/findReplace/types/HighlightHelper.js.map +1 -0
- package/lib-amd/findReplace/utils/HighlightHelperImpl.d.ts +9 -0
- package/lib-amd/findReplace/utils/HighlightHelperImpl.js +66 -0
- package/lib-amd/findReplace/utils/HighlightHelperImpl.js.map +1 -0
- package/lib-amd/findReplace/utils/constants.d.ts +28 -0
- package/lib-amd/findReplace/utils/constants.js +34 -0
- package/lib-amd/findReplace/utils/constants.js.map +1 -0
- package/lib-amd/findReplace/utils/replaceTextInRange.d.ts +4 -0
- package/lib-amd/findReplace/utils/replaceTextInRange.js +72 -0
- package/lib-amd/findReplace/utils/replaceTextInRange.js.map +1 -0
- package/lib-amd/findReplace/utils/setMarkedIndex.d.ts +6 -0
- package/lib-amd/findReplace/utils/setMarkedIndex.js +30 -0
- package/lib-amd/findReplace/utils/setMarkedIndex.js.map +1 -0
- package/lib-amd/findReplace/utils/sortRanges.d.ts +5 -0
- package/lib-amd/findReplace/utils/sortRanges.js +25 -0
- package/lib-amd/findReplace/utils/sortRanges.js.map +1 -0
- package/lib-amd/findReplace/utils/updateHighlight.d.ts +6 -0
- package/lib-amd/findReplace/utils/updateHighlight.js +46 -0
- package/lib-amd/findReplace/utils/updateHighlight.js.map +1 -0
- package/lib-amd/index.d.ts +9 -0
- package/lib-amd/index.js +8 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/paste/PastePlugin.js +5 -32
- package/lib-amd/paste/PastePlugin.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +5 -32
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-amd/paste/parsers/adjustPercentileLineHeightParser.d.ts +8 -0
- package/lib-amd/paste/parsers/adjustPercentileLineHeightParser.js +28 -0
- package/lib-amd/paste/parsers/adjustPercentileLineHeightParser.js.map +1 -0
- package/lib-amd/paste/parsers/blockElementParser.d.ts +7 -0
- package/lib-amd/paste/parsers/blockElementParser.js +17 -0
- package/lib-amd/paste/parsers/blockElementParser.js.map +1 -0
- package/lib-amd/paste/parsers/imageSizeParser.d.ts +6 -0
- package/lib-amd/paste/parsers/imageSizeParser.js +25 -0
- package/lib-amd/paste/parsers/imageSizeParser.js.map +1 -0
- package/lib-amd/paste/parsers/listLevelParser.d.ts +10 -0
- package/lib-amd/paste/parsers/listLevelParser.js +21 -0
- package/lib-amd/paste/parsers/listLevelParser.js.map +1 -0
- package/lib-amd/paste/parsers/tableBorderParser.d.ts +5 -0
- package/lib-amd/paste/parsers/tableBorderParser.js +29 -0
- package/lib-amd/paste/parsers/tableBorderParser.js.map +1 -0
- package/lib-amd/paste/parsers/wordTableParser.d.ts +8 -0
- package/lib-amd/paste/parsers/wordTableParser.js +22 -0
- package/lib-amd/paste/parsers/wordTableParser.js.map +1 -0
- package/lib-amd/shortcut/shortcuts.js +15 -3
- package/lib-amd/shortcut/shortcuts.js.map +1 -1
- package/lib-mjs/announce/AnnouncePlugin.d.ts +32 -0
- package/lib-mjs/announce/AnnouncePlugin.js +63 -0
- package/lib-mjs/announce/AnnouncePlugin.js.map +1 -0
- package/lib-mjs/announce/tableSelectionUtils.d.ts +17 -0
- package/lib-mjs/announce/tableSelectionUtils.js +67 -0
- package/lib-mjs/announce/tableSelectionUtils.js.map +1 -0
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js +1 -34
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-mjs/findReplace/FindReplacePlugin.d.ts +42 -0
- package/lib-mjs/findReplace/FindReplacePlugin.js +94 -0
- package/lib-mjs/findReplace/FindReplacePlugin.js.map +1 -0
- package/lib-mjs/findReplace/createFindReplaceContext.d.ts +8 -0
- package/lib-mjs/findReplace/createFindReplaceContext.js +22 -0
- package/lib-mjs/findReplace/createFindReplaceContext.js.map +1 -0
- package/lib-mjs/findReplace/find.d.ts +11 -0
- package/lib-mjs/findReplace/find.js +16 -0
- package/lib-mjs/findReplace/find.js.map +1 -0
- package/lib-mjs/findReplace/moveHighlight.d.ts +9 -0
- package/lib-mjs/findReplace/moveHighlight.js +17 -0
- package/lib-mjs/findReplace/moveHighlight.js.map +1 -0
- package/lib-mjs/findReplace/replace.d.ts +10 -0
- package/lib-mjs/findReplace/replace.js +44 -0
- package/lib-mjs/findReplace/replace.js.map +1 -0
- package/lib-mjs/findReplace/types/FindReplaceContext.d.ts +38 -0
- package/lib-mjs/findReplace/types/FindReplaceContext.js +2 -0
- package/lib-mjs/findReplace/types/FindReplaceContext.js.map +1 -0
- package/lib-mjs/findReplace/types/FindReplaceHighlightOptions.d.ts +13 -0
- package/lib-mjs/findReplace/types/FindReplaceHighlightOptions.js +2 -0
- package/lib-mjs/findReplace/types/FindReplaceHighlightOptions.js.map +1 -0
- package/lib-mjs/findReplace/types/HighlightHelper.d.ts +23 -0
- package/lib-mjs/findReplace/types/HighlightHelper.js +2 -0
- package/lib-mjs/findReplace/types/HighlightHelper.js.map +1 -0
- package/lib-mjs/findReplace/utils/HighlightHelperImpl.d.ts +9 -0
- package/lib-mjs/findReplace/utils/HighlightHelperImpl.js +61 -0
- package/lib-mjs/findReplace/utils/HighlightHelperImpl.js.map +1 -0
- package/lib-mjs/findReplace/utils/constants.d.ts +28 -0
- package/lib-mjs/findReplace/utils/constants.js +29 -0
- package/lib-mjs/findReplace/utils/constants.js.map +1 -0
- package/lib-mjs/findReplace/utils/replaceTextInRange.d.ts +4 -0
- package/lib-mjs/findReplace/utils/replaceTextInRange.js +67 -0
- package/lib-mjs/findReplace/utils/replaceTextInRange.js.map +1 -0
- package/lib-mjs/findReplace/utils/setMarkedIndex.d.ts +6 -0
- package/lib-mjs/findReplace/utils/setMarkedIndex.js +25 -0
- package/lib-mjs/findReplace/utils/setMarkedIndex.js.map +1 -0
- package/lib-mjs/findReplace/utils/sortRanges.d.ts +5 -0
- package/lib-mjs/findReplace/utils/sortRanges.js +19 -0
- package/lib-mjs/findReplace/utils/sortRanges.js.map +1 -0
- package/lib-mjs/findReplace/utils/updateHighlight.d.ts +6 -0
- package/lib-mjs/findReplace/utils/updateHighlight.js +44 -0
- package/lib-mjs/findReplace/utils/updateHighlight.js.map +1 -0
- package/lib-mjs/index.d.ts +9 -0
- package/lib-mjs/index.js +6 -0
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/paste/PastePlugin.js +5 -29
- package/lib-mjs/paste/PastePlugin.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +3 -27
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-mjs/paste/parsers/adjustPercentileLineHeightParser.d.ts +8 -0
- package/lib-mjs/paste/parsers/adjustPercentileLineHeightParser.js +22 -0
- package/lib-mjs/paste/parsers/adjustPercentileLineHeightParser.js.map +1 -0
- package/lib-mjs/paste/parsers/blockElementParser.d.ts +7 -0
- package/lib-mjs/paste/parsers/blockElementParser.js +11 -0
- package/lib-mjs/paste/parsers/blockElementParser.js.map +1 -0
- package/lib-mjs/paste/parsers/imageSizeParser.d.ts +6 -0
- package/lib-mjs/paste/parsers/imageSizeParser.js +20 -0
- package/lib-mjs/paste/parsers/imageSizeParser.js.map +1 -0
- package/lib-mjs/paste/parsers/listLevelParser.d.ts +10 -0
- package/lib-mjs/paste/parsers/listLevelParser.js +15 -0
- package/lib-mjs/paste/parsers/listLevelParser.js.map +1 -0
- package/lib-mjs/paste/parsers/tableBorderParser.d.ts +5 -0
- package/lib-mjs/paste/parsers/tableBorderParser.js +24 -0
- package/lib-mjs/paste/parsers/tableBorderParser.js.map +1 -0
- package/lib-mjs/paste/parsers/wordTableParser.d.ts +8 -0
- package/lib-mjs/paste/parsers/wordTableParser.js +16 -0
- package/lib-mjs/paste/parsers/wordTableParser.js.map +1 -0
- package/lib-mjs/shortcut/shortcuts.js +15 -3
- package/lib-mjs/shortcut/shortcuts.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IEditor, PluginEvent, EditorPlugin } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* AnnouncePlugin helps editor announce table selection changes for accessibility
|
|
4
|
+
*/
|
|
5
|
+
export declare class AnnouncePlugin implements EditorPlugin {
|
|
6
|
+
private editor;
|
|
7
|
+
private previousSelection;
|
|
8
|
+
/**
|
|
9
|
+
* Get name of this plugin
|
|
10
|
+
*/
|
|
11
|
+
getName(): string;
|
|
12
|
+
/**
|
|
13
|
+
* The first method that editor will call to a plugin when editor is initializing.
|
|
14
|
+
* It will pass in the editor instance, plugin should take this chance to save the
|
|
15
|
+
* editor reference so that it can call to any editor method or format API later.
|
|
16
|
+
* @param editor The editor object
|
|
17
|
+
*/
|
|
18
|
+
initialize(editor: IEditor): void;
|
|
19
|
+
/**
|
|
20
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
21
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
22
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
23
|
+
*/
|
|
24
|
+
dispose(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
27
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
28
|
+
* exclusively by another plugin.
|
|
29
|
+
* @param event The event to handle:
|
|
30
|
+
*/
|
|
31
|
+
onPluginEvent(event: PluginEvent): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnnouncePlugin = void 0;
|
|
4
|
+
var tableSelectionUtils_1 = require("./tableSelectionUtils");
|
|
5
|
+
/**
|
|
6
|
+
* AnnouncePlugin helps editor announce table selection changes for accessibility
|
|
7
|
+
*/
|
|
8
|
+
var AnnouncePlugin = /** @class */ (function () {
|
|
9
|
+
function AnnouncePlugin() {
|
|
10
|
+
this.editor = null;
|
|
11
|
+
this.previousSelection = null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get name of this plugin
|
|
15
|
+
*/
|
|
16
|
+
AnnouncePlugin.prototype.getName = function () {
|
|
17
|
+
return 'Announce';
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The first method that editor will call to a plugin when editor is initializing.
|
|
21
|
+
* It will pass in the editor instance, plugin should take this chance to save the
|
|
22
|
+
* editor reference so that it can call to any editor method or format API later.
|
|
23
|
+
* @param editor The editor object
|
|
24
|
+
*/
|
|
25
|
+
AnnouncePlugin.prototype.initialize = function (editor) {
|
|
26
|
+
this.editor = editor;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
30
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
31
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
32
|
+
*/
|
|
33
|
+
AnnouncePlugin.prototype.dispose = function () {
|
|
34
|
+
this.editor = null;
|
|
35
|
+
this.previousSelection = null;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
39
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
40
|
+
* exclusively by another plugin.
|
|
41
|
+
* @param event The event to handle:
|
|
42
|
+
*/
|
|
43
|
+
AnnouncePlugin.prototype.onPluginEvent = function (event) {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
if (!this.editor) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (event.eventType == 'selectionChanged') {
|
|
49
|
+
if (((_a = event.newSelection) === null || _a === void 0 ? void 0 : _a.type) == 'table') {
|
|
50
|
+
var action = (0, tableSelectionUtils_1.getIsSelectingOrUnselecting)(((_b = this.previousSelection) === null || _b === void 0 ? void 0 : _b.type) == 'table' ? this.previousSelection : null, event.newSelection);
|
|
51
|
+
if (action && event.newSelection.tableSelectionInfo) {
|
|
52
|
+
this.editor.announce({
|
|
53
|
+
defaultStrings: action === 'unselecting' ? 'unselected' : 'selected',
|
|
54
|
+
formatStrings: [
|
|
55
|
+
(0, tableSelectionUtils_1.retrieveStringFromParsedTable)(event.newSelection.tableSelectionInfo),
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
this.previousSelection = event.newSelection;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return AnnouncePlugin;
|
|
64
|
+
}());
|
|
65
|
+
exports.AnnouncePlugin = AnnouncePlugin;
|
|
66
|
+
//# sourceMappingURL=AnnouncePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnouncePlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/announce/AnnouncePlugin.ts"],"names":[],"mappings":";;;AAAA,6DAAmG;AAQnG;;GAEG;AACH;IAAA;QACY,WAAM,GAAmB,IAAI,CAAC;QAC9B,sBAAiB,GAAwB,IAAI,CAAC;IA2D1D,CAAC;IAzDG;;OAEG;IACH,gCAAO,GAAP;QACI,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACH,mCAAU,GAAV,UAAW,MAAe;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,gCAAO,GAAP;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACH,sCAAa,GAAb,UAAc,KAAkB;;QAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACd,OAAO;SACV;QAED,IAAI,KAAK,CAAC,SAAS,IAAI,kBAAkB,EAAE;YACvC,IAAI,CAAA,MAAA,KAAK,CAAC,YAAY,0CAAE,IAAI,KAAI,OAAO,EAAE;gBACrC,IAAM,MAAM,GAAG,IAAA,iDAA2B,EACtC,CAAA,MAAA,IAAI,CAAC,iBAAiB,0CAAE,IAAI,KAAI,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,EACvE,KAAK,CAAC,YAAY,CACrB,CAAC;gBACF,IAAI,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,kBAAkB,EAAE;oBACjD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;wBACjB,cAAc,EAAE,MAAM,KAAK,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU;wBACpE,aAAa,EAAE;4BACX,IAAA,mDAA6B,EAAC,KAAK,CAAC,YAAY,CAAC,kBAAkB,CAAC;yBACvE;qBACJ,CAAC,CAAC;iBACN;aACJ;YAED,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,YAAY,CAAC;SAC/C;IACL,CAAC;IACL,qBAAC;AAAD,CAAC,AA7DD,IA6DC;AA7DY,wCAAc","sourcesContent":["import { getIsSelectingOrUnselecting, retrieveStringFromParsedTable } from './tableSelectionUtils';\nimport type {\n IEditor,\n PluginEvent,\n EditorPlugin,\n DOMSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * AnnouncePlugin helps editor announce table selection changes for accessibility\n */\nexport class AnnouncePlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private previousSelection: DOMSelection | null = null;\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'Announce';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IEditor) {\n this.editor = editor;\n }\n\n /**\n * The last method that editor will call to a plugin before it is disposed.\n * Plugin can take this chance to clear the reference to editor. After this method is\n * called, plugin should not call to any editor method since it will result in error.\n */\n dispose() {\n this.editor = null;\n this.previousSelection = null;\n }\n\n /**\n * Core method for a plugin. Once an event happens in editor, editor will call this\n * method of each plugin to handle the event as long as the event is not handled\n * exclusively by another plugin.\n * @param event The event to handle:\n */\n onPluginEvent(event: PluginEvent) {\n if (!this.editor) {\n return;\n }\n\n if (event.eventType == 'selectionChanged') {\n if (event.newSelection?.type == 'table') {\n const action = getIsSelectingOrUnselecting(\n this.previousSelection?.type == 'table' ? this.previousSelection : null,\n event.newSelection\n );\n if (action && event.newSelection.tableSelectionInfo) {\n this.editor.announce({\n defaultStrings: action === 'unselecting' ? 'unselected' : 'selected',\n formatStrings: [\n retrieveStringFromParsedTable(event.newSelection.tableSelectionInfo),\n ],\n });\n }\n }\n\n this.previousSelection = event.newSelection;\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TableSelectionInfo, TableSelection } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Retrieves text content from selected table cells in a parsed table structure
|
|
5
|
+
* @param tsInfo Table selection information containing the parsed table and coordinates
|
|
6
|
+
* @returns Combined text content from all selected cells, separated by spaces
|
|
7
|
+
*/
|
|
8
|
+
export declare function retrieveStringFromParsedTable(tsInfo: TableSelectionInfo): string;
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
* Determines whether the table selection is expanding (selecting more) or contracting (selecting less)
|
|
12
|
+
* @param prevTableSelection Previous table selection object containing firstRow, lastRow, firstColumn, and lastColumn properties
|
|
13
|
+
* @param firstCo Current first coordinate of the selection (with row, col properties)
|
|
14
|
+
* @param lastCo Current last coordinate of the selection (with row, col properties)
|
|
15
|
+
* @returns 'selecting' if expanding selection, 'unselecting' if contracting, or null if no change
|
|
16
|
+
*/
|
|
17
|
+
export declare function getIsSelectingOrUnselecting(prevTableSelection: TableSelection | null, newTableSelection: TableSelection): 'selecting' | 'unselecting' | null;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getIsSelectingOrUnselecting = exports.retrieveStringFromParsedTable = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Retrieves text content from selected table cells in a parsed table structure
|
|
7
|
+
* @param tsInfo Table selection information containing the parsed table and coordinates
|
|
8
|
+
* @returns Combined text content from all selected cells, separated by spaces
|
|
9
|
+
*/
|
|
10
|
+
function retrieveStringFromParsedTable(tsInfo) {
|
|
11
|
+
var parsedTable = tsInfo.parsedTable, firstCo = tsInfo.firstCo, lastCo = tsInfo.lastCo;
|
|
12
|
+
var result = '';
|
|
13
|
+
if (lastCo) {
|
|
14
|
+
for (var r = firstCo.row; r <= lastCo.row; r++) {
|
|
15
|
+
for (var c = firstCo.col; c <= lastCo.col; c++) {
|
|
16
|
+
var cell = parsedTable[r] && parsedTable[r][c];
|
|
17
|
+
if (cell && typeof cell != 'string') {
|
|
18
|
+
result += ' ' + cell.innerText + ',';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
exports.retrieveStringFromParsedTable = retrieveStringFromParsedTable;
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
* Determines whether the table selection is expanding (selecting more) or contracting (selecting less)
|
|
29
|
+
* @param prevTableSelection Previous table selection object containing firstRow, lastRow, firstColumn, and lastColumn properties
|
|
30
|
+
* @param firstCo Current first coordinate of the selection (with row, col properties)
|
|
31
|
+
* @param lastCo Current last coordinate of the selection (with row, col properties)
|
|
32
|
+
* @returns 'selecting' if expanding selection, 'unselecting' if contracting, or null if no change
|
|
33
|
+
*/
|
|
34
|
+
function getIsSelectingOrUnselecting(prevTableSelection, newTableSelection) {
|
|
35
|
+
if (!prevTableSelection) {
|
|
36
|
+
return 'selecting';
|
|
37
|
+
}
|
|
38
|
+
var prevFirstRow = prevTableSelection.firstRow, prevLastRow = prevTableSelection.lastRow, prevFirstColumn = prevTableSelection.firstColumn, prevLastColumn = prevTableSelection.lastColumn;
|
|
39
|
+
var newFirstRow = newTableSelection.firstRow, newLastRow = newTableSelection.lastRow, newFirstColumn = newTableSelection.firstColumn, newLastColumn = newTableSelection.lastColumn;
|
|
40
|
+
var prevRowSpan = Math.abs(prevLastRow - prevFirstRow) + 1;
|
|
41
|
+
var prevColSpan = Math.abs(prevLastColumn - prevFirstColumn) + 1;
|
|
42
|
+
var prevArea = prevRowSpan * prevColSpan;
|
|
43
|
+
var newRowSpan = Math.abs(newLastRow - newFirstRow) + 1;
|
|
44
|
+
var newColSpan = Math.abs(newLastColumn - newFirstColumn) + 1;
|
|
45
|
+
var newArea = newRowSpan * newColSpan;
|
|
46
|
+
// Check if selections are identical
|
|
47
|
+
if (prevFirstRow === newFirstRow &&
|
|
48
|
+
prevLastRow === newLastRow &&
|
|
49
|
+
prevFirstColumn === newFirstColumn &&
|
|
50
|
+
prevLastColumn === newLastColumn) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (newArea > prevArea) {
|
|
54
|
+
return 'selecting';
|
|
55
|
+
}
|
|
56
|
+
else if (newArea < prevArea) {
|
|
57
|
+
return 'unselecting';
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// Same area but different positions
|
|
61
|
+
return 'selecting';
|
|
62
|
+
}
|
|
63
|
+
if (prevFirstColumn !== newFirstColumn ||
|
|
64
|
+
prevFirstRow !== newFirstRow ||
|
|
65
|
+
prevLastColumn !== newLastColumn ||
|
|
66
|
+
prevLastRow !== newLastRow) {
|
|
67
|
+
return 'selecting';
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
exports.getIsSelectingOrUnselecting = getIsSelectingOrUnselecting;
|
|
72
|
+
//# sourceMappingURL=tableSelectionUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableSelectionUtils.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/announce/tableSelectionUtils.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,SAAgB,6BAA6B,CAAC,MAA0B;IAC5D,IAAA,WAAW,GAAsB,MAAM,YAA5B,EAAE,OAAO,GAAa,MAAM,QAAnB,EAAE,MAAM,GAAK,MAAM,OAAX,CAAY;IAChD,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,IAAI,MAAM,EAAE;QACR,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;YAC5C,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;gBAC5C,IAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjD,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,QAAQ,EAAE;oBACjC,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;iBACxC;aACJ;SACJ;KACJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAhBD,sEAgBC;AAED;;;;;;;GAOG;AACH,SAAgB,2BAA2B,CACvC,kBAAyC,EACzC,iBAAiC;IAEjC,IAAI,CAAC,kBAAkB,EAAE;QACrB,OAAO,WAAW,CAAC;KACtB;IAGG,IAAU,YAAY,GAItB,kBAAkB,SAJI,EACb,WAAW,GAGpB,kBAAkB,QAHE,EACP,eAAe,GAE5B,kBAAkB,YAFU,EAChB,cAAc,GAC1B,kBAAkB,WADQ,CACP;IAGnB,IAAU,WAAW,GAIrB,iBAAiB,SAJI,EACZ,UAAU,GAGnB,iBAAiB,QAHE,EACN,cAAc,GAE3B,iBAAiB,YAFU,EACf,aAAa,GACzB,iBAAiB,WADQ,CACP;IAEtB,IAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAC7D,IAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IACnE,IAAM,QAAQ,GAAG,WAAW,GAAG,WAAW,CAAC;IAE3C,IAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAC1D,IAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IAChE,IAAM,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC;IAExC,oCAAoC;IACpC,IACI,YAAY,KAAK,WAAW;QAC5B,WAAW,KAAK,UAAU;QAC1B,eAAe,KAAK,cAAc;QAClC,cAAc,KAAK,aAAa,EAClC;QACE,OAAO,IAAI,CAAC;KACf;IAED,IAAI,OAAO,GAAG,QAAQ,EAAE;QACpB,OAAO,WAAW,CAAC;KACtB;SAAM,IAAI,OAAO,GAAG,QAAQ,EAAE;QAC3B,OAAO,aAAa,CAAC;KACxB;SAAM;QACH,oCAAoC;QACpC,OAAO,WAAW,CAAC;KACtB;IAED,IACI,eAAe,KAAK,cAAc;QAClC,YAAY,KAAK,WAAW;QAC5B,cAAc,KAAK,aAAa;QAChC,WAAW,KAAK,UAAU,EAC5B;QACE,OAAO,WAAW,CAAC;KACtB;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AA3DD,kEA2DC","sourcesContent":["import type { TableSelectionInfo, TableSelection } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Retrieves text content from selected table cells in a parsed table structure\n * @param tsInfo Table selection information containing the parsed table and coordinates\n * @returns Combined text content from all selected cells, separated by spaces\n */\nexport function retrieveStringFromParsedTable(tsInfo: TableSelectionInfo): string {\n const { parsedTable, firstCo, lastCo } = tsInfo;\n let result = '';\n\n if (lastCo) {\n for (let r = firstCo.row; r <= lastCo.row; r++) {\n for (let c = firstCo.col; c <= lastCo.col; c++) {\n const cell = parsedTable[r] && parsedTable[r][c];\n if (cell && typeof cell != 'string') {\n result += ' ' + cell.innerText + ',';\n }\n }\n }\n }\n\n return result;\n}\n\n/**\n * @internal\n * Determines whether the table selection is expanding (selecting more) or contracting (selecting less)\n * @param prevTableSelection Previous table selection object containing firstRow, lastRow, firstColumn, and lastColumn properties\n * @param firstCo Current first coordinate of the selection (with row, col properties)\n * @param lastCo Current last coordinate of the selection (with row, col properties)\n * @returns 'selecting' if expanding selection, 'unselecting' if contracting, or null if no change\n */\nexport function getIsSelectingOrUnselecting(\n prevTableSelection: TableSelection | null,\n newTableSelection: TableSelection\n): 'selecting' | 'unselecting' | null {\n if (!prevTableSelection) {\n return 'selecting';\n }\n\n const {\n firstRow: prevFirstRow,\n lastRow: prevLastRow,\n firstColumn: prevFirstColumn,\n lastColumn: prevLastColumn,\n } = prevTableSelection;\n\n const {\n firstRow: newFirstRow,\n lastRow: newLastRow,\n firstColumn: newFirstColumn,\n lastColumn: newLastColumn,\n } = newTableSelection;\n\n const prevRowSpan = Math.abs(prevLastRow - prevFirstRow) + 1;\n const prevColSpan = Math.abs(prevLastColumn - prevFirstColumn) + 1;\n const prevArea = prevRowSpan * prevColSpan;\n\n const newRowSpan = Math.abs(newLastRow - newFirstRow) + 1;\n const newColSpan = Math.abs(newLastColumn - newFirstColumn) + 1;\n const newArea = newRowSpan * newColSpan;\n\n // Check if selections are identical\n if (\n prevFirstRow === newFirstRow &&\n prevLastRow === newLastRow &&\n prevFirstColumn === newFirstColumn &&\n prevLastColumn === newLastColumn\n ) {\n return null;\n }\n\n if (newArea > prevArea) {\n return 'selecting';\n } else if (newArea < prevArea) {\n return 'unselecting';\n } else {\n // Same area but different positions\n return 'selecting';\n }\n\n if (\n prevFirstColumn !== newFirstColumn ||\n prevFirstRow !== newFirstRow ||\n prevLastColumn !== newLastColumn ||\n prevLastRow !== newLastRow\n ) {\n return 'selecting';\n }\n\n return null;\n}\n"]}
|
|
@@ -28,24 +28,6 @@ var handleEnterOnList = function (context) {
|
|
|
28
28
|
], (0, tslib_1.__read)(path.slice(index + 1)), false));
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
var listIndex = listParent.blocks.indexOf(listItem);
|
|
32
|
-
var nextBlock = listParent.blocks[listIndex + 1];
|
|
33
|
-
if (nextBlock) {
|
|
34
|
-
if ((0, roosterjs_content_model_dom_1.isBlockGroupOfType)(nextBlock, 'ListItem') &&
|
|
35
|
-
nextBlock.levels[0]) {
|
|
36
|
-
nextBlock.levels.forEach(function (level) {
|
|
37
|
-
// Remove startNumberOverride so that next list item can join current list, unless it is 1.
|
|
38
|
-
// List start with 1 means it should be an explicit new list and should never join another list before it
|
|
39
|
-
if (level.format.startNumberOverride !== 1) {
|
|
40
|
-
level.format.startNumberOverride = undefined;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
if (listItem.levels.length == 0) {
|
|
44
|
-
var nextBlockIndex = findIndex(listParent.blocks, nextBlock.levels.length);
|
|
45
|
-
nextBlock.levels[nextBlock.levels.length - 1].format.startNumberOverride = nextBlockIndex;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
31
|
context.deleteResult = 'range';
|
|
50
32
|
}
|
|
51
33
|
}
|
|
@@ -87,19 +69,4 @@ var createNewListLevel = function (listItem) {
|
|
|
87
69
|
return (0, roosterjs_content_model_dom_1.createListLevel)(level.listType, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, level.format), { startNumberOverride: undefined, displayForDummyItem: undefined }), level.dataset);
|
|
88
70
|
});
|
|
89
71
|
};
|
|
90
|
-
var findIndex = function (blocks, levelLength) {
|
|
91
|
-
var counter = 1;
|
|
92
|
-
for (var i = 0; i < blocks.length; i++) {
|
|
93
|
-
var listItem = blocks[i];
|
|
94
|
-
if ((0, roosterjs_content_model_dom_1.isBlockGroupOfType)(listItem, 'ListItem') &&
|
|
95
|
-
listItem.levels.length === levelLength) {
|
|
96
|
-
counter++;
|
|
97
|
-
}
|
|
98
|
-
else if ((0, roosterjs_content_model_dom_1.isBlockGroupOfType)(listItem, 'ListItem') &&
|
|
99
|
-
listItem.levels.length == 0) {
|
|
100
|
-
return counter;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return counter;
|
|
104
|
-
};
|
|
105
72
|
//# sourceMappingURL=handleEnterOnList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleEnterOnList.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/inputSteps/handleEnterOnList.ts"],"names":[],"mappings":";;;;AAAA,2EAAkE;AAClE,0DAAyD;AACzD,2EAQqC;AAYrC;;GAEG;AACI,IAAM,iBAAiB,GAAwB,UAAA,OAAO;IACjD,IAAA,YAAY,GAAkB,OAAO,aAAzB,EAAE,WAAW,GAAK,OAAO,YAAZ,CAAa;IAE9C,IAAI,YAAY,IAAI,YAAY,IAAI,YAAY,IAAI,iBAAiB,EAAE;QAC3D,IAAA,IAAI,GAAK,WAAW,KAAhB,CAAiB;QAC7B,IAAM,KAAK,GAAG,IAAA,+DAAiC,EAC3C,IAAI,EACJ,CAAC,UAAU,CAAC,EACZ,CAAC,WAAW,EAAE,iBAAiB,CAAC,CACnC,CAAC;QAEF,IAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACrC,IAAM,UAAU,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAEnC,IAAI,CAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,cAAc,MAAK,UAAU,IAAI,UAAU,EAAE;YAC/D,IAAI,QAAQ,GAAG,IAAA,yCAAW,EAAC,gBAAgB,CAAC,CAAC;YAE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AAkB,EAAuB,QAAQ,EAAE,UAAU,CAAC;YAC9D,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,WAAW,EACxC;YACE,OAAO,EAAE,CAAC;SACb;aAAM,IACH,IAAA,gDAAkB,EAAuB,QAAQ,EAAE,UAAU,CAAC;YAC9D,QAAQ,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,EAC7B;YACE,OAAO,OAAO,CAAC;SAClB;KACJ;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { getListAnnounceData } from 'roosterjs-content-model-api';\nimport { splitParagraph } from '../utils/splitParagraph';\nimport {\n copyFormat,\n createListItem,\n createListLevel,\n getClosestAncestorBlockGroupIndex,\n isBlockGroupOfType,\n ListFormats,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlockFormat,\n ContentModelListItem,\n DeleteSelectionStep,\n ReadonlyContentModelBlock,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelListItem,\n ShallowMutableContentModelListItem,\n ValidDeleteSelectionContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const handleEnterOnList: DeleteSelectionStep = context => {\n const { deleteResult, insertPoint } = context;\n\n if (deleteResult == 'notDeleted' || deleteResult == 'nothingToDelete') {\n const { path } = insertPoint;\n const index = getClosestAncestorBlockGroupIndex(\n path,\n ['ListItem'],\n ['TableCell', 'FormatContainer']\n );\n\n const readonlyListItem = path[index];\n const listParent = path[index + 1];\n\n if (readonlyListItem?.blockGroupType === 'ListItem' && listParent) {\n let listItem = mutateBlock(readonlyListItem);\n\n if (isEmptyListItem(listItem)) {\n listItem.levels.pop();\n } else {\n listItem = createNewListItem(context, listItem, listParent);\n\n if (context.formatContext) {\n context.formatContext.announceData = getListAnnounceData([\n listItem,\n ...path.slice(index + 1),\n ]);\n }\n }\n\n const listIndex = listParent.blocks.indexOf(listItem);\n const nextBlock = listParent.blocks[listIndex + 1];\n\n if (nextBlock) {\n if (\n isBlockGroupOfType<ContentModelListItem>(nextBlock, 'ListItem') &&\n nextBlock.levels[0]\n ) {\n nextBlock.levels.forEach(level => {\n // Remove startNumberOverride so that next list item can join current list, unless it is 1.\n // List start with 1 means it should be an explicit new list and should never join another list before it\n if (level.format.startNumberOverride !== 1) {\n level.format.startNumberOverride = undefined;\n }\n });\n\n if (listItem.levels.length == 0) {\n const nextBlockIndex = findIndex(\n listParent.blocks,\n nextBlock.levels.length\n );\n\n nextBlock.levels[\n nextBlock.levels.length - 1\n ].format.startNumberOverride = nextBlockIndex;\n }\n }\n }\n\n context.deleteResult = 'range';\n }\n }\n};\n\nconst isEmptyListItem = (listItem: ReadonlyContentModelListItem) => {\n return listItem.blocks.length === 1 && isEmptyParagraph(listItem.blocks[0]);\n};\n\nconst isEmptyParagraph = (block: ReadonlyContentModelBlock) => {\n return (\n block.blockType === 'Paragraph' &&\n block.segments.length === 2 &&\n block.segments[0].segmentType === 'SelectionMarker' &&\n block.segments[1].segmentType === 'Br'\n );\n};\n\nconst createNewListItem = (\n context: ValidDeleteSelectionContext,\n listItem: ReadonlyContentModelListItem,\n listParent: ReadonlyContentModelBlockGroup\n) => {\n const { insertPoint } = context;\n const listIndex = listParent.blocks.indexOf(listItem);\n const currentPara = insertPoint.paragraph;\n const paraIndex = listItem.blocks.indexOf(currentPara);\n const newParagraph = splitParagraph(insertPoint);\n\n const levels = createNewListLevel(listItem);\n const newListItem: ShallowMutableContentModelListItem = createListItem(\n levels,\n listItem.formatHolder.format\n );\n\n newListItem.blocks.push(newParagraph);\n\n copyFormat<ContentModelBlockFormat>(newListItem.format, listItem.format, ListFormats);\n\n const remainingBlockCount = listItem.blocks.length - paraIndex - 1;\n\n if (paraIndex >= 0 && remainingBlockCount > 0) {\n newListItem.blocks.push(\n ...mutateBlock(listItem).blocks.splice(paraIndex + 1, remainingBlockCount)\n );\n }\n\n insertPoint.paragraph = newParagraph;\n mutateBlock(listParent).blocks.splice(listIndex + 1, 0, newListItem);\n\n if (context.lastParagraph == currentPara) {\n context.lastParagraph = newParagraph;\n }\n\n return newListItem;\n};\n\nconst createNewListLevel = (listItem: ReadonlyContentModelListItem) => {\n return listItem.levels.map(level => {\n return createListLevel(\n level.listType,\n {\n ...level.format,\n startNumberOverride: undefined,\n displayForDummyItem: undefined, // When ENTER, we should create a new regular list item, so force its dummy item display to undefined\n },\n level.dataset\n );\n });\n};\n\nconst findIndex = (blocks: readonly ReadonlyContentModelBlock[], levelLength: number) => {\n let counter = 1;\n for (let i = 0; i < blocks.length; i++) {\n const listItem = blocks[i];\n\n if (\n isBlockGroupOfType<ContentModelListItem>(listItem, 'ListItem') &&\n listItem.levels.length === levelLength\n ) {\n counter++;\n } else if (\n isBlockGroupOfType<ContentModelListItem>(listItem, 'ListItem') &&\n listItem.levels.length == 0\n ) {\n return counter;\n }\n }\n\n return counter;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"handleEnterOnList.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/inputSteps/handleEnterOnList.ts"],"names":[],"mappings":";;;;AAAA,2EAAkE;AAClE,0DAAyD;AACzD,2EAOqC;AAWrC;;GAEG;AACI,IAAM,iBAAiB,GAAwB,UAAA,OAAO;IACjD,IAAA,YAAY,GAAkB,OAAO,aAAzB,EAAE,WAAW,GAAK,OAAO,YAAZ,CAAa;IAE9C,IAAI,YAAY,IAAI,YAAY,IAAI,YAAY,IAAI,iBAAiB,EAAE;QAC3D,IAAA,IAAI,GAAK,WAAW,KAAhB,CAAiB;QAC7B,IAAM,KAAK,GAAG,IAAA,+DAAiC,EAC3C,IAAI,EACJ,CAAC,UAAU,CAAC,EACZ,CAAC,WAAW,EAAE,iBAAiB,CAAC,CACnC,CAAC;QAEF,IAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACrC,IAAM,UAAU,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAEnC,IAAI,CAAA,gBAAgB,aAAhB,gBAAgB,u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,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,UAAA,KAAK;QAC5B,OAAO,IAAA,6CAAe,EAClB,KAAK,CAAC,QAAQ,kDAEP,KAAK,CAAC,MAAM,KACf,mBAAmB,EAAE,SAAS,EAC9B,mBAAmB,EAAE,SAAS,KAElC,KAAK,CAAC,OAAO,CAChB,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["import { getListAnnounceData } from 'roosterjs-content-model-api';\nimport { splitParagraph } from '../utils/splitParagraph';\nimport {\n copyFormat,\n createListItem,\n createListLevel,\n getClosestAncestorBlockGroupIndex,\n ListFormats,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlockFormat,\n DeleteSelectionStep,\n ReadonlyContentModelBlock,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelListItem,\n ShallowMutableContentModelListItem,\n ValidDeleteSelectionContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const handleEnterOnList: DeleteSelectionStep = context => {\n const { deleteResult, insertPoint } = context;\n\n if (deleteResult == 'notDeleted' || deleteResult == 'nothingToDelete') {\n const { path } = insertPoint;\n const index = getClosestAncestorBlockGroupIndex(\n path,\n ['ListItem'],\n ['TableCell', 'FormatContainer']\n );\n\n const readonlyListItem = path[index];\n const listParent = path[index + 1];\n\n if (readonlyListItem?.blockGroupType === 'ListItem' && listParent) {\n let listItem = mutateBlock(readonlyListItem);\n\n if (isEmptyListItem(listItem)) {\n listItem.levels.pop();\n } else {\n listItem = createNewListItem(context, listItem, listParent);\n\n if (context.formatContext) {\n context.formatContext.announceData = getListAnnounceData([\n listItem,\n ...path.slice(index + 1),\n ]);\n }\n }\n\n context.deleteResult = 'range';\n }\n }\n};\n\nconst isEmptyListItem = (listItem: ReadonlyContentModelListItem) => {\n return listItem.blocks.length === 1 && isEmptyParagraph(listItem.blocks[0]);\n};\n\nconst isEmptyParagraph = (block: ReadonlyContentModelBlock) => {\n return (\n block.blockType === 'Paragraph' &&\n block.segments.length === 2 &&\n block.segments[0].segmentType === 'SelectionMarker' &&\n block.segments[1].segmentType === 'Br'\n );\n};\n\nconst createNewListItem = (\n context: ValidDeleteSelectionContext,\n listItem: ReadonlyContentModelListItem,\n listParent: ReadonlyContentModelBlockGroup\n) => {\n const { insertPoint } = context;\n const listIndex = listParent.blocks.indexOf(listItem);\n const currentPara = insertPoint.paragraph;\n const paraIndex = listItem.blocks.indexOf(currentPara);\n const newParagraph = splitParagraph(insertPoint);\n\n const levels = createNewListLevel(listItem);\n const newListItem: ShallowMutableContentModelListItem = createListItem(\n levels,\n listItem.formatHolder.format\n );\n\n newListItem.blocks.push(newParagraph);\n\n copyFormat<ContentModelBlockFormat>(newListItem.format, listItem.format, ListFormats);\n\n const remainingBlockCount = listItem.blocks.length - paraIndex - 1;\n\n if (paraIndex >= 0 && remainingBlockCount > 0) {\n newListItem.blocks.push(\n ...mutateBlock(listItem).blocks.splice(paraIndex + 1, remainingBlockCount)\n );\n }\n\n insertPoint.paragraph = newParagraph;\n mutateBlock(listParent).blocks.splice(listIndex + 1, 0, newListItem);\n\n if (context.lastParagraph == currentPara) {\n context.lastParagraph = newParagraph;\n }\n\n return newListItem;\n};\n\nconst createNewListLevel = (listItem: ReadonlyContentModelListItem) => {\n return listItem.levels.map(level => {\n return createListLevel(\n level.listType,\n {\n ...level.format,\n startNumberOverride: undefined,\n displayForDummyItem: undefined, // When ENTER, we should create a new regular list item, so force its dummy item display to undefined\n },\n level.dataset\n );\n });\n};\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { FindReplaceHighlightOptions } from './types/FindReplaceHighlightOptions';
|
|
2
|
+
import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
|
|
3
|
+
import type { FindReplaceContext } from './types/FindReplaceContext';
|
|
4
|
+
/**
|
|
5
|
+
* Plugin for finding and replacing text in the editor, maintain the highlights for found and replaced text
|
|
6
|
+
*/
|
|
7
|
+
export declare class FindReplacePlugin implements EditorPlugin {
|
|
8
|
+
private context;
|
|
9
|
+
private editor;
|
|
10
|
+
private findHighlightStyle;
|
|
11
|
+
private replaceHighlightStyle;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a FindReplacePlugin instance
|
|
14
|
+
* @param context FindReplaceContext to use. It will be disposed when plugin is being disposed.
|
|
15
|
+
* @param options Options for highlighting styles
|
|
16
|
+
*/
|
|
17
|
+
constructor(context: FindReplaceContext, options?: FindReplaceHighlightOptions);
|
|
18
|
+
/**
|
|
19
|
+
* Get name of this plugin
|
|
20
|
+
*/
|
|
21
|
+
getName(): string;
|
|
22
|
+
/**
|
|
23
|
+
* The first method that editor will call to a plugin when editor is initializing.
|
|
24
|
+
* It will pass in the editor instance, plugin should take this chance to save the
|
|
25
|
+
* editor reference so that it can call to any editor method or format API later.
|
|
26
|
+
* @param editor The editor object
|
|
27
|
+
*/
|
|
28
|
+
initialize(editor: IEditor): void;
|
|
29
|
+
/**
|
|
30
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
31
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
32
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
33
|
+
*/
|
|
34
|
+
dispose(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
37
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
38
|
+
* exclusively by another plugin.
|
|
39
|
+
* @param event The event to handle:
|
|
40
|
+
*/
|
|
41
|
+
onPluginEvent(event: PluginEvent): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindReplacePlugin = void 0;
|
|
4
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
5
|
+
var updateHighlight_1 = require("./utils/updateHighlight");
|
|
6
|
+
var constants_1 = require("./utils/constants");
|
|
7
|
+
var DefaultFindHighlightStyle = 'background-color: yellow;';
|
|
8
|
+
var DefaultReplaceHighlightStyle = 'background-color: orange;';
|
|
9
|
+
/**
|
|
10
|
+
* Plugin for finding and replacing text in the editor, maintain the highlights for found and replaced text
|
|
11
|
+
*/
|
|
12
|
+
var FindReplacePlugin = /** @class */ (function () {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a FindReplacePlugin instance
|
|
15
|
+
* @param context FindReplaceContext to use. It will be disposed when plugin is being disposed.
|
|
16
|
+
* @param options Options for highlighting styles
|
|
17
|
+
*/
|
|
18
|
+
function FindReplacePlugin(context, options) {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
this.context = context;
|
|
21
|
+
this.editor = null;
|
|
22
|
+
this.findHighlightStyle = (_a = options === null || options === void 0 ? void 0 : options.findHighlightStyle) !== null && _a !== void 0 ? _a : DefaultFindHighlightStyle;
|
|
23
|
+
this.replaceHighlightStyle = (_b = options === null || options === void 0 ? void 0 : options.replaceHighlightStyle) !== null && _b !== void 0 ? _b : DefaultReplaceHighlightStyle;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get name of this plugin
|
|
27
|
+
*/
|
|
28
|
+
FindReplacePlugin.prototype.getName = function () {
|
|
29
|
+
return 'FindReplace';
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The first method that editor will call to a plugin when editor is initializing.
|
|
33
|
+
* It will pass in the editor instance, plugin should take this chance to save the
|
|
34
|
+
* editor reference so that it can call to any editor method or format API later.
|
|
35
|
+
* @param editor The editor object
|
|
36
|
+
*/
|
|
37
|
+
FindReplacePlugin.prototype.initialize = function (editor) {
|
|
38
|
+
var _a;
|
|
39
|
+
this.editor = editor;
|
|
40
|
+
var win = (_a = editor.getDocument().defaultView) !== null && _a !== void 0 ? _a : window;
|
|
41
|
+
this.context.findHighlight.initialize(win);
|
|
42
|
+
this.context.replaceHighlight.initialize(win);
|
|
43
|
+
this.editor.setEditorStyle(constants_1.FindHighlightRuleKey, this.findHighlightStyle, [
|
|
44
|
+
constants_1.FindHighlightSelector,
|
|
45
|
+
]);
|
|
46
|
+
this.editor.setEditorStyle(constants_1.ReplaceHighlightRuleKey, this.replaceHighlightStyle, [
|
|
47
|
+
constants_1.ReplaceHighlightSelector,
|
|
48
|
+
]);
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
52
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
53
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
54
|
+
*/
|
|
55
|
+
FindReplacePlugin.prototype.dispose = function () {
|
|
56
|
+
this.context.findHighlight.dispose();
|
|
57
|
+
this.context.replaceHighlight.dispose();
|
|
58
|
+
if (this.editor) {
|
|
59
|
+
this.editor.setEditorStyle(constants_1.FindHighlightRuleKey, null /*cssRule*/);
|
|
60
|
+
this.editor.setEditorStyle(constants_1.ReplaceHighlightRuleKey, null /*cssRule*/);
|
|
61
|
+
this.editor = null;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
66
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
67
|
+
* exclusively by another plugin.
|
|
68
|
+
* @param event The event to handle:
|
|
69
|
+
*/
|
|
70
|
+
FindReplacePlugin.prototype.onPluginEvent = function (event) {
|
|
71
|
+
if (!this.context.text || !this.editor) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
switch (event.eventType) {
|
|
75
|
+
case 'input':
|
|
76
|
+
var selection = this.editor.getDOMSelection();
|
|
77
|
+
if ((selection === null || selection === void 0 ? void 0 : selection.type) == 'range') {
|
|
78
|
+
var block = this.editor
|
|
79
|
+
.getDOMHelper()
|
|
80
|
+
.findClosestBlockElement(selection.range.startContainer);
|
|
81
|
+
(0, updateHighlight_1.updateHighlight)(this.editor, this.context, [block], [block]);
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case 'contentChanged':
|
|
85
|
+
if (!event.contentModel && event.source != roosterjs_content_model_dom_1.ChangeSource.Replace) {
|
|
86
|
+
(0, updateHighlight_1.updateHighlight)(this.editor, this.context);
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case 'rewriteFromModel':
|
|
90
|
+
(0, updateHighlight_1.updateHighlight)(this.editor, this.context, event.addedBlockElements, event.removedBlockElements);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
return FindReplacePlugin;
|
|
95
|
+
}());
|
|
96
|
+
exports.FindReplacePlugin = FindReplacePlugin;
|
|
97
|
+
//# sourceMappingURL=FindReplacePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FindReplacePlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/findReplace/FindReplacePlugin.ts"],"names":[],"mappings":";;;AAAA,2EAA2D;AAC3D,2DAA0D;AAE1D,+CAK2B;AAI3B,IAAM,yBAAyB,GAAG,2BAA2B,CAAC;AAC9D,IAAM,4BAA4B,GAAG,2BAA2B,CAAC;AAEjE;;GAEG;AACH;IAKI;;;;OAIG;IACH,2BAAoB,OAA2B,EAAE,OAAqC;;QAAlE,YAAO,GAAP,OAAO,CAAoB;QATvC,WAAM,GAAmB,IAAI,CAAC;QAUlC,IAAI,CAAC,kBAAkB,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,kBAAkB,mCAAI,yBAAyB,CAAC;QACnF,IAAI,CAAC,qBAAqB,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,qBAAqB,mCAAI,4BAA4B,CAAC;IAChG,CAAC;IAED;;OAEG;IACH,mCAAO,GAAP;QACI,OAAO,aAAa,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACH,sCAAU,GAAV,UAAW,MAAe;;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAM,GAAG,GAA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BAC5B,IAAM,KAAK,GAAG,IAAI,CAAC,MAAM;yBACpB,YAAY,EAAE;yBACd,uBAAuB,CAAC,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;oBAE7D,IAAA,iCAAe,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;iBAChE;gBAED,MAAM;YACV,KAAK,gBAAgB;gBACjB,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,MAAM,IAAI,0CAAY,CAAC,OAAO,EAAE;oBAC7D,IAAA,iCAAe,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;iBAC9C;gBAED,MAAM;YAEV,KAAK,kBAAkB;gBACnB,IAAA,iCAAe,EACX,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,EACZ,KAAK,CAAC,kBAAkB,EACxB,KAAK,CAAC,oBAAoB,CAC7B,CAAC;gBAEF,MAAM;SACb;IACL,CAAC;IACL,wBAAC;AAAD,CAAC,AAvGD,IAuGC;AAvGY,8CAAiB","sourcesContent":["import { ChangeSource } from 'roosterjs-content-model-dom';\nimport { updateHighlight } from './utils/updateHighlight';\nimport type { FindReplaceHighlightOptions } from './types/FindReplaceHighlightOptions';\nimport {\n FindHighlightRuleKey,\n FindHighlightSelector,\n ReplaceHighlightRuleKey,\n ReplaceHighlightSelector,\n} from './utils/constants';\nimport type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';\nimport type { FindReplaceContext } from './types/FindReplaceContext';\n\nconst DefaultFindHighlightStyle = 'background-color: yellow;';\nconst DefaultReplaceHighlightStyle = 'background-color: orange;';\n\n/**\n * Plugin for finding and replacing text in the editor, maintain the highlights for found and replaced text\n */\nexport class FindReplacePlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private findHighlightStyle: string;\n private replaceHighlightStyle: string;\n\n /**\n * Creates a FindReplacePlugin instance\n * @param context FindReplaceContext to use. It will be disposed when plugin is being disposed.\n * @param options Options for highlighting styles\n */\n constructor(private context: FindReplaceContext, options?: FindReplaceHighlightOptions) {\n this.findHighlightStyle = options?.findHighlightStyle ?? DefaultFindHighlightStyle;\n this.replaceHighlightStyle = options?.replaceHighlightStyle ?? DefaultReplaceHighlightStyle;\n }\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'FindReplace';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IEditor) {\n this.editor = editor;\n\n const win = editor.getDocument().defaultView ?? window;\n\n this.context.findHighlight.initialize(win);\n this.context.replaceHighlight.initialize(win);\n\n this.editor.setEditorStyle(FindHighlightRuleKey, this.findHighlightStyle, [\n FindHighlightSelector,\n ]);\n this.editor.setEditorStyle(ReplaceHighlightRuleKey, this.replaceHighlightStyle, [\n ReplaceHighlightSelector,\n ]);\n }\n\n /**\n * The last method that editor will call to a plugin before it is disposed.\n * Plugin can take this chance to clear the reference to editor. After this method is\n * called, plugin should not call to any editor method since it will result in error.\n */\n dispose() {\n this.context.findHighlight.dispose();\n this.context.replaceHighlight.dispose();\n\n if (this.editor) {\n this.editor.setEditorStyle(FindHighlightRuleKey, null /*cssRule*/);\n this.editor.setEditorStyle(ReplaceHighlightRuleKey, null /*cssRule*/);\n\n this.editor = null;\n }\n }\n\n /**\n * Core method for a plugin. Once an event happens in editor, editor will call this\n * method of each plugin to handle the event as long as the event is not handled\n * exclusively by another plugin.\n * @param event The event to handle:\n */\n onPluginEvent(event: PluginEvent) {\n if (!this.context.text || !this.editor) {\n return;\n }\n\n switch (event.eventType) {\n case 'input':\n const selection = this.editor.getDOMSelection();\n\n if (selection?.type == 'range') {\n const block = this.editor\n .getDOMHelper()\n .findClosestBlockElement(selection.range.startContainer);\n\n updateHighlight(this.editor, this.context, [block], [block]);\n }\n\n break;\n case 'contentChanged':\n if (!event.contentModel && event.source != ChangeSource.Replace) {\n updateHighlight(this.editor, this.context);\n }\n\n break;\n\n case 'rewriteFromModel':\n updateHighlight(\n this.editor,\n this.context,\n event.addedBlockElements,\n event.removedBlockElements\n );\n\n break;\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FindReplaceContext } from './types/FindReplaceContext';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a FindReplaceContext object with default values
|
|
4
|
+
* @param win The window object
|
|
5
|
+
* @param scrollMargin Margin size (in pixels) when scrolling to a highlighted item
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function createFindReplaceContext(scrollMargin?: number): FindReplaceContext;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFindReplaceContext = void 0;
|
|
4
|
+
var HighlightHelperImpl_1 = require("./utils/HighlightHelperImpl");
|
|
5
|
+
var constants_1 = require("./utils/constants");
|
|
6
|
+
/**
|
|
7
|
+
* Creates a FindReplaceContext object with default values
|
|
8
|
+
* @param win The window object
|
|
9
|
+
* @param scrollMargin Margin size (in pixels) when scrolling to a highlighted item
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
function createFindReplaceContext(scrollMargin) {
|
|
13
|
+
if (scrollMargin === void 0) { scrollMargin = constants_1.ScrollMargin; }
|
|
14
|
+
return {
|
|
15
|
+
text: null,
|
|
16
|
+
matchCase: false,
|
|
17
|
+
wholeWord: false,
|
|
18
|
+
ranges: [],
|
|
19
|
+
markedIndex: -1,
|
|
20
|
+
scrollMargin: scrollMargin,
|
|
21
|
+
findHighlight: (0, HighlightHelperImpl_1.createHighlightHelper)(constants_1.FindHighlightStyleKey),
|
|
22
|
+
replaceHighlight: (0, HighlightHelperImpl_1.createHighlightHelper)(constants_1.ReplaceHighlightStyleKey),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.createFindReplaceContext = createFindReplaceContext;
|
|
26
|
+
//# sourceMappingURL=createFindReplaceContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFindReplaceContext.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/findReplace/createFindReplaceContext.ts"],"names":[],"mappings":";;;AAAA,mEAAoE;AACpE,+CAAkG;AAGlG;;;;;GAKG;AACH,SAAgB,wBAAwB,CAAC,YAAmC;IAAnC,6BAAA,EAAA,eAAuB,wBAAY;IACxE,OAAO;QACH,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,CAAC,CAAC;QACf,YAAY,cAAA;QACZ,aAAa,EAAE,IAAA,2CAAqB,EAAC,iCAAqB,CAAC;QAC3D,gBAAgB,EAAE,IAAA,2CAAqB,EAAC,oCAAwB,CAAC;KACpE,CAAC;AACN,CAAC;AAXD,4DAWC","sourcesContent":["import { createHighlightHelper } from './utils/HighlightHelperImpl';\nimport { FindHighlightStyleKey, ReplaceHighlightStyleKey, ScrollMargin } from './utils/constants';\nimport type { FindReplaceContext } from './types/FindReplaceContext';\n\n/**\n * Creates a FindReplaceContext object with default values\n * @param win The window object\n * @param scrollMargin Margin size (in pixels) when scrolling to a highlighted item\n * @returns\n */\nexport function createFindReplaceContext(scrollMargin: number = ScrollMargin): FindReplaceContext {\n return {\n text: null,\n matchCase: false,\n wholeWord: false,\n ranges: [],\n markedIndex: -1,\n scrollMargin,\n findHighlight: createHighlightHelper(FindHighlightStyleKey),\n replaceHighlight: createHighlightHelper(ReplaceHighlightStyleKey),\n };\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FindReplaceContext } from './types/FindReplaceContext';
|
|
2
|
+
import type { IEditor } from 'roosterjs-content-model-types';
|
|
3
|
+
/**
|
|
4
|
+
* Start a find operation in the editor
|
|
5
|
+
* @param editor The editor instance
|
|
6
|
+
* @param context The FindReplaceContext to use
|
|
7
|
+
* @param text The text to find
|
|
8
|
+
* @param matchCase Whether to match case
|
|
9
|
+
* @param wholeWord Whether to match whole words only
|
|
10
|
+
*/
|
|
11
|
+
export declare function find(editor: IEditor, context: FindReplaceContext, text: string | null, matchCase?: boolean, wholeWord?: boolean): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.find = void 0;
|
|
4
|
+
var updateHighlight_1 = require("./utils/updateHighlight");
|
|
5
|
+
/**
|
|
6
|
+
* Start a find operation in the editor
|
|
7
|
+
* @param editor The editor instance
|
|
8
|
+
* @param context The FindReplaceContext to use
|
|
9
|
+
* @param text The text to find
|
|
10
|
+
* @param matchCase Whether to match case
|
|
11
|
+
* @param wholeWord Whether to match whole words only
|
|
12
|
+
*/
|
|
13
|
+
function find(editor, context, text, matchCase, wholeWord) {
|
|
14
|
+
context.text = text;
|
|
15
|
+
context.matchCase = !!matchCase;
|
|
16
|
+
context.wholeWord = !!wholeWord;
|
|
17
|
+
(0, updateHighlight_1.updateHighlight)(editor, context);
|
|
18
|
+
}
|
|
19
|
+
exports.find = find;
|
|
20
|
+
//# sourceMappingURL=find.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/findReplace/find.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAI1D;;;;;;;GAOG;AACH,SAAgB,IAAI,CAChB,MAAe,EACf,OAA2B,EAC3B,IAAmB,EACnB,SAAmB,EACnB,SAAmB;IAEnB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IACpB,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC;IAChC,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC;IAEhC,IAAA,iCAAe,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrC,CAAC;AAZD,oBAYC","sourcesContent":["import { updateHighlight } from './utils/updateHighlight';\nimport type { FindReplaceContext } from './types/FindReplaceContext';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Start a find operation in the editor\n * @param editor The editor instance\n * @param context The FindReplaceContext to use\n * @param text The text to find\n * @param matchCase Whether to match case\n * @param wholeWord Whether to match whole words only\n */\nexport function find(\n editor: IEditor,\n context: FindReplaceContext,\n text: string | null,\n matchCase?: boolean,\n wholeWord?: boolean\n): void {\n context.text = text;\n context.matchCase = !!matchCase;\n context.wholeWord = !!wholeWord;\n\n updateHighlight(editor, context);\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IEditor } from 'roosterjs-content-model-types';
|
|
2
|
+
import type { FindReplaceContext } from './types/FindReplaceContext';
|
|
3
|
+
/**
|
|
4
|
+
* Move the highlight to next or previous match
|
|
5
|
+
* @param editor The editor instance
|
|
6
|
+
* @param context The FindReplaceContext to use
|
|
7
|
+
* @param forward Whether to move forward or backward
|
|
8
|
+
*/
|
|
9
|
+
export declare function moveHighlight(editor: IEditor, context: FindReplaceContext, forward: boolean): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.moveHighlight = void 0;
|
|
4
|
+
var setMarkedIndex_1 = require("./utils/setMarkedIndex");
|
|
5
|
+
/**
|
|
6
|
+
* Move the highlight to next or previous match
|
|
7
|
+
* @param editor The editor instance
|
|
8
|
+
* @param context The FindReplaceContext to use
|
|
9
|
+
* @param forward Whether to move forward or backward
|
|
10
|
+
*/
|
|
11
|
+
function moveHighlight(editor, context, forward) {
|
|
12
|
+
if (context.ranges.length > 0) {
|
|
13
|
+
var newIndex = !forward && context.markedIndex == -1
|
|
14
|
+
? context.ranges.length - 1
|
|
15
|
+
: (context.markedIndex + (forward ? 1 : -1) + context.ranges.length) %
|
|
16
|
+
context.ranges.length;
|
|
17
|
+
(0, setMarkedIndex_1.setMarkedIndex)(editor, context, newIndex);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.moveHighlight = moveHighlight;
|
|
21
|
+
//# sourceMappingURL=moveHighlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moveHighlight.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/findReplace/moveHighlight.ts"],"names":[],"mappings":";;;AAAA,yDAAwD;AAIxD;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,MAAe,EAAE,OAA2B,EAAE,OAAgB;IACxF,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3B,IAAM,QAAQ,GACV,CAAC,OAAO,IAAI,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC;YACjC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;YAC3B,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;gBAClE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;QAEhC,IAAA,+BAAc,EAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;KAC7C;AACL,CAAC;AAVD,sCAUC","sourcesContent":["import { setMarkedIndex } from './utils/setMarkedIndex';\nimport type { IEditor } from 'roosterjs-content-model-types';\nimport type { FindReplaceContext } from './types/FindReplaceContext';\n\n/**\n * Move the highlight to next or previous match\n * @param editor The editor instance\n * @param context The FindReplaceContext to use\n * @param forward Whether to move forward or backward\n */\nexport function moveHighlight(editor: IEditor, context: FindReplaceContext, forward: boolean) {\n if (context.ranges.length > 0) {\n const newIndex =\n !forward && context.markedIndex == -1\n ? context.ranges.length - 1\n : (context.markedIndex + (forward ? 1 : -1) + context.ranges.length) %\n context.ranges.length;\n\n setMarkedIndex(editor, context, newIndex);\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IEditor } from 'roosterjs-content-model-types';
|
|
2
|
+
import type { FindReplaceContext } from './types/FindReplaceContext';
|
|
3
|
+
/**
|
|
4
|
+
* Replace the currently found item or all found items in the editor
|
|
5
|
+
* @param editor The editor instance
|
|
6
|
+
* @param context The FindReplaceContext to use
|
|
7
|
+
* @param replaceText The text to replace with
|
|
8
|
+
* @param replaceAll Whether to replace all found items
|
|
9
|
+
*/
|
|
10
|
+
export declare function replace(editor: IEditor, context: FindReplaceContext, replaceText: string, replaceAll?: boolean): void;
|