roosterjs-content-model-plugins 9.1.0 → 9.3.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/autoFormat/AutoFormatPlugin.d.ts +15 -5
- package/lib/autoFormat/AutoFormatPlugin.js +41 -4
- package/lib/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib/autoFormat/link/createLink.js +2 -0
- package/lib/autoFormat/link/createLink.js.map +1 -1
- package/lib/autoFormat/list/keyboardListTrigger.js +7 -9
- package/lib/autoFormat/list/keyboardListTrigger.js.map +1 -1
- package/lib/autoFormat/numbers/transformFraction.d.ts +5 -0
- package/lib/autoFormat/numbers/transformFraction.js +27 -0
- package/lib/autoFormat/numbers/transformFraction.js.map +1 -0
- package/lib/autoFormat/numbers/transformOrdinals.d.ts +5 -0
- package/lib/autoFormat/numbers/transformOrdinals.js +32 -0
- package/lib/autoFormat/numbers/transformOrdinals.js.map +1 -0
- package/lib/customReplace/CustomReplacePlugin.d.ts +61 -0
- package/lib/customReplace/CustomReplacePlugin.js +87 -0
- package/lib/customReplace/CustomReplacePlugin.js.map +1 -0
- package/lib/edit/EditPlugin.js +19 -1
- package/lib/edit/EditPlugin.js.map +1 -1
- package/lib/edit/inputSteps/handleEnterOnList.js +8 -1
- package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib/edit/keyboardDelete.js +1 -0
- package/lib/edit/keyboardDelete.js.map +1 -1
- package/lib/edit/keyboardInput.js +1 -0
- package/lib/edit/keyboardInput.js.map +1 -1
- package/lib/edit/keyboardTab.js +5 -5
- package/lib/edit/keyboardTab.js.map +1 -1
- package/lib/edit/tabUtils/handleTabOnList.d.ts +2 -2
- package/lib/edit/tabUtils/handleTabOnList.js +3 -3
- package/lib/edit/tabUtils/handleTabOnList.js.map +1 -1
- package/lib/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
- package/lib/edit/tabUtils/handleTabOnParagraph.js +2 -2
- package/lib/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
- package/lib/hyperlink/HyperlinkPlugin.js +4 -1
- package/lib/hyperlink/HyperlinkPlugin.js.map +1 -1
- package/lib/index.d.ts +8 -1
- package/lib/index.js +8 -1
- package/lib/index.js.map +1 -1
- package/lib/markdown/utils/setFormat.js +11 -9
- package/lib/markdown/utils/setFormat.js.map +1 -1
- package/lib/picker/PickerHandler.d.ts +112 -0
- package/lib/picker/PickerHandler.js +3 -0
- package/lib/picker/PickerHandler.js.map +1 -0
- package/lib/picker/PickerHelper.d.ts +22 -0
- package/lib/picker/PickerHelper.js +3 -0
- package/lib/picker/PickerHelper.js.map +1 -0
- package/lib/picker/PickerHelperImpl.d.ts +25 -0
- package/lib/picker/PickerHelperImpl.js +54 -0
- package/lib/picker/PickerHelperImpl.js.map +1 -0
- package/lib/picker/PickerPlugin.d.ts +54 -0
- package/lib/picker/PickerPlugin.js +217 -0
- package/lib/picker/PickerPlugin.js.map +1 -0
- package/lib/picker/getQueryString.d.ts +5 -0
- package/lib/picker/getQueryString.js +36 -0
- package/lib/picker/getQueryString.js.map +1 -0
- package/lib/pluginUtils/Rect/getDOMInsertPointRect.d.ts +7 -0
- package/lib/pluginUtils/Rect/getDOMInsertPointRect.js +57 -0
- package/lib/pluginUtils/Rect/getDOMInsertPointRect.js.map +1 -0
- package/lib/shortcut/ShortcutPlugin.js +1 -0
- package/lib/shortcut/ShortcutPlugin.js.map +1 -1
- package/lib/shortcut/shortcuts.d.ts +7 -0
- package/lib/shortcut/shortcuts.js +15 -1
- package/lib/shortcut/shortcuts.js.map +1 -1
- package/lib/shortcut/utils/setShortcutIndentationCommand.js +2 -2
- package/lib/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
- package/lib/tableEdit/OnTableEditorCreatedCallback.d.ts +5 -0
- package/lib/tableEdit/OnTableEditorCreatedCallback.js +3 -0
- package/lib/tableEdit/OnTableEditorCreatedCallback.js.map +1 -0
- package/lib/tableEdit/TableEditPlugin.d.ts +7 -1
- package/lib/tableEdit/TableEditPlugin.js +7 -2
- package/lib/tableEdit/TableEditPlugin.js.map +1 -1
- package/lib/tableEdit/editors/TableEditor.d.ts +9 -1
- package/lib/tableEdit/editors/TableEditor.js +51 -15
- package/lib/tableEdit/editors/TableEditor.js.map +1 -1
- package/lib/tableEdit/editors/features/CellResizer.d.ts +9 -1
- package/lib/tableEdit/editors/features/CellResizer.js +11 -3
- package/lib/tableEdit/editors/features/CellResizer.js.map +1 -1
- package/lib/tableEdit/editors/features/TableEditFeature.d.ts +1 -1
- package/lib/tableEdit/editors/features/TableEditFeature.js +6 -6
- package/lib/tableEdit/editors/features/TableEditFeature.js.map +1 -1
- package/lib/tableEdit/editors/features/TableEditFeatureName.d.ts +4 -0
- package/lib/tableEdit/editors/features/TableEditFeatureName.js +3 -0
- package/lib/tableEdit/editors/features/TableEditFeatureName.js.map +1 -0
- package/lib/tableEdit/editors/features/TableInserter.d.ts +10 -1
- package/lib/tableEdit/editors/features/TableInserter.js +18 -12
- package/lib/tableEdit/editors/features/TableInserter.js.map +1 -1
- package/lib/tableEdit/editors/features/TableMover.d.ts +48 -3
- package/lib/tableEdit/editors/features/TableMover.js +212 -24
- package/lib/tableEdit/editors/features/TableMover.js.map +1 -1
- package/lib/tableEdit/editors/features/TableResizer.d.ts +7 -2
- package/lib/tableEdit/editors/features/TableResizer.js +25 -6
- package/lib/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/lib/watermark/WatermarkPlugin.d.ts +1 -1
- package/lib/watermark/WatermarkPlugin.js +2 -1
- package/lib/watermark/WatermarkPlugin.js.map +1 -1
- package/lib/watermark/isModelEmptyFast.js +4 -0
- package/lib/watermark/isModelEmptyFast.js.map +1 -1
- package/lib-amd/autoFormat/AutoFormatPlugin.d.ts +15 -5
- package/lib-amd/autoFormat/AutoFormatPlugin.js +39 -5
- package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib-amd/autoFormat/link/createLink.js +2 -0
- package/lib-amd/autoFormat/link/createLink.js.map +1 -1
- package/lib-amd/autoFormat/list/keyboardListTrigger.js +7 -9
- package/lib-amd/autoFormat/list/keyboardListTrigger.js.map +1 -1
- package/lib-amd/autoFormat/numbers/transformFraction.d.ts +5 -0
- package/lib-amd/autoFormat/numbers/transformFraction.js +28 -0
- package/lib-amd/autoFormat/numbers/transformFraction.js.map +1 -0
- package/lib-amd/autoFormat/numbers/transformOrdinals.d.ts +5 -0
- package/lib-amd/autoFormat/numbers/transformOrdinals.js +33 -0
- package/lib-amd/autoFormat/numbers/transformOrdinals.js.map +1 -0
- package/lib-amd/customReplace/CustomReplacePlugin.d.ts +61 -0
- package/lib-amd/customReplace/CustomReplacePlugin.js +88 -0
- package/lib-amd/customReplace/CustomReplacePlugin.js.map +1 -0
- package/lib-amd/edit/EditPlugin.js +19 -1
- package/lib-amd/edit/EditPlugin.js.map +1 -1
- package/lib-amd/edit/inputSteps/handleEnterOnList.js +8 -2
- package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-amd/edit/keyboardDelete.js +1 -0
- package/lib-amd/edit/keyboardDelete.js.map +1 -1
- package/lib-amd/edit/keyboardInput.js +1 -0
- package/lib-amd/edit/keyboardInput.js.map +1 -1
- package/lib-amd/edit/keyboardTab.js +5 -5
- package/lib-amd/edit/keyboardTab.js.map +1 -1
- package/lib-amd/edit/tabUtils/handleTabOnList.d.ts +2 -2
- package/lib-amd/edit/tabUtils/handleTabOnList.js +3 -3
- package/lib-amd/edit/tabUtils/handleTabOnList.js.map +1 -1
- package/lib-amd/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
- package/lib-amd/edit/tabUtils/handleTabOnParagraph.js +2 -2
- package/lib-amd/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
- package/lib-amd/hyperlink/HyperlinkPlugin.js +4 -1
- package/lib-amd/hyperlink/HyperlinkPlugin.js.map +1 -1
- package/lib-amd/index.d.ts +8 -1
- package/lib-amd/index.js +6 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/markdown/utils/setFormat.js +11 -9
- package/lib-amd/markdown/utils/setFormat.js.map +1 -1
- package/lib-amd/picker/PickerHandler.d.ts +112 -0
- package/lib-amd/picker/PickerHandler.js +5 -0
- package/lib-amd/picker/PickerHandler.js.map +1 -0
- package/lib-amd/picker/PickerHelper.d.ts +22 -0
- package/lib-amd/picker/PickerHelper.js +5 -0
- package/lib-amd/picker/PickerHelper.js.map +1 -0
- package/lib-amd/picker/PickerHelperImpl.d.ts +25 -0
- package/lib-amd/picker/PickerHelperImpl.js +53 -0
- package/lib-amd/picker/PickerHelperImpl.js.map +1 -0
- package/lib-amd/picker/PickerPlugin.d.ts +54 -0
- package/lib-amd/picker/PickerPlugin.js +215 -0
- package/lib-amd/picker/PickerPlugin.js.map +1 -0
- package/lib-amd/picker/getQueryString.d.ts +5 -0
- package/lib-amd/picker/getQueryString.js +37 -0
- package/lib-amd/picker/getQueryString.js.map +1 -0
- package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.d.ts +7 -0
- package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.js +58 -0
- package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.js.map +1 -0
- package/lib-amd/shortcut/ShortcutPlugin.js +1 -0
- package/lib-amd/shortcut/ShortcutPlugin.js.map +1 -1
- package/lib-amd/shortcut/shortcuts.d.ts +7 -0
- package/lib-amd/shortcut/shortcuts.js +15 -1
- package/lib-amd/shortcut/shortcuts.js.map +1 -1
- package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js +2 -2
- package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
- package/lib-amd/tableEdit/OnTableEditorCreatedCallback.d.ts +5 -0
- package/lib-amd/tableEdit/OnTableEditorCreatedCallback.js +5 -0
- package/lib-amd/tableEdit/OnTableEditorCreatedCallback.js.map +1 -0
- package/lib-amd/tableEdit/TableEditPlugin.d.ts +7 -1
- package/lib-amd/tableEdit/TableEditPlugin.js +7 -2
- package/lib-amd/tableEdit/TableEditPlugin.js.map +1 -1
- package/lib-amd/tableEdit/editors/TableEditor.d.ts +9 -1
- package/lib-amd/tableEdit/editors/TableEditor.js +51 -15
- package/lib-amd/tableEdit/editors/TableEditor.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/CellResizer.d.ts +9 -1
- package/lib-amd/tableEdit/editors/features/CellResizer.js +11 -3
- package/lib-amd/tableEdit/editors/features/CellResizer.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/TableEditFeature.d.ts +1 -1
- package/lib-amd/tableEdit/editors/features/TableEditFeature.js +6 -6
- package/lib-amd/tableEdit/editors/features/TableEditFeature.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/TableEditFeatureName.d.ts +4 -0
- package/lib-amd/tableEdit/editors/features/TableEditFeatureName.js +5 -0
- package/lib-amd/tableEdit/editors/features/TableEditFeatureName.js.map +1 -0
- package/lib-amd/tableEdit/editors/features/TableInserter.d.ts +10 -1
- package/lib-amd/tableEdit/editors/features/TableInserter.js +18 -12
- package/lib-amd/tableEdit/editors/features/TableInserter.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/TableMover.d.ts +48 -3
- package/lib-amd/tableEdit/editors/features/TableMover.js +212 -25
- package/lib-amd/tableEdit/editors/features/TableMover.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/TableResizer.d.ts +7 -2
- package/lib-amd/tableEdit/editors/features/TableResizer.js +25 -7
- package/lib-amd/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/lib-amd/watermark/WatermarkPlugin.d.ts +1 -1
- package/lib-amd/watermark/WatermarkPlugin.js +2 -1
- package/lib-amd/watermark/WatermarkPlugin.js.map +1 -1
- package/lib-amd/watermark/isModelEmptyFast.js +4 -0
- package/lib-amd/watermark/isModelEmptyFast.js.map +1 -1
- package/lib-mjs/autoFormat/AutoFormatPlugin.d.ts +15 -5
- package/lib-mjs/autoFormat/AutoFormatPlugin.js +41 -4
- package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib-mjs/autoFormat/link/createLink.js +3 -1
- package/lib-mjs/autoFormat/link/createLink.js.map +1 -1
- package/lib-mjs/autoFormat/list/keyboardListTrigger.js +7 -9
- package/lib-mjs/autoFormat/list/keyboardListTrigger.js.map +1 -1
- package/lib-mjs/autoFormat/numbers/transformFraction.d.ts +5 -0
- package/lib-mjs/autoFormat/numbers/transformFraction.js +23 -0
- package/lib-mjs/autoFormat/numbers/transformFraction.js.map +1 -0
- package/lib-mjs/autoFormat/numbers/transformOrdinals.d.ts +5 -0
- package/lib-mjs/autoFormat/numbers/transformOrdinals.js +28 -0
- package/lib-mjs/autoFormat/numbers/transformOrdinals.js.map +1 -0
- package/lib-mjs/customReplace/CustomReplacePlugin.d.ts +61 -0
- package/lib-mjs/customReplace/CustomReplacePlugin.js +84 -0
- package/lib-mjs/customReplace/CustomReplacePlugin.js.map +1 -0
- package/lib-mjs/edit/EditPlugin.js +19 -1
- package/lib-mjs/edit/EditPlugin.js.map +1 -1
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js +8 -1
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-mjs/edit/keyboardDelete.js +1 -0
- package/lib-mjs/edit/keyboardDelete.js.map +1 -1
- package/lib-mjs/edit/keyboardInput.js +1 -0
- package/lib-mjs/edit/keyboardInput.js.map +1 -1
- package/lib-mjs/edit/keyboardTab.js +5 -5
- package/lib-mjs/edit/keyboardTab.js.map +1 -1
- package/lib-mjs/edit/tabUtils/handleTabOnList.d.ts +2 -2
- package/lib-mjs/edit/tabUtils/handleTabOnList.js +3 -3
- package/lib-mjs/edit/tabUtils/handleTabOnList.js.map +1 -1
- package/lib-mjs/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
- package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js +2 -2
- package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
- package/lib-mjs/hyperlink/HyperlinkPlugin.js +4 -1
- package/lib-mjs/hyperlink/HyperlinkPlugin.js.map +1 -1
- package/lib-mjs/index.d.ts +8 -1
- package/lib-mjs/index.js +4 -1
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/markdown/utils/setFormat.js +11 -9
- package/lib-mjs/markdown/utils/setFormat.js.map +1 -1
- package/lib-mjs/picker/PickerHandler.d.ts +112 -0
- package/lib-mjs/picker/PickerHandler.js +2 -0
- package/lib-mjs/picker/PickerHandler.js.map +1 -0
- package/lib-mjs/picker/PickerHelper.d.ts +22 -0
- package/lib-mjs/picker/PickerHelper.js +2 -0
- package/lib-mjs/picker/PickerHelper.js.map +1 -0
- package/lib-mjs/picker/PickerHelperImpl.d.ts +25 -0
- package/lib-mjs/picker/PickerHelperImpl.js +51 -0
- package/lib-mjs/picker/PickerHelperImpl.js.map +1 -0
- package/lib-mjs/picker/PickerPlugin.d.ts +54 -0
- package/lib-mjs/picker/PickerPlugin.js +214 -0
- package/lib-mjs/picker/PickerPlugin.js.map +1 -0
- package/lib-mjs/picker/getQueryString.d.ts +5 -0
- package/lib-mjs/picker/getQueryString.js +32 -0
- package/lib-mjs/picker/getQueryString.js.map +1 -0
- package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.d.ts +7 -0
- package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.js +53 -0
- package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.js.map +1 -0
- package/lib-mjs/shortcut/ShortcutPlugin.js +2 -1
- package/lib-mjs/shortcut/ShortcutPlugin.js.map +1 -1
- package/lib-mjs/shortcut/shortcuts.d.ts +7 -0
- package/lib-mjs/shortcut/shortcuts.js +14 -0
- package/lib-mjs/shortcut/shortcuts.js.map +1 -1
- package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js +2 -2
- package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
- package/lib-mjs/tableEdit/OnTableEditorCreatedCallback.d.ts +5 -0
- package/lib-mjs/tableEdit/OnTableEditorCreatedCallback.js +2 -0
- package/lib-mjs/tableEdit/OnTableEditorCreatedCallback.js.map +1 -0
- package/lib-mjs/tableEdit/TableEditPlugin.d.ts +7 -1
- package/lib-mjs/tableEdit/TableEditPlugin.js +7 -2
- package/lib-mjs/tableEdit/TableEditPlugin.js.map +1 -1
- package/lib-mjs/tableEdit/editors/TableEditor.d.ts +9 -1
- package/lib-mjs/tableEdit/editors/TableEditor.js +52 -16
- package/lib-mjs/tableEdit/editors/TableEditor.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/CellResizer.d.ts +9 -1
- package/lib-mjs/tableEdit/editors/features/CellResizer.js +10 -2
- package/lib-mjs/tableEdit/editors/features/CellResizer.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/TableEditFeature.d.ts +1 -1
- package/lib-mjs/tableEdit/editors/features/TableEditFeature.js +6 -6
- package/lib-mjs/tableEdit/editors/features/TableEditFeature.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/TableEditFeatureName.d.ts +4 -0
- package/lib-mjs/tableEdit/editors/features/TableEditFeatureName.js +2 -0
- package/lib-mjs/tableEdit/editors/features/TableEditFeatureName.js.map +1 -0
- package/lib-mjs/tableEdit/editors/features/TableInserter.d.ts +10 -1
- package/lib-mjs/tableEdit/editors/features/TableInserter.js +17 -11
- package/lib-mjs/tableEdit/editors/features/TableInserter.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/TableMover.d.ts +48 -3
- package/lib-mjs/tableEdit/editors/features/TableMover.js +209 -24
- package/lib-mjs/tableEdit/editors/features/TableMover.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/TableResizer.d.ts +7 -2
- package/lib-mjs/tableEdit/editors/features/TableResizer.js +23 -4
- package/lib-mjs/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/lib-mjs/watermark/WatermarkPlugin.d.ts +1 -1
- package/lib-mjs/watermark/WatermarkPlugin.js +2 -1
- package/lib-mjs/watermark/WatermarkPlugin.js.map +1 -1
- package/lib-mjs/watermark/isModelEmptyFast.js +4 -0
- package/lib-mjs/watermark/isModelEmptyFast.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-dom"], function (require, exports, roosterjs_content_model_dom_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getDOMInsertPointRect = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* Get bounding rect of the given DOM insert point
|
|
7
|
+
* @param doc The document object
|
|
8
|
+
* @param pos The input DOM insert point
|
|
9
|
+
*/
|
|
10
|
+
function getDOMInsertPointRect(doc, pos) {
|
|
11
|
+
var _a;
|
|
12
|
+
var node = pos.node, offset = pos.offset;
|
|
13
|
+
var range = doc.createRange();
|
|
14
|
+
range.setStart(node, offset);
|
|
15
|
+
// 1) try to get rect using range.getBoundingClientRect()
|
|
16
|
+
var rect = (0, roosterjs_content_model_dom_1.normalizeRect)(range.getBoundingClientRect());
|
|
17
|
+
if (rect) {
|
|
18
|
+
return rect;
|
|
19
|
+
}
|
|
20
|
+
// 2) try to get rect using range.getClientRects
|
|
21
|
+
while (node.lastChild) {
|
|
22
|
+
if (offset == node.childNodes.length) {
|
|
23
|
+
node = node.lastChild;
|
|
24
|
+
offset = node.childNodes.length;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
node = node.childNodes[offset];
|
|
28
|
+
offset = 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
var rects = range.getClientRects && range.getClientRects();
|
|
32
|
+
rect = rects && rects.length == 1 ? (0, roosterjs_content_model_dom_1.normalizeRect)(rects[0]) : null;
|
|
33
|
+
if (rect) {
|
|
34
|
+
return rect;
|
|
35
|
+
}
|
|
36
|
+
// 3) if node is text node, try inserting a SPAN and get the rect of SPAN for others
|
|
37
|
+
if ((0, roosterjs_content_model_dom_1.isNodeOfType)(node, 'TEXT_NODE')) {
|
|
38
|
+
var span = node.ownerDocument.createElement('span');
|
|
39
|
+
span.textContent = '\u200b';
|
|
40
|
+
range.insertNode(span);
|
|
41
|
+
rect = (0, roosterjs_content_model_dom_1.normalizeRect)(span.getBoundingClientRect());
|
|
42
|
+
(_a = span.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(span);
|
|
43
|
+
if (rect) {
|
|
44
|
+
return rect;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// 4) try getBoundingClientRect on element
|
|
48
|
+
if ((0, roosterjs_content_model_dom_1.isNodeOfType)(node, 'ELEMENT_NODE') && node.getBoundingClientRect) {
|
|
49
|
+
rect = (0, roosterjs_content_model_dom_1.normalizeRect)(node.getBoundingClientRect());
|
|
50
|
+
if (rect) {
|
|
51
|
+
return rect;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
exports.getDOMInsertPointRect = getDOMInsertPointRect;
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=getDOMInsertPointRect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDOMInsertPointRect.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/pluginUtils/Rect/getDOMInsertPointRect.ts"],"names":[],"mappings":";;;;IAGA;;;;OAIG;IACH,SAAgB,qBAAqB,CAAC,GAAa,EAAE,GAAmB;;QAC9D,IAAA,IAAI,GAAa,GAAG,KAAhB,EAAE,MAAM,GAAK,GAAG,OAAR,CAAS;QAC3B,IAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QAEhC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAE7B,yDAAyD;QACzD,IAAI,IAAI,GAAG,IAAA,2CAAa,EAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAExD,IAAI,IAAI,EAAE;YACN,OAAO,IAAI,CAAC;SACf;QAED,gDAAgD;QAChD,OAAO,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,MAAM,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;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAtDD,sDAsDC","sourcesContent":["import { isNodeOfType, normalizeRect } from 'roosterjs-content-model-dom';\nimport type { DOMInsertPoint, Rect } from 'roosterjs-content-model-types';\n\n/**\n * Get bounding rect of the given DOM insert point\n * @param doc The document object\n * @param pos The input DOM insert point\n */\nexport function getDOMInsertPointRect(doc: Document, pos: DOMInsertPoint): Rect | null {\n let { node, offset } = pos;\n const range = doc.createRange();\n\n range.setStart(node, offset);\n\n // 1) try to get rect using range.getBoundingClientRect()\n let rect = normalizeRect(range.getBoundingClientRect());\n\n if (rect) {\n return rect;\n }\n\n // 2) try to get rect using range.getClientRects\n while (node.lastChild) {\n if (offset == node.childNodes.length) {\n node = node.lastChild;\n offset = node.childNodes.length;\n } else {\n node = node.childNodes[offset];\n offset = 0;\n }\n }\n\n const rects = range.getClientRects && range.getClientRects();\n rect = rects && rects.length == 1 ? normalizeRect(rects[0]) : null;\n if (rect) {\n return rect;\n }\n\n // 3) if node is text node, try inserting a SPAN and get the rect of SPAN for others\n if (isNodeOfType(node, 'TEXT_NODE')) {\n const span = node.ownerDocument.createElement('span');\n\n span.textContent = '\\u200b';\n range.insertNode(span);\n rect = normalizeRect(span.getBoundingClientRect());\n span.parentNode?.removeChild(span);\n\n if (rect) {\n return rect;\n }\n }\n\n // 4) try getBoundingClientRect on element\n if (isNodeOfType(node, 'ELEMENT_NODE') && node.getBoundingClientRect) {\n rect = normalizeRect(node.getBoundingClientRect());\n\n if (rect) {\n return rect;\n }\n }\n\n return null;\n}\n"]}
|
|
@@ -10,6 +10,7 @@ define(["require", "exports", "roosterjs-content-model-dom", "./shortcuts"], fun
|
|
|
10
10
|
shortcuts_1.ShortcutUndo,
|
|
11
11
|
shortcuts_1.ShortcutUndo2,
|
|
12
12
|
shortcuts_1.ShortcutRedo,
|
|
13
|
+
shortcuts_1.ShortcutRedoAlt,
|
|
13
14
|
shortcuts_1.ShortcutRedoMacOS,
|
|
14
15
|
shortcuts_1.ShortcutBullet,
|
|
15
16
|
shortcuts_1.ShortcutNumbering,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShortcutPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/shortcut/ShortcutPlugin.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"ShortcutPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/shortcut/ShortcutPlugin.ts"],"names":[],"mappings":";;;;IA0BA,IAAM,gBAAgB,GAAsB;QACxC,wBAAY;QACZ,0BAAc;QACd,6BAAiB;QACjB,+BAAmB;QACnB,wBAAY;QACZ,yBAAa;QACb,wBAAY;QACZ,2BAAe;QACf,6BAAiB;QACjB,0BAAc;QACd,6BAAiB;QACjB,gCAAoB;QACpB,gCAAoB;QACpB,8BAAkB;QAClB,+BAAmB;KACtB,CAAC;IACF,IAAM,eAAe,GAAG,wBAAwB,CAAC;IAEjD;;OAEG;IACH;QAII;;;WAGG;QACH,wBAAoB,SAA+C;YAA/C,0BAAA,EAAA,4BAA+C;YAA/C,cAAS,GAAT,SAAS,CAAsC;YAP3D,WAAM,GAAmB,IAAI,CAAC;YAC9B,UAAK,GAAG,KAAK,CAAC;QAMgD,CAAC;QAEvE;;WAEG;QACH,gCAAO,GAAP;YACI,OAAO,UAAU,CAAC;QACtB,CAAC;QAED;;;;;WAKG;QACH,mCAAU,GAAV,UAAW,MAAe;YACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC;QACtD,CAAC;QAED;;;;WAIG;QACH,gCAAO,GAAP;YACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACvB,CAAC;QAED;;;;;;;WAOG;QACH,mDAA0B,GAA1B,UAA2B,KAAkB;YACzC,OAAO,CACH,KAAK,CAAC,SAAS,IAAI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,IAAI,CAAC;aACnB;QACL,CAAC;QAEO,sCAAa,GAArB,UAAsB,WAAkC,EAAE,KAAoB;YAClE,IAAA,OAAO,GAAuC,KAAK,QAA5C,EAAE,MAAM,GAA+B,KAAK,OAApC,EAAE,QAAQ,GAAqB,KAAK,SAA1B,EAAE,KAAK,GAAc,KAAK,MAAnB,EAAE,OAAO,GAAK,KAAK,QAAV,CAAW;YAC5D,IAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;YAClD,IAAM,aAAa,GACf,CAAC,WAAW,CAAC,WAAW,IAAI,MAAM,IAAI,UAAU,IAAI,CAAC,MAAM,CAAC;gBAC5D,CAAC,WAAW,CAAC,WAAW,IAAI,KAAK,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC;YAEhE,OAAO,aAAa,IAAI,QAAQ,IAAI,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,KAAK,IAAI,KAAK,CAAC;QAC3F,CAAC;QACL,qBAAC;IAAD,CAAC,AA3GD,IA2GC;IA3GY,wCAAc","sourcesContent":["import { cacheGetEventData } from 'roosterjs-content-model-dom';\nimport type { ShortcutCommand, ShortcutKeyDefinition } from './ShortcutCommand';\nimport {\n ShortcutBold,\n ShortcutBullet,\n ShortcutClearFormat,\n ShortcutDecreaseFont,\n ShortcutIncreaseFont,\n ShortcutIndentList,\n ShortcutItalic,\n ShortcutNumbering,\n ShortcutOutdentList,\n ShortcutRedo,\n ShortcutRedoAlt,\n ShortcutRedoMacOS,\n ShortcutUnderline,\n ShortcutUndo,\n ShortcutUndo2,\n} from './shortcuts';\nimport type {\n EditorPlugin,\n IEditor,\n KeyDownEvent,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\nconst defaultShortcuts: ShortcutCommand[] = [\n ShortcutBold,\n ShortcutItalic,\n ShortcutUnderline,\n ShortcutClearFormat,\n ShortcutUndo,\n ShortcutUndo2,\n ShortcutRedo,\n ShortcutRedoAlt,\n ShortcutRedoMacOS,\n ShortcutBullet,\n ShortcutNumbering,\n ShortcutIncreaseFont,\n ShortcutDecreaseFont,\n ShortcutIndentList,\n ShortcutOutdentList,\n];\nconst CommandCacheKey = '__ShortcutCommandCache';\n\n/**\n * Shortcut plugin hook on the specified shortcut keys and trigger related format API\n */\nexport class ShortcutPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private isMac = false;\n\n /**\n * Create a new instance of ShortcutPlugin\n * @param [shortcuts=defaultShortcuts] Allowed commands\n */\n constructor(private shortcuts: ShortcutCommand[] = defaultShortcuts) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'Shortcut';\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 this.isMac = !!this.editor.getEnvironment().isMac;\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 }\n\n /**\n * Check if the plugin should handle the given event exclusively.\n * Handle an event exclusively means other plugin will not receive this event in\n * onPluginEvent method.\n * If two plugins will return true in willHandleEventExclusively() for the same event,\n * the final result depends on the order of the plugins are added into editor\n * @param event The event to check:\n */\n willHandleEventExclusively(event: PluginEvent) {\n return (\n event.eventType == 'keyDown' &&\n (event.rawEvent.ctrlKey || event.rawEvent.altKey || event.rawEvent.metaKey) &&\n !!this.cacheGetCommand(event)\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.editor && event.eventType == 'keyDown') {\n const command = this.cacheGetCommand(event);\n\n if (command) {\n command.onClick(this.editor);\n event.rawEvent.preventDefault();\n }\n }\n }\n\n private cacheGetCommand(event: KeyDownEvent) {\n return cacheGetEventData(event, CommandCacheKey, event => {\n const editor = this.editor;\n\n return (\n editor &&\n this.shortcuts.filter(\n command =>\n this.matchOS(command.environment) &&\n this.matchShortcut(command.shortcutKey, event.rawEvent)\n )[0]\n );\n });\n }\n\n private matchOS(environment?: 'all' | 'mac' | 'nonMac') {\n switch (environment) {\n case 'mac':\n return this.isMac;\n\n case 'nonMac':\n return !this.isMac;\n\n default:\n return true;\n }\n }\n\n private matchShortcut(shortcutKey: ShortcutKeyDefinition, event: KeyboardEvent) {\n const { ctrlKey, altKey, shiftKey, which, metaKey } = event;\n const ctrlOrMeta = this.isMac ? metaKey : ctrlKey;\n const matchModifier =\n (shortcutKey.modifierKey == 'ctrl' && ctrlOrMeta && !altKey) ||\n (shortcutKey.modifierKey == 'alt' && altKey && !ctrlOrMeta);\n\n return matchModifier && shiftKey == shortcutKey.shiftKey && shortcutKey.which == which;\n }\n}\n"]}
|
|
@@ -42,11 +42,18 @@ export declare const ShortcutUndo2: ShortcutCommand;
|
|
|
42
42
|
*/
|
|
43
43
|
export declare const ShortcutRedo: ShortcutCommand;
|
|
44
44
|
/**
|
|
45
|
+
* @deprecated
|
|
45
46
|
* Shortcut command for Redo 2
|
|
46
47
|
* Windows: N/A
|
|
47
48
|
* MacOS: Meta + Shift + Z
|
|
48
49
|
*/
|
|
49
50
|
export declare const ShortcutRedoMacOS: ShortcutCommand;
|
|
51
|
+
/**
|
|
52
|
+
* Shortcut command for Redo 3
|
|
53
|
+
* Windows: Ctrl + Shift + Z
|
|
54
|
+
* MacOS: Meta + Shift + Z
|
|
55
|
+
*/
|
|
56
|
+
export declare const ShortcutRedoAlt: ShortcutCommand;
|
|
50
57
|
/**
|
|
51
58
|
* Shortcut command for Bullet List
|
|
52
59
|
* Windows: Ctrl + . (Period)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "roosterjs-content-model-core", "./utils/setShortcutIndentationCommand", "roosterjs-content-model-api"], function (require, exports, roosterjs_content_model_core_1, setShortcutIndentationCommand_1, roosterjs_content_model_api_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ShortcutOutdentList = exports.ShortcutIndentList = exports.ShortcutDecreaseFont = exports.ShortcutIncreaseFont = exports.ShortcutNumbering = exports.ShortcutBullet = exports.ShortcutRedoMacOS = exports.ShortcutRedo = exports.ShortcutUndo2 = exports.ShortcutUndo = exports.ShortcutClearFormat = exports.ShortcutUnderline = exports.ShortcutItalic = exports.ShortcutBold = void 0;
|
|
4
|
+
exports.ShortcutOutdentList = exports.ShortcutIndentList = exports.ShortcutDecreaseFont = exports.ShortcutIncreaseFont = exports.ShortcutNumbering = exports.ShortcutBullet = exports.ShortcutRedoAlt = exports.ShortcutRedoMacOS = exports.ShortcutRedo = exports.ShortcutUndo2 = exports.ShortcutUndo = exports.ShortcutClearFormat = exports.ShortcutUnderline = exports.ShortcutItalic = exports.ShortcutBold = void 0;
|
|
5
5
|
var Keys;
|
|
6
6
|
(function (Keys) {
|
|
7
7
|
Keys[Keys["BACKSPACE"] = 8] = "BACKSPACE";
|
|
@@ -112,6 +112,7 @@ define(["require", "exports", "roosterjs-content-model-core", "./utils/setShortc
|
|
|
112
112
|
environment: 'nonMac',
|
|
113
113
|
};
|
|
114
114
|
/**
|
|
115
|
+
* @deprecated
|
|
115
116
|
* Shortcut command for Redo 2
|
|
116
117
|
* Windows: N/A
|
|
117
118
|
* MacOS: Meta + Shift + Z
|
|
@@ -125,6 +126,19 @@ define(["require", "exports", "roosterjs-content-model-core", "./utils/setShortc
|
|
|
125
126
|
onClick: function (editor) { return (0, roosterjs_content_model_core_1.redo)(editor); },
|
|
126
127
|
environment: 'mac',
|
|
127
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* Shortcut command for Redo 3
|
|
131
|
+
* Windows: Ctrl + Shift + Z
|
|
132
|
+
* MacOS: Meta + Shift + Z
|
|
133
|
+
*/
|
|
134
|
+
exports.ShortcutRedoAlt = {
|
|
135
|
+
shortcutKey: {
|
|
136
|
+
modifierKey: 'ctrl',
|
|
137
|
+
shiftKey: true,
|
|
138
|
+
which: 90 /* Z */,
|
|
139
|
+
},
|
|
140
|
+
onClick: function (editor) { return (0, roosterjs_content_model_core_1.redo)(editor); },
|
|
141
|
+
};
|
|
128
142
|
/**
|
|
129
143
|
* Shortcut command for Bullet List
|
|
130
144
|
* Windows: Ctrl + . (Period)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shortcuts.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/shortcut/shortcuts.ts"],"names":[],"mappings":";;;;IAaA,IAAW,IAaV;IAbD,WAAW,IAAI;QACX,yCAAa,CAAA;QACb,kCAAU,CAAA;QACV,0BAAM,CAAA;QACN,0BAAM,CAAA;QACN,0BAAM,CAAA;QACN,0BAAM,CAAA;QACN,0BAAM,CAAA;QACN,mCAAW,CAAA;QACX,qCAAY,CAAA;QACZ,mDAAmB,CAAA;QACnB,4CAAe,CAAA;QACf,0CAAc,CAAA;IAClB,CAAC,EAbU,IAAI,KAAJ,IAAI,QAad;IAED;;;;OAIG;IACU,QAAA,YAAY,GAAoB;QACzC,WAAW,EAAE;YACT,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,KAAK;YACf,KAAK,YAAQ;SAChB;QACD,OAAO,EAAE,UAAA,MAAM,IAAI,OAAA,IAAA,wCAAU,EAAC,MAAM,CAAC,EAAlB,CAAkB;KACxC,CAAC;IAEF;;;;OAIG;IACU,QAAA,cAAc,GAAoB;QAC3C,WAAW,EAAE;YACT,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,KAAK;YACf,KAAK,YAAQ;SAChB;QACD,OAAO,EAAE,UAAA,MAAM,IAAI,OAAA,IAAA,0CAAY,EAAC,MAAM,CAAC,EAApB,CAAoB;KAC1C,CAAC;IAEF;;;;OAIG;IACU,QAAA,iBAAiB,GA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E,QAAQ,CAAC,CAAC;QACpD,CAAC;QACD,WAAW,EAAE,QAAQ;KACxB,CAAC;IAEF;;;;OAIG;IACU,QAAA,mBAAmB,GAAoB;QAChD,WAAW,EAAE;YACT,WAAW,EAAE,KAAK;YAClB,QAAQ,EAAE,IAAI;YACd,KAAK,oBAAgB;SACxB;QACD,OAAO,EAAE,UAAA,MAAM;YACX,IAAA,6DAA6B,EAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACrD,CAAC;QACD,WAAW,EAAE,QAAQ;KACxB,CAAC","sourcesContent":["import { redo, undo } from 'roosterjs-content-model-core';\nimport { setShortcutIndentationCommand } from './utils/setShortcutIndentationCommand';\nimport {\n changeFontSize,\n clearFormat,\n toggleBold,\n toggleBullet,\n toggleItalic,\n toggleNumbering,\n toggleUnderline,\n} from 'roosterjs-content-model-api';\nimport type { ShortcutCommand } from './ShortcutCommand';\n\nconst enum Keys {\n BACKSPACE = 8,\n SPACE = 32,\n B = 66,\n I = 73,\n U = 85,\n Y = 89,\n Z = 90,\n COMMA = 188,\n PERIOD = 190,\n FORWARD_SLASH = 191,\n ArrowRight = 39,\n ArrowLeft = 37,\n}\n\n/**\n * Shortcut command for Bold\n * Windows: Ctrl + B\n * MacOS: Meta + B\n */\nexport const ShortcutBold: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.B,\n },\n onClick: editor => toggleBold(editor),\n};\n\n/**\n * Shortcut command for Italic\n * Windows: Ctrl + I\n * MacOS: Meta + I\n */\nexport const ShortcutItalic: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.I,\n },\n onClick: editor => toggleItalic(editor),\n};\n\n/**\n * Shortcut command for Underline\n * Windows: Ctrl + U\n * MacOS: Meta + U\n */\nexport const ShortcutUnderline: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.U,\n },\n onClick: editor => toggleUnderline(editor),\n};\n\n/**\n * Shortcut command for Clear Format\n * Windows: Ctrl + Space\n * MacOS: N/A\n */\nexport const ShortcutClearFormat: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.SPACE,\n },\n onClick: editor => clearFormat(editor),\n environment: 'nonMac',\n};\n\n/**\n * Shortcut command for Undo 1\n * Windows: Ctrl + Z\n * MacOS: Meta + Z\n */\nexport const ShortcutUndo: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.Z,\n },\n onClick: editor => undo(editor),\n};\n\n/**\n * Shortcut command for Undo 2\n * Windows: Alt + Backspace\n * MacOS: N/A\n */\nexport const ShortcutUndo2: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'alt',\n shiftKey: false,\n which: Keys.BACKSPACE,\n },\n onClick: editor => undo(editor),\n environment: 'nonMac',\n};\n\n/**\n * Shortcut command for Redo 1\n * Windows: Ctrl + Y\n * MacOS: N/A\n */\nexport const ShortcutRedo: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.Y,\n },\n onClick: editor => redo(editor),\n environment: 'nonMac',\n};\n\n/**\n * @deprecated\n * Shortcut command for Redo 2\n * Windows: N/A\n * MacOS: Meta + Shift + Z\n */\nexport const ShortcutRedoMacOS: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: true,\n which: Keys.Z,\n },\n onClick: editor => redo(editor),\n environment: 'mac',\n};\n\n/**\n * Shortcut command for Redo 3\n * Windows: Ctrl + Shift + Z\n * MacOS: Meta + Shift + Z\n */\nexport const ShortcutRedoAlt: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: true,\n which: Keys.Z,\n },\n onClick: editor => redo(editor),\n};\n\n/**\n * Shortcut command for Bullet List\n * Windows: Ctrl + . (Period)\n * MacOS: Meta + . (Period)\n */\nexport const ShortcutBullet: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.PERIOD,\n },\n onClick: editor => toggleBullet(editor),\n};\n\n/**\n * Shortcut command for Numbering List\n * Windows: Ctrl + / (Forward slash)\n * MacOS: Meta + / (Forward slash)\n */\nexport const ShortcutNumbering: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.FORWARD_SLASH,\n },\n onClick: editor => toggleNumbering(editor),\n};\n\n/**\n * Shortcut command for Increase Font\n * Windows: Ctrl + Shift + . (Period)\n * MacOS: Meta + Shift + . (Period)\n */\nexport const ShortcutIncreaseFont: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: true,\n which: Keys.PERIOD,\n },\n onClick: editor => changeFontSize(editor, 'increase'),\n};\n\n/**\n * Shortcut command for Decrease Font\n * Windows: Ctrl + Shift + , (Comma)\n * MacOS: Meta + Shift + , (Comma)\n */\nexport const ShortcutDecreaseFont: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: true,\n which: Keys.COMMA,\n },\n onClick: editor => changeFontSize(editor, 'decrease'),\n};\n\n/**\n * Shortcut command for Intent list\n * Windows: Alt + Shift + Arrow Right\n * MacOS: N/A\n */\nexport const ShortcutIndentList: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'alt',\n shiftKey: true,\n which: Keys.ArrowRight,\n },\n onClick: editor => {\n setShortcutIndentationCommand(editor, 'indent');\n },\n environment: 'nonMac',\n};\n\n/**\n * Shortcut command for Outdent list\n * Windows: Alt + Shift + Arrow Left\n * MacOS: N/A\n */\nexport const ShortcutOutdentList: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'alt',\n shiftKey: true,\n which: Keys.ArrowLeft,\n },\n onClick: editor => {\n setShortcutIndentationCommand(editor, 'outdent');\n },\n environment: 'nonMac',\n};\n"]}
|
|
@@ -6,12 +6,12 @@ define(["require", "exports", "roosterjs-content-model-dom", "roosterjs-content-
|
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
8
|
function setShortcutIndentationCommand(editor, operation) {
|
|
9
|
-
editor.formatContentModel(function (model) {
|
|
9
|
+
editor.formatContentModel(function (model, context) {
|
|
10
10
|
var listItem = (0, roosterjs_content_model_dom_1.getFirstSelectedListItem)(model);
|
|
11
11
|
if (listItem &&
|
|
12
12
|
listItem.blocks[0].blockType == 'Paragraph' &&
|
|
13
13
|
listItem.blocks[0].segments[0].segmentType == 'SelectionMarker') {
|
|
14
|
-
(0, roosterjs_content_model_api_1.setModelIndentation)(model, operation);
|
|
14
|
+
(0, roosterjs_content_model_api_1.setModelIndentation)(model, operation, undefined /*length*/, context);
|
|
15
15
|
return true;
|
|
16
16
|
}
|
|
17
17
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setShortcutIndentationCommand.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/shortcut/utils/setShortcutIndentationCommand.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,6BAA6B,CAAC,MAAe,EAAE,SAA+B;QAC1F,MAAM,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"setShortcutIndentationCommand.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/shortcut/utils/setShortcutIndentationCommand.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,6BAA6B,CAAC,MAAe,EAAE,SAA+B;QAC1F,MAAM,CAAC,kBAAkB,CAAC,UAAC,KAAK,EAAE,OAAO;YACrC,IAAM,QAAQ,GAAG,IAAA,sDAAwB,EAAC,KAAK,CAAC,CAAC;YAEjD,IACI,QAAQ;gBACR,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,WAAW;gBAC3C,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,EACjE;gBACE,IAAA,iDAAmB,EAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;gBACrE,OAAO,IAAI,CAAC;aACf;YACD,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;IACP,CAAC;IAdD,sEAcC","sourcesContent":["import { getFirstSelectedListItem } from 'roosterjs-content-model-dom';\nimport { setModelIndentation } from 'roosterjs-content-model-api';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function setShortcutIndentationCommand(editor: IEditor, operation: 'indent' | 'outdent') {\n editor.formatContentModel((model, context) => {\n const listItem = getFirstSelectedListItem(model);\n\n if (\n listItem &&\n listItem.blocks[0].blockType == 'Paragraph' &&\n listItem.blocks[0].segments[0].segmentType == 'SelectionMarker'\n ) {\n setModelIndentation(model, operation, undefined /*length*/, context);\n return true;\n }\n return false;\n });\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TableEditFeatureName } from './editors/features/TableEditFeatureName';
|
|
2
|
+
/**
|
|
3
|
+
* Optional callback when creating a TableEditPlugin, allows to customize the Selectors element as required.
|
|
4
|
+
*/
|
|
5
|
+
export declare type OnTableEditorCreatedCallback = (featureType: TableEditFeatureName, element: HTMLElement) => () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnTableEditorCreatedCallback.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/OnTableEditorCreatedCallback.ts"],"names":[],"mappings":"","sourcesContent":["import type { TableEditFeatureName } from './editors/features/TableEditFeatureName';\n\n/**\n * Optional callback when creating a TableEditPlugin, allows to customize the Selectors element as required.\n */\nexport type OnTableEditorCreatedCallback = (\n featureType: TableEditFeatureName,\n element: HTMLElement\n) => () => void;\n"]}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import type { TableEditFeatureName } from './editors/features/TableEditFeatureName';
|
|
2
|
+
import type { OnTableEditorCreatedCallback } from './OnTableEditorCreatedCallback';
|
|
1
3
|
import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
|
|
2
4
|
/**
|
|
3
5
|
* TableEdit plugin, provides the ability to resize a table by drag-and-drop
|
|
4
6
|
*/
|
|
5
7
|
export declare class TableEditPlugin implements EditorPlugin {
|
|
6
8
|
private anchorContainerSelector?;
|
|
9
|
+
private onTableEditorCreated?;
|
|
10
|
+
private disableFeatures?;
|
|
7
11
|
private editor;
|
|
8
12
|
private onMouseMoveDisposer;
|
|
9
13
|
private tableRectMap;
|
|
@@ -13,8 +17,10 @@ export declare class TableEditPlugin implements EditorPlugin {
|
|
|
13
17
|
* @param anchorContainerSelector An optional selector string to specify the container to host the plugin.
|
|
14
18
|
* The container must not be affected by transform: scale(), otherwise the position calculation will be wrong.
|
|
15
19
|
* If not specified, the plugin will be inserted in document.body
|
|
20
|
+
* @param onTableEditorCreated An optional callback to customize the Table Editors elements when created.
|
|
21
|
+
* @param disableFeatures An optional array of TableEditFeatures to disable
|
|
16
22
|
*/
|
|
17
|
-
constructor(anchorContainerSelector?: string | undefined);
|
|
23
|
+
constructor(anchorContainerSelector?: string | undefined, onTableEditorCreated?: OnTableEditorCreatedCallback | undefined, disableFeatures?: TableEditFeatureName[] | undefined);
|
|
18
24
|
/**
|
|
19
25
|
* Get a friendly name of this plugin
|
|
20
26
|
*/
|
|
@@ -12,10 +12,14 @@ define(["require", "exports", "roosterjs-content-model-dom", "./editors/TableEdi
|
|
|
12
12
|
* @param anchorContainerSelector An optional selector string to specify the container to host the plugin.
|
|
13
13
|
* The container must not be affected by transform: scale(), otherwise the position calculation will be wrong.
|
|
14
14
|
* If not specified, the plugin will be inserted in document.body
|
|
15
|
+
* @param onTableEditorCreated An optional callback to customize the Table Editors elements when created.
|
|
16
|
+
* @param disableFeatures An optional array of TableEditFeatures to disable
|
|
15
17
|
*/
|
|
16
|
-
function TableEditPlugin(anchorContainerSelector) {
|
|
18
|
+
function TableEditPlugin(anchorContainerSelector, onTableEditorCreated, disableFeatures) {
|
|
17
19
|
var _this = this;
|
|
18
20
|
this.anchorContainerSelector = anchorContainerSelector;
|
|
21
|
+
this.onTableEditorCreated = onTableEditorCreated;
|
|
22
|
+
this.disableFeatures = disableFeatures;
|
|
19
23
|
this.editor = null;
|
|
20
24
|
this.onMouseMoveDisposer = null;
|
|
21
25
|
this.tableRectMap = null;
|
|
@@ -93,6 +97,7 @@ define(["require", "exports", "roosterjs-content-model-dom", "./editors/TableEdi
|
|
|
93
97
|
this.disposeTableEditor();
|
|
94
98
|
this.editor = null;
|
|
95
99
|
this.onMouseMoveDisposer = null;
|
|
100
|
+
this.onTableEditorCreated = undefined;
|
|
96
101
|
};
|
|
97
102
|
/**
|
|
98
103
|
* Handle events triggered from editor
|
|
@@ -123,7 +128,7 @@ define(["require", "exports", "roosterjs-content-model-dom", "./editors/TableEdi
|
|
|
123
128
|
var container = this.anchorContainerSelector
|
|
124
129
|
? this.editor.getDocument().querySelector(this.anchorContainerSelector)
|
|
125
130
|
: undefined;
|
|
126
|
-
this.tableEditor = new TableEditor_1.TableEditor(this.editor, table, this.invalidateTableRects, (0, roosterjs_content_model_dom_1.isNodeOfType)(container, 'ELEMENT_NODE') ? container : undefined, event === null || event === void 0 ? void 0 : event.currentTarget);
|
|
131
|
+
this.tableEditor = new TableEditor_1.TableEditor(this.editor, table, this.invalidateTableRects, (0, roosterjs_content_model_dom_1.isNodeOfType)(container, 'ELEMENT_NODE') ? container : undefined, event === null || event === void 0 ? void 0 : event.currentTarget, this.onTableEditorCreated, this.disableFeatures);
|
|
127
132
|
}
|
|
128
133
|
};
|
|
129
134
|
TableEditPlugin.prototype.disposeTableEditor = function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableEditPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/TableEditPlugin.ts"],"names":[],"mappings":";;;;IAIA,IAAM,oBAAoB,GAAG,EAAE,CAAC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model-dom';\nimport { TableEditor } from './editors/TableEditor';\nimport type { EditorPlugin, IEditor, PluginEvent, Rect } from 'roosterjs-content-model-types';\n\nconst TABLE_RESIZER_LENGTH = 12;\n\n/**\n * TableEdit plugin, provides the ability to resize a table by drag-and-drop\n */\nexport class TableEditPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private onMouseMoveDisposer: (() => void) | null = null;\n private tableRectMap: { table: HTMLTableElement; rect: Rect }[] | null = null;\n private tableEditor: TableEditor | null = null;\n\n /**\n * Construct a new instance of TableResize plugin\n * @param anchorContainerSelector An optional selector string to specify the container to host the plugin.\n * The container must not be affected by transform: scale(), otherwise the position calculation will be wrong.\n * If not specified, the plugin will be inserted in document.body\n */\n constructor(private anchorContainerSelector?: string) {}\n\n /**\n * Get a friendly name of this plugin\n */\n getName() {\n return 'TableEdit';\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 this.editor = editor;\n this.onMouseMoveDisposer = this.editor.attachDomEvent({\n mousemove: { beforeDispatch: this.onMouseMove },\n });\n const scrollContainer = this.editor.getScrollContainer();\n scrollContainer.addEventListener('mouseout', this.onMouseOut);\n }\n\n private onMouseOut = ({ relatedTarget, currentTarget }: MouseEvent) => {\n const relatedTargetNode = relatedTarget as Node;\n const currentTargetNode = currentTarget as Node;\n if (\n isNodeOfType(relatedTargetNode, 'ELEMENT_NODE') &&\n isNodeOfType(currentTargetNode, 'ELEMENT_NODE') &&\n this.tableEditor &&\n !this.tableEditor.isOwnedElement(relatedTargetNode) &&\n !currentTargetNode.contains(relatedTargetNode)\n ) {\n this.setTableEditor(null);\n }\n };\n\n /**\n * Dispose this plugin\n */\n dispose() {\n const scrollContainer = this.editor?.getScrollContainer();\n scrollContainer?.removeEventListener('mouseout', this.onMouseOut);\n this.onMouseMoveDisposer?.();\n this.invalidateTableRects();\n this.disposeTableEditor();\n this.editor = null;\n this.onMouseMoveDisposer = null;\n }\n\n /**\n * Handle events triggered from editor\n * @param event PluginEvent object\n */\n onPluginEvent(e: PluginEvent) {\n switch (e.eventType) {\n case 'input':\n case 'contentChanged':\n case 'scroll':\n case 'zoomChanged':\n this.setTableEditor(null);\n this.invalidateTableRects();\n break;\n }\n }\n\n private onMouseMove = (event: Event) => {\n const e = event as MouseEvent;\n\n if (e.buttons > 0 || !this.editor) {\n return;\n }\n\n this.ensureTableRects();\n\n const editorWindow = this.editor.getDocument().defaultView || window;\n const x = e.pageX - editorWindow.scrollX;\n const y = e.pageY - editorWindow.scrollY;\n let currentTable: HTMLTableElement | null = null;\n\n //Find table in range of mouse\n if (this.tableRectMap) {\n for (let i = this.tableRectMap.length - 1; i >= 0; i--) {\n const { table, rect } = this.tableRectMap[i];\n\n if (\n x >= rect.left - TABLE_RESIZER_LENGTH &&\n x <= rect.right + TABLE_RESIZER_LENGTH &&\n y >= rect.top - TABLE_RESIZER_LENGTH &&\n y <= rect.bottom + TABLE_RESIZER_LENGTH\n ) {\n currentTable = table;\n break;\n }\n }\n }\n\n this.setTableEditor(currentTable, e);\n this.tableEditor?.onMouseMove(x, y);\n };\n\n /**\n * @internal Public only for unit test\n * @param table Table to use when setting the Editors\n * @param event (Optional) Mouse event\n */\n public setTableEditor(table: HTMLTableElement | null, event?: MouseEvent) {\n if (this.tableEditor && !this.tableEditor.isEditing() && table != this.tableEditor.table) {\n this.disposeTableEditor();\n }\n\n if (!this.tableEditor && table && this.editor && table.rows.length > 0) {\n // anchorContainerSelector is used to specify the container to host the plugin, which can be outside of the editor's div\n const container = this.anchorContainerSelector\n ? this.editor.getDocument().querySelector(this.anchorContainerSelector)\n : undefined;\n\n this.tableEditor = new TableEditor(\n this.editor,\n table,\n this.invalidateTableRects,\n isNodeOfType(container, 'ELEMENT_NODE') ? container : undefined,\n event?.currentTarget\n );\n }\n }\n\n private invalidateTableRects = () => {\n this.tableRectMap = null;\n };\n\n private disposeTableEditor() {\n this.tableEditor?.dispose();\n this.tableEditor = null;\n }\n\n private ensureTableRects() {\n if (!this.tableRectMap && this.editor) {\n this.tableRectMap = [];\n\n const tables = this.editor.getDOMHelper().queryElements('table');\n tables.forEach(table => {\n if (table.isContentEditable) {\n const rect = normalizeRect(table.getBoundingClientRect());\n if (rect && this.tableRectMap) {\n this.tableRectMap.push({\n table,\n rect,\n });\n }\n }\n });\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TableEditPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/TableEditPlugin.ts"],"names":[],"mappings":";;;;IAMA,IAAM,oBAAoB,GAAG,EAAE,CAAC;IAEhC;;OAEG;IACH;QAMI;;;;;;;WAOG;QACH,yBACY,uBAAgC,EAChC,oBAAmD,EACnD,eAAwC;YAHpD,iBAII;YAHQ,4BAAuB,GAAvB,uBAAuB,CAAS;YAChC,yBAAoB,GAApB,oBAAoB,CAA+B;YACnD,oBAAe,GAAf,eAAe,CAAyB;YAhB5C,WAAM,GAAmB,IAAI,CAAC;YAC9B,wBAAmB,GAAwB,IAAI,CAAC;YAChD,iBAAY,GAAqD,IAAI,CAAC;YACtE,gBAAW,GAAuB,IAAI,CAAC;YAoCvC,eAAU,GAAG,UAAC,EAA4C;oBAA1C,aAAa,mBAAA,EAAE,aAAa,mBAAA;gBAChD,IAAM,iBAAiB,GAAG,aAAqB,CAAC;gBAChD,IAAM,iBAAiB,GAAG,aAAqB,CAAC;gBAChD,IACI,IAAA,0CAAY,EAAC,iBAAiB,EAAE,cAAc,CAAC;oBAC/C,IAAA,0CAAY,EAAC,iBAAiB,EAAE,cAAc,CAAC;oBAC/C,KAAI,CAAC,WAAW;oBAChB,CAAC,KAAI,CAAC,WAAW,CAAC,cAAc,CAAC,iBAAiB,CAAC;oBACnD,CAAC,iBAAiB,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAChD;oBACE,KAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;iBAC7B;YACL,CAAC,CAAC;YAgCM,gBAAW,GAAG,UAAC,K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AC;gBAEvB,IAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;gBACjE,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;oBAChB,IAAI,KAAK,CAAC,iBAAiB,EAAE;wBACzB,IAAM,IAAI,GAAG,IAAA,2CAAa,EAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC;wBAC1D,IAAI,IAAI,IAAI,KAAI,CAAC,YAAY,EAAE;4BAC3B,KAAI,CAAC,YAAY,CAAC,IAAI,CAAC;gCACnB,KAAK,OAAA;gCACL,IAAI,MAAA;6BACP,CAAC,CAAC;yBACN;qBACJ;gBACL,CAAC,CAAC,CAAC;aACN;QACL,CAAC;QACL,sBAAC;IAAD,CAAC,AA9KD,IA8KC;IA9KY,0CAAe","sourcesContent":["import { isNodeOfType, normalizeRect } from 'roosterjs-content-model-dom';\nimport { TableEditor } from './editors/TableEditor';\nimport type { TableEditFeatureName } from './editors/features/TableEditFeatureName';\nimport type { OnTableEditorCreatedCallback } from './OnTableEditorCreatedCallback';\nimport type { EditorPlugin, IEditor, PluginEvent, Rect } from 'roosterjs-content-model-types';\n\nconst TABLE_RESIZER_LENGTH = 12;\n\n/**\n * TableEdit plugin, provides the ability to resize a table by drag-and-drop\n */\nexport class TableEditPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private onMouseMoveDisposer: (() => void) | null = null;\n private tableRectMap: { table: HTMLTableElement; rect: Rect }[] | null = null;\n private tableEditor: TableEditor | null = null;\n\n /**\n * Construct a new instance of TableResize plugin\n * @param anchorContainerSelector An optional selector string to specify the container to host the plugin.\n * The container must not be affected by transform: scale(), otherwise the position calculation will be wrong.\n * If not specified, the plugin will be inserted in document.body\n * @param onTableEditorCreated An optional callback to customize the Table Editors elements when created.\n * @param disableFeatures An optional array of TableEditFeatures to disable\n */\n constructor(\n private anchorContainerSelector?: string,\n private onTableEditorCreated?: OnTableEditorCreatedCallback,\n private disableFeatures?: TableEditFeatureName[]\n ) {}\n\n /**\n * Get a friendly name of this plugin\n */\n getName() {\n return 'TableEdit';\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 this.editor = editor;\n this.onMouseMoveDisposer = this.editor.attachDomEvent({\n mousemove: { beforeDispatch: this.onMouseMove },\n });\n const scrollContainer = this.editor.getScrollContainer();\n scrollContainer.addEventListener('mouseout', this.onMouseOut);\n }\n\n private onMouseOut = ({ relatedTarget, currentTarget }: MouseEvent) => {\n const relatedTargetNode = relatedTarget as Node;\n const currentTargetNode = currentTarget as Node;\n if (\n isNodeOfType(relatedTargetNode, 'ELEMENT_NODE') &&\n isNodeOfType(currentTargetNode, 'ELEMENT_NODE') &&\n this.tableEditor &&\n !this.tableEditor.isOwnedElement(relatedTargetNode) &&\n !currentTargetNode.contains(relatedTargetNode)\n ) {\n this.setTableEditor(null);\n }\n };\n\n /**\n * Dispose this plugin\n */\n dispose() {\n const scrollContainer = this.editor?.getScrollContainer();\n scrollContainer?.removeEventListener('mouseout', this.onMouseOut);\n this.onMouseMoveDisposer?.();\n this.invalidateTableRects();\n this.disposeTableEditor();\n this.editor = null;\n this.onMouseMoveDisposer = null;\n this.onTableEditorCreated = undefined;\n }\n\n /**\n * Handle events triggered from editor\n * @param event PluginEvent object\n */\n onPluginEvent(e: PluginEvent) {\n switch (e.eventType) {\n case 'input':\n case 'contentChanged':\n case 'scroll':\n case 'zoomChanged':\n this.setTableEditor(null);\n this.invalidateTableRects();\n break;\n }\n }\n\n private onMouseMove = (event: Event) => {\n const e = event as MouseEvent;\n\n if (e.buttons > 0 || !this.editor) {\n return;\n }\n\n this.ensureTableRects();\n\n const editorWindow = this.editor.getDocument().defaultView || window;\n const x = e.pageX - editorWindow.scrollX;\n const y = e.pageY - editorWindow.scrollY;\n let currentTable: HTMLTableElement | null = null;\n\n //Find table in range of mouse\n if (this.tableRectMap) {\n for (let i = this.tableRectMap.length - 1; i >= 0; i--) {\n const { table, rect } = this.tableRectMap[i];\n\n if (\n x >= rect.left - TABLE_RESIZER_LENGTH &&\n x <= rect.right + TABLE_RESIZER_LENGTH &&\n y >= rect.top - TABLE_RESIZER_LENGTH &&\n y <= rect.bottom + TABLE_RESIZER_LENGTH\n ) {\n currentTable = table;\n break;\n }\n }\n }\n\n this.setTableEditor(currentTable, e);\n this.tableEditor?.onMouseMove(x, y);\n };\n\n /**\n * @internal Public only for unit test\n * @param table Table to use when setting the Editors\n * @param event (Optional) Mouse event\n */\n public setTableEditor(table: HTMLTableElement | null, event?: MouseEvent) {\n if (this.tableEditor && !this.tableEditor.isEditing() && table != this.tableEditor.table) {\n this.disposeTableEditor();\n }\n\n if (!this.tableEditor && table && this.editor && table.rows.length > 0) {\n // anchorContainerSelector is used to specify the container to host the plugin, which can be outside of the editor's div\n const container = this.anchorContainerSelector\n ? this.editor.getDocument().querySelector(this.anchorContainerSelector)\n : undefined;\n\n this.tableEditor = new TableEditor(\n this.editor,\n table,\n this.invalidateTableRects,\n isNodeOfType(container, 'ELEMENT_NODE') ? container : undefined,\n event?.currentTarget,\n this.onTableEditorCreated,\n this.disableFeatures\n );\n }\n }\n\n private invalidateTableRects = () => {\n this.tableRectMap = null;\n };\n\n private disposeTableEditor() {\n this.tableEditor?.dispose();\n this.tableEditor = null;\n }\n\n private ensureTableRects() {\n if (!this.tableRectMap && this.editor) {\n this.tableRectMap = [];\n\n const tables = this.editor.getDOMHelper().queryElements('table');\n tables.forEach(table => {\n if (table.isContentEditable) {\n const rect = normalizeRect(table.getBoundingClientRect());\n if (rect && this.tableRectMap) {\n this.tableRectMap.push({\n table,\n rect,\n });\n }\n }\n });\n }\n }\n}\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { OnTableEditorCreatedCallback } from '../OnTableEditorCreatedCallback';
|
|
1
2
|
import type { IEditor } from 'roosterjs-content-model-types';
|
|
3
|
+
import type { TableEditFeatureName } from './features/TableEditFeatureName';
|
|
2
4
|
/**
|
|
3
5
|
* @internal
|
|
4
6
|
*
|
|
@@ -34,6 +36,8 @@ export declare class TableEditor {
|
|
|
34
36
|
private onChanged;
|
|
35
37
|
private anchorContainer?;
|
|
36
38
|
private contentDiv?;
|
|
39
|
+
private onTableEditorCreated?;
|
|
40
|
+
private disableFeatures?;
|
|
37
41
|
private horizontalInserter;
|
|
38
42
|
private verticalInserter;
|
|
39
43
|
private horizontalResizer;
|
|
@@ -43,12 +47,13 @@ export declare class TableEditor {
|
|
|
43
47
|
private isRTL;
|
|
44
48
|
private range;
|
|
45
49
|
private isCurrentlyEditing;
|
|
46
|
-
constructor(editor: IEditor, table: HTMLTableElement, onChanged: () => void, anchorContainer?: HTMLElement | undefined, contentDiv?: EventTarget | null | undefined);
|
|
50
|
+
constructor(editor: IEditor, table: HTMLTableElement, onChanged: () => void, anchorContainer?: HTMLElement | undefined, contentDiv?: EventTarget | null | undefined, onTableEditorCreated?: OnTableEditorCreatedCallback | undefined, disableFeatures?: TableEditFeatureName[] | undefined);
|
|
47
51
|
dispose(): void;
|
|
48
52
|
isEditing(): boolean;
|
|
49
53
|
isOwnedElement(node: Node): boolean;
|
|
50
54
|
onMouseMove(x: number, y: number): void;
|
|
51
55
|
private setEditorFeatures;
|
|
56
|
+
private onEditorCreated;
|
|
52
57
|
private setResizingTd;
|
|
53
58
|
/**
|
|
54
59
|
* create or remove TableInserter
|
|
@@ -62,7 +67,9 @@ export declare class TableEditor {
|
|
|
62
67
|
private onFinishEditing;
|
|
63
68
|
private onStartTableResize;
|
|
64
69
|
private onStartCellResize;
|
|
70
|
+
private onStartTableMove;
|
|
65
71
|
private onStartResize;
|
|
72
|
+
private onEndTableMove;
|
|
66
73
|
private onInserted;
|
|
67
74
|
/**
|
|
68
75
|
* Public only for testing purposes
|
|
@@ -70,4 +77,5 @@ export declare class TableEditor {
|
|
|
70
77
|
*/
|
|
71
78
|
onSelect: (table: HTMLTableElement) => void;
|
|
72
79
|
private getOnMouseOut;
|
|
80
|
+
private isFeatureDisabled;
|
|
73
81
|
}
|
|
@@ -38,7 +38,7 @@ define(["require", "exports", "./features/CellResizer", "./features/TableInserte
|
|
|
38
38
|
* When set a different current table or change current TD, we need to update these areas
|
|
39
39
|
*/
|
|
40
40
|
var TableEditor = /** @class */ (function () {
|
|
41
|
-
function TableEditor(editor, table, onChanged, anchorContainer, contentDiv) {
|
|
41
|
+
function TableEditor(editor, table, onChanged, anchorContainer, contentDiv, onTableEditorCreated, disableFeatures) {
|
|
42
42
|
var _this = this;
|
|
43
43
|
var _a;
|
|
44
44
|
this.editor = editor;
|
|
@@ -46,6 +46,8 @@ define(["require", "exports", "./features/CellResizer", "./features/TableInserte
|
|
|
46
46
|
this.onChanged = onChanged;
|
|
47
47
|
this.anchorContainer = anchorContainer;
|
|
48
48
|
this.contentDiv = contentDiv;
|
|
49
|
+
this.onTableEditorCreated = onTableEditorCreated;
|
|
50
|
+
this.disableFeatures = disableFeatures;
|
|
49
51
|
// 1, 2 - Insert a column or a row
|
|
50
52
|
this.horizontalInserter = null;
|
|
51
53
|
this.verticalInserter = null;
|
|
@@ -57,6 +59,20 @@ define(["require", "exports", "./features/CellResizer", "./features/TableInserte
|
|
|
57
59
|
// 6 - Move as well as select whole table
|
|
58
60
|
this.tableMover = null;
|
|
59
61
|
this.range = null;
|
|
62
|
+
this.onEditorCreated = function (featureType, element) {
|
|
63
|
+
var _a;
|
|
64
|
+
var disposer = (_a = _this.onTableEditorCreated) === null || _a === void 0 ? void 0 : _a.call(_this, featureType, element);
|
|
65
|
+
var onMouseOut = element && _this.getOnMouseOut(element);
|
|
66
|
+
if (onMouseOut) {
|
|
67
|
+
element.addEventListener('mouseout', onMouseOut);
|
|
68
|
+
}
|
|
69
|
+
return function () {
|
|
70
|
+
disposer === null || disposer === void 0 ? void 0 : disposer();
|
|
71
|
+
if (onMouseOut) {
|
|
72
|
+
element.removeEventListener('mouseout', onMouseOut);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
};
|
|
60
76
|
this.onFinishEditing = function () {
|
|
61
77
|
_this.editor.focus();
|
|
62
78
|
if (_this.range) {
|
|
@@ -76,6 +92,16 @@ define(["require", "exports", "./features/CellResizer", "./features/TableInserte
|
|
|
76
92
|
_this.disposeTableResizer();
|
|
77
93
|
_this.onStartResize();
|
|
78
94
|
};
|
|
95
|
+
this.onStartTableMove = function () {
|
|
96
|
+
_this.isCurrentlyEditing = true;
|
|
97
|
+
_this.disposeTableResizer();
|
|
98
|
+
_this.disposeTableInserter();
|
|
99
|
+
_this.disposeCellResizers();
|
|
100
|
+
};
|
|
101
|
+
this.onEndTableMove = function () {
|
|
102
|
+
_this.disposeTableMover();
|
|
103
|
+
return _this.onFinishEditing();
|
|
104
|
+
};
|
|
79
105
|
this.onInserted = function () {
|
|
80
106
|
_this.disposeTableResizer();
|
|
81
107
|
_this.onFinishEditing();
|
|
@@ -85,14 +111,16 @@ define(["require", "exports", "./features/CellResizer", "./features/TableInserte
|
|
|
85
111
|
* @param table the table to select
|
|
86
112
|
*/
|
|
87
113
|
this.onSelect = function (table) {
|
|
114
|
+
var _a, _b;
|
|
88
115
|
_this.editor.focus();
|
|
89
116
|
if (table) {
|
|
117
|
+
var parsedTable = (0, roosterjs_content_model_dom_1.parseTableCells)(table);
|
|
90
118
|
var selection = {
|
|
91
119
|
table: table,
|
|
92
120
|
firstRow: 0,
|
|
93
121
|
firstColumn: 0,
|
|
94
|
-
lastRow:
|
|
95
|
-
lastColumn:
|
|
122
|
+
lastRow: parsedTable.length - 1,
|
|
123
|
+
lastColumn: ((_b = (_a = parsedTable[0]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) - 1,
|
|
96
124
|
type: 'table',
|
|
97
125
|
};
|
|
98
126
|
_this.editor.setDOMSelection(selection);
|
|
@@ -104,7 +132,8 @@ define(["require", "exports", "./features/CellResizer", "./features/TableInserte
|
|
|
104
132
|
ev.relatedTarget != feature &&
|
|
105
133
|
(0, roosterjs_content_model_dom_1.isNodeOfType)(_this.contentDiv, 'ELEMENT_NODE') &&
|
|
106
134
|
(0, roosterjs_content_model_dom_1.isNodeOfType)(ev.relatedTarget, 'ELEMENT_NODE') &&
|
|
107
|
-
!(_this.contentDiv == ev.relatedTarget)
|
|
135
|
+
!(_this.contentDiv == ev.relatedTarget) &&
|
|
136
|
+
!_this.isEditing()) {
|
|
108
137
|
_this.dispose();
|
|
109
138
|
}
|
|
110
139
|
};
|
|
@@ -138,7 +167,6 @@ define(["require", "exports", "./features/CellResizer", "./features/TableInserte
|
|
|
138
167
|
var _a;
|
|
139
168
|
// Get whole table rect
|
|
140
169
|
var tableRect = (0, roosterjs_content_model_dom_1.normalizeRect)(this.table.getBoundingClientRect());
|
|
141
|
-
//console.log('>>>tableRect', tableRect);
|
|
142
170
|
if (!tableRect) {
|
|
143
171
|
return;
|
|
144
172
|
}
|
|
@@ -176,7 +204,8 @@ define(["require", "exports", "./features/CellResizer", "./features/TableInserte
|
|
|
176
204
|
if (i === 0 && topOrSide == 0 /* top */) {
|
|
177
205
|
var center = (tdRect.left + tdRect.right) / 2;
|
|
178
206
|
var isOnRightHalf = this.isRTL ? x < center : x > center;
|
|
179
|
-
this.
|
|
207
|
+
!this.isFeatureDisabled('VerticalTableInserter') &&
|
|
208
|
+
this.setInserterTd(isOnRightHalf ? td : tr.cells[j - 1], false /*isHorizontal*/);
|
|
180
209
|
}
|
|
181
210
|
else if (j === 0 && topOrSide == 1 /* side */) {
|
|
182
211
|
var tdAbove = (_a = this.table.rows[i - 1]) === null || _a === void 0 ? void 0 : _a.cells[0];
|
|
@@ -188,14 +217,15 @@ define(["require", "exports", "./features/CellResizer", "./features/TableInserte
|
|
|
188
217
|
: this.isRTL
|
|
189
218
|
? tdAboveRect.right === tdRect.right
|
|
190
219
|
: tdAboveRect.left === tdRect.left;
|
|
191
|
-
this.
|
|
192
|
-
|
|
193
|
-
|
|
220
|
+
!this.isFeatureDisabled('HorizontalTableInserter') &&
|
|
221
|
+
this.setInserterTd(y < (tdRect.top + tdRect.bottom) / 2 && isTdNotAboveMerged
|
|
222
|
+
? tdAbove
|
|
223
|
+
: td, true /*isHorizontal*/);
|
|
194
224
|
}
|
|
195
225
|
else {
|
|
196
226
|
this.setInserterTd(null);
|
|
197
227
|
}
|
|
198
|
-
this.setResizingTd(td);
|
|
228
|
+
!this.isFeatureDisabled('CellResizer') && this.setResizingTd(td);
|
|
199
229
|
//Cell found
|
|
200
230
|
break;
|
|
201
231
|
}
|
|
@@ -208,11 +238,13 @@ define(["require", "exports", "./features/CellResizer", "./features/TableInserte
|
|
|
208
238
|
this.setEditorFeatures();
|
|
209
239
|
};
|
|
210
240
|
TableEditor.prototype.setEditorFeatures = function () {
|
|
211
|
-
|
|
212
|
-
|
|
241
|
+
var disableSelector = this.isFeatureDisabled('TableSelector');
|
|
242
|
+
var disableMovement = this.isFeatureDisabled('TableMover');
|
|
243
|
+
if (!this.tableMover && !(disableSelector && disableMovement)) {
|
|
244
|
+
this.tableMover = (0, TableMover_1.createTableMover)(this.table, this.editor, this.isRTL, disableSelector ? function () { } : this.onSelect, this.onStartTableMove, this.onEndTableMove, this.contentDiv, this.anchorContainer, this.onEditorCreated, disableMovement);
|
|
213
245
|
}
|
|
214
|
-
if (!this.tableResizer) {
|
|
215
|
-
this.tableResizer = (0, TableResizer_1.createTableResizer)(this.table, this.editor, this.isRTL, this.onStartTableResize, this.onFinishEditing, this.contentDiv, this.anchorContainer);
|
|
246
|
+
if (!this.tableResizer && !this.isFeatureDisabled('TableResizer')) {
|
|
247
|
+
this.tableResizer = (0, TableResizer_1.createTableResizer)(this.table, this.editor, this.isRTL, this.onStartTableResize, this.onFinishEditing, this.contentDiv, this.anchorContainer, this.onTableEditorCreated);
|
|
216
248
|
}
|
|
217
249
|
};
|
|
218
250
|
TableEditor.prototype.setResizingTd = function (td) {
|
|
@@ -234,7 +266,7 @@ define(["require", "exports", "./features/CellResizer", "./features/TableInserte
|
|
|
234
266
|
this.disposeTableInserter();
|
|
235
267
|
}
|
|
236
268
|
if (!this.horizontalInserter && !this.verticalInserter && td) {
|
|
237
|
-
var newInserter = (0, TableInserter_1.createTableInserter)(this.editor, td, this.table, this.isRTL, !!isHorizontal, this.onInserted, this.
|
|
269
|
+
var newInserter = (0, TableInserter_1.createTableInserter)(this.editor, td, this.table, this.isRTL, !!isHorizontal, this.onInserted, this.anchorContainer, this.onEditorCreated);
|
|
238
270
|
if (isHorizontal) {
|
|
239
271
|
this.horizontalInserter = newInserter;
|
|
240
272
|
}
|
|
@@ -283,6 +315,10 @@ define(["require", "exports", "./features/CellResizer", "./features/TableInserte
|
|
|
283
315
|
}
|
|
284
316
|
this.editor.takeSnapshot();
|
|
285
317
|
};
|
|
318
|
+
TableEditor.prototype.isFeatureDisabled = function (feature) {
|
|
319
|
+
var _a;
|
|
320
|
+
return (_a = this.disableFeatures) === null || _a === void 0 ? void 0 : _a.includes(feature);
|
|
321
|
+
};
|
|
286
322
|
return TableEditor;
|
|
287
323
|
}());
|
|
288
324
|
exports.TableEditor = TableEditor;
|