roosterjs-content-model-plugins 9.48.0 → 9.50.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/dragAndDrop/DragAndDropPlugin.d.ts +49 -0
- package/lib/dragAndDrop/DragAndDropPlugin.js +87 -0
- package/lib/dragAndDrop/DragAndDropPlugin.js.map +1 -0
- package/lib/dragAndDrop/utils/cleanForbiddenElements.d.ts +7 -0
- package/lib/dragAndDrop/utils/cleanForbiddenElements.js +34 -0
- package/lib/dragAndDrop/utils/cleanForbiddenElements.js.map +1 -0
- package/lib/dragAndDrop/utils/handleDroppedContent.d.ts +6 -0
- package/lib/dragAndDrop/utils/handleDroppedContent.js +35 -0
- package/lib/dragAndDrop/utils/handleDroppedContent.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib-amd/dragAndDrop/DragAndDropPlugin.d.ts +49 -0
- package/lib-amd/dragAndDrop/DragAndDropPlugin.js +88 -0
- package/lib-amd/dragAndDrop/DragAndDropPlugin.js.map +1 -0
- package/lib-amd/dragAndDrop/utils/cleanForbiddenElements.d.ts +7 -0
- package/lib-amd/dragAndDrop/utils/cleanForbiddenElements.js +35 -0
- package/lib-amd/dragAndDrop/utils/cleanForbiddenElements.js.map +1 -0
- package/lib-amd/dragAndDrop/utils/handleDroppedContent.d.ts +6 -0
- package/lib-amd/dragAndDrop/utils/handleDroppedContent.js +35 -0
- package/lib-amd/dragAndDrop/utils/handleDroppedContent.js.map +1 -0
- package/lib-amd/index.d.ts +1 -0
- package/lib-amd/index.js +3 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-mjs/dragAndDrop/DragAndDropPlugin.d.ts +49 -0
- package/lib-mjs/dragAndDrop/DragAndDropPlugin.js +84 -0
- package/lib-mjs/dragAndDrop/DragAndDropPlugin.js.map +1 -0
- package/lib-mjs/dragAndDrop/utils/cleanForbiddenElements.d.ts +7 -0
- package/lib-mjs/dragAndDrop/utils/cleanForbiddenElements.js +30 -0
- package/lib-mjs/dragAndDrop/utils/cleanForbiddenElements.js.map +1 -0
- package/lib-mjs/dragAndDrop/utils/handleDroppedContent.d.ts +6 -0
- package/lib-mjs/dragAndDrop/utils/handleDroppedContent.js +31 -0
- package/lib-mjs/dragAndDrop/utils/handleDroppedContent.js.map +1 -0
- package/lib-mjs/index.d.ts +1 -0
- package/lib-mjs/index.js +1 -0
- package/lib-mjs/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Options for DragAndDrop plugin
|
|
4
|
+
*/
|
|
5
|
+
export interface DragAndDropOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Forbidden elements that cannot be dropped in the editor
|
|
8
|
+
* @default ['iframe']
|
|
9
|
+
*/
|
|
10
|
+
forbiddenElements?: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* DragAndDrop plugin, handles ContentChanged event when change source is "Drop"
|
|
14
|
+
* to sanitize dropped content, similar to how PastePlugin sanitizes pasted content.
|
|
15
|
+
*/
|
|
16
|
+
export declare class DragAndDropPlugin implements EditorPlugin {
|
|
17
|
+
private editor;
|
|
18
|
+
private forbiddenElements;
|
|
19
|
+
private isInternalDragging;
|
|
20
|
+
private disposer;
|
|
21
|
+
/**
|
|
22
|
+
* Construct a new instance of DragAndDropPlugin
|
|
23
|
+
*/
|
|
24
|
+
constructor(options?: DragAndDropOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Get name of this plugin
|
|
27
|
+
*/
|
|
28
|
+
getName(): string;
|
|
29
|
+
/**
|
|
30
|
+
* The first method that editor will call to a plugin when editor is initializing.
|
|
31
|
+
* It will pass in the editor instance, plugin should take this chance to save the
|
|
32
|
+
* editor reference so that it can call to any editor method or format API later.
|
|
33
|
+
* @param editor The editor object
|
|
34
|
+
*/
|
|
35
|
+
initialize(editor: IEditor): void;
|
|
36
|
+
/**
|
|
37
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
38
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
39
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
40
|
+
*/
|
|
41
|
+
dispose(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
44
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
45
|
+
* exclusively by another plugin.
|
|
46
|
+
* @param event The event to handle:
|
|
47
|
+
*/
|
|
48
|
+
onPluginEvent(event: PluginEvent): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DragAndDropPlugin = void 0;
|
|
4
|
+
var handleDroppedContent_1 = require("./utils/handleDroppedContent");
|
|
5
|
+
var DefaultOptions = {
|
|
6
|
+
forbiddenElements: ['iframe'],
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* DragAndDrop plugin, handles ContentChanged event when change source is "Drop"
|
|
10
|
+
* to sanitize dropped content, similar to how PastePlugin sanitizes pasted content.
|
|
11
|
+
*/
|
|
12
|
+
var DragAndDropPlugin = /** @class */ (function () {
|
|
13
|
+
/**
|
|
14
|
+
* Construct a new instance of DragAndDropPlugin
|
|
15
|
+
*/
|
|
16
|
+
function DragAndDropPlugin(options) {
|
|
17
|
+
if (options === void 0) { options = DefaultOptions; }
|
|
18
|
+
var _a;
|
|
19
|
+
this.editor = null;
|
|
20
|
+
this.forbiddenElements = [];
|
|
21
|
+
this.isInternalDragging = false;
|
|
22
|
+
this.disposer = null;
|
|
23
|
+
this.forbiddenElements = (_a = options.forbiddenElements) !== null && _a !== void 0 ? _a : [];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get name of this plugin
|
|
27
|
+
*/
|
|
28
|
+
DragAndDropPlugin.prototype.getName = function () {
|
|
29
|
+
return 'DragAndDrop';
|
|
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
|
+
DragAndDropPlugin.prototype.initialize = function (editor) {
|
|
38
|
+
var _this = this;
|
|
39
|
+
this.editor = editor;
|
|
40
|
+
this.disposer = editor.attachDomEvent({
|
|
41
|
+
dragstart: {
|
|
42
|
+
beforeDispatch: function (_ev) {
|
|
43
|
+
_this.isInternalDragging = true;
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
50
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
51
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
52
|
+
*/
|
|
53
|
+
DragAndDropPlugin.prototype.dispose = function () {
|
|
54
|
+
this.editor = null;
|
|
55
|
+
if (this.disposer) {
|
|
56
|
+
this.disposer();
|
|
57
|
+
this.disposer = null;
|
|
58
|
+
}
|
|
59
|
+
this.isInternalDragging = false;
|
|
60
|
+
this.forbiddenElements = [];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
64
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
65
|
+
* exclusively by another plugin.
|
|
66
|
+
* @param event The event to handle:
|
|
67
|
+
*/
|
|
68
|
+
DragAndDropPlugin.prototype.onPluginEvent = function (event) {
|
|
69
|
+
var _a;
|
|
70
|
+
if (this.editor && event.eventType == 'beforeDrop') {
|
|
71
|
+
if (this.isInternalDragging) {
|
|
72
|
+
this.isInternalDragging = false;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
var dropEvent = event.rawEvent;
|
|
76
|
+
var html = (_a = dropEvent.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData('text/html');
|
|
77
|
+
if (html) {
|
|
78
|
+
(0, handleDroppedContent_1.handleDroppedContent)(this.editor, dropEvent, html, this.forbiddenElements);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
return DragAndDropPlugin;
|
|
85
|
+
}());
|
|
86
|
+
exports.DragAndDropPlugin = DragAndDropPlugin;
|
|
87
|
+
//# sourceMappingURL=DragAndDropPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DragAndDropPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/dragAndDrop/DragAndDropPlugin.ts"],"names":[],"mappings":";;;AAAA,qEAAoE;AAcpE,IAAM,cAAc,GAAG;IACnB,iBAAiB,EAAE,CAAC,QAAQ,CAAC;CAChC,CAAC;AAEF;;;GAGG;AACH;IAMI;;OAEG;IACH,2BAAY,OAA4C;QAA5C,wBAAA,EAAA,wBAA4C;;QARhD,WAAM,GAAmB,IAAI,CAAC;QAC9B,sBAAiB,GAAa,EAAE,CAAC;QACjC,uBAAkB,GAAY,KAAK,CAAC;QACpC,aAAQ,GAAwB,IAAI,CAAC;QAMzC,IAAI,CAAC,iBAAiB,GAAG,MAAA,OAAO,CAAC,iBAAiB,mCAAI,EAAE,CAAC;IAC7D,CAAC;IAED;;OAEG;IACH,mCAAO,GAAP;QACI,OAAO,aAAa,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACH,sCAAU,GAAV,UAAW,MAAe;QAA1B,iBASC;QARG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC;YAClC,SAAS,EAAE;gBACP,cAAc,EAAE,UAAA,GAAG;oBACf,KAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;gBACnC,CAAC;aACJ;SACJ,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACH,mCAAO,GAAP;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACxB;QACD,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACH,yCAAa,GAAb,UAAc,KAAkB;;QAC5B,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,YAAY,EAAE;YAChD,IAAI,IAAI,CAAC,kBAAkB,EAAE;gBACzB,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;aACnC;iBAAM;gBACH,IAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC;gBACjC,IAAM,IAAI,GAAG,MAAA,SAAS,CAAC,YAAY,0CAAE,OAAO,CAAC,WAAW,CAAC,CAAC;gBAE1D,IAAI,IAAI,EAAE;oBACN,IAAA,2CAAoB,EAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;iBAC9E;aACJ;YACD,OAAO;SACV;IACL,CAAC;IACL,wBAAC;AAAD,CAAC,AAzED,IAyEC;AAzEY,8CAAiB","sourcesContent":["import { handleDroppedContent } from './utils/handleDroppedContent';\nimport type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';\n\n/**\n * Options for DragAndDrop plugin\n */\nexport interface DragAndDropOptions {\n /**\n * Forbidden elements that cannot be dropped in the editor\n * @default ['iframe']\n */\n forbiddenElements?: string[];\n}\n\nconst DefaultOptions = {\n forbiddenElements: ['iframe'],\n};\n\n/**\n * DragAndDrop plugin, handles ContentChanged event when change source is \"Drop\"\n * to sanitize dropped content, similar to how PastePlugin sanitizes pasted content.\n */\nexport class DragAndDropPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private forbiddenElements: string[] = [];\n private isInternalDragging: boolean = false;\n private disposer: (() => void) | null = null;\n\n /**\n * Construct a new instance of DragAndDropPlugin\n */\n constructor(options: DragAndDropOptions = DefaultOptions) {\n this.forbiddenElements = options.forbiddenElements ?? [];\n }\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'DragAndDrop';\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.disposer = editor.attachDomEvent({\n dragstart: {\n beforeDispatch: _ev => {\n this.isInternalDragging = true;\n },\n },\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.editor = null;\n if (this.disposer) {\n this.disposer();\n this.disposer = null;\n }\n this.isInternalDragging = false;\n this.forbiddenElements = [];\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 == 'beforeDrop') {\n if (this.isInternalDragging) {\n this.isInternalDragging = false;\n } else {\n const dropEvent = event.rawEvent;\n const html = dropEvent.dataTransfer?.getData('text/html');\n\n if (html) {\n handleDroppedContent(this.editor, dropEvent, html, this.forbiddenElements);\n }\n }\n return;\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* Remove all forbidden elements from a parsed HTML document
|
|
4
|
+
* @param doc The parsed HTML document to clean
|
|
5
|
+
* @param forbiddenElements Array of tag names to remove (e.g., ['iframe', 'script'])
|
|
6
|
+
*/
|
|
7
|
+
export declare function cleanForbiddenElements(doc: Document, forbiddenElements: string[]): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanForbiddenElements = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
* Remove all forbidden elements from a parsed HTML document
|
|
8
|
+
* @param doc The parsed HTML document to clean
|
|
9
|
+
* @param forbiddenElements Array of tag names to remove (e.g., ['iframe', 'script'])
|
|
10
|
+
*/
|
|
11
|
+
function cleanForbiddenElements(doc, forbiddenElements) {
|
|
12
|
+
var e_1, _a;
|
|
13
|
+
var _b;
|
|
14
|
+
if (forbiddenElements.length === 0) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
var selector = forbiddenElements.join(',');
|
|
18
|
+
var elements = Array.from(doc.body.querySelectorAll(selector));
|
|
19
|
+
try {
|
|
20
|
+
for (var elements_1 = (0, tslib_1.__values)(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
|
|
21
|
+
var element = elements_1_1.value;
|
|
22
|
+
(_b = element.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(element);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
26
|
+
finally {
|
|
27
|
+
try {
|
|
28
|
+
if (elements_1_1 && !elements_1_1.done && (_a = elements_1.return)) _a.call(elements_1);
|
|
29
|
+
}
|
|
30
|
+
finally { if (e_1) throw e_1.error; }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.cleanForbiddenElements = cleanForbiddenElements;
|
|
34
|
+
//# sourceMappingURL=cleanForbiddenElements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanForbiddenElements.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/cleanForbiddenElements.ts"],"names":[],"mappings":";;;;AAAA;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,GAAa,EAAE,iBAA2B;;;IAC7E,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE;QAChC,OAAO;KACV;IAED,IAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,IAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;;QAEjE,KAAsB,IAAA,aAAA,sBAAA,QAAQ,CAAA,kCAAA,wDAAE;YAA3B,IAAM,OAAO,qBAAA;YACd,MAAA,OAAO,CAAC,UAAU,0CAAE,WAAW,CAAC,OAAO,CAAC,CAAC;SAC5C;;;;;;;;;AACL,CAAC;AAXD,wDAWC","sourcesContent":["/**\n * @internal\n * Remove all forbidden elements from a parsed HTML document\n * @param doc The parsed HTML document to clean\n * @param forbiddenElements Array of tag names to remove (e.g., ['iframe', 'script'])\n */\nexport function cleanForbiddenElements(doc: Document, forbiddenElements: string[]): void {\n if (forbiddenElements.length === 0) {\n return;\n }\n\n const selector = forbiddenElements.join(',');\n const elements = Array.from(doc.body.querySelectorAll(selector));\n\n for (const element of elements) {\n element.parentNode?.removeChild(element);\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IEditor } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Handle dropped HTML content by inserting it at the drop position
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleDroppedContent(editor: IEditor, event: DragEvent, html: string, forbiddenElements: string[]): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleDroppedContent = void 0;
|
|
4
|
+
var cleanForbiddenElements_1 = require("./cleanForbiddenElements");
|
|
5
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
* Handle dropped HTML content by inserting it at the drop position
|
|
9
|
+
*/
|
|
10
|
+
function handleDroppedContent(editor, event, html, forbiddenElements) {
|
|
11
|
+
var doc = editor.getDocument();
|
|
12
|
+
var domPosition = (0, roosterjs_content_model_dom_1.getNodePositionFromEvent)(doc, editor.getDOMHelper(), event.x, event.y);
|
|
13
|
+
if (domPosition) {
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
event.stopPropagation();
|
|
16
|
+
var range = doc.createRange();
|
|
17
|
+
range.setStart(domPosition.node, domPosition.offset);
|
|
18
|
+
range.collapse(true);
|
|
19
|
+
var parsedHtml = editor.getDOMCreator().htmlToDOM(html);
|
|
20
|
+
(0, cleanForbiddenElements_1.cleanForbiddenElements)(parsedHtml, forbiddenElements);
|
|
21
|
+
var droppedModel_1 = (0, roosterjs_content_model_dom_1.domToContentModel)(parsedHtml.body, (0, roosterjs_content_model_dom_1.createDomToModelContext)());
|
|
22
|
+
editor.formatContentModel(function (model, context) {
|
|
23
|
+
(0, roosterjs_content_model_dom_1.mergeModel)(model, droppedModel_1, context);
|
|
24
|
+
return true;
|
|
25
|
+
}, {
|
|
26
|
+
selectionOverride: {
|
|
27
|
+
type: 'range',
|
|
28
|
+
range: range,
|
|
29
|
+
isReverted: false,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.handleDroppedContent = handleDroppedContent;
|
|
35
|
+
//# sourceMappingURL=handleDroppedContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleDroppedContent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/handleDroppedContent.ts"],"names":[],"mappings":";;;AAAA,mEAAkE;AAClE,2EAKqC;AAGrC;;;GAGG;AACH,SAAgB,oBAAoB,CAChC,MAAe,EACf,KAAgB,EAChB,IAAY,EACZ,iBAA2B;IAE3B,IAAM,GAAG,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACjC,IAAM,WAAW,GAAG,IAAA,sDAAwB,EAAC,GAAG,EAAE,MAAM,CAAC,YAAY,EAAE,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAE3F,IAAI,WAAW,EAAE;QACb,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,KAAK,CAAC,eAAe,EAAE,CAAC;QAExB,IAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QAChC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QACrD,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAErB,IAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC1D,IAAA,+CAAsB,EAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;QAEtD,IAAM,cAAY,GAAG,IAAA,+CAAiB,EAAC,UAAU,CAAC,IAAI,EAAE,IAAA,qDAAuB,GAAE,CAAC,CAAC;QAEnF,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;YACX,IAAA,wCAAU,EAAC,KAAK,EAAE,cAAY,EAAE,OAAO,CAAC,CAAC;YACzC,OAAO,IAAI,CAAC;QAChB,CAAC,EACD;YACI,iBAAiB,EAAE;gBACf,IAAI,EAAE,OAAO;gBACb,KAAK,OAAA;gBACL,UAAU,EAAE,KAAK;aACpB;SACJ,CACJ,CAAC;KACL;AACL,CAAC;AApCD,oDAoCC","sourcesContent":["import { cleanForbiddenElements } from './cleanForbiddenElements';\nimport {\n createDomToModelContext,\n domToContentModel,\n getNodePositionFromEvent,\n mergeModel,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Handle dropped HTML content by inserting it at the drop position\n */\nexport function handleDroppedContent(\n editor: IEditor,\n event: DragEvent,\n html: string,\n forbiddenElements: string[]\n): void {\n const doc = editor.getDocument();\n const domPosition = getNodePositionFromEvent(doc, editor.getDOMHelper(), event.x, event.y);\n\n if (domPosition) {\n event.preventDefault();\n event.stopPropagation();\n\n const range = doc.createRange();\n range.setStart(domPosition.node, domPosition.offset);\n range.collapse(true);\n\n const parsedHtml = editor.getDOMCreator().htmlToDOM(html);\n cleanForbiddenElements(parsedHtml, forbiddenElements);\n\n const droppedModel = domToContentModel(parsedHtml.body, createDomToModelContext());\n\n editor.formatContentModel(\n (model, context) => {\n mergeModel(model, droppedModel, context);\n return true;\n },\n {\n selectionOverride: {\n type: 'range',\n range,\n isReverted: false,\n },\n }\n );\n }\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -36,3 +36,4 @@ export { FindReplaceContext } from './findReplace/types/FindReplaceContext';
|
|
|
36
36
|
export { HighlightHelper } from './findReplace/types/HighlightHelper';
|
|
37
37
|
export { FindReplaceHighlightOptions } from './findReplace/types/FindReplaceHighlightOptions';
|
|
38
38
|
export { AnnouncePlugin } from './announce/AnnouncePlugin';
|
|
39
|
+
export { DragAndDropPlugin, DragAndDropOptions } from './dragAndDrop/DragAndDropPlugin';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AnnouncePlugin = exports.moveHighlight = exports.replace = exports.find = exports.createFindReplaceContext = exports.FindReplacePlugin = exports.TouchPlugin = exports.HiddenPropertyPlugin = exports.ImageEditPlugin = exports.CustomReplacePlugin = exports.PickerPlugin = exports.HyperlinkPlugin = exports.MarkdownPlugin = exports.isModelEmptyFast = exports.WatermarkPlugin = exports.ContextMenuPluginBase = exports.ShortcutPlugin = exports.ShortcutOutdentList = exports.ShortcutIndentList = exports.ShortcutDecreaseFont = exports.ShortcutIncreaseFont = exports.ShortcutNumbering = exports.ShortcutBullet = exports.ShortcutRedoMacOS = exports.ShortcutRedoAlt = exports.ShortcutRedo = exports.ShortcutUndo2 = exports.ShortcutUndo = exports.ShortcutClearFormat = exports.ShortcutUnderline = exports.ShortcutItalic = exports.ShortcutBold = exports.AutoFormatPlugin = exports.EditPlugin = exports.DefaultSanitizers = exports.PastePlugin = exports.TableEditPlugin = void 0;
|
|
3
|
+
exports.DragAndDropPlugin = exports.AnnouncePlugin = exports.moveHighlight = exports.replace = exports.find = exports.createFindReplaceContext = exports.FindReplacePlugin = exports.TouchPlugin = exports.HiddenPropertyPlugin = exports.ImageEditPlugin = exports.CustomReplacePlugin = exports.PickerPlugin = exports.HyperlinkPlugin = exports.MarkdownPlugin = exports.isModelEmptyFast = exports.WatermarkPlugin = exports.ContextMenuPluginBase = exports.ShortcutPlugin = exports.ShortcutOutdentList = exports.ShortcutIndentList = exports.ShortcutDecreaseFont = exports.ShortcutIncreaseFont = exports.ShortcutNumbering = exports.ShortcutBullet = exports.ShortcutRedoMacOS = exports.ShortcutRedoAlt = exports.ShortcutRedo = exports.ShortcutUndo2 = exports.ShortcutUndo = exports.ShortcutClearFormat = exports.ShortcutUnderline = exports.ShortcutItalic = exports.ShortcutBold = exports.AutoFormatPlugin = exports.EditPlugin = exports.DefaultSanitizers = exports.PastePlugin = exports.TableEditPlugin = void 0;
|
|
4
4
|
var TableEditPlugin_1 = require("./tableEdit/TableEditPlugin");
|
|
5
5
|
Object.defineProperty(exports, "TableEditPlugin", { enumerable: true, get: function () { return TableEditPlugin_1.TableEditPlugin; } });
|
|
6
6
|
var PastePlugin_1 = require("./paste/PastePlugin");
|
|
@@ -61,4 +61,6 @@ var moveHighlight_1 = require("./findReplace/moveHighlight");
|
|
|
61
61
|
Object.defineProperty(exports, "moveHighlight", { enumerable: true, get: function () { return moveHighlight_1.moveHighlight; } });
|
|
62
62
|
var AnnouncePlugin_1 = require("./announce/AnnouncePlugin");
|
|
63
63
|
Object.defineProperty(exports, "AnnouncePlugin", { enumerable: true, get: function () { return AnnouncePlugin_1.AnnouncePlugin; } });
|
|
64
|
+
var DragAndDropPlugin_1 = require("./dragAndDrop/DragAndDropPlugin");
|
|
65
|
+
Object.defineProperty(exports, "DragAndDropPlugin", { enumerable: true, get: function () { return DragAndDropPlugin_1.DragAndDropPlugin; } });
|
|
64
66
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-plugins/lib/index.ts"],"names":[],"mappings":";;;AAAA,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AAIxB,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AACpB,+DAA8D;AAArD,sHAAA,iBAAiB,OAAA;AAC1B,gDAA+C;AAAtC,wGAAA,UAAU,OAAA;AAEnB,kEAAiE;AAAxD,oHAAA,gBAAgB,OAAA;AAGzB,kDAgB8B;AAf1B,yGAAA,YAAY,OAAA;AACZ,2GAAA,cAAc,OAAA;AACd,8GAAA,iBAAiB,OAAA;AACjB,gHAAA,mBAAmB,OAAA;AACnB,yGAAA,YAAY,OAAA;AACZ,0GAAA,aAAa,OAAA;AACb,yGAAA,YAAY,OAAA;AACZ,4GAAA,eAAe,OAAA;AACf,8GAAA,iBAAiB,OAAA;AACjB,2GAAA,cAAc,OAAA;AACd,8GAAA,iBAAiB,OAAA;AACjB,iHAAA,oBAAoB,OAAA;AACpB,iHAAA,oBAAoB,OAAA;AACpB,+GAAA,kBAAkB,OAAA;AAClB,gHAAA,mBAAmB,OAAA;AAEvB,4DAA2D;AAAlD,gHAAA,cAAc,OAAA;AAEvB,iFAAoG;AAA3F,8HAAA,qBAAqB,OAAA;AAC9B,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AAExB,iEAAgE;AAAvD,oHAAA,gBAAgB,OAAA;AACzB,4DAA4E;AAAnE,gHAAA,cAAc,OAAA;AACvB,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AAExB,sDAAqD;AAA5C,4GAAA,YAAY,OAAA;AAGrB,2EAAyF;AAAhF,0HAAA,mBAAmB,OAAA;AAC5B,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AAExB,8EAA6E;AAApE,4HAAA,oBAAoB,OAAA;AAE7B,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AACpB,qEAAoE;AAA3D,sHAAA,iBAAiB,OAAA;AAC1B,mFAAkF;AAAzE,oIAAA,wBAAwB,OAAA;AACjC,2CAA0C;AAAjC,4FAAA,IAAI,OAAA;AACb,iDAAgD;AAAvC,kGAAA,OAAO,OAAA;AAChB,6DAA4D;AAAnD,8GAAA,aAAa,OAAA;AAItB,4DAA2D;AAAlD,gHAAA,cAAc,OAAA","sourcesContent":["export { TableEditPlugin } from './tableEdit/TableEditPlugin';\nexport { OnTableEditorCreatedCallback } from './tableEdit/OnTableEditorCreatedCallback';\nexport { TableEditFeatureName } from './tableEdit/editors/features/TableEditFeatureName';\nexport { TableWithRoot } from './tableEdit/TableWithRoot';\nexport { PastePlugin } from './paste/PastePlugin';\nexport { DefaultSanitizers } from './paste/DefaultSanitizers';\nexport { EditPlugin } from './edit/EditPlugin';\nexport { EditOptions, HandleTabOptions } from './edit/EditOptions';\nexport { AutoFormatPlugin } from './autoFormat/AutoFormatPlugin';\nexport { AutoFormatOptions } from './autoFormat/interface/AutoFormatOptions';\n\nexport {\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} from './shortcut/shortcuts';\nexport { ShortcutPlugin } from './shortcut/ShortcutPlugin';\nexport { ShortcutKeyDefinition, ShortcutCommand } from './shortcut/ShortcutCommand';\nexport { ContextMenuPluginBase, ContextMenuOptions } from './contextMenuBase/ContextMenuPluginBase';\nexport { WatermarkPlugin } from './watermark/WatermarkPlugin';\nexport { WatermarkFormat } from './watermark/WatermarkFormat';\nexport { isModelEmptyFast } from './watermark/isModelEmptyFast';\nexport { MarkdownPlugin, MarkdownOptions } from './markdown/MarkdownPlugin';\nexport { HyperlinkPlugin } from './hyperlink/HyperlinkPlugin';\nexport { HyperlinkToolTip } from './hyperlink/HyperlinkToolTip';\nexport { PickerPlugin } from './picker/PickerPlugin';\nexport { PickerHelper } from './picker/PickerHelper';\nexport { PickerSelectionChangMode, PickerDirection, PickerHandler } from './picker/PickerHandler';\nexport { CustomReplacePlugin, CustomReplace } from './customReplace/CustomReplacePlugin';\nexport { ImageEditPlugin } from './imageEdit/ImageEditPlugin';\nexport { ImageEditOptions } from './imageEdit/types/ImageEditOptions';\nexport { HiddenPropertyPlugin } from './hiddenProperty/HiddenPropertyPlugin';\nexport { HiddenPropertyOptions } from './hiddenProperty/HiddenPropertyOptions';\nexport { TouchPlugin } from './touch/TouchPlugin';\nexport { FindReplacePlugin } from './findReplace/FindReplacePlugin';\nexport { createFindReplaceContext } from './findReplace/createFindReplaceContext';\nexport { find } from './findReplace/find';\nexport { replace } from './findReplace/replace';\nexport { moveHighlight } from './findReplace/moveHighlight';\nexport { FindReplaceContext } from './findReplace/types/FindReplaceContext';\nexport { HighlightHelper } from './findReplace/types/HighlightHelper';\nexport { FindReplaceHighlightOptions } from './findReplace/types/FindReplaceHighlightOptions';\nexport { AnnouncePlugin } from './announce/AnnouncePlugin';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-plugins/lib/index.ts"],"names":[],"mappings":";;;AAAA,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AAIxB,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AACpB,+DAA8D;AAArD,sHAAA,iBAAiB,OAAA;AAC1B,gDAA+C;AAAtC,wGAAA,UAAU,OAAA;AAEnB,kEAAiE;AAAxD,oHAAA,gBAAgB,OAAA;AAGzB,kDAgB8B;AAf1B,yGAAA,YAAY,OAAA;AACZ,2GAAA,cAAc,OAAA;AACd,8GAAA,iBAAiB,OAAA;AACjB,gHAAA,mBAAmB,OAAA;AACnB,yGAAA,YAAY,OAAA;AACZ,0GAAA,aAAa,OAAA;AACb,yGAAA,YAAY,OAAA;AACZ,4GAAA,eAAe,OAAA;AACf,8GAAA,iBAAiB,OAAA;AACjB,2GAAA,cAAc,OAAA;AACd,8GAAA,iBAAiB,OAAA;AACjB,iHAAA,oBAAoB,OAAA;AACpB,iHAAA,oBAAoB,OAAA;AACpB,+GAAA,kBAAkB,OAAA;AAClB,gHAAA,mBAAmB,OAAA;AAEvB,4DAA2D;AAAlD,gHAAA,cAAc,OAAA;AAEvB,iFAAoG;AAA3F,8HAAA,qBAAqB,OAAA;AAC9B,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AAExB,iEAAgE;AAAvD,oHAAA,gBAAgB,OAAA;AACzB,4DAA4E;AAAnE,gHAAA,cAAc,OAAA;AACvB,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AAExB,sDAAqD;AAA5C,4GAAA,YAAY,OAAA;AAGrB,2EAAyF;AAAhF,0HAAA,mBAAmB,OAAA;AAC5B,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AAExB,8EAA6E;AAApE,4HAAA,oBAAoB,OAAA;AAE7B,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AACpB,qEAAoE;AAA3D,sHAAA,iBAAiB,OAAA;AAC1B,mFAAkF;AAAzE,oIAAA,wBAAwB,OAAA;AACjC,2CAA0C;AAAjC,4FAAA,IAAI,OAAA;AACb,iDAAgD;AAAvC,kGAAA,OAAO,OAAA;AAChB,6DAA4D;AAAnD,8GAAA,aAAa,OAAA;AAItB,4DAA2D;AAAlD,gHAAA,cAAc,OAAA;AACvB,qEAAwF;AAA/E,sHAAA,iBAAiB,OAAA","sourcesContent":["export { TableEditPlugin } from './tableEdit/TableEditPlugin';\nexport { OnTableEditorCreatedCallback } from './tableEdit/OnTableEditorCreatedCallback';\nexport { TableEditFeatureName } from './tableEdit/editors/features/TableEditFeatureName';\nexport { TableWithRoot } from './tableEdit/TableWithRoot';\nexport { PastePlugin } from './paste/PastePlugin';\nexport { DefaultSanitizers } from './paste/DefaultSanitizers';\nexport { EditPlugin } from './edit/EditPlugin';\nexport { EditOptions, HandleTabOptions } from './edit/EditOptions';\nexport { AutoFormatPlugin } from './autoFormat/AutoFormatPlugin';\nexport { AutoFormatOptions } from './autoFormat/interface/AutoFormatOptions';\n\nexport {\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} from './shortcut/shortcuts';\nexport { ShortcutPlugin } from './shortcut/ShortcutPlugin';\nexport { ShortcutKeyDefinition, ShortcutCommand } from './shortcut/ShortcutCommand';\nexport { ContextMenuPluginBase, ContextMenuOptions } from './contextMenuBase/ContextMenuPluginBase';\nexport { WatermarkPlugin } from './watermark/WatermarkPlugin';\nexport { WatermarkFormat } from './watermark/WatermarkFormat';\nexport { isModelEmptyFast } from './watermark/isModelEmptyFast';\nexport { MarkdownPlugin, MarkdownOptions } from './markdown/MarkdownPlugin';\nexport { HyperlinkPlugin } from './hyperlink/HyperlinkPlugin';\nexport { HyperlinkToolTip } from './hyperlink/HyperlinkToolTip';\nexport { PickerPlugin } from './picker/PickerPlugin';\nexport { PickerHelper } from './picker/PickerHelper';\nexport { PickerSelectionChangMode, PickerDirection, PickerHandler } from './picker/PickerHandler';\nexport { CustomReplacePlugin, CustomReplace } from './customReplace/CustomReplacePlugin';\nexport { ImageEditPlugin } from './imageEdit/ImageEditPlugin';\nexport { ImageEditOptions } from './imageEdit/types/ImageEditOptions';\nexport { HiddenPropertyPlugin } from './hiddenProperty/HiddenPropertyPlugin';\nexport { HiddenPropertyOptions } from './hiddenProperty/HiddenPropertyOptions';\nexport { TouchPlugin } from './touch/TouchPlugin';\nexport { FindReplacePlugin } from './findReplace/FindReplacePlugin';\nexport { createFindReplaceContext } from './findReplace/createFindReplaceContext';\nexport { find } from './findReplace/find';\nexport { replace } from './findReplace/replace';\nexport { moveHighlight } from './findReplace/moveHighlight';\nexport { FindReplaceContext } from './findReplace/types/FindReplaceContext';\nexport { HighlightHelper } from './findReplace/types/HighlightHelper';\nexport { FindReplaceHighlightOptions } from './findReplace/types/FindReplaceHighlightOptions';\nexport { AnnouncePlugin } from './announce/AnnouncePlugin';\nexport { DragAndDropPlugin, DragAndDropOptions } from './dragAndDrop/DragAndDropPlugin';\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Options for DragAndDrop plugin
|
|
4
|
+
*/
|
|
5
|
+
export interface DragAndDropOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Forbidden elements that cannot be dropped in the editor
|
|
8
|
+
* @default ['iframe']
|
|
9
|
+
*/
|
|
10
|
+
forbiddenElements?: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* DragAndDrop plugin, handles ContentChanged event when change source is "Drop"
|
|
14
|
+
* to sanitize dropped content, similar to how PastePlugin sanitizes pasted content.
|
|
15
|
+
*/
|
|
16
|
+
export declare class DragAndDropPlugin implements EditorPlugin {
|
|
17
|
+
private editor;
|
|
18
|
+
private forbiddenElements;
|
|
19
|
+
private isInternalDragging;
|
|
20
|
+
private disposer;
|
|
21
|
+
/**
|
|
22
|
+
* Construct a new instance of DragAndDropPlugin
|
|
23
|
+
*/
|
|
24
|
+
constructor(options?: DragAndDropOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Get name of this plugin
|
|
27
|
+
*/
|
|
28
|
+
getName(): string;
|
|
29
|
+
/**
|
|
30
|
+
* The first method that editor will call to a plugin when editor is initializing.
|
|
31
|
+
* It will pass in the editor instance, plugin should take this chance to save the
|
|
32
|
+
* editor reference so that it can call to any editor method or format API later.
|
|
33
|
+
* @param editor The editor object
|
|
34
|
+
*/
|
|
35
|
+
initialize(editor: IEditor): void;
|
|
36
|
+
/**
|
|
37
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
38
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
39
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
40
|
+
*/
|
|
41
|
+
dispose(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
44
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
45
|
+
* exclusively by another plugin.
|
|
46
|
+
* @param event The event to handle:
|
|
47
|
+
*/
|
|
48
|
+
onPluginEvent(event: PluginEvent): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
define(["require", "exports", "./utils/handleDroppedContent"], function (require, exports, handleDroppedContent_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.DragAndDropPlugin = void 0;
|
|
5
|
+
var DefaultOptions = {
|
|
6
|
+
forbiddenElements: ['iframe'],
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* DragAndDrop plugin, handles ContentChanged event when change source is "Drop"
|
|
10
|
+
* to sanitize dropped content, similar to how PastePlugin sanitizes pasted content.
|
|
11
|
+
*/
|
|
12
|
+
var DragAndDropPlugin = /** @class */ (function () {
|
|
13
|
+
/**
|
|
14
|
+
* Construct a new instance of DragAndDropPlugin
|
|
15
|
+
*/
|
|
16
|
+
function DragAndDropPlugin(options) {
|
|
17
|
+
if (options === void 0) { options = DefaultOptions; }
|
|
18
|
+
var _a;
|
|
19
|
+
this.editor = null;
|
|
20
|
+
this.forbiddenElements = [];
|
|
21
|
+
this.isInternalDragging = false;
|
|
22
|
+
this.disposer = null;
|
|
23
|
+
this.forbiddenElements = (_a = options.forbiddenElements) !== null && _a !== void 0 ? _a : [];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get name of this plugin
|
|
27
|
+
*/
|
|
28
|
+
DragAndDropPlugin.prototype.getName = function () {
|
|
29
|
+
return 'DragAndDrop';
|
|
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
|
+
DragAndDropPlugin.prototype.initialize = function (editor) {
|
|
38
|
+
var _this = this;
|
|
39
|
+
this.editor = editor;
|
|
40
|
+
this.disposer = editor.attachDomEvent({
|
|
41
|
+
dragstart: {
|
|
42
|
+
beforeDispatch: function (_ev) {
|
|
43
|
+
_this.isInternalDragging = true;
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
50
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
51
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
52
|
+
*/
|
|
53
|
+
DragAndDropPlugin.prototype.dispose = function () {
|
|
54
|
+
this.editor = null;
|
|
55
|
+
if (this.disposer) {
|
|
56
|
+
this.disposer();
|
|
57
|
+
this.disposer = null;
|
|
58
|
+
}
|
|
59
|
+
this.isInternalDragging = false;
|
|
60
|
+
this.forbiddenElements = [];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
64
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
65
|
+
* exclusively by another plugin.
|
|
66
|
+
* @param event The event to handle:
|
|
67
|
+
*/
|
|
68
|
+
DragAndDropPlugin.prototype.onPluginEvent = function (event) {
|
|
69
|
+
var _a;
|
|
70
|
+
if (this.editor && event.eventType == 'beforeDrop') {
|
|
71
|
+
if (this.isInternalDragging) {
|
|
72
|
+
this.isInternalDragging = false;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
var dropEvent = event.rawEvent;
|
|
76
|
+
var html = (_a = dropEvent.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData('text/html');
|
|
77
|
+
if (html) {
|
|
78
|
+
(0, handleDroppedContent_1.handleDroppedContent)(this.editor, dropEvent, html, this.forbiddenElements);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
return DragAndDropPlugin;
|
|
85
|
+
}());
|
|
86
|
+
exports.DragAndDropPlugin = DragAndDropPlugin;
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=DragAndDropPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DragAndDropPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/dragAndDrop/DragAndDropPlugin.ts"],"names":[],"mappings":";;;;IAcA,IAAM,cAAc,GAAG;QACnB,iBAAiB,EAAE,CAAC,QAAQ,CAAC;KAChC,CAAC;IAEF;;;OAGG;IACH;QAMI;;WAEG;QACH,2BAAY,OAA4C;YAA5C,wBAAA,EAAA,wBAA4C;;YARhD,WAAM,GAAmB,IAAI,CAAC;YAC9B,sBAAiB,GAAa,EAAE,CAAC;YACjC,uBAAkB,GAAY,KAAK,CAAC;YACpC,aAAQ,GAAwB,IAAI,CAAC;YAMzC,IAAI,CAAC,iBAAiB,GAAG,MAAA,OAAO,CAAC,iBAAiB,mCAAI,EAAE,CAAC;QAC7D,CAAC;QAED;;WAEG;QACH,mCAAO,GAAP;YACI,OAAO,aAAa,CAAC;QACzB,CAAC;QAED;;;;;WAKG;QACH,sCAAU,GAAV,UAAW,MAAe;YAA1B,iBASC;YARG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC;gBAClC,SAAS,EAAE;oBACP,cAAc,EAAE,UAAA,GAAG;wBACf,KAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;oBACnC,CAAC;iBACJ;aACJ,CAAC,CAAC;QACP,CAAC;QAED;;;;WAIG;QACH,mCAAO,GAAP;YACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACf,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAChB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;aACxB;YACD,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;YAChC,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAChC,CAAC;QAED;;;;;WAKG;QACH,yCAAa,GAAb,UAAc,KAAkB;;YAC5B,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,YAAY,EAAE;gBAChD,IAAI,IAAI,CAAC,kBAAkB,EAAE;oBACzB,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;iBACnC;qBAAM;oBACH,IAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC;oBACjC,IAAM,IAAI,GAAG,MAAA,SAAS,CAAC,YAAY,0CAAE,OAAO,CAAC,WAAW,CAAC,CAAC;oBAE1D,IAAI,IAAI,EAAE;wBACN,IAAA,2CAAoB,EAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;qBAC9E;iBACJ;gBACD,OAAO;aACV;QACL,CAAC;QACL,wBAAC;IAAD,CAAC,AAzED,IAyEC;IAzEY,8CAAiB","sourcesContent":["import { handleDroppedContent } from './utils/handleDroppedContent';\nimport type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';\n\n/**\n * Options for DragAndDrop plugin\n */\nexport interface DragAndDropOptions {\n /**\n * Forbidden elements that cannot be dropped in the editor\n * @default ['iframe']\n */\n forbiddenElements?: string[];\n}\n\nconst DefaultOptions = {\n forbiddenElements: ['iframe'],\n};\n\n/**\n * DragAndDrop plugin, handles ContentChanged event when change source is \"Drop\"\n * to sanitize dropped content, similar to how PastePlugin sanitizes pasted content.\n */\nexport class DragAndDropPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private forbiddenElements: string[] = [];\n private isInternalDragging: boolean = false;\n private disposer: (() => void) | null = null;\n\n /**\n * Construct a new instance of DragAndDropPlugin\n */\n constructor(options: DragAndDropOptions = DefaultOptions) {\n this.forbiddenElements = options.forbiddenElements ?? [];\n }\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'DragAndDrop';\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.disposer = editor.attachDomEvent({\n dragstart: {\n beforeDispatch: _ev => {\n this.isInternalDragging = true;\n },\n },\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.editor = null;\n if (this.disposer) {\n this.disposer();\n this.disposer = null;\n }\n this.isInternalDragging = false;\n this.forbiddenElements = [];\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 == 'beforeDrop') {\n if (this.isInternalDragging) {\n this.isInternalDragging = false;\n } else {\n const dropEvent = event.rawEvent;\n const html = dropEvent.dataTransfer?.getData('text/html');\n\n if (html) {\n handleDroppedContent(this.editor, dropEvent, html, this.forbiddenElements);\n }\n }\n return;\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* Remove all forbidden elements from a parsed HTML document
|
|
4
|
+
* @param doc The parsed HTML document to clean
|
|
5
|
+
* @param forbiddenElements Array of tag names to remove (e.g., ['iframe', 'script'])
|
|
6
|
+
*/
|
|
7
|
+
export declare function cleanForbiddenElements(doc: Document, forbiddenElements: string[]): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.cleanForbiddenElements = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
* Remove all forbidden elements from a parsed HTML document
|
|
8
|
+
* @param doc The parsed HTML document to clean
|
|
9
|
+
* @param forbiddenElements Array of tag names to remove (e.g., ['iframe', 'script'])
|
|
10
|
+
*/
|
|
11
|
+
function cleanForbiddenElements(doc, forbiddenElements) {
|
|
12
|
+
var e_1, _a;
|
|
13
|
+
var _b;
|
|
14
|
+
if (forbiddenElements.length === 0) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
var selector = forbiddenElements.join(',');
|
|
18
|
+
var elements = Array.from(doc.body.querySelectorAll(selector));
|
|
19
|
+
try {
|
|
20
|
+
for (var elements_1 = (0, tslib_1.__values)(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
|
|
21
|
+
var element = elements_1_1.value;
|
|
22
|
+
(_b = element.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(element);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
26
|
+
finally {
|
|
27
|
+
try {
|
|
28
|
+
if (elements_1_1 && !elements_1_1.done && (_a = elements_1.return)) _a.call(elements_1);
|
|
29
|
+
}
|
|
30
|
+
finally { if (e_1) throw e_1.error; }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.cleanForbiddenElements = cleanForbiddenElements;
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=cleanForbiddenElements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanForbiddenElements.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/cleanForbiddenElements.ts"],"names":[],"mappings":";;;;IAAA;;;;;OAKG;IACH,SAAgB,sBAAsB,CAAC,GAAa,EAAE,iBAA2B;;;QAC7E,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE;YAChC,OAAO;SACV;QAED,IAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;;YAEjE,KAAsB,IAAA,aAAA,sBAAA,QAAQ,CAAA,kCAAA,wDAAE;gBAA3B,IAAM,OAAO,qBAAA;gBACd,MAAA,OAAO,CAAC,UAAU,0CAAE,WAAW,CAAC,OAAO,CAAC,CAAC;aAC5C;;;;;;;;;IACL,CAAC;IAXD,wDAWC","sourcesContent":["/**\n * @internal\n * Remove all forbidden elements from a parsed HTML document\n * @param doc The parsed HTML document to clean\n * @param forbiddenElements Array of tag names to remove (e.g., ['iframe', 'script'])\n */\nexport function cleanForbiddenElements(doc: Document, forbiddenElements: string[]): void {\n if (forbiddenElements.length === 0) {\n return;\n }\n\n const selector = forbiddenElements.join(',');\n const elements = Array.from(doc.body.querySelectorAll(selector));\n\n for (const element of elements) {\n element.parentNode?.removeChild(element);\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IEditor } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Handle dropped HTML content by inserting it at the drop position
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleDroppedContent(editor: IEditor, event: DragEvent, html: string, forbiddenElements: string[]): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
define(["require", "exports", "./cleanForbiddenElements", "roosterjs-content-model-dom"], function (require, exports, cleanForbiddenElements_1, roosterjs_content_model_dom_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.handleDroppedContent = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
* Handle dropped HTML content by inserting it at the drop position
|
|
8
|
+
*/
|
|
9
|
+
function handleDroppedContent(editor, event, html, forbiddenElements) {
|
|
10
|
+
var doc = editor.getDocument();
|
|
11
|
+
var domPosition = (0, roosterjs_content_model_dom_1.getNodePositionFromEvent)(doc, editor.getDOMHelper(), event.x, event.y);
|
|
12
|
+
if (domPosition) {
|
|
13
|
+
event.preventDefault();
|
|
14
|
+
event.stopPropagation();
|
|
15
|
+
var range = doc.createRange();
|
|
16
|
+
range.setStart(domPosition.node, domPosition.offset);
|
|
17
|
+
range.collapse(true);
|
|
18
|
+
var parsedHtml = editor.getDOMCreator().htmlToDOM(html);
|
|
19
|
+
(0, cleanForbiddenElements_1.cleanForbiddenElements)(parsedHtml, forbiddenElements);
|
|
20
|
+
var droppedModel_1 = (0, roosterjs_content_model_dom_1.domToContentModel)(parsedHtml.body, (0, roosterjs_content_model_dom_1.createDomToModelContext)());
|
|
21
|
+
editor.formatContentModel(function (model, context) {
|
|
22
|
+
(0, roosterjs_content_model_dom_1.mergeModel)(model, droppedModel_1, context);
|
|
23
|
+
return true;
|
|
24
|
+
}, {
|
|
25
|
+
selectionOverride: {
|
|
26
|
+
type: 'range',
|
|
27
|
+
range: range,
|
|
28
|
+
isReverted: false,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.handleDroppedContent = handleDroppedContent;
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=handleDroppedContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleDroppedContent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/handleDroppedContent.ts"],"names":[],"mappings":";;;;IASA;;;OAGG;IACH,SAAgB,oBAAoB,CAChC,MAAe,EACf,KAAgB,EAChB,IAAY,EACZ,iBAA2B;QAE3B,IAAM,GAAG,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QACjC,IAAM,WAAW,GAAG,IAAA,sDAAwB,EAAC,GAAG,EAAE,MAAM,CAAC,YAAY,EAAE,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QAE3F,IAAI,WAAW,EAAE;YACb,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,KAAK,CAAC,eAAe,EAAE,CAAC;YAExB,IAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;YAChC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;YACrD,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAErB,IAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAC1D,IAAA,+CAAsB,EAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;YAEtD,IAAM,cAAY,GAAG,IAAA,+CAAiB,EAAC,UAAU,CAAC,IAAI,EAAE,IAAA,qDAAuB,GAAE,CAAC,CAAC;YAEnF,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;gBACX,IAAA,wCAAU,EAAC,KAAK,EAAE,cAAY,EAAE,OAAO,CAAC,CAAC;gBACzC,OAAO,IAAI,CAAC;YAChB,CAAC,EACD;gBACI,iBAAiB,EAAE;oBACf,IAAI,EAAE,OAAO;oBACb,KAAK,OAAA;oBACL,UAAU,EAAE,KAAK;iBACpB;aACJ,CACJ,CAAC;SACL;IACL,CAAC;IApCD,oDAoCC","sourcesContent":["import { cleanForbiddenElements } from './cleanForbiddenElements';\nimport {\n createDomToModelContext,\n domToContentModel,\n getNodePositionFromEvent,\n mergeModel,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Handle dropped HTML content by inserting it at the drop position\n */\nexport function handleDroppedContent(\n editor: IEditor,\n event: DragEvent,\n html: string,\n forbiddenElements: string[]\n): void {\n const doc = editor.getDocument();\n const domPosition = getNodePositionFromEvent(doc, editor.getDOMHelper(), event.x, event.y);\n\n if (domPosition) {\n event.preventDefault();\n event.stopPropagation();\n\n const range = doc.createRange();\n range.setStart(domPosition.node, domPosition.offset);\n range.collapse(true);\n\n const parsedHtml = editor.getDOMCreator().htmlToDOM(html);\n cleanForbiddenElements(parsedHtml, forbiddenElements);\n\n const droppedModel = domToContentModel(parsedHtml.body, createDomToModelContext());\n\n editor.formatContentModel(\n (model, context) => {\n mergeModel(model, droppedModel, context);\n return true;\n },\n {\n selectionOverride: {\n type: 'range',\n range,\n isReverted: false,\n },\n }\n );\n }\n}\n"]}
|
package/lib-amd/index.d.ts
CHANGED
|
@@ -36,3 +36,4 @@ export { FindReplaceContext } from './findReplace/types/FindReplaceContext';
|
|
|
36
36
|
export { HighlightHelper } from './findReplace/types/HighlightHelper';
|
|
37
37
|
export { FindReplaceHighlightOptions } from './findReplace/types/FindReplaceHighlightOptions';
|
|
38
38
|
export { AnnouncePlugin } from './announce/AnnouncePlugin';
|
|
39
|
+
export { DragAndDropPlugin, DragAndDropOptions } from './dragAndDrop/DragAndDropPlugin';
|
package/lib-amd/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
define(["require", "exports", "./tableEdit/TableEditPlugin", "./paste/PastePlugin", "./paste/DefaultSanitizers", "./edit/EditPlugin", "./autoFormat/AutoFormatPlugin", "./shortcut/shortcuts", "./shortcut/ShortcutPlugin", "./contextMenuBase/ContextMenuPluginBase", "./watermark/WatermarkPlugin", "./watermark/isModelEmptyFast", "./markdown/MarkdownPlugin", "./hyperlink/HyperlinkPlugin", "./picker/PickerPlugin", "./customReplace/CustomReplacePlugin", "./imageEdit/ImageEditPlugin", "./hiddenProperty/HiddenPropertyPlugin", "./touch/TouchPlugin", "./findReplace/FindReplacePlugin", "./findReplace/createFindReplaceContext", "./findReplace/find", "./findReplace/replace", "./findReplace/moveHighlight", "./announce/AnnouncePlugin"], function (require, exports, TableEditPlugin_1, PastePlugin_1, DefaultSanitizers_1, EditPlugin_1, AutoFormatPlugin_1, shortcuts_1, ShortcutPlugin_1, ContextMenuPluginBase_1, WatermarkPlugin_1, isModelEmptyFast_1, MarkdownPlugin_1, HyperlinkPlugin_1, PickerPlugin_1, CustomReplacePlugin_1, ImageEditPlugin_1, HiddenPropertyPlugin_1, TouchPlugin_1, FindReplacePlugin_1, createFindReplaceContext_1, find_1, replace_1, moveHighlight_1, AnnouncePlugin_1) {
|
|
1
|
+
define(["require", "exports", "./tableEdit/TableEditPlugin", "./paste/PastePlugin", "./paste/DefaultSanitizers", "./edit/EditPlugin", "./autoFormat/AutoFormatPlugin", "./shortcut/shortcuts", "./shortcut/ShortcutPlugin", "./contextMenuBase/ContextMenuPluginBase", "./watermark/WatermarkPlugin", "./watermark/isModelEmptyFast", "./markdown/MarkdownPlugin", "./hyperlink/HyperlinkPlugin", "./picker/PickerPlugin", "./customReplace/CustomReplacePlugin", "./imageEdit/ImageEditPlugin", "./hiddenProperty/HiddenPropertyPlugin", "./touch/TouchPlugin", "./findReplace/FindReplacePlugin", "./findReplace/createFindReplaceContext", "./findReplace/find", "./findReplace/replace", "./findReplace/moveHighlight", "./announce/AnnouncePlugin", "./dragAndDrop/DragAndDropPlugin"], function (require, exports, TableEditPlugin_1, PastePlugin_1, DefaultSanitizers_1, EditPlugin_1, AutoFormatPlugin_1, shortcuts_1, ShortcutPlugin_1, ContextMenuPluginBase_1, WatermarkPlugin_1, isModelEmptyFast_1, MarkdownPlugin_1, HyperlinkPlugin_1, PickerPlugin_1, CustomReplacePlugin_1, ImageEditPlugin_1, HiddenPropertyPlugin_1, TouchPlugin_1, FindReplacePlugin_1, createFindReplaceContext_1, find_1, replace_1, moveHighlight_1, AnnouncePlugin_1, DragAndDropPlugin_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.AnnouncePlugin = exports.moveHighlight = exports.replace = exports.find = exports.createFindReplaceContext = exports.FindReplacePlugin = exports.TouchPlugin = exports.HiddenPropertyPlugin = exports.ImageEditPlugin = exports.CustomReplacePlugin = exports.PickerPlugin = exports.HyperlinkPlugin = exports.MarkdownPlugin = exports.isModelEmptyFast = exports.WatermarkPlugin = exports.ContextMenuPluginBase = exports.ShortcutPlugin = exports.ShortcutOutdentList = exports.ShortcutIndentList = exports.ShortcutDecreaseFont = exports.ShortcutIncreaseFont = exports.ShortcutNumbering = exports.ShortcutBullet = exports.ShortcutRedoMacOS = exports.ShortcutRedoAlt = exports.ShortcutRedo = exports.ShortcutUndo2 = exports.ShortcutUndo = exports.ShortcutClearFormat = exports.ShortcutUnderline = exports.ShortcutItalic = exports.ShortcutBold = exports.AutoFormatPlugin = exports.EditPlugin = exports.DefaultSanitizers = exports.PastePlugin = exports.TableEditPlugin = void 0;
|
|
4
|
+
exports.DragAndDropPlugin = exports.AnnouncePlugin = exports.moveHighlight = exports.replace = exports.find = exports.createFindReplaceContext = exports.FindReplacePlugin = exports.TouchPlugin = exports.HiddenPropertyPlugin = exports.ImageEditPlugin = exports.CustomReplacePlugin = exports.PickerPlugin = exports.HyperlinkPlugin = exports.MarkdownPlugin = exports.isModelEmptyFast = exports.WatermarkPlugin = exports.ContextMenuPluginBase = exports.ShortcutPlugin = exports.ShortcutOutdentList = exports.ShortcutIndentList = exports.ShortcutDecreaseFont = exports.ShortcutIncreaseFont = exports.ShortcutNumbering = exports.ShortcutBullet = exports.ShortcutRedoMacOS = exports.ShortcutRedoAlt = exports.ShortcutRedo = exports.ShortcutUndo2 = exports.ShortcutUndo = exports.ShortcutClearFormat = exports.ShortcutUnderline = exports.ShortcutItalic = exports.ShortcutBold = exports.AutoFormatPlugin = exports.EditPlugin = exports.DefaultSanitizers = exports.PastePlugin = exports.TableEditPlugin = void 0;
|
|
5
5
|
Object.defineProperty(exports, "TableEditPlugin", { enumerable: true, get: function () { return TableEditPlugin_1.TableEditPlugin; } });
|
|
6
6
|
Object.defineProperty(exports, "PastePlugin", { enumerable: true, get: function () { return PastePlugin_1.PastePlugin; } });
|
|
7
7
|
Object.defineProperty(exports, "DefaultSanitizers", { enumerable: true, get: function () { return DefaultSanitizers_1.DefaultSanitizers; } });
|
|
@@ -39,5 +39,6 @@ define(["require", "exports", "./tableEdit/TableEditPlugin", "./paste/PastePlugi
|
|
|
39
39
|
Object.defineProperty(exports, "replace", { enumerable: true, get: function () { return replace_1.replace; } });
|
|
40
40
|
Object.defineProperty(exports, "moveHighlight", { enumerable: true, get: function () { return moveHighlight_1.moveHighlight; } });
|
|
41
41
|
Object.defineProperty(exports, "AnnouncePlugin", { enumerable: true, get: function () { return AnnouncePlugin_1.AnnouncePlugin; } });
|
|
42
|
+
Object.defineProperty(exports, "DragAndDropPlugin", { enumerable: true, get: function () { return DragAndDropPlugin_1.DragAndDropPlugin; } });
|
|
42
43
|
});
|
|
43
44
|
//# sourceMappingURL=index.js.map
|
package/lib-amd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-plugins/lib/index.ts"],"names":[],"mappings":";;;;IAAS,kHAAA,eAAe,OAAA;IAIf,0GAAA,WAAW,OAAA;IACX,sHAAA,iBAAiB,OAAA;IACjB,wGAAA,UAAU,OAAA;IAEV,oHAAA,gBAAgB,OAAA;IAIrB,yGAAA,YAAY,OAAA;IACZ,2GAAA,cAAc,OAAA;IACd,8GAAA,iBAAiB,OAAA;IACjB,gHAAA,mBAAmB,OAAA;IACnB,yGAAA,YAAY,OAAA;IACZ,0GAAA,aAAa,OAAA;IACb,yGAAA,YAAY,OAAA;IACZ,4GAAA,eAAe,OAAA;IACf,8GAAA,iBAAiB,OAAA;IACjB,2GAAA,cAAc,OAAA;IACd,8GAAA,iBAAiB,OAAA;IACjB,iHAAA,oBAAoB,OAAA;IACpB,iHAAA,oBAAoB,OAAA;IACpB,+GAAA,kBAAkB,OAAA;IAClB,gHAAA,mBAAmB,OAAA;IAEd,gHAAA,cAAc,OAAA;IAEd,8HAAA,qBAAqB,OAAA;IACrB,kHAAA,eAAe,OAAA;IAEf,oHAAA,gBAAgB,OAAA;IAChB,gHAAA,cAAc,OAAA;IACd,kHAAA,eAAe,OAAA;IAEf,4GAAA,YAAY,OAAA;IAGZ,0HAAA,mBAAmB,OAAA;IACnB,kHAAA,eAAe,OAAA;IAEf,4HAAA,oBAAoB,OAAA;IAEpB,0GAAA,WAAW,OAAA;IACX,sHAAA,iBAAiB,OAAA;IACjB,oIAAA,wBAAwB,OAAA;IACxB,4FAAA,IAAI,OAAA;IACJ,kGAAA,OAAO,OAAA;IACP,8GAAA,aAAa,OAAA;IAIb,gHAAA,cAAc,OAAA","sourcesContent":["export { TableEditPlugin } from './tableEdit/TableEditPlugin';\nexport { OnTableEditorCreatedCallback } from './tableEdit/OnTableEditorCreatedCallback';\nexport { TableEditFeatureName } from './tableEdit/editors/features/TableEditFeatureName';\nexport { TableWithRoot } from './tableEdit/TableWithRoot';\nexport { PastePlugin } from './paste/PastePlugin';\nexport { DefaultSanitizers } from './paste/DefaultSanitizers';\nexport { EditPlugin } from './edit/EditPlugin';\nexport { EditOptions, HandleTabOptions } from './edit/EditOptions';\nexport { AutoFormatPlugin } from './autoFormat/AutoFormatPlugin';\nexport { AutoFormatOptions } from './autoFormat/interface/AutoFormatOptions';\n\nexport {\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} from './shortcut/shortcuts';\nexport { ShortcutPlugin } from './shortcut/ShortcutPlugin';\nexport { ShortcutKeyDefinition, ShortcutCommand } from './shortcut/ShortcutCommand';\nexport { ContextMenuPluginBase, ContextMenuOptions } from './contextMenuBase/ContextMenuPluginBase';\nexport { WatermarkPlugin } from './watermark/WatermarkPlugin';\nexport { WatermarkFormat } from './watermark/WatermarkFormat';\nexport { isModelEmptyFast } from './watermark/isModelEmptyFast';\nexport { MarkdownPlugin, MarkdownOptions } from './markdown/MarkdownPlugin';\nexport { HyperlinkPlugin } from './hyperlink/HyperlinkPlugin';\nexport { HyperlinkToolTip } from './hyperlink/HyperlinkToolTip';\nexport { PickerPlugin } from './picker/PickerPlugin';\nexport { PickerHelper } from './picker/PickerHelper';\nexport { PickerSelectionChangMode, PickerDirection, PickerHandler } from './picker/PickerHandler';\nexport { CustomReplacePlugin, CustomReplace } from './customReplace/CustomReplacePlugin';\nexport { ImageEditPlugin } from './imageEdit/ImageEditPlugin';\nexport { ImageEditOptions } from './imageEdit/types/ImageEditOptions';\nexport { HiddenPropertyPlugin } from './hiddenProperty/HiddenPropertyPlugin';\nexport { HiddenPropertyOptions } from './hiddenProperty/HiddenPropertyOptions';\nexport { TouchPlugin } from './touch/TouchPlugin';\nexport { FindReplacePlugin } from './findReplace/FindReplacePlugin';\nexport { createFindReplaceContext } from './findReplace/createFindReplaceContext';\nexport { find } from './findReplace/find';\nexport { replace } from './findReplace/replace';\nexport { moveHighlight } from './findReplace/moveHighlight';\nexport { FindReplaceContext } from './findReplace/types/FindReplaceContext';\nexport { HighlightHelper } from './findReplace/types/HighlightHelper';\nexport { FindReplaceHighlightOptions } from './findReplace/types/FindReplaceHighlightOptions';\nexport { AnnouncePlugin } from './announce/AnnouncePlugin';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-plugins/lib/index.ts"],"names":[],"mappings":";;;;IAAS,kHAAA,eAAe,OAAA;IAIf,0GAAA,WAAW,OAAA;IACX,sHAAA,iBAAiB,OAAA;IACjB,wGAAA,UAAU,OAAA;IAEV,oHAAA,gBAAgB,OAAA;IAIrB,yGAAA,YAAY,OAAA;IACZ,2GAAA,cAAc,OAAA;IACd,8GAAA,iBAAiB,OAAA;IACjB,gHAAA,mBAAmB,OAAA;IACnB,yGAAA,YAAY,OAAA;IACZ,0GAAA,aAAa,OAAA;IACb,yGAAA,YAAY,OAAA;IACZ,4GAAA,eAAe,OAAA;IACf,8GAAA,iBAAiB,OAAA;IACjB,2GAAA,cAAc,OAAA;IACd,8GAAA,iBAAiB,OAAA;IACjB,iHAAA,oBAAoB,OAAA;IACpB,iHAAA,oBAAoB,OAAA;IACpB,+GAAA,kBAAkB,OAAA;IAClB,gHAAA,mBAAmB,OAAA;IAEd,gHAAA,cAAc,OAAA;IAEd,8HAAA,qBAAqB,OAAA;IACrB,kHAAA,eAAe,OAAA;IAEf,oHAAA,gBAAgB,OAAA;IAChB,gHAAA,cAAc,OAAA;IACd,kHAAA,eAAe,OAAA;IAEf,4GAAA,YAAY,OAAA;IAGZ,0HAAA,mBAAmB,OAAA;IACnB,kHAAA,eAAe,OAAA;IAEf,4HAAA,oBAAoB,OAAA;IAEpB,0GAAA,WAAW,OAAA;IACX,sHAAA,iBAAiB,OAAA;IACjB,oIAAA,wBAAwB,OAAA;IACxB,4FAAA,IAAI,OAAA;IACJ,kGAAA,OAAO,OAAA;IACP,8GAAA,aAAa,OAAA;IAIb,gHAAA,cAAc,OAAA;IACd,sHAAA,iBAAiB,OAAA","sourcesContent":["export { TableEditPlugin } from './tableEdit/TableEditPlugin';\nexport { OnTableEditorCreatedCallback } from './tableEdit/OnTableEditorCreatedCallback';\nexport { TableEditFeatureName } from './tableEdit/editors/features/TableEditFeatureName';\nexport { TableWithRoot } from './tableEdit/TableWithRoot';\nexport { PastePlugin } from './paste/PastePlugin';\nexport { DefaultSanitizers } from './paste/DefaultSanitizers';\nexport { EditPlugin } from './edit/EditPlugin';\nexport { EditOptions, HandleTabOptions } from './edit/EditOptions';\nexport { AutoFormatPlugin } from './autoFormat/AutoFormatPlugin';\nexport { AutoFormatOptions } from './autoFormat/interface/AutoFormatOptions';\n\nexport {\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} from './shortcut/shortcuts';\nexport { ShortcutPlugin } from './shortcut/ShortcutPlugin';\nexport { ShortcutKeyDefinition, ShortcutCommand } from './shortcut/ShortcutCommand';\nexport { ContextMenuPluginBase, ContextMenuOptions } from './contextMenuBase/ContextMenuPluginBase';\nexport { WatermarkPlugin } from './watermark/WatermarkPlugin';\nexport { WatermarkFormat } from './watermark/WatermarkFormat';\nexport { isModelEmptyFast } from './watermark/isModelEmptyFast';\nexport { MarkdownPlugin, MarkdownOptions } from './markdown/MarkdownPlugin';\nexport { HyperlinkPlugin } from './hyperlink/HyperlinkPlugin';\nexport { HyperlinkToolTip } from './hyperlink/HyperlinkToolTip';\nexport { PickerPlugin } from './picker/PickerPlugin';\nexport { PickerHelper } from './picker/PickerHelper';\nexport { PickerSelectionChangMode, PickerDirection, PickerHandler } from './picker/PickerHandler';\nexport { CustomReplacePlugin, CustomReplace } from './customReplace/CustomReplacePlugin';\nexport { ImageEditPlugin } from './imageEdit/ImageEditPlugin';\nexport { ImageEditOptions } from './imageEdit/types/ImageEditOptions';\nexport { HiddenPropertyPlugin } from './hiddenProperty/HiddenPropertyPlugin';\nexport { HiddenPropertyOptions } from './hiddenProperty/HiddenPropertyOptions';\nexport { TouchPlugin } from './touch/TouchPlugin';\nexport { FindReplacePlugin } from './findReplace/FindReplacePlugin';\nexport { createFindReplaceContext } from './findReplace/createFindReplaceContext';\nexport { find } from './findReplace/find';\nexport { replace } from './findReplace/replace';\nexport { moveHighlight } from './findReplace/moveHighlight';\nexport { FindReplaceContext } from './findReplace/types/FindReplaceContext';\nexport { HighlightHelper } from './findReplace/types/HighlightHelper';\nexport { FindReplaceHighlightOptions } from './findReplace/types/FindReplaceHighlightOptions';\nexport { AnnouncePlugin } from './announce/AnnouncePlugin';\nexport { DragAndDropPlugin, DragAndDropOptions } from './dragAndDrop/DragAndDropPlugin';\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Options for DragAndDrop plugin
|
|
4
|
+
*/
|
|
5
|
+
export interface DragAndDropOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Forbidden elements that cannot be dropped in the editor
|
|
8
|
+
* @default ['iframe']
|
|
9
|
+
*/
|
|
10
|
+
forbiddenElements?: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* DragAndDrop plugin, handles ContentChanged event when change source is "Drop"
|
|
14
|
+
* to sanitize dropped content, similar to how PastePlugin sanitizes pasted content.
|
|
15
|
+
*/
|
|
16
|
+
export declare class DragAndDropPlugin implements EditorPlugin {
|
|
17
|
+
private editor;
|
|
18
|
+
private forbiddenElements;
|
|
19
|
+
private isInternalDragging;
|
|
20
|
+
private disposer;
|
|
21
|
+
/**
|
|
22
|
+
* Construct a new instance of DragAndDropPlugin
|
|
23
|
+
*/
|
|
24
|
+
constructor(options?: DragAndDropOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Get name of this plugin
|
|
27
|
+
*/
|
|
28
|
+
getName(): string;
|
|
29
|
+
/**
|
|
30
|
+
* The first method that editor will call to a plugin when editor is initializing.
|
|
31
|
+
* It will pass in the editor instance, plugin should take this chance to save the
|
|
32
|
+
* editor reference so that it can call to any editor method or format API later.
|
|
33
|
+
* @param editor The editor object
|
|
34
|
+
*/
|
|
35
|
+
initialize(editor: IEditor): void;
|
|
36
|
+
/**
|
|
37
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
38
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
39
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
40
|
+
*/
|
|
41
|
+
dispose(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
44
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
45
|
+
* exclusively by another plugin.
|
|
46
|
+
* @param event The event to handle:
|
|
47
|
+
*/
|
|
48
|
+
onPluginEvent(event: PluginEvent): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { handleDroppedContent } from './utils/handleDroppedContent';
|
|
2
|
+
var DefaultOptions = {
|
|
3
|
+
forbiddenElements: ['iframe'],
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* DragAndDrop plugin, handles ContentChanged event when change source is "Drop"
|
|
7
|
+
* to sanitize dropped content, similar to how PastePlugin sanitizes pasted content.
|
|
8
|
+
*/
|
|
9
|
+
var DragAndDropPlugin = /** @class */ (function () {
|
|
10
|
+
/**
|
|
11
|
+
* Construct a new instance of DragAndDropPlugin
|
|
12
|
+
*/
|
|
13
|
+
function DragAndDropPlugin(options) {
|
|
14
|
+
if (options === void 0) { options = DefaultOptions; }
|
|
15
|
+
var _a;
|
|
16
|
+
this.editor = null;
|
|
17
|
+
this.forbiddenElements = [];
|
|
18
|
+
this.isInternalDragging = false;
|
|
19
|
+
this.disposer = null;
|
|
20
|
+
this.forbiddenElements = (_a = options.forbiddenElements) !== null && _a !== void 0 ? _a : [];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get name of this plugin
|
|
24
|
+
*/
|
|
25
|
+
DragAndDropPlugin.prototype.getName = function () {
|
|
26
|
+
return 'DragAndDrop';
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The first method that editor will call to a plugin when editor is initializing.
|
|
30
|
+
* It will pass in the editor instance, plugin should take this chance to save the
|
|
31
|
+
* editor reference so that it can call to any editor method or format API later.
|
|
32
|
+
* @param editor The editor object
|
|
33
|
+
*/
|
|
34
|
+
DragAndDropPlugin.prototype.initialize = function (editor) {
|
|
35
|
+
var _this = this;
|
|
36
|
+
this.editor = editor;
|
|
37
|
+
this.disposer = editor.attachDomEvent({
|
|
38
|
+
dragstart: {
|
|
39
|
+
beforeDispatch: function (_ev) {
|
|
40
|
+
_this.isInternalDragging = true;
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
47
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
48
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
49
|
+
*/
|
|
50
|
+
DragAndDropPlugin.prototype.dispose = function () {
|
|
51
|
+
this.editor = null;
|
|
52
|
+
if (this.disposer) {
|
|
53
|
+
this.disposer();
|
|
54
|
+
this.disposer = null;
|
|
55
|
+
}
|
|
56
|
+
this.isInternalDragging = false;
|
|
57
|
+
this.forbiddenElements = [];
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
61
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
62
|
+
* exclusively by another plugin.
|
|
63
|
+
* @param event The event to handle:
|
|
64
|
+
*/
|
|
65
|
+
DragAndDropPlugin.prototype.onPluginEvent = function (event) {
|
|
66
|
+
var _a;
|
|
67
|
+
if (this.editor && event.eventType == 'beforeDrop') {
|
|
68
|
+
if (this.isInternalDragging) {
|
|
69
|
+
this.isInternalDragging = false;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
var dropEvent = event.rawEvent;
|
|
73
|
+
var html = (_a = dropEvent.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData('text/html');
|
|
74
|
+
if (html) {
|
|
75
|
+
handleDroppedContent(this.editor, dropEvent, html, this.forbiddenElements);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
return DragAndDropPlugin;
|
|
82
|
+
}());
|
|
83
|
+
export { DragAndDropPlugin };
|
|
84
|
+
//# sourceMappingURL=DragAndDropPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DragAndDropPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/dragAndDrop/DragAndDropPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAcpE,IAAM,cAAc,GAAG;IACnB,iBAAiB,EAAE,CAAC,QAAQ,CAAC;CAChC,CAAC;AAEF;;;GAGG;AACH;IAMI;;OAEG;IACH,2BAAY,OAA4C;QAA5C,wBAAA,EAAA,wBAA4C;;QARhD,WAAM,GAAmB,IAAI,CAAC;QAC9B,sBAAiB,GAAa,EAAE,CAAC;QACjC,uBAAkB,GAAY,KAAK,CAAC;QACpC,aAAQ,GAAwB,IAAI,CAAC;QAMzC,IAAI,CAAC,iBAAiB,GAAG,MAAA,OAAO,CAAC,iBAAiB,mCAAI,EAAE,CAAC;IAC7D,CAAC;IAED;;OAEG;IACH,mCAAO,GAAP;QACI,OAAO,aAAa,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACH,sCAAU,GAAV,UAAW,MAAe;QAA1B,iBASC;QARG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC;YAClC,SAAS,EAAE;gBACP,cAAc,EAAE,UAAA,GAAG;oBACf,KAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;gBACnC,CAAC;aACJ;SACJ,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACH,mCAAO,GAAP;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACxB;QACD,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACH,yCAAa,GAAb,UAAc,KAAkB;;QAC5B,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,YAAY,EAAE;YAChD,IAAI,IAAI,CAAC,kBAAkB,EAAE;gBACzB,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;aACnC;iBAAM;gBACH,IAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC;gBACjC,IAAM,IAAI,GAAG,MAAA,SAAS,CAAC,YAAY,0CAAE,OAAO,CAAC,WAAW,CAAC,CAAC;gBAE1D,IAAI,IAAI,EAAE;oBACN,oBAAoB,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;iBAC9E;aACJ;YACD,OAAO;SACV;IACL,CAAC;IACL,wBAAC;AAAD,CAAC,AAzED,IAyEC","sourcesContent":["import { handleDroppedContent } from './utils/handleDroppedContent';\nimport type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';\n\n/**\n * Options for DragAndDrop plugin\n */\nexport interface DragAndDropOptions {\n /**\n * Forbidden elements that cannot be dropped in the editor\n * @default ['iframe']\n */\n forbiddenElements?: string[];\n}\n\nconst DefaultOptions = {\n forbiddenElements: ['iframe'],\n};\n\n/**\n * DragAndDrop plugin, handles ContentChanged event when change source is \"Drop\"\n * to sanitize dropped content, similar to how PastePlugin sanitizes pasted content.\n */\nexport class DragAndDropPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private forbiddenElements: string[] = [];\n private isInternalDragging: boolean = false;\n private disposer: (() => void) | null = null;\n\n /**\n * Construct a new instance of DragAndDropPlugin\n */\n constructor(options: DragAndDropOptions = DefaultOptions) {\n this.forbiddenElements = options.forbiddenElements ?? [];\n }\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'DragAndDrop';\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.disposer = editor.attachDomEvent({\n dragstart: {\n beforeDispatch: _ev => {\n this.isInternalDragging = true;\n },\n },\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.editor = null;\n if (this.disposer) {\n this.disposer();\n this.disposer = null;\n }\n this.isInternalDragging = false;\n this.forbiddenElements = [];\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 == 'beforeDrop') {\n if (this.isInternalDragging) {\n this.isInternalDragging = false;\n } else {\n const dropEvent = event.rawEvent;\n const html = dropEvent.dataTransfer?.getData('text/html');\n\n if (html) {\n handleDroppedContent(this.editor, dropEvent, html, this.forbiddenElements);\n }\n }\n return;\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* Remove all forbidden elements from a parsed HTML document
|
|
4
|
+
* @param doc The parsed HTML document to clean
|
|
5
|
+
* @param forbiddenElements Array of tag names to remove (e.g., ['iframe', 'script'])
|
|
6
|
+
*/
|
|
7
|
+
export declare function cleanForbiddenElements(doc: Document, forbiddenElements: string[]): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __values } from "tslib";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Remove all forbidden elements from a parsed HTML document
|
|
5
|
+
* @param doc The parsed HTML document to clean
|
|
6
|
+
* @param forbiddenElements Array of tag names to remove (e.g., ['iframe', 'script'])
|
|
7
|
+
*/
|
|
8
|
+
export function cleanForbiddenElements(doc, forbiddenElements) {
|
|
9
|
+
var e_1, _a;
|
|
10
|
+
var _b;
|
|
11
|
+
if (forbiddenElements.length === 0) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
var selector = forbiddenElements.join(',');
|
|
15
|
+
var elements = Array.from(doc.body.querySelectorAll(selector));
|
|
16
|
+
try {
|
|
17
|
+
for (var elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
|
|
18
|
+
var element = elements_1_1.value;
|
|
19
|
+
(_b = element.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(element);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
23
|
+
finally {
|
|
24
|
+
try {
|
|
25
|
+
if (elements_1_1 && !elements_1_1.done && (_a = elements_1.return)) _a.call(elements_1);
|
|
26
|
+
}
|
|
27
|
+
finally { if (e_1) throw e_1.error; }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=cleanForbiddenElements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanForbiddenElements.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/cleanForbiddenElements.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAa,EAAE,iBAA2B;;;IAC7E,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE;QAChC,OAAO;KACV;IAED,IAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,IAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;;QAEjE,KAAsB,IAAA,aAAA,SAAA,QAAQ,CAAA,kCAAA,wDAAE;YAA3B,IAAM,OAAO,qBAAA;YACd,MAAA,OAAO,CAAC,UAAU,0CAAE,WAAW,CAAC,OAAO,CAAC,CAAC;SAC5C;;;;;;;;;AACL,CAAC","sourcesContent":["/**\n * @internal\n * Remove all forbidden elements from a parsed HTML document\n * @param doc The parsed HTML document to clean\n * @param forbiddenElements Array of tag names to remove (e.g., ['iframe', 'script'])\n */\nexport function cleanForbiddenElements(doc: Document, forbiddenElements: string[]): void {\n if (forbiddenElements.length === 0) {\n return;\n }\n\n const selector = forbiddenElements.join(',');\n const elements = Array.from(doc.body.querySelectorAll(selector));\n\n for (const element of elements) {\n element.parentNode?.removeChild(element);\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IEditor } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Handle dropped HTML content by inserting it at the drop position
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleDroppedContent(editor: IEditor, event: DragEvent, html: string, forbiddenElements: string[]): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { cleanForbiddenElements } from './cleanForbiddenElements';
|
|
2
|
+
import { createDomToModelContext, domToContentModel, getNodePositionFromEvent, mergeModel, } from 'roosterjs-content-model-dom';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* Handle dropped HTML content by inserting it at the drop position
|
|
6
|
+
*/
|
|
7
|
+
export function handleDroppedContent(editor, event, html, forbiddenElements) {
|
|
8
|
+
var doc = editor.getDocument();
|
|
9
|
+
var domPosition = getNodePositionFromEvent(doc, editor.getDOMHelper(), event.x, event.y);
|
|
10
|
+
if (domPosition) {
|
|
11
|
+
event.preventDefault();
|
|
12
|
+
event.stopPropagation();
|
|
13
|
+
var range = doc.createRange();
|
|
14
|
+
range.setStart(domPosition.node, domPosition.offset);
|
|
15
|
+
range.collapse(true);
|
|
16
|
+
var parsedHtml = editor.getDOMCreator().htmlToDOM(html);
|
|
17
|
+
cleanForbiddenElements(parsedHtml, forbiddenElements);
|
|
18
|
+
var droppedModel_1 = domToContentModel(parsedHtml.body, createDomToModelContext());
|
|
19
|
+
editor.formatContentModel(function (model, context) {
|
|
20
|
+
mergeModel(model, droppedModel_1, context);
|
|
21
|
+
return true;
|
|
22
|
+
}, {
|
|
23
|
+
selectionOverride: {
|
|
24
|
+
type: 'range',
|
|
25
|
+
range: range,
|
|
26
|
+
isReverted: false,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=handleDroppedContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleDroppedContent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/dragAndDrop/utils/handleDroppedContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACH,uBAAuB,EACvB,iBAAiB,EACjB,wBAAwB,EACxB,UAAU,GACb,MAAM,6BAA6B,CAAC;AAGrC;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAChC,MAAe,EACf,KAAgB,EAChB,IAAY,EACZ,iBAA2B;IAE3B,IAAM,GAAG,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACjC,IAAM,WAAW,GAAG,wBAAwB,CAAC,GAAG,EAAE,MAAM,CAAC,YAAY,EAAE,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAE3F,IAAI,WAAW,EAAE;QACb,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,KAAK,CAAC,eAAe,EAAE,CAAC;QAExB,IAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QAChC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QACrD,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAErB,IAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC1D,sBAAsB,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;QAEtD,IAAM,cAAY,GAAG,iBAAiB,CAAC,UAAU,CAAC,IAAI,EAAE,uBAAuB,EAAE,CAAC,CAAC;QAEnF,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;YACX,UAAU,CAAC,KAAK,EAAE,cAAY,EAAE,OAAO,CAAC,CAAC;YACzC,OAAO,IAAI,CAAC;QAChB,CAAC,EACD;YACI,iBAAiB,EAAE;gBACf,IAAI,EAAE,OAAO;gBACb,KAAK,OAAA;gBACL,UAAU,EAAE,KAAK;aACpB;SACJ,CACJ,CAAC;KACL;AACL,CAAC","sourcesContent":["import { cleanForbiddenElements } from './cleanForbiddenElements';\nimport {\n createDomToModelContext,\n domToContentModel,\n getNodePositionFromEvent,\n mergeModel,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Handle dropped HTML content by inserting it at the drop position\n */\nexport function handleDroppedContent(\n editor: IEditor,\n event: DragEvent,\n html: string,\n forbiddenElements: string[]\n): void {\n const doc = editor.getDocument();\n const domPosition = getNodePositionFromEvent(doc, editor.getDOMHelper(), event.x, event.y);\n\n if (domPosition) {\n event.preventDefault();\n event.stopPropagation();\n\n const range = doc.createRange();\n range.setStart(domPosition.node, domPosition.offset);\n range.collapse(true);\n\n const parsedHtml = editor.getDOMCreator().htmlToDOM(html);\n cleanForbiddenElements(parsedHtml, forbiddenElements);\n\n const droppedModel = domToContentModel(parsedHtml.body, createDomToModelContext());\n\n editor.formatContentModel(\n (model, context) => {\n mergeModel(model, droppedModel, context);\n return true;\n },\n {\n selectionOverride: {\n type: 'range',\n range,\n isReverted: false,\n },\n }\n );\n }\n}\n"]}
|
package/lib-mjs/index.d.ts
CHANGED
|
@@ -36,3 +36,4 @@ export { FindReplaceContext } from './findReplace/types/FindReplaceContext';
|
|
|
36
36
|
export { HighlightHelper } from './findReplace/types/HighlightHelper';
|
|
37
37
|
export { FindReplaceHighlightOptions } from './findReplace/types/FindReplaceHighlightOptions';
|
|
38
38
|
export { AnnouncePlugin } from './announce/AnnouncePlugin';
|
|
39
|
+
export { DragAndDropPlugin, DragAndDropOptions } from './dragAndDrop/DragAndDropPlugin';
|
package/lib-mjs/index.js
CHANGED
|
@@ -21,4 +21,5 @@ export { find } from './findReplace/find';
|
|
|
21
21
|
export { replace } from './findReplace/replace';
|
|
22
22
|
export { moveHighlight } from './findReplace/moveHighlight';
|
|
23
23
|
export { AnnouncePlugin } from './announce/AnnouncePlugin';
|
|
24
|
+
export { DragAndDropPlugin } from './dragAndDrop/DragAndDropPlugin';
|
|
24
25
|
//# sourceMappingURL=index.js.map
|
package/lib-mjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-plugins/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAI9D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EACH,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAsB,MAAM,yCAAyC,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAmB,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,mBAAmB,EAAiB,MAAM,qCAAqC,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAI5D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["export { TableEditPlugin } from './tableEdit/TableEditPlugin';\nexport { OnTableEditorCreatedCallback } from './tableEdit/OnTableEditorCreatedCallback';\nexport { TableEditFeatureName } from './tableEdit/editors/features/TableEditFeatureName';\nexport { TableWithRoot } from './tableEdit/TableWithRoot';\nexport { PastePlugin } from './paste/PastePlugin';\nexport { DefaultSanitizers } from './paste/DefaultSanitizers';\nexport { EditPlugin } from './edit/EditPlugin';\nexport { EditOptions, HandleTabOptions } from './edit/EditOptions';\nexport { AutoFormatPlugin } from './autoFormat/AutoFormatPlugin';\nexport { AutoFormatOptions } from './autoFormat/interface/AutoFormatOptions';\n\nexport {\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} from './shortcut/shortcuts';\nexport { ShortcutPlugin } from './shortcut/ShortcutPlugin';\nexport { ShortcutKeyDefinition, ShortcutCommand } from './shortcut/ShortcutCommand';\nexport { ContextMenuPluginBase, ContextMenuOptions } from './contextMenuBase/ContextMenuPluginBase';\nexport { WatermarkPlugin } from './watermark/WatermarkPlugin';\nexport { WatermarkFormat } from './watermark/WatermarkFormat';\nexport { isModelEmptyFast } from './watermark/isModelEmptyFast';\nexport { MarkdownPlugin, MarkdownOptions } from './markdown/MarkdownPlugin';\nexport { HyperlinkPlugin } from './hyperlink/HyperlinkPlugin';\nexport { HyperlinkToolTip } from './hyperlink/HyperlinkToolTip';\nexport { PickerPlugin } from './picker/PickerPlugin';\nexport { PickerHelper } from './picker/PickerHelper';\nexport { PickerSelectionChangMode, PickerDirection, PickerHandler } from './picker/PickerHandler';\nexport { CustomReplacePlugin, CustomReplace } from './customReplace/CustomReplacePlugin';\nexport { ImageEditPlugin } from './imageEdit/ImageEditPlugin';\nexport { ImageEditOptions } from './imageEdit/types/ImageEditOptions';\nexport { HiddenPropertyPlugin } from './hiddenProperty/HiddenPropertyPlugin';\nexport { HiddenPropertyOptions } from './hiddenProperty/HiddenPropertyOptions';\nexport { TouchPlugin } from './touch/TouchPlugin';\nexport { FindReplacePlugin } from './findReplace/FindReplacePlugin';\nexport { createFindReplaceContext } from './findReplace/createFindReplaceContext';\nexport { find } from './findReplace/find';\nexport { replace } from './findReplace/replace';\nexport { moveHighlight } from './findReplace/moveHighlight';\nexport { FindReplaceContext } from './findReplace/types/FindReplaceContext';\nexport { HighlightHelper } from './findReplace/types/HighlightHelper';\nexport { FindReplaceHighlightOptions } from './findReplace/types/FindReplaceHighlightOptions';\nexport { AnnouncePlugin } from './announce/AnnouncePlugin';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/roosterjs-content-model-plugins/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAI9D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EACH,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAsB,MAAM,yCAAyC,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAmB,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,mBAAmB,EAAiB,MAAM,qCAAqC,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAI5D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAsB,MAAM,iCAAiC,CAAC","sourcesContent":["export { TableEditPlugin } from './tableEdit/TableEditPlugin';\nexport { OnTableEditorCreatedCallback } from './tableEdit/OnTableEditorCreatedCallback';\nexport { TableEditFeatureName } from './tableEdit/editors/features/TableEditFeatureName';\nexport { TableWithRoot } from './tableEdit/TableWithRoot';\nexport { PastePlugin } from './paste/PastePlugin';\nexport { DefaultSanitizers } from './paste/DefaultSanitizers';\nexport { EditPlugin } from './edit/EditPlugin';\nexport { EditOptions, HandleTabOptions } from './edit/EditOptions';\nexport { AutoFormatPlugin } from './autoFormat/AutoFormatPlugin';\nexport { AutoFormatOptions } from './autoFormat/interface/AutoFormatOptions';\n\nexport {\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} from './shortcut/shortcuts';\nexport { ShortcutPlugin } from './shortcut/ShortcutPlugin';\nexport { ShortcutKeyDefinition, ShortcutCommand } from './shortcut/ShortcutCommand';\nexport { ContextMenuPluginBase, ContextMenuOptions } from './contextMenuBase/ContextMenuPluginBase';\nexport { WatermarkPlugin } from './watermark/WatermarkPlugin';\nexport { WatermarkFormat } from './watermark/WatermarkFormat';\nexport { isModelEmptyFast } from './watermark/isModelEmptyFast';\nexport { MarkdownPlugin, MarkdownOptions } from './markdown/MarkdownPlugin';\nexport { HyperlinkPlugin } from './hyperlink/HyperlinkPlugin';\nexport { HyperlinkToolTip } from './hyperlink/HyperlinkToolTip';\nexport { PickerPlugin } from './picker/PickerPlugin';\nexport { PickerHelper } from './picker/PickerHelper';\nexport { PickerSelectionChangMode, PickerDirection, PickerHandler } from './picker/PickerHandler';\nexport { CustomReplacePlugin, CustomReplace } from './customReplace/CustomReplacePlugin';\nexport { ImageEditPlugin } from './imageEdit/ImageEditPlugin';\nexport { ImageEditOptions } from './imageEdit/types/ImageEditOptions';\nexport { HiddenPropertyPlugin } from './hiddenProperty/HiddenPropertyPlugin';\nexport { HiddenPropertyOptions } from './hiddenProperty/HiddenPropertyOptions';\nexport { TouchPlugin } from './touch/TouchPlugin';\nexport { FindReplacePlugin } from './findReplace/FindReplacePlugin';\nexport { createFindReplaceContext } from './findReplace/createFindReplaceContext';\nexport { find } from './findReplace/find';\nexport { replace } from './findReplace/replace';\nexport { moveHighlight } from './findReplace/moveHighlight';\nexport { FindReplaceContext } from './findReplace/types/FindReplaceContext';\nexport { HighlightHelper } from './findReplace/types/HighlightHelper';\nexport { FindReplaceHighlightOptions } from './findReplace/types/FindReplaceHighlightOptions';\nexport { AnnouncePlugin } from './announce/AnnouncePlugin';\nexport { DragAndDropPlugin, DragAndDropOptions } from './dragAndDrop/DragAndDropPlugin';\n"]}
|
package/package.json
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
"description": "Plugins for roosterjs",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"tslib": "^2.3.1",
|
|
6
|
-
"roosterjs-content-model-core": "^9.
|
|
7
|
-
"roosterjs-content-model-dom": "^9.
|
|
8
|
-
"roosterjs-content-model-types": "^9.
|
|
9
|
-
"roosterjs-content-model-api": "^9.
|
|
6
|
+
"roosterjs-content-model-core": "^9.50.0",
|
|
7
|
+
"roosterjs-content-model-dom": "^9.50.0",
|
|
8
|
+
"roosterjs-content-model-types": "^9.50.0",
|
|
9
|
+
"roosterjs-content-model-api": "^9.50.0"
|
|
10
10
|
},
|
|
11
|
-
"version": "9.
|
|
11
|
+
"version": "9.50.0",
|
|
12
12
|
"main": "./lib/index.js",
|
|
13
13
|
"typings": "./lib/index.d.ts",
|
|
14
14
|
"module": "./lib-mjs/index.js",
|