TF-2591 Run js script on drop with HtmlEditor

This commit is contained in:
DatDang
2024-03-01 15:45:46 +07:00
committed by Dat H. Pham
parent 80a32559d9
commit 7abcea6320
2 changed files with 50 additions and 2 deletions
+16
View File
@@ -16,6 +16,22 @@ class HtmlUtils {
});''',
name: 'lineHeight100Percent');
static const registerDropListener = (
script: '''
document.querySelector(".note-editable").addEventListener(
"drop",
(event) => window.parent.postMessage(
JSON.stringify({"name": "registerDropListener"})))''',
name: 'registerDropListener');
static const unregisterDropListener = (
script: '''
console.log("unregisterDropListener");
const editor = document.querySelector(".note-editable");
const newEditor = editor.cloneNode(true);
editor.parentNode.replaceChild(newEditor, editor);''',
name: 'unregisterDropListener');
static String customCssStyleHtmlEditor({TextDirection direction = TextDirection.ltr}) {
if (PlatformInfo.isWeb) {
return '''