@lambo-design/shared 1.0.0-beta.345 → 1.0.0-beta.346
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/package.json +1 -1
- package/utils/context-menu.js +29 -15
package/package.json
CHANGED
package/utils/context-menu.js
CHANGED
|
@@ -54,8 +54,10 @@ export function enableRightClick(element = document) {
|
|
|
54
54
|
*/
|
|
55
55
|
function preventRightClick(e) {
|
|
56
56
|
// 统一配置读取
|
|
57
|
-
const
|
|
58
|
-
const
|
|
57
|
+
const ownerDocument = e.currentTarget.ownerDocument;
|
|
58
|
+
const currentWin = (ownerDocument != null ? ownerDocument.defaultView : undefined) || e.currentTarget;
|
|
59
|
+
const top = currentWin.top;
|
|
60
|
+
const contextMenuConfig = currentWin.contextMenu || (top != null ? top.contextMenu : undefined);
|
|
59
61
|
|
|
60
62
|
if (contextMenuConfig !== '0') return;
|
|
61
63
|
|
|
@@ -71,8 +73,10 @@ function preventRightClick(e) {
|
|
|
71
73
|
function preventRightClickByMouseUp(e) {
|
|
72
74
|
if (e.button !== 2) return;
|
|
73
75
|
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
+
const ownerDocument = e.currentTarget.ownerDocument;
|
|
77
|
+
const currentWin = (ownerDocument != null ? ownerDocument.defaultView : undefined) || e.currentTarget;
|
|
78
|
+
const top = currentWin.top;
|
|
79
|
+
const contextMenuConfig = currentWin.contextMenu || (top != null ? top.contextMenu : undefined);
|
|
76
80
|
|
|
77
81
|
if (contextMenuConfig === '0') {
|
|
78
82
|
e.preventDefault();
|
|
@@ -103,7 +107,9 @@ export function enableShortcutKeys() {
|
|
|
103
107
|
|
|
104
108
|
function preventConfiguredShortcuts(e) {
|
|
105
109
|
const currentWin = e.currentTarget;
|
|
106
|
-
|
|
110
|
+
|
|
111
|
+
const top = currentWin.top;
|
|
112
|
+
const shortcutKeyConfig = currentWin.shortcutKey || (top != null ? top.shortcutKey : undefined);
|
|
107
113
|
|
|
108
114
|
if (shortcutKeyConfig !== '0') return;
|
|
109
115
|
|
|
@@ -143,8 +149,12 @@ export function enableF12(element = document) {
|
|
|
143
149
|
|
|
144
150
|
// F12拦截函数
|
|
145
151
|
function preventF12(e) {
|
|
146
|
-
|
|
147
|
-
const
|
|
152
|
+
|
|
153
|
+
const ownerDocument = e.currentTarget.ownerDocument;
|
|
154
|
+
const currentWin = (ownerDocument != null ? ownerDocument.defaultView : undefined) || e.currentTarget;
|
|
155
|
+
|
|
156
|
+
const top = currentWin.top;
|
|
157
|
+
const shortcutF12Config = currentWin.shortcutF12 || (top != null ? top.shortcutF12 : undefined);
|
|
148
158
|
|
|
149
159
|
if (shortcutF12Config !== '0') return;
|
|
150
160
|
|
|
@@ -197,8 +207,12 @@ export function enableTextSelection(element = document) {
|
|
|
197
207
|
* 文字选中拦截
|
|
198
208
|
*/
|
|
199
209
|
function preventTextSelection(e) {
|
|
200
|
-
|
|
201
|
-
const
|
|
210
|
+
|
|
211
|
+
const ownerDocument = e.currentTarget.ownerDocument;
|
|
212
|
+
const currentWin = (ownerDocument != null ? ownerDocument.defaultView : undefined) || e.currentTarget;
|
|
213
|
+
|
|
214
|
+
const top = currentWin.top;
|
|
215
|
+
const textSelectedConfig = currentWin.textSelected || (top != null ? top.textSelected : undefined);
|
|
202
216
|
|
|
203
217
|
if (textSelectedConfig !== '0') return;
|
|
204
218
|
|
|
@@ -209,13 +223,16 @@ function preventTextSelection(e) {
|
|
|
209
223
|
}
|
|
210
224
|
|
|
211
225
|
/**
|
|
212
|
-
*
|
|
226
|
+
* 适配一些其他浏览器的文字选中
|
|
213
227
|
*/
|
|
214
228
|
function preventTextSelectionByMouseDown(e) {
|
|
215
229
|
if (e.button !== 0) return;
|
|
216
230
|
|
|
217
|
-
const
|
|
218
|
-
const
|
|
231
|
+
const ownerDocument = e.currentTarget.ownerDocument;
|
|
232
|
+
const currentWin = (ownerDocument != null ? ownerDocument.defaultView : undefined) || e.currentTarget;
|
|
233
|
+
|
|
234
|
+
const top = currentWin.top;
|
|
235
|
+
const textSelectedConfig = currentWin.textSelected || (top != null ? top.textSelected : undefined);
|
|
219
236
|
|
|
220
237
|
if (textSelectedConfig !== '0') return;
|
|
221
238
|
|
|
@@ -224,7 +241,6 @@ function preventTextSelectionByMouseDown(e) {
|
|
|
224
241
|
return false;
|
|
225
242
|
}
|
|
226
243
|
|
|
227
|
-
|
|
228
244
|
function showNotification(message) {
|
|
229
245
|
const notification = document.createElement('div');
|
|
230
246
|
notification.className = 'notification';
|
|
@@ -238,7 +254,6 @@ function showNotification(message) {
|
|
|
238
254
|
notification.classList.add('show');
|
|
239
255
|
}, 10);
|
|
240
256
|
|
|
241
|
-
|
|
242
257
|
setTimeout(() => {
|
|
243
258
|
notification.classList.remove('show');
|
|
244
259
|
setTimeout(() => {
|
|
@@ -246,5 +261,4 @@ function showNotification(message) {
|
|
|
246
261
|
}, 500);
|
|
247
262
|
}, 2000);
|
|
248
263
|
}
|
|
249
|
-
|
|
250
264
|
}
|