vue-editify 0.2.8 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- package/examples/App.vue +11 -6
- package/lib/components/button/button.vue.d.ts +271 -0
- package/lib/components/button/props.d.ts +4 -0
- package/lib/components/checkbox/checkbox.vue.d.ts +2 -2
- package/lib/components/layer/layer.vue.d.ts +12 -3
- package/lib/components/layer/props.d.ts +4 -0
- package/lib/components/menu/menu.vue.d.ts +12 -0
- package/lib/components/menu/props.d.ts +4 -0
- package/lib/components/toolbar/props.d.ts +8 -0
- package/lib/components/toolbar/toolbar.vue.d.ts +18 -0
- package/lib/components/tooltip/props.d.ts +4 -0
- package/lib/components/tooltip/tooltip.vue.d.ts +9 -0
- package/lib/core/tool.d.ts +7 -0
- package/lib/editify/editify.vue.d.ts +89 -28
- package/lib/editify/props.d.ts +8 -0
- package/lib/editify.es.js +472 -382
- package/lib/editify.umd.js +2 -2
- package/lib/hljs/index.d.ts +7 -4
- package/lib/index.d.ts +90 -29
- package/package.json +6 -6
- package/src/components/button/button.less +48 -48
- package/src/components/button/button.vue +4 -3
- package/src/components/button/props.ts +5 -0
- package/src/components/layer/layer.less +1 -1
- package/src/components/layer/layer.vue +111 -84
- package/src/components/layer/props.ts +6 -1
- package/src/components/menu/menu.less +0 -1
- package/src/components/menu/menu.vue +46 -70
- package/src/components/menu/props.ts +5 -0
- package/src/components/toolbar/props.ts +10 -0
- package/src/components/toolbar/toolbar.vue +49 -49
- package/src/components/tooltip/props.ts +5 -0
- package/src/components/tooltip/tooltip.less +7 -15
- package/src/components/tooltip/tooltip.vue +5 -7
- package/src/core/tool.ts +27 -1
- package/src/editify/editify.less +0 -5
- package/src/editify/editify.vue +10 -6
- package/src/editify/props.ts +10 -0
- package/src/hljs/index.ts +34 -28
- package/src/index.ts +1 -1
@@ -1,12 +1,14 @@
|
|
1
1
|
<template>
|
2
|
-
<
|
3
|
-
<
|
4
|
-
<
|
5
|
-
|
6
|
-
<
|
2
|
+
<Teleport to="body">
|
3
|
+
<Transition :name="animation ? 'editify-layer-' + animation : 'editify-layer'" @enter="handleEnter" @after-enter="el => emits('shown', el)" @after-leave="el => emits('hidden', el)">
|
4
|
+
<div v-if="modelValue" class="editify-layer" :data-editify-placement="realPlacement || null" :style="{ zIndex: zIndex }" ref="elRef">
|
5
|
+
<Triangle v-if="showTriangle" :color="border && borderColor ? borderColor : background" :background="background" :placement="triPlacement" ref="triangleRef" />
|
6
|
+
<div ref="wrapRef" class="editify-layer-wrap" :class="{ 'editify-border': border }" :style="wrapStyle">
|
7
|
+
<slot></slot>
|
8
|
+
</div>
|
7
9
|
</div>
|
8
|
-
</
|
9
|
-
</
|
10
|
+
</Transition>
|
11
|
+
</Teleport>
|
10
12
|
</template>
|
11
13
|
<script setup lang="ts">
|
12
14
|
import { computed, getCurrentInstance, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
|
@@ -27,6 +29,8 @@ const realPlacement = ref<LayerPlacementType | null>(null)
|
|
27
29
|
const wrapRef = ref<HTMLElement | null>(null)
|
28
30
|
const elRef = ref<HTMLElement | null>(null)
|
29
31
|
const triangleRef = ref<InstanceType<typeof Triangle> | null>(null)
|
32
|
+
const MOUSEDOWN = ref<boolean>(false)
|
33
|
+
const MOUSEMOVE = ref<boolean>(false)
|
30
34
|
|
31
35
|
//三角形位置
|
32
36
|
const triPlacement = computed<TrianglePlacementType>(() => {
|
@@ -44,6 +48,7 @@ const triPlacement = computed<TrianglePlacementType>(() => {
|
|
44
48
|
}
|
45
49
|
return 'top'
|
46
50
|
})
|
51
|
+
//浮层主体样式
|
47
52
|
const wrapStyle = computed<ObjectType>(() => {
|
48
53
|
return {
|
49
54
|
borderColor: props.border ? props.borderColor || '' : '',
|
@@ -58,9 +63,19 @@ const getNode = () => {
|
|
58
63
|
return null
|
59
64
|
}
|
60
65
|
if (DapElement.isElement(props.node)) {
|
61
|
-
return
|
66
|
+
return props.node as HTMLElement
|
62
67
|
}
|
63
|
-
return
|
68
|
+
return document.body.querySelector(props.node as string) as HTMLElement
|
69
|
+
}
|
70
|
+
//获取滚动容器元素
|
71
|
+
const getScrollNode = () => {
|
72
|
+
if (!props.scrollNode) {
|
73
|
+
return null
|
74
|
+
}
|
75
|
+
if (DapElement.isElement(props.scrollNode)) {
|
76
|
+
return props.scrollNode as HTMLElement
|
77
|
+
}
|
78
|
+
return document.body.querySelector(props.scrollNode as string) as HTMLElement
|
64
79
|
}
|
65
80
|
//根据range设置三角形位置
|
66
81
|
const setTrianglePositionByRange = () => {
|
@@ -168,23 +183,23 @@ const setPositionByRange = () => {
|
|
168
183
|
const firstRect = rects[0]
|
169
184
|
//range的最后一个位置
|
170
185
|
const lastRect = rects[rects.length - 1]
|
171
|
-
//定位父元素的位置
|
172
|
-
const parentRect = DapElement.getElementBounding(<HTMLElement>elRef.value!.offsetParent)
|
173
186
|
//可视窗口高度
|
174
187
|
const documentHeight = document.documentElement.clientHeight || window.innerHeight
|
175
188
|
//可视窗口宽度
|
176
189
|
const documentWidth = document.documentElement.clientWidth || window.innerWidth
|
190
|
+
//滚动容器位置
|
191
|
+
const scrollRect = DapElement.getElementBounding(getScrollNode() || document.documentElement)
|
177
192
|
|
178
193
|
if (props.placement == 'top' || props.placement == 'top-start' || props.placement == 'top-end') {
|
179
|
-
if (firstRect.top >=
|
194
|
+
if (firstRect.top >= scrollRect.top && firstRect.top >= elRef.value!.offsetHeight) {
|
180
195
|
realPlacement.value = props.placement
|
181
|
-
} else if (documentHeight - lastRect.bottom >=
|
196
|
+
} else if (documentHeight - lastRect.bottom >= scrollRect.bottom && documentHeight - lastRect.bottom >= elRef.value!.offsetHeight) {
|
182
197
|
realPlacement.value = props.placement == 'top' ? 'bottom' : props.placement == 'top-start' ? 'bottom-start' : 'bottom-end'
|
183
198
|
}
|
184
199
|
} else if (props.placement == 'bottom' || props.placement == 'bottom-start' || props.placement == 'bottom-end') {
|
185
|
-
if (documentHeight - lastRect.bottom >=
|
200
|
+
if (documentHeight - lastRect.bottom >= scrollRect.bottom && documentHeight - lastRect.bottom >= elRef.value!.offsetHeight) {
|
186
201
|
realPlacement.value = props.placement
|
187
|
-
} else if (firstRect.top >=
|
202
|
+
} else if (firstRect.top >= scrollRect.top && firstRect.top >= elRef.value!.offsetHeight) {
|
188
203
|
realPlacement.value = props.placement == 'bottom' ? 'top' : props.placement == 'bottom-start' ? 'top-start' : 'top-end'
|
189
204
|
}
|
190
205
|
}
|
@@ -238,141 +253,141 @@ const setPositionByRange = () => {
|
|
238
253
|
nextTick(() => {
|
239
254
|
//设置位置对应的样式
|
240
255
|
if (realPlacement.value == 'top') {
|
241
|
-
elRef.value!.style.left = firstRect.left
|
256
|
+
elRef.value!.style.left = firstRect.left + firstRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
242
257
|
elRef.value!.style.right = 'auto'
|
243
|
-
elRef.value!.style.top = firstRect.top -
|
258
|
+
elRef.value!.style.top = firstRect.top - elRef.value!.offsetHeight + 'px'
|
244
259
|
elRef.value!.style.bottom = 'auto'
|
245
260
|
} else if (realPlacement.value == 'top-start') {
|
246
|
-
elRef.value!.style.left = firstRect.left
|
261
|
+
elRef.value!.style.left = firstRect.left + 'px'
|
247
262
|
elRef.value!.style.right = 'auto'
|
248
|
-
elRef.value!.style.top = firstRect.top -
|
263
|
+
elRef.value!.style.top = firstRect.top - elRef.value!.offsetHeight + 'px'
|
249
264
|
elRef.value!.style.bottom = 'auto'
|
250
265
|
} else if (realPlacement.value == 'top-end') {
|
251
266
|
elRef.value!.style.left = 'auto'
|
252
|
-
elRef.value!.style.right = documentWidth - firstRect.right
|
253
|
-
elRef.value!.style.top = firstRect.top -
|
267
|
+
elRef.value!.style.right = documentWidth - firstRect.right + 'px'
|
268
|
+
elRef.value!.style.top = firstRect.top - elRef.value!.offsetHeight + 'px'
|
254
269
|
elRef.value!.style.bottom = 'auto'
|
255
270
|
} else if (realPlacement.value == 'bottom') {
|
256
|
-
elRef.value!.style.left = lastRect.left
|
271
|
+
elRef.value!.style.left = lastRect.left + lastRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
257
272
|
elRef.value!.style.right = 'auto'
|
258
273
|
elRef.value!.style.top = 'auto'
|
259
|
-
elRef.value!.style.bottom = documentHeight - lastRect.bottom -
|
274
|
+
elRef.value!.style.bottom = documentHeight - lastRect.bottom - elRef.value!.offsetHeight + 'px'
|
260
275
|
} else if (realPlacement.value == 'bottom-start') {
|
261
|
-
elRef.value!.style.left = lastRect.left
|
276
|
+
elRef.value!.style.left = lastRect.left + 'px'
|
262
277
|
elRef.value!.style.right = 'auto'
|
263
278
|
elRef.value!.style.top = 'auto'
|
264
|
-
elRef.value!.style.bottom = documentHeight - lastRect.bottom -
|
279
|
+
elRef.value!.style.bottom = documentHeight - lastRect.bottom - elRef.value!.offsetHeight + 'px'
|
265
280
|
} else if (realPlacement.value == 'bottom-end') {
|
266
281
|
elRef.value!.style.left = 'auto'
|
267
|
-
elRef.value!.style.right = documentWidth - lastRect.right
|
282
|
+
elRef.value!.style.right = documentWidth - lastRect.right + 'px'
|
268
283
|
elRef.value!.style.top = 'auto'
|
269
|
-
elRef.value!.style.bottom = documentHeight - lastRect.bottom -
|
284
|
+
elRef.value!.style.bottom = documentHeight - lastRect.bottom - elRef.value!.offsetHeight + 'px'
|
270
285
|
} else {
|
271
286
|
elRef.value!.style.top = 'auto'
|
272
|
-
elRef.value!.style.bottom = (
|
287
|
+
elRef.value!.style.bottom = Math.max(scrollRect.bottom, 0) + 'px'
|
273
288
|
if (props.placement == 'top') {
|
274
289
|
//top-end
|
275
290
|
if (documentWidth - firstRect.right + firstRect.width / 2 < elRef.value!.offsetWidth / 2) {
|
276
291
|
elRef.value!.style.left = 'auto'
|
277
|
-
elRef.value!.style.right = documentWidth - firstRect.right
|
292
|
+
elRef.value!.style.right = documentWidth - firstRect.right + 'px'
|
278
293
|
}
|
279
294
|
//top-start
|
280
295
|
else if (firstRect.left + firstRect.width / 2 < elRef.value!.offsetWidth / 2) {
|
281
|
-
elRef.value!.style.left = firstRect.left
|
296
|
+
elRef.value!.style.left = firstRect.left + 'px'
|
282
297
|
elRef.value!.style.right = 'auto'
|
283
298
|
}
|
284
299
|
//top
|
285
300
|
else {
|
286
|
-
elRef.value!.style.left = firstRect.left
|
301
|
+
elRef.value!.style.left = firstRect.left + firstRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
287
302
|
elRef.value!.style.right = 'auto'
|
288
303
|
}
|
289
304
|
} else if (props.placement == 'bottom') {
|
290
305
|
//bottom-end
|
291
306
|
if (documentWidth - lastRect.right + lastRect.width / 2 < elRef.value!.offsetWidth / 2) {
|
292
307
|
elRef.value!.style.left = 'auto'
|
293
|
-
elRef.value!.style.right = documentWidth - lastRect.right
|
308
|
+
elRef.value!.style.right = documentWidth - lastRect.right + 'px'
|
294
309
|
}
|
295
310
|
//bottom-start
|
296
311
|
else if (lastRect.left + lastRect.width / 2 < elRef.value!.offsetWidth / 2) {
|
297
|
-
elRef.value!.style.left = lastRect.left
|
312
|
+
elRef.value!.style.left = lastRect.left + 'px'
|
298
313
|
elRef.value!.style.right = 'auto'
|
299
314
|
}
|
300
315
|
//bottom
|
301
316
|
else {
|
302
|
-
elRef.value!.style.left = lastRect.left
|
317
|
+
elRef.value!.style.left = lastRect.left + lastRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
303
318
|
elRef.value!.style.right = 'auto'
|
304
319
|
}
|
305
320
|
} else if (props.placement == 'top-start') {
|
306
321
|
if (documentWidth - firstRect.right + firstRect.width < elRef.value!.offsetWidth) {
|
307
322
|
//top
|
308
323
|
if (documentWidth - firstRect.right + firstRect.width / 2 >= elRef.value!.offsetWidth / 2) {
|
309
|
-
elRef.value!.style.left = firstRect.left
|
324
|
+
elRef.value!.style.left = firstRect.left + firstRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
310
325
|
elRef.value!.style.right = 'auto'
|
311
326
|
}
|
312
327
|
//top-end
|
313
328
|
else {
|
314
329
|
elRef.value!.style.left = 'auto'
|
315
|
-
elRef.value!.style.right = documentWidth - firstRect.right
|
330
|
+
elRef.value!.style.right = documentWidth - firstRect.right + 'px'
|
316
331
|
}
|
317
332
|
}
|
318
333
|
//top-start
|
319
334
|
else {
|
320
|
-
elRef.value!.style.left = firstRect.left
|
335
|
+
elRef.value!.style.left = firstRect.left + 'px'
|
321
336
|
elRef.value!.style.right = 'auto'
|
322
337
|
}
|
323
338
|
} else if (props.placement == 'bottom-start') {
|
324
339
|
if (documentWidth - lastRect.right + lastRect.width < elRef.value!.offsetWidth) {
|
325
340
|
//bottom
|
326
341
|
if (documentWidth - lastRect.right + lastRect.width / 2 >= elRef.value!.offsetWidth / 2) {
|
327
|
-
elRef.value!.style.left = lastRect.left
|
342
|
+
elRef.value!.style.left = lastRect.left + lastRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
328
343
|
elRef.value!.style.right = 'auto'
|
329
344
|
}
|
330
345
|
//bottom-end
|
331
346
|
else {
|
332
347
|
elRef.value!.style.left = 'auto'
|
333
|
-
elRef.value!.style.right = documentWidth - lastRect.right
|
348
|
+
elRef.value!.style.right = documentWidth - lastRect.right + 'px'
|
334
349
|
}
|
335
350
|
}
|
336
351
|
//bottom-start
|
337
352
|
else {
|
338
|
-
elRef.value!.style.left = lastRect.left
|
353
|
+
elRef.value!.style.left = lastRect.left + 'px'
|
339
354
|
elRef.value!.style.right = 'auto'
|
340
355
|
}
|
341
356
|
} else if (props.placement == 'top-end') {
|
342
357
|
if (firstRect.left + firstRect.width < elRef.value!.offsetWidth) {
|
343
358
|
//top
|
344
359
|
if (firstRect.left + firstRect.width / 2 >= elRef.value!.offsetWidth / 2) {
|
345
|
-
elRef.value!.style.left = firstRect.left
|
360
|
+
elRef.value!.style.left = firstRect.left + firstRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
346
361
|
elRef.value!.style.right = 'auto'
|
347
362
|
}
|
348
363
|
//top-start
|
349
364
|
else {
|
350
|
-
elRef.value!.style.left = firstRect.left
|
365
|
+
elRef.value!.style.left = firstRect.left + 'px'
|
351
366
|
elRef.value!.style.right = 'auto'
|
352
367
|
}
|
353
368
|
}
|
354
369
|
//top-end
|
355
370
|
else {
|
356
371
|
elRef.value!.style.left = 'auto'
|
357
|
-
elRef.value!.style.right = documentWidth - firstRect.right
|
372
|
+
elRef.value!.style.right = documentWidth - firstRect.right + 'px'
|
358
373
|
}
|
359
374
|
} else if (props.placement == 'bottom-end') {
|
360
375
|
if (lastRect.left + lastRect.width < elRef.value!.offsetWidth) {
|
361
376
|
//bottom
|
362
377
|
if (lastRect.left + lastRect.width / 2 >= elRef.value!.offsetWidth / 2) {
|
363
|
-
elRef.value!.style.left = lastRect.left
|
378
|
+
elRef.value!.style.left = lastRect.left + lastRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
364
379
|
elRef.value!.style.right = 'auto'
|
365
380
|
}
|
366
381
|
//bottom-start
|
367
382
|
else {
|
368
|
-
elRef.value!.style.left = lastRect.left
|
383
|
+
elRef.value!.style.left = lastRect.left + 'px'
|
369
384
|
elRef.value!.style.right = 'auto'
|
370
385
|
}
|
371
386
|
}
|
372
387
|
//bottom-end
|
373
388
|
else {
|
374
389
|
elRef.value!.style.left = 'auto'
|
375
|
-
elRef.value!.style.right = documentWidth - lastRect.right
|
390
|
+
elRef.value!.style.right = documentWidth - lastRect.right + 'px'
|
376
391
|
}
|
377
392
|
}
|
378
393
|
}
|
@@ -394,19 +409,19 @@ const setPositionByNode = () => {
|
|
394
409
|
realPlacement.value = null
|
395
410
|
//关联元素位置
|
396
411
|
const nodeRect = DapElement.getElementBounding(node)
|
397
|
-
|
398
|
-
const
|
412
|
+
//滚动容器位置
|
413
|
+
const scrollRect = DapElement.getElementBounding(getScrollNode() || document.documentElement)
|
399
414
|
//设置真实的位置
|
400
415
|
if (props.placement == 'top' || props.placement == 'top-start' || props.placement == 'top-end') {
|
401
|
-
if (nodeRect.top >=
|
416
|
+
if (nodeRect.top >= scrollRect.top && nodeRect.top >= elRef.value!.offsetHeight) {
|
402
417
|
realPlacement.value = props.placement
|
403
|
-
} else if (nodeRect.bottom >=
|
418
|
+
} else if (nodeRect.bottom >= scrollRect.bottom && nodeRect.bottom >= elRef.value!.offsetHeight) {
|
404
419
|
realPlacement.value = props.placement == 'top' ? 'bottom' : props.placement == 'top-start' ? 'bottom-start' : 'bottom-end'
|
405
420
|
}
|
406
421
|
} else if (props.placement == 'bottom' || props.placement == 'bottom-start' || props.placement == 'bottom-end') {
|
407
|
-
if (nodeRect.bottom >=
|
422
|
+
if (nodeRect.bottom >= scrollRect.bottom && nodeRect.bottom >= elRef.value!.offsetHeight) {
|
408
423
|
realPlacement.value = props.placement
|
409
|
-
} else if (nodeRect.top >=
|
424
|
+
} else if (nodeRect.top >= scrollRect.top && nodeRect.top >= elRef.value!.offsetHeight) {
|
410
425
|
realPlacement.value = props.placement == 'bottom' ? 'top' : props.placement == 'bottom-start' ? 'top-start' : 'top-end'
|
411
426
|
}
|
412
427
|
}
|
@@ -460,74 +475,74 @@ const setPositionByNode = () => {
|
|
460
475
|
nextTick(() => {
|
461
476
|
//设置位置对应的样式
|
462
477
|
if (realPlacement.value == 'top') {
|
463
|
-
elRef.value!.style.left = nodeRect.left
|
478
|
+
elRef.value!.style.left = nodeRect.left + node.offsetWidth / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
464
479
|
elRef.value!.style.right = 'auto'
|
465
|
-
elRef.value!.style.top = nodeRect.top -
|
480
|
+
elRef.value!.style.top = nodeRect.top - elRef.value!.offsetHeight + 'px'
|
466
481
|
elRef.value!.style.bottom = 'auto'
|
467
482
|
} else if (realPlacement.value == 'top-start') {
|
468
|
-
elRef.value!.style.left = nodeRect.left
|
483
|
+
elRef.value!.style.left = nodeRect.left + 'px'
|
469
484
|
elRef.value!.style.right = 'auto'
|
470
|
-
elRef.value!.style.top = nodeRect.top -
|
485
|
+
elRef.value!.style.top = nodeRect.top - elRef.value!.offsetHeight + 'px'
|
471
486
|
elRef.value!.style.bottom = 'auto'
|
472
487
|
} else if (realPlacement.value == 'top-end') {
|
473
488
|
elRef.value!.style.left = 'auto'
|
474
|
-
elRef.value!.style.right = nodeRect.right
|
475
|
-
elRef.value!.style.top = nodeRect.top -
|
489
|
+
elRef.value!.style.right = nodeRect.right + 'px'
|
490
|
+
elRef.value!.style.top = nodeRect.top - elRef.value!.offsetHeight + 'px'
|
476
491
|
elRef.value!.style.bottom = 'auto'
|
477
492
|
} else if (realPlacement.value == 'bottom') {
|
478
|
-
elRef.value!.style.left = nodeRect.left
|
493
|
+
elRef.value!.style.left = nodeRect.left + node.offsetWidth / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
479
494
|
elRef.value!.style.right = 'auto'
|
480
495
|
elRef.value!.style.top = 'auto'
|
481
|
-
elRef.value!.style.bottom = nodeRect.bottom -
|
496
|
+
elRef.value!.style.bottom = nodeRect.bottom - elRef.value!.offsetHeight + 'px'
|
482
497
|
} else if (realPlacement.value == 'bottom-start') {
|
483
|
-
elRef.value!.style.left = nodeRect.left
|
498
|
+
elRef.value!.style.left = nodeRect.left + 'px'
|
484
499
|
elRef.value!.style.right = 'auto'
|
485
500
|
elRef.value!.style.top = 'auto'
|
486
|
-
elRef.value!.style.bottom = nodeRect.bottom -
|
501
|
+
elRef.value!.style.bottom = nodeRect.bottom - elRef.value!.offsetHeight + 'px'
|
487
502
|
} else if (realPlacement.value == 'bottom-end') {
|
488
503
|
elRef.value!.style.left = 'auto'
|
489
|
-
elRef.value!.style.right = nodeRect.right
|
504
|
+
elRef.value!.style.right = nodeRect.right + 'px'
|
490
505
|
elRef.value!.style.top = 'auto'
|
491
|
-
elRef.value!.style.bottom = nodeRect.bottom -
|
506
|
+
elRef.value!.style.bottom = nodeRect.bottom - elRef.value!.offsetHeight + 'px'
|
492
507
|
} else {
|
493
508
|
elRef.value!.style.top = 'auto'
|
494
|
-
elRef.value!.style.bottom = (
|
509
|
+
elRef.value!.style.bottom = Math.max(scrollRect.bottom, 0) + 'px'
|
495
510
|
if (props.placement == 'top' || props.placement == 'bottom') {
|
496
511
|
if (nodeRect.right + node.offsetWidth / 2 < elRef.value!.offsetWidth / 2) {
|
497
512
|
elRef.value!.style.left = 'auto'
|
498
|
-
elRef.value!.style.right = nodeRect.right
|
513
|
+
elRef.value!.style.right = nodeRect.right + 'px'
|
499
514
|
} else if (nodeRect.left + node.offsetWidth / 2 < elRef.value!.offsetWidth / 2) {
|
500
|
-
elRef.value!.style.left = nodeRect.left
|
515
|
+
elRef.value!.style.left = nodeRect.left + 'px'
|
501
516
|
elRef.value!.style.right = 'auto'
|
502
517
|
} else {
|
503
|
-
elRef.value!.style.left = nodeRect.left
|
518
|
+
elRef.value!.style.left = nodeRect.left + node.offsetWidth / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
504
519
|
elRef.value!.style.right = 'auto'
|
505
520
|
}
|
506
521
|
} else if (props.placement == 'top-start' || props.placement == 'bottom-start') {
|
507
522
|
if (nodeRect.right + node.offsetWidth < elRef.value!.offsetWidth) {
|
508
523
|
if (nodeRect.right + node.offsetWidth / 2 >= elRef.value!.offsetWidth / 2) {
|
509
|
-
elRef.value!.style.left = nodeRect.left
|
524
|
+
elRef.value!.style.left = nodeRect.left + node.offsetWidth / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
510
525
|
elRef.value!.style.right = 'auto'
|
511
526
|
} else {
|
512
527
|
elRef.value!.style.left = 'auto'
|
513
|
-
elRef.value!.style.right = nodeRect.right
|
528
|
+
elRef.value!.style.right = nodeRect.right + 'px'
|
514
529
|
}
|
515
530
|
} else {
|
516
|
-
elRef.value!.style.left = nodeRect.left
|
531
|
+
elRef.value!.style.left = nodeRect.left + 'px'
|
517
532
|
elRef.value!.style.right = 'auto'
|
518
533
|
}
|
519
534
|
} else if (props.placement == 'top-end' || props.placement == 'bottom-end') {
|
520
535
|
if (nodeRect.left + node.offsetWidth < elRef.value!.offsetWidth) {
|
521
536
|
if (nodeRect.left + node.offsetWidth / 2 >= elRef.value!.offsetWidth / 2) {
|
522
|
-
elRef.value!.style.left = nodeRect.left
|
537
|
+
elRef.value!.style.left = nodeRect.left + node.offsetWidth / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
523
538
|
elRef.value!.style.right = 'auto'
|
524
539
|
} else {
|
525
|
-
elRef.value!.style.left = nodeRect.left
|
540
|
+
elRef.value!.style.left = nodeRect.left + 'px'
|
526
541
|
elRef.value!.style.right = 'auto'
|
527
542
|
}
|
528
543
|
} else {
|
529
544
|
elRef.value!.style.left = 'auto'
|
530
|
-
elRef.value!.style.right = nodeRect.right
|
545
|
+
elRef.value!.style.right = nodeRect.right + 'px'
|
531
546
|
}
|
532
547
|
}
|
533
548
|
}
|
@@ -553,26 +568,25 @@ const handleEnter = (el: Element) => {
|
|
553
568
|
setPosition()
|
554
569
|
emits('show', el)
|
555
570
|
}
|
556
|
-
//完全显示后
|
557
|
-
const handleAfterEnter = (el: Element) => {
|
558
|
-
emits('shown', el)
|
559
|
-
}
|
560
|
-
//完全隐藏后
|
561
|
-
const handleAfterLeave = (el: Element) => {
|
562
|
-
emits('hidden', el)
|
563
|
-
}
|
564
571
|
//窗口尺寸改动
|
565
572
|
const handleResize = () => {
|
566
573
|
if (props.modelValue) {
|
567
574
|
emits('update:modelValue', false)
|
568
575
|
}
|
569
576
|
}
|
570
|
-
|
577
|
+
//点击定位元素和自身以外的元素关闭浮层
|
571
578
|
const handleClick = (e: Event) => {
|
579
|
+
//如果鼠标移动了则不是点击事件
|
580
|
+
if (MOUSEMOVE.value) {
|
581
|
+
return
|
582
|
+
}
|
572
583
|
if (!DapElement.isElement(elRef.value)) {
|
573
584
|
return
|
574
585
|
}
|
575
|
-
if (DapElement.isContains(
|
586
|
+
if (DapElement.isContains(elRef.value!, e.target as HTMLElement)) {
|
587
|
+
return
|
588
|
+
}
|
589
|
+
if (!props.useRange && getNode()! && DapElement.isContains(getNode()!, e.target as HTMLElement)) {
|
576
590
|
return
|
577
591
|
}
|
578
592
|
if (props.modelValue) {
|
@@ -584,6 +598,19 @@ onMounted(() => {
|
|
584
598
|
if (props.modelValue) {
|
585
599
|
setPosition()
|
586
600
|
}
|
601
|
+
DapEvent.on(window, `mousedown.editify_layer_${instance.uid} mousemove.editify_layer_${instance.uid} mouseup.editify_layer_${instance.uid}`, e => {
|
602
|
+
if (e.type == 'mousedown') {
|
603
|
+
MOUSEDOWN.value = true
|
604
|
+
MOUSEMOVE.value = false
|
605
|
+
} else if (e.type == 'mousemove') {
|
606
|
+
if (MOUSEDOWN.value) {
|
607
|
+
MOUSEMOVE.value = true
|
608
|
+
}
|
609
|
+
} else if (e.type == 'mouseup') {
|
610
|
+
MOUSEDOWN.value = false
|
611
|
+
}
|
612
|
+
})
|
613
|
+
|
587
614
|
DapEvent.on(window, `click.editify_layer_${instance.uid}`, handleClick)
|
588
615
|
DapEvent.on(window, `resize.editify_layer_${instance.uid}`, handleResize)
|
589
616
|
})
|
@@ -15,6 +15,11 @@ export const LayerProps = {
|
|
15
15
|
type: [String, HTMLElement] as PropType<string | HTMLElement | null>,
|
16
16
|
default: null
|
17
17
|
},
|
18
|
+
//关联滚动容器元素,为toolbar设计使用的属性
|
19
|
+
scrollNode: {
|
20
|
+
type: [String, HTMLElement] as PropType<string | HTMLElement | null>,
|
21
|
+
default: null
|
22
|
+
},
|
18
23
|
//是否显示边框
|
19
24
|
border: {
|
20
25
|
type: Boolean,
|
@@ -51,7 +56,7 @@ export const LayerProps = {
|
|
51
56
|
//层级
|
52
57
|
zIndex: {
|
53
58
|
type: Number,
|
54
|
-
default:
|
59
|
+
default: 1
|
55
60
|
},
|
56
61
|
//动画
|
57
62
|
animation: {
|