vue-editify 0.2.9 → 0.2.11
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/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 +456 -386
- 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 +4 -4
- 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 +94 -89
- 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,15 +1,17 @@
|
|
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
|
-
import { computed, getCurrentInstance, nextTick,
|
14
|
+
import { computed, getCurrentInstance, nextTick, onMounted, ref } from 'vue'
|
13
15
|
import { element as DapElement, event as DapEvent } from 'dap-util'
|
14
16
|
import Triangle from '@/components/triangle/triangle.vue'
|
15
17
|
import { TrianglePlacementType } from '@/components/triangle/props'
|
@@ -44,6 +46,7 @@ const triPlacement = computed<TrianglePlacementType>(() => {
|
|
44
46
|
}
|
45
47
|
return 'top'
|
46
48
|
})
|
49
|
+
//浮层主体样式
|
47
50
|
const wrapStyle = computed<ObjectType>(() => {
|
48
51
|
return {
|
49
52
|
borderColor: props.border ? props.borderColor || '' : '',
|
@@ -58,9 +61,19 @@ const getNode = () => {
|
|
58
61
|
return null
|
59
62
|
}
|
60
63
|
if (DapElement.isElement(props.node)) {
|
61
|
-
return
|
64
|
+
return props.node as HTMLElement
|
62
65
|
}
|
63
|
-
return
|
66
|
+
return document.body.querySelector(props.node as string) as HTMLElement
|
67
|
+
}
|
68
|
+
//获取滚动容器元素
|
69
|
+
const getScrollNode = () => {
|
70
|
+
if (!props.scrollNode) {
|
71
|
+
return null
|
72
|
+
}
|
73
|
+
if (DapElement.isElement(props.scrollNode)) {
|
74
|
+
return props.scrollNode as HTMLElement
|
75
|
+
}
|
76
|
+
return document.body.querySelector(props.scrollNode as string) as HTMLElement
|
64
77
|
}
|
65
78
|
//根据range设置三角形位置
|
66
79
|
const setTrianglePositionByRange = () => {
|
@@ -168,23 +181,23 @@ const setPositionByRange = () => {
|
|
168
181
|
const firstRect = rects[0]
|
169
182
|
//range的最后一个位置
|
170
183
|
const lastRect = rects[rects.length - 1]
|
171
|
-
//定位父元素的位置
|
172
|
-
const parentRect = DapElement.getElementBounding(<HTMLElement>elRef.value!.offsetParent)
|
173
184
|
//可视窗口高度
|
174
185
|
const documentHeight = document.documentElement.clientHeight || window.innerHeight
|
175
186
|
//可视窗口宽度
|
176
187
|
const documentWidth = document.documentElement.clientWidth || window.innerWidth
|
188
|
+
//滚动容器位置
|
189
|
+
const scrollRect = DapElement.getElementBounding(getScrollNode() || document.documentElement)
|
177
190
|
|
178
191
|
if (props.placement == 'top' || props.placement == 'top-start' || props.placement == 'top-end') {
|
179
|
-
if (firstRect.top >=
|
192
|
+
if (firstRect.top >= scrollRect.top && firstRect.top >= elRef.value!.offsetHeight) {
|
180
193
|
realPlacement.value = props.placement
|
181
|
-
} else if (documentHeight - lastRect.bottom >=
|
194
|
+
} else if (documentHeight - lastRect.bottom >= scrollRect.bottom && documentHeight - lastRect.bottom >= elRef.value!.offsetHeight) {
|
182
195
|
realPlacement.value = props.placement == 'top' ? 'bottom' : props.placement == 'top-start' ? 'bottom-start' : 'bottom-end'
|
183
196
|
}
|
184
197
|
} else if (props.placement == 'bottom' || props.placement == 'bottom-start' || props.placement == 'bottom-end') {
|
185
|
-
if (documentHeight - lastRect.bottom >=
|
198
|
+
if (documentHeight - lastRect.bottom >= scrollRect.bottom && documentHeight - lastRect.bottom >= elRef.value!.offsetHeight) {
|
186
199
|
realPlacement.value = props.placement
|
187
|
-
} else if (firstRect.top >=
|
200
|
+
} else if (firstRect.top >= scrollRect.top && firstRect.top >= elRef.value!.offsetHeight) {
|
188
201
|
realPlacement.value = props.placement == 'bottom' ? 'top' : props.placement == 'bottom-start' ? 'top-start' : 'top-end'
|
189
202
|
}
|
190
203
|
}
|
@@ -238,141 +251,141 @@ const setPositionByRange = () => {
|
|
238
251
|
nextTick(() => {
|
239
252
|
//设置位置对应的样式
|
240
253
|
if (realPlacement.value == 'top') {
|
241
|
-
elRef.value!.style.left = firstRect.left
|
254
|
+
elRef.value!.style.left = firstRect.left + firstRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
242
255
|
elRef.value!.style.right = 'auto'
|
243
|
-
elRef.value!.style.top = firstRect.top -
|
256
|
+
elRef.value!.style.top = firstRect.top - elRef.value!.offsetHeight + 'px'
|
244
257
|
elRef.value!.style.bottom = 'auto'
|
245
258
|
} else if (realPlacement.value == 'top-start') {
|
246
|
-
elRef.value!.style.left = firstRect.left
|
259
|
+
elRef.value!.style.left = firstRect.left + 'px'
|
247
260
|
elRef.value!.style.right = 'auto'
|
248
|
-
elRef.value!.style.top = firstRect.top -
|
261
|
+
elRef.value!.style.top = firstRect.top - elRef.value!.offsetHeight + 'px'
|
249
262
|
elRef.value!.style.bottom = 'auto'
|
250
263
|
} else if (realPlacement.value == 'top-end') {
|
251
264
|
elRef.value!.style.left = 'auto'
|
252
|
-
elRef.value!.style.right = documentWidth - firstRect.right
|
253
|
-
elRef.value!.style.top = firstRect.top -
|
265
|
+
elRef.value!.style.right = documentWidth - firstRect.right + 'px'
|
266
|
+
elRef.value!.style.top = firstRect.top - elRef.value!.offsetHeight + 'px'
|
254
267
|
elRef.value!.style.bottom = 'auto'
|
255
268
|
} else if (realPlacement.value == 'bottom') {
|
256
|
-
elRef.value!.style.left = lastRect.left
|
269
|
+
elRef.value!.style.left = lastRect.left + lastRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
257
270
|
elRef.value!.style.right = 'auto'
|
258
271
|
elRef.value!.style.top = 'auto'
|
259
|
-
elRef.value!.style.bottom = documentHeight - lastRect.bottom -
|
272
|
+
elRef.value!.style.bottom = documentHeight - lastRect.bottom - elRef.value!.offsetHeight + 'px'
|
260
273
|
} else if (realPlacement.value == 'bottom-start') {
|
261
|
-
elRef.value!.style.left = lastRect.left
|
274
|
+
elRef.value!.style.left = lastRect.left + 'px'
|
262
275
|
elRef.value!.style.right = 'auto'
|
263
276
|
elRef.value!.style.top = 'auto'
|
264
|
-
elRef.value!.style.bottom = documentHeight - lastRect.bottom -
|
277
|
+
elRef.value!.style.bottom = documentHeight - lastRect.bottom - elRef.value!.offsetHeight + 'px'
|
265
278
|
} else if (realPlacement.value == 'bottom-end') {
|
266
279
|
elRef.value!.style.left = 'auto'
|
267
|
-
elRef.value!.style.right = documentWidth - lastRect.right
|
280
|
+
elRef.value!.style.right = documentWidth - lastRect.right + 'px'
|
268
281
|
elRef.value!.style.top = 'auto'
|
269
|
-
elRef.value!.style.bottom = documentHeight - lastRect.bottom -
|
282
|
+
elRef.value!.style.bottom = documentHeight - lastRect.bottom - elRef.value!.offsetHeight + 'px'
|
270
283
|
} else {
|
271
284
|
elRef.value!.style.top = 'auto'
|
272
|
-
elRef.value!.style.bottom = (
|
285
|
+
elRef.value!.style.bottom = Math.max(scrollRect.bottom, 0) + 'px'
|
273
286
|
if (props.placement == 'top') {
|
274
287
|
//top-end
|
275
288
|
if (documentWidth - firstRect.right + firstRect.width / 2 < elRef.value!.offsetWidth / 2) {
|
276
289
|
elRef.value!.style.left = 'auto'
|
277
|
-
elRef.value!.style.right = documentWidth - firstRect.right
|
290
|
+
elRef.value!.style.right = documentWidth - firstRect.right + 'px'
|
278
291
|
}
|
279
292
|
//top-start
|
280
293
|
else if (firstRect.left + firstRect.width / 2 < elRef.value!.offsetWidth / 2) {
|
281
|
-
elRef.value!.style.left = firstRect.left
|
294
|
+
elRef.value!.style.left = firstRect.left + 'px'
|
282
295
|
elRef.value!.style.right = 'auto'
|
283
296
|
}
|
284
297
|
//top
|
285
298
|
else {
|
286
|
-
elRef.value!.style.left = firstRect.left
|
299
|
+
elRef.value!.style.left = firstRect.left + firstRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
287
300
|
elRef.value!.style.right = 'auto'
|
288
301
|
}
|
289
302
|
} else if (props.placement == 'bottom') {
|
290
303
|
//bottom-end
|
291
304
|
if (documentWidth - lastRect.right + lastRect.width / 2 < elRef.value!.offsetWidth / 2) {
|
292
305
|
elRef.value!.style.left = 'auto'
|
293
|
-
elRef.value!.style.right = documentWidth - lastRect.right
|
306
|
+
elRef.value!.style.right = documentWidth - lastRect.right + 'px'
|
294
307
|
}
|
295
308
|
//bottom-start
|
296
309
|
else if (lastRect.left + lastRect.width / 2 < elRef.value!.offsetWidth / 2) {
|
297
|
-
elRef.value!.style.left = lastRect.left
|
310
|
+
elRef.value!.style.left = lastRect.left + 'px'
|
298
311
|
elRef.value!.style.right = 'auto'
|
299
312
|
}
|
300
313
|
//bottom
|
301
314
|
else {
|
302
|
-
elRef.value!.style.left = lastRect.left
|
315
|
+
elRef.value!.style.left = lastRect.left + lastRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
303
316
|
elRef.value!.style.right = 'auto'
|
304
317
|
}
|
305
318
|
} else if (props.placement == 'top-start') {
|
306
319
|
if (documentWidth - firstRect.right + firstRect.width < elRef.value!.offsetWidth) {
|
307
320
|
//top
|
308
321
|
if (documentWidth - firstRect.right + firstRect.width / 2 >= elRef.value!.offsetWidth / 2) {
|
309
|
-
elRef.value!.style.left = firstRect.left
|
322
|
+
elRef.value!.style.left = firstRect.left + firstRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
310
323
|
elRef.value!.style.right = 'auto'
|
311
324
|
}
|
312
325
|
//top-end
|
313
326
|
else {
|
314
327
|
elRef.value!.style.left = 'auto'
|
315
|
-
elRef.value!.style.right = documentWidth - firstRect.right
|
328
|
+
elRef.value!.style.right = documentWidth - firstRect.right + 'px'
|
316
329
|
}
|
317
330
|
}
|
318
331
|
//top-start
|
319
332
|
else {
|
320
|
-
elRef.value!.style.left = firstRect.left
|
333
|
+
elRef.value!.style.left = firstRect.left + 'px'
|
321
334
|
elRef.value!.style.right = 'auto'
|
322
335
|
}
|
323
336
|
} else if (props.placement == 'bottom-start') {
|
324
337
|
if (documentWidth - lastRect.right + lastRect.width < elRef.value!.offsetWidth) {
|
325
338
|
//bottom
|
326
339
|
if (documentWidth - lastRect.right + lastRect.width / 2 >= elRef.value!.offsetWidth / 2) {
|
327
|
-
elRef.value!.style.left = lastRect.left
|
340
|
+
elRef.value!.style.left = lastRect.left + lastRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
328
341
|
elRef.value!.style.right = 'auto'
|
329
342
|
}
|
330
343
|
//bottom-end
|
331
344
|
else {
|
332
345
|
elRef.value!.style.left = 'auto'
|
333
|
-
elRef.value!.style.right = documentWidth - lastRect.right
|
346
|
+
elRef.value!.style.right = documentWidth - lastRect.right + 'px'
|
334
347
|
}
|
335
348
|
}
|
336
349
|
//bottom-start
|
337
350
|
else {
|
338
|
-
elRef.value!.style.left = lastRect.left
|
351
|
+
elRef.value!.style.left = lastRect.left + 'px'
|
339
352
|
elRef.value!.style.right = 'auto'
|
340
353
|
}
|
341
354
|
} else if (props.placement == 'top-end') {
|
342
355
|
if (firstRect.left + firstRect.width < elRef.value!.offsetWidth) {
|
343
356
|
//top
|
344
357
|
if (firstRect.left + firstRect.width / 2 >= elRef.value!.offsetWidth / 2) {
|
345
|
-
elRef.value!.style.left = firstRect.left
|
358
|
+
elRef.value!.style.left = firstRect.left + firstRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
346
359
|
elRef.value!.style.right = 'auto'
|
347
360
|
}
|
348
361
|
//top-start
|
349
362
|
else {
|
350
|
-
elRef.value!.style.left = firstRect.left
|
363
|
+
elRef.value!.style.left = firstRect.left + 'px'
|
351
364
|
elRef.value!.style.right = 'auto'
|
352
365
|
}
|
353
366
|
}
|
354
367
|
//top-end
|
355
368
|
else {
|
356
369
|
elRef.value!.style.left = 'auto'
|
357
|
-
elRef.value!.style.right = documentWidth - firstRect.right
|
370
|
+
elRef.value!.style.right = documentWidth - firstRect.right + 'px'
|
358
371
|
}
|
359
372
|
} else if (props.placement == 'bottom-end') {
|
360
373
|
if (lastRect.left + lastRect.width < elRef.value!.offsetWidth) {
|
361
374
|
//bottom
|
362
375
|
if (lastRect.left + lastRect.width / 2 >= elRef.value!.offsetWidth / 2) {
|
363
|
-
elRef.value!.style.left = lastRect.left
|
376
|
+
elRef.value!.style.left = lastRect.left + lastRect.width / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
364
377
|
elRef.value!.style.right = 'auto'
|
365
378
|
}
|
366
379
|
//bottom-start
|
367
380
|
else {
|
368
|
-
elRef.value!.style.left = lastRect.left
|
381
|
+
elRef.value!.style.left = lastRect.left + 'px'
|
369
382
|
elRef.value!.style.right = 'auto'
|
370
383
|
}
|
371
384
|
}
|
372
385
|
//bottom-end
|
373
386
|
else {
|
374
387
|
elRef.value!.style.left = 'auto'
|
375
|
-
elRef.value!.style.right = documentWidth - lastRect.right
|
388
|
+
elRef.value!.style.right = documentWidth - lastRect.right + 'px'
|
376
389
|
}
|
377
390
|
}
|
378
391
|
}
|
@@ -394,19 +407,19 @@ const setPositionByNode = () => {
|
|
394
407
|
realPlacement.value = null
|
395
408
|
//关联元素位置
|
396
409
|
const nodeRect = DapElement.getElementBounding(node)
|
397
|
-
|
398
|
-
const
|
410
|
+
//滚动容器位置
|
411
|
+
const scrollRect = DapElement.getElementBounding(getScrollNode() || document.documentElement)
|
399
412
|
//设置真实的位置
|
400
413
|
if (props.placement == 'top' || props.placement == 'top-start' || props.placement == 'top-end') {
|
401
|
-
if (nodeRect.top >=
|
414
|
+
if (nodeRect.top >= scrollRect.top && nodeRect.top >= elRef.value!.offsetHeight) {
|
402
415
|
realPlacement.value = props.placement
|
403
|
-
} else if (nodeRect.bottom >=
|
416
|
+
} else if (nodeRect.bottom >= scrollRect.bottom && nodeRect.bottom >= elRef.value!.offsetHeight) {
|
404
417
|
realPlacement.value = props.placement == 'top' ? 'bottom' : props.placement == 'top-start' ? 'bottom-start' : 'bottom-end'
|
405
418
|
}
|
406
419
|
} else if (props.placement == 'bottom' || props.placement == 'bottom-start' || props.placement == 'bottom-end') {
|
407
|
-
if (nodeRect.bottom >=
|
420
|
+
if (nodeRect.bottom >= scrollRect.bottom && nodeRect.bottom >= elRef.value!.offsetHeight) {
|
408
421
|
realPlacement.value = props.placement
|
409
|
-
} else if (nodeRect.top >=
|
422
|
+
} else if (nodeRect.top >= scrollRect.top && nodeRect.top >= elRef.value!.offsetHeight) {
|
410
423
|
realPlacement.value = props.placement == 'bottom' ? 'top' : props.placement == 'bottom-start' ? 'top-start' : 'top-end'
|
411
424
|
}
|
412
425
|
}
|
@@ -460,74 +473,74 @@ const setPositionByNode = () => {
|
|
460
473
|
nextTick(() => {
|
461
474
|
//设置位置对应的样式
|
462
475
|
if (realPlacement.value == 'top') {
|
463
|
-
elRef.value!.style.left = nodeRect.left
|
476
|
+
elRef.value!.style.left = nodeRect.left + node.offsetWidth / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
464
477
|
elRef.value!.style.right = 'auto'
|
465
|
-
elRef.value!.style.top = nodeRect.top -
|
478
|
+
elRef.value!.style.top = nodeRect.top - elRef.value!.offsetHeight + 'px'
|
466
479
|
elRef.value!.style.bottom = 'auto'
|
467
480
|
} else if (realPlacement.value == 'top-start') {
|
468
|
-
elRef.value!.style.left = nodeRect.left
|
481
|
+
elRef.value!.style.left = nodeRect.left + 'px'
|
469
482
|
elRef.value!.style.right = 'auto'
|
470
|
-
elRef.value!.style.top = nodeRect.top -
|
483
|
+
elRef.value!.style.top = nodeRect.top - elRef.value!.offsetHeight + 'px'
|
471
484
|
elRef.value!.style.bottom = 'auto'
|
472
485
|
} else if (realPlacement.value == 'top-end') {
|
473
486
|
elRef.value!.style.left = 'auto'
|
474
|
-
elRef.value!.style.right = nodeRect.right
|
475
|
-
elRef.value!.style.top = nodeRect.top -
|
487
|
+
elRef.value!.style.right = nodeRect.right + 'px'
|
488
|
+
elRef.value!.style.top = nodeRect.top - elRef.value!.offsetHeight + 'px'
|
476
489
|
elRef.value!.style.bottom = 'auto'
|
477
490
|
} else if (realPlacement.value == 'bottom') {
|
478
|
-
elRef.value!.style.left = nodeRect.left
|
491
|
+
elRef.value!.style.left = nodeRect.left + node.offsetWidth / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
479
492
|
elRef.value!.style.right = 'auto'
|
480
493
|
elRef.value!.style.top = 'auto'
|
481
|
-
elRef.value!.style.bottom = nodeRect.bottom -
|
494
|
+
elRef.value!.style.bottom = nodeRect.bottom - elRef.value!.offsetHeight + 'px'
|
482
495
|
} else if (realPlacement.value == 'bottom-start') {
|
483
|
-
elRef.value!.style.left = nodeRect.left
|
496
|
+
elRef.value!.style.left = nodeRect.left + 'px'
|
484
497
|
elRef.value!.style.right = 'auto'
|
485
498
|
elRef.value!.style.top = 'auto'
|
486
|
-
elRef.value!.style.bottom = nodeRect.bottom -
|
499
|
+
elRef.value!.style.bottom = nodeRect.bottom - elRef.value!.offsetHeight + 'px'
|
487
500
|
} else if (realPlacement.value == 'bottom-end') {
|
488
501
|
elRef.value!.style.left = 'auto'
|
489
|
-
elRef.value!.style.right = nodeRect.right
|
502
|
+
elRef.value!.style.right = nodeRect.right + 'px'
|
490
503
|
elRef.value!.style.top = 'auto'
|
491
|
-
elRef.value!.style.bottom = nodeRect.bottom -
|
504
|
+
elRef.value!.style.bottom = nodeRect.bottom - elRef.value!.offsetHeight + 'px'
|
492
505
|
} else {
|
493
506
|
elRef.value!.style.top = 'auto'
|
494
|
-
elRef.value!.style.bottom = (
|
507
|
+
elRef.value!.style.bottom = Math.max(scrollRect.bottom, 0) + 'px'
|
495
508
|
if (props.placement == 'top' || props.placement == 'bottom') {
|
496
509
|
if (nodeRect.right + node.offsetWidth / 2 < elRef.value!.offsetWidth / 2) {
|
497
510
|
elRef.value!.style.left = 'auto'
|
498
|
-
elRef.value!.style.right = nodeRect.right
|
511
|
+
elRef.value!.style.right = nodeRect.right + 'px'
|
499
512
|
} else if (nodeRect.left + node.offsetWidth / 2 < elRef.value!.offsetWidth / 2) {
|
500
|
-
elRef.value!.style.left = nodeRect.left
|
513
|
+
elRef.value!.style.left = nodeRect.left + 'px'
|
501
514
|
elRef.value!.style.right = 'auto'
|
502
515
|
} else {
|
503
|
-
elRef.value!.style.left = nodeRect.left
|
516
|
+
elRef.value!.style.left = nodeRect.left + node.offsetWidth / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
504
517
|
elRef.value!.style.right = 'auto'
|
505
518
|
}
|
506
519
|
} else if (props.placement == 'top-start' || props.placement == 'bottom-start') {
|
507
520
|
if (nodeRect.right + node.offsetWidth < elRef.value!.offsetWidth) {
|
508
521
|
if (nodeRect.right + node.offsetWidth / 2 >= elRef.value!.offsetWidth / 2) {
|
509
|
-
elRef.value!.style.left = nodeRect.left
|
522
|
+
elRef.value!.style.left = nodeRect.left + node.offsetWidth / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
510
523
|
elRef.value!.style.right = 'auto'
|
511
524
|
} else {
|
512
525
|
elRef.value!.style.left = 'auto'
|
513
|
-
elRef.value!.style.right = nodeRect.right
|
526
|
+
elRef.value!.style.right = nodeRect.right + 'px'
|
514
527
|
}
|
515
528
|
} else {
|
516
|
-
elRef.value!.style.left = nodeRect.left
|
529
|
+
elRef.value!.style.left = nodeRect.left + 'px'
|
517
530
|
elRef.value!.style.right = 'auto'
|
518
531
|
}
|
519
532
|
} else if (props.placement == 'top-end' || props.placement == 'bottom-end') {
|
520
533
|
if (nodeRect.left + node.offsetWidth < elRef.value!.offsetWidth) {
|
521
534
|
if (nodeRect.left + node.offsetWidth / 2 >= elRef.value!.offsetWidth / 2) {
|
522
|
-
elRef.value!.style.left = nodeRect.left
|
535
|
+
elRef.value!.style.left = nodeRect.left + node.offsetWidth / 2 - elRef.value!.offsetWidth / 2 + 'px'
|
523
536
|
elRef.value!.style.right = 'auto'
|
524
537
|
} else {
|
525
|
-
elRef.value!.style.left = nodeRect.left
|
538
|
+
elRef.value!.style.left = nodeRect.left + 'px'
|
526
539
|
elRef.value!.style.right = 'auto'
|
527
540
|
}
|
528
541
|
} else {
|
529
542
|
elRef.value!.style.left = 'auto'
|
530
|
-
elRef.value!.style.right = nodeRect.right
|
543
|
+
elRef.value!.style.right = nodeRect.right + 'px'
|
531
544
|
}
|
532
545
|
}
|
533
546
|
}
|
@@ -553,26 +566,21 @@ const handleEnter = (el: Element) => {
|
|
553
566
|
setPosition()
|
554
567
|
emits('show', el)
|
555
568
|
}
|
556
|
-
//完全显示后
|
557
|
-
const handleAfterEnter = (el: Element) => {
|
558
|
-
emits('shown', el)
|
559
|
-
}
|
560
|
-
//完全隐藏后
|
561
|
-
const handleAfterLeave = (el: Element) => {
|
562
|
-
emits('hidden', el)
|
563
|
-
}
|
564
569
|
//窗口尺寸改动
|
565
570
|
const handleResize = () => {
|
566
571
|
if (props.modelValue) {
|
567
572
|
emits('update:modelValue', false)
|
568
573
|
}
|
569
574
|
}
|
570
|
-
|
575
|
+
//点击定位元素和自身以外的元素关闭浮层
|
571
576
|
const handleClick = (e: Event) => {
|
572
577
|
if (!DapElement.isElement(elRef.value)) {
|
573
578
|
return
|
574
579
|
}
|
575
|
-
if (DapElement.isContains(
|
580
|
+
if (DapElement.isContains(elRef.value!, e.target as HTMLElement)) {
|
581
|
+
return
|
582
|
+
}
|
583
|
+
if (!props.useRange && getNode()! && DapElement.isContains(getNode()!, e.target as HTMLElement)) {
|
576
584
|
return
|
577
585
|
}
|
578
586
|
if (props.modelValue) {
|
@@ -584,12 +592,9 @@ onMounted(() => {
|
|
584
592
|
if (props.modelValue) {
|
585
593
|
setPosition()
|
586
594
|
}
|
587
|
-
DapEvent.on(window, `
|
595
|
+
DapEvent.on(window, `mousedown.editify_layer_${instance.uid}`, handleClick)
|
588
596
|
DapEvent.on(window, `resize.editify_layer_${instance.uid}`, handleResize)
|
589
597
|
})
|
590
|
-
onBeforeUnmount(() => {
|
591
|
-
DapEvent.off(window, `click.editify_layer_${instance.uid} resize.editify_layer_${instance.uid}`)
|
592
|
-
})
|
593
598
|
|
594
599
|
defineExpose({
|
595
600
|
setPosition
|
@@ -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: {
|