plusui-native-core 0.1.43 → 0.1.44
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/Core/CMakeLists.txt +1 -0
- package/Core/Features/Window/window.cpp +77 -43
- package/package.json +1 -1
package/Core/CMakeLists.txt
CHANGED
|
@@ -767,6 +767,12 @@ Window Window::create(void *windowHandle, const WindowConfig &config) {
|
|
|
767
767
|
Window win;
|
|
768
768
|
win.pImpl->config = config;
|
|
769
769
|
|
|
770
|
+
// Pure native file-drop mode: when native FileDrop is enabled,
|
|
771
|
+
// fully disable browser/WebView drag-drop handling.
|
|
772
|
+
if (win.pImpl->config.enableFileDrop) {
|
|
773
|
+
win.pImpl->config.disableWebviewDragDrop = true;
|
|
774
|
+
}
|
|
775
|
+
|
|
770
776
|
#ifdef _WIN32
|
|
771
777
|
HWND hwnd = static_cast<HWND>(windowHandle);
|
|
772
778
|
|
|
@@ -829,24 +835,31 @@ Window Window::create(void *windowHandle, const WindowConfig &config) {
|
|
|
829
835
|
// and allows the native FileDrop API to handle them instead
|
|
830
836
|
if (pImpl->config.disableWebviewDragDrop) {
|
|
831
837
|
std::string disableDragDropScript = R"(
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
838
|
+
(function() {
|
|
839
|
+
if (window.__plusui_nativeFileDropOnly) return;
|
|
840
|
+
window.__plusui_nativeFileDropOnly = true;
|
|
841
|
+
|
|
842
|
+
var block = function(e) {
|
|
843
|
+
if (!e) return false;
|
|
844
|
+
e.preventDefault();
|
|
845
|
+
e.stopPropagation();
|
|
846
|
+
if (typeof e.stopImmediatePropagation === 'function') {
|
|
847
|
+
e.stopImmediatePropagation();
|
|
848
|
+
}
|
|
849
|
+
if (e.dataTransfer) {
|
|
850
|
+
try { e.dataTransfer.dropEffect = 'none'; } catch (_) {}
|
|
851
|
+
}
|
|
852
|
+
return false;
|
|
853
|
+
};
|
|
854
|
+
|
|
855
|
+
window.__plusui_dragDropEvents = ['dragenter', 'dragover', 'dragleave', 'drop'];
|
|
856
|
+
window.__plusui_dragDropBlocker = block;
|
|
857
|
+
|
|
858
|
+
window.__plusui_dragDropEvents.forEach(function(eventName) {
|
|
859
|
+
window.addEventListener(eventName, block, true);
|
|
860
|
+
document.addEventListener(eventName, block, true);
|
|
861
|
+
});
|
|
862
|
+
})();
|
|
850
863
|
)";
|
|
851
864
|
pImpl->webview->AddScriptToExecuteOnDocumentCreated(
|
|
852
865
|
std::wstring(disableDragDropScript.begin(),
|
|
@@ -1175,17 +1188,21 @@ Window Window::create(void *windowHandle, const WindowConfig &config) {
|
|
|
1175
1188
|
// Disable webview drag & drop behavior to allow native FileDrop API
|
|
1176
1189
|
if (win.pImpl->config.disableWebviewDragDrop) {
|
|
1177
1190
|
NSString *disableDragDropScript = @"(function() {"
|
|
1178
|
-
"
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
"
|
|
1185
|
-
"
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1191
|
+
"if (window.__plusui_nativeFileDropOnly) return;"
|
|
1192
|
+
"window.__plusui_nativeFileDropOnly = true;"
|
|
1193
|
+
"var block = function(e) {"
|
|
1194
|
+
"if (!e) return false;"
|
|
1195
|
+
"e.preventDefault();"
|
|
1196
|
+
"e.stopPropagation();"
|
|
1197
|
+
"if (typeof e.stopImmediatePropagation === 'function') e.stopImmediatePropagation();"
|
|
1198
|
+
"if (e.dataTransfer) { try { e.dataTransfer.dropEffect = 'none'; } catch (_) {} }"
|
|
1199
|
+
"return false;"
|
|
1200
|
+
"};"
|
|
1201
|
+
"window.__plusui_dragDropEvents = ['dragenter','dragover','dragleave','drop'];"
|
|
1202
|
+
"window.__plusui_dragDropBlocker = block;"
|
|
1203
|
+
"window.__plusui_dragDropEvents.forEach(function(eventName) {"
|
|
1204
|
+
"window.addEventListener(eventName, block, true);"
|
|
1205
|
+
"document.addEventListener(eventName, block, true);"
|
|
1189
1206
|
"});"
|
|
1190
1207
|
"})();";
|
|
1191
1208
|
|
|
@@ -1631,30 +1648,47 @@ void Window::setWebviewDragDropEnabled(bool enabled) {
|
|
|
1631
1648
|
// Enable webview drag-drop by removing our prevention handlers
|
|
1632
1649
|
script = R"(
|
|
1633
1650
|
(function() {
|
|
1634
|
-
|
|
1635
|
-
|
|
1651
|
+
var events = window.__plusui_dragDropEvents || ['dragenter', 'dragover', 'dragleave', 'drop'];
|
|
1652
|
+
var blocker = window.__plusui_dragDropBlocker;
|
|
1653
|
+
if (blocker) {
|
|
1654
|
+
events.forEach(function(eventName) {
|
|
1655
|
+
window.removeEventListener(eventName, blocker, true);
|
|
1656
|
+
document.removeEventListener(eventName, blocker, true);
|
|
1657
|
+
});
|
|
1636
1658
|
}
|
|
1659
|
+
delete window.__plusui_dragDropBlocker;
|
|
1660
|
+
delete window.__plusui_dragDropEvents;
|
|
1661
|
+
delete window.__plusui_dragDropDisabled;
|
|
1662
|
+
delete window.__plusui_nativeFileDropOnly;
|
|
1637
1663
|
})();
|
|
1638
1664
|
)";
|
|
1639
1665
|
} else {
|
|
1640
1666
|
// Disable webview drag-drop by preventing default behavior
|
|
1641
1667
|
script = R"(
|
|
1642
1668
|
(function() {
|
|
1643
|
-
if (window.
|
|
1669
|
+
if (window.__plusui_nativeFileDropOnly) return;
|
|
1670
|
+
window.__plusui_nativeFileDropOnly = true;
|
|
1644
1671
|
window.__plusui_dragDropDisabled = true;
|
|
1645
1672
|
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
}
|
|
1673
|
+
var block = function(e) {
|
|
1674
|
+
if (!e) return false;
|
|
1675
|
+
e.preventDefault();
|
|
1676
|
+
e.stopPropagation();
|
|
1677
|
+
if (typeof e.stopImmediatePropagation === 'function') {
|
|
1678
|
+
e.stopImmediatePropagation();
|
|
1679
|
+
}
|
|
1680
|
+
if (e.dataTransfer) {
|
|
1681
|
+
try { e.dataTransfer.dropEffect = 'none'; } catch (_) {}
|
|
1682
|
+
}
|
|
1683
|
+
return false;
|
|
1684
|
+
};
|
|
1685
|
+
|
|
1686
|
+
window.__plusui_dragDropEvents = ['dragenter', 'dragover', 'dragleave', 'drop'];
|
|
1687
|
+
window.__plusui_dragDropBlocker = block;
|
|
1653
1688
|
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
}, true);
|
|
1689
|
+
window.__plusui_dragDropEvents.forEach(function(eventName) {
|
|
1690
|
+
window.addEventListener(eventName, block, true);
|
|
1691
|
+
document.addEventListener(eventName, block, true);
|
|
1658
1692
|
});
|
|
1659
1693
|
})();
|
|
1660
1694
|
)";
|