vue-editify 0.2.13 → 0.2.15
Sign up to get free protection for your applications and to get access to all the features.
- package/examples/App.vue +49 -67
- package/lib/components/button/button.vue.d.ts +62 -60
- package/lib/components/button/index.d.ts +4 -0
- package/lib/components/button/props.d.ts +12 -1
- package/lib/components/checkbox/checkbox.vue.d.ts +9 -9
- package/lib/components/checkbox/index.d.ts +4 -0
- package/lib/components/checkbox/props.d.ts +2 -2
- package/lib/components/colors/colors.vue.d.ts +4 -4
- package/lib/components/colors/index.d.ts +4 -0
- package/lib/components/colors/props.d.ts +2 -2
- package/lib/components/icon/index.d.ts +4 -0
- package/lib/components/insertAttachment/index.d.ts +4 -0
- package/lib/{plugins/attachment → components}/insertAttachment/insertAttachment.vue.d.ts +3 -3
- package/lib/{plugins/attachment → components}/insertAttachment/props.d.ts +1 -1
- package/lib/components/insertImage/index.d.ts +4 -0
- package/lib/components/insertImage/insertImage.vue.d.ts +3 -3
- package/lib/components/insertImage/props.d.ts +1 -1
- package/lib/components/insertLink/index.d.ts +4 -0
- package/lib/components/insertLink/insertLink.vue.d.ts +6 -6
- package/lib/components/insertLink/props.d.ts +3 -3
- package/lib/components/insertMathformula/index.d.ts +4 -0
- package/lib/{plugins/mathformula → components}/insertMathformula/insertMathformula.vue.d.ts +3 -3
- package/lib/{plugins/mathformula → components}/insertMathformula/props.d.ts +2 -2
- package/lib/components/insertTable/index.d.ts +4 -0
- package/lib/components/insertTable/insertTable.vue.d.ts +3 -3
- package/lib/components/insertTable/props.d.ts +2 -2
- package/lib/components/insertVideo/index.d.ts +4 -0
- package/lib/components/insertVideo/insertVideo.vue.d.ts +3 -3
- package/lib/components/insertVideo/props.d.ts +1 -1
- package/lib/components/layer/index.d.ts +4 -0
- package/lib/components/layer/layer.vue.d.ts +10 -8
- package/lib/components/tooltip/index.d.ts +4 -0
- package/lib/components/tooltip/tooltip.vue.d.ts +6 -4
- package/lib/components/triangle/index.d.ts +4 -0
- package/lib/components/triangle/triangle.vue.d.ts +1 -1
- package/lib/components/updateLink/index.d.ts +4 -0
- package/lib/components/updateLink/props.d.ts +17 -0
- package/lib/components/updateLink/updateLink.vue.d.ts +38 -0
- package/lib/core/function.d.ts +113 -36
- package/lib/core/rule.d.ts +20 -0
- package/lib/core/tool.d.ts +36 -34
- package/lib/editify/editify.vue.d.ts +86 -53
- package/lib/editify/menu/index.d.ts +4 -0
- package/lib/{components → editify}/menu/menu.vue.d.ts +3 -4
- package/lib/{components → editify}/menu/props.d.ts +1 -1
- package/lib/editify/props.d.ts +3 -7
- package/lib/editify/toolbar/index.d.ts +4 -0
- package/lib/{components → editify}/toolbar/props.d.ts +2 -2
- package/lib/{components → editify}/toolbar/toolbar.vue.d.ts +53 -53
- package/lib/editify.es.js +8879 -7668
- package/lib/editify.umd.js +2 -2
- package/lib/feature/align.d.ts +32 -0
- package/lib/feature/attachment.d.ts +18 -0
- package/lib/feature/backColor.d.ts +32 -0
- package/lib/feature/bold.d.ts +32 -0
- package/lib/feature/code.d.ts +32 -0
- package/lib/feature/codeBlock.d.ts +32 -0
- package/lib/feature/fontFamily.d.ts +32 -0
- package/lib/feature/fontSize.d.ts +32 -0
- package/lib/feature/foreColor.d.ts +32 -0
- package/lib/feature/formatClear.d.ts +32 -0
- package/lib/feature/fullScreen.d.ts +18 -0
- package/lib/feature/heading.d.ts +32 -0
- package/lib/feature/image.d.ts +32 -0
- package/lib/feature/indent.d.ts +18 -0
- package/lib/feature/infoBlock.d.ts +18 -0
- package/lib/feature/italic.d.ts +32 -0
- package/lib/feature/lineHeight.d.ts +32 -0
- package/lib/feature/link.d.ts +26 -0
- package/lib/feature/mathformula.d.ts +22 -0
- package/lib/feature/orderList.d.ts +32 -0
- package/lib/feature/panel.d.ts +18 -0
- package/lib/feature/quote.d.ts +18 -0
- package/lib/feature/redo.d.ts +18 -0
- package/lib/feature/separator.d.ts +18 -0
- package/lib/feature/sourceView.d.ts +18 -0
- package/lib/feature/strikethrough.d.ts +32 -0
- package/lib/feature/sub.d.ts +32 -0
- package/lib/feature/super.d.ts +32 -0
- package/lib/feature/table.d.ts +32 -0
- package/lib/feature/task.d.ts +32 -0
- package/lib/feature/underline.d.ts +32 -0
- package/lib/feature/undo.d.ts +18 -0
- package/lib/feature/unorderList.d.ts +32 -0
- package/lib/feature/video.d.ts +38 -0
- package/lib/index.d.ts +104 -69
- package/package.json +5 -5
- package/src/components/button/button.vue +21 -24
- package/src/components/button/index.ts +5 -0
- package/src/components/button/props.ts +14 -1
- package/src/components/checkbox/checkbox.vue +1 -1
- package/src/components/checkbox/index.ts +5 -0
- package/src/components/checkbox/props.ts +1 -1
- package/src/components/colors/colors.vue +3 -3
- package/src/components/colors/index.ts +5 -0
- package/src/components/colors/props.ts +2 -2
- package/src/components/icon/index.ts +5 -0
- package/src/components/insertAttachment/index.ts +5 -0
- package/src/{plugins/attachment → components}/insertAttachment/insertAttachment.vue +4 -2
- package/src/{plugins/attachment → components}/insertAttachment/props.ts +1 -1
- package/src/components/insertImage/index.ts +5 -0
- package/src/components/insertImage/insertImage.vue +5 -5
- package/src/components/insertImage/props.ts +1 -1
- package/src/components/insertLink/index.ts +5 -0
- package/src/components/insertLink/insertLink.vue +10 -10
- package/src/components/insertLink/props.ts +3 -3
- package/src/components/insertMathformula/index.ts +5 -0
- package/src/{plugins/mathformula → components}/insertMathformula/props.ts +2 -2
- package/src/components/insertTable/index.ts +5 -0
- package/src/components/insertTable/props.ts +2 -2
- package/src/components/insertVideo/index.ts +5 -0
- package/src/components/insertVideo/insertVideo.vue +2 -2
- package/src/components/insertVideo/props.ts +1 -1
- package/src/components/layer/index.ts +5 -0
- package/src/components/layer/layer.vue +42 -4
- package/src/components/tooltip/index.ts +5 -0
- package/src/components/tooltip/tooltip.vue +1 -1
- package/src/components/triangle/index.ts +5 -0
- package/src/components/triangle/triangle.vue +1 -1
- package/src/components/updateLink/index.ts +5 -0
- package/src/components/updateLink/props.ts +21 -0
- package/src/components/{toolbar/toolbar.less → updateLink/updateLink.less} +4 -20
- package/src/components/updateLink/updateLink.vue +74 -0
- package/src/core/function.ts +289 -97
- package/src/core/rule.ts +96 -7
- package/src/core/tool.ts +234 -78
- package/src/editify/editify.less +2 -0
- package/src/editify/editify.vue +182 -185
- package/src/editify/menu/index.ts +5 -0
- package/src/editify/menu/menu.vue +215 -0
- package/src/{components → editify}/menu/props.ts +1 -1
- package/src/editify/props.ts +7 -11
- package/src/editify/toolbar/index.ts +5 -0
- package/src/{components → editify}/toolbar/props.ts +1 -1
- package/src/editify/toolbar/toolbar.less +10 -0
- package/src/editify/toolbar/toolbar.vue +103 -0
- package/src/feature/align.ts +128 -0
- package/src/feature/attachment.ts +109 -0
- package/src/feature/backColor.ts +171 -0
- package/src/feature/bold.ts +136 -0
- package/src/feature/code.ts +136 -0
- package/src/feature/codeBlock.ts +204 -0
- package/src/feature/fontFamily.ts +140 -0
- package/src/feature/fontSize.ts +142 -0
- package/src/feature/foreColor.ts +173 -0
- package/src/feature/formatClear.ts +118 -0
- package/src/feature/fullScreen.ts +57 -0
- package/src/feature/heading.ts +154 -0
- package/src/feature/image.ts +225 -0
- package/src/feature/indent.ts +73 -0
- package/src/feature/infoBlock.ts +94 -0
- package/src/feature/italic.ts +136 -0
- package/src/feature/lineHeight.ts +165 -0
- package/src/feature/link.ts +149 -0
- package/src/feature/mathformula.ts +147 -0
- package/src/feature/orderList.ts +116 -0
- package/src/feature/panel.ts +108 -0
- package/src/feature/quote.ts +61 -0
- package/src/feature/redo.ts +56 -0
- package/src/feature/separator.ts +62 -0
- package/src/feature/sourceView.ts +59 -0
- package/src/feature/strikethrough.ts +136 -0
- package/src/feature/sub.ts +136 -0
- package/src/feature/super.ts +136 -0
- package/src/feature/table.ts +994 -0
- package/src/feature/task.ts +116 -0
- package/src/feature/underline.ts +136 -0
- package/src/feature/undo.ts +56 -0
- package/src/feature/unorderList.ts +116 -0
- package/src/feature/video.ts +339 -0
- package/src/hljs/index.ts +1 -1
- package/src/index.ts +69 -21
- package/src/locale/en_US.ts +3 -3
- package/src/locale/zh_CN.ts +3 -3
- package/lib/plugins/attachment/index.d.ts +0 -37
- package/lib/plugins/infoBlock/index.d.ts +0 -55
- package/lib/plugins/mathformula/index.d.ts +0 -49
- package/lib/plugins/panel/index.d.ts +0 -48
- package/src/components/menu/menu.vue +0 -1655
- package/src/components/toolbar/toolbar.vue +0 -1677
- package/src/plugins/attachment/index.ts +0 -237
- package/src/plugins/infoBlock/index.ts +0 -238
- package/src/plugins/mathformula/index.ts +0 -295
- package/src/plugins/panel/index.ts +0 -228
- package/tsconfig.json +0 -31
- package/tsconfig.node.json +0 -11
- /package/src/{plugins/attachment → components}/insertAttachment/insertAttachment.less +0 -0
- /package/src/{plugins/mathformula → components}/insertMathformula/insertMathformula.less +0 -0
- /package/src/{plugins/mathformula → components}/insertMathformula/insertMathformula.vue +0 -0
- /package/src/{components → editify}/menu/menu.less +0 -0
@@ -24,16 +24,18 @@
|
|
24
24
|
</div>
|
25
25
|
</template>
|
26
26
|
<script setup lang="ts">
|
27
|
-
import { file as DapFile } from 'dap-util'
|
28
27
|
import { computed, inject, ref, watch } from 'vue'
|
28
|
+
import { file as DapFile } from 'dap-util'
|
29
29
|
import { ObjectType } from '@/core/tool'
|
30
|
-
import Icon from '@/components/icon
|
30
|
+
import { Icon } from '@/components/icon'
|
31
31
|
import { InsertAttachmentProps } from './props'
|
32
32
|
|
33
33
|
defineOptions({
|
34
34
|
name: 'InsertAttachment'
|
35
35
|
})
|
36
|
+
//属性
|
36
37
|
const props = defineProps(InsertAttachmentProps)
|
38
|
+
//事件
|
37
39
|
const emits = defineEmits(['change', 'insert'])
|
38
40
|
|
39
41
|
const $editTrans = inject<(key: string) => any>('$editTrans')!
|
@@ -20,10 +20,10 @@
|
|
20
20
|
</div>
|
21
21
|
</template>
|
22
22
|
<script setup lang="ts">
|
23
|
-
import { file as DapFile } from 'dap-util'
|
24
23
|
import { computed, inject, ref, watch } from 'vue'
|
25
|
-
import
|
24
|
+
import { file as DapFile } from 'dap-util'
|
26
25
|
import { ObjectType } from '@/core/tool'
|
26
|
+
import { Icon } from '@/components/icon'
|
27
27
|
import { InsertImageProps } from './props'
|
28
28
|
|
29
29
|
defineOptions({
|
@@ -61,12 +61,12 @@ const getSuffix = (file: File) => {
|
|
61
61
|
//输入框获取焦点
|
62
62
|
const handleInputFocus = (e: Event) => {
|
63
63
|
if (props.color) {
|
64
|
-
;(
|
64
|
+
;(e.currentTarget as HTMLInputElement).style.borderColor = props.color
|
65
65
|
}
|
66
66
|
}
|
67
67
|
//输入框失去焦点
|
68
68
|
const handleInputBlur = (e: Event) => {
|
69
|
-
;(
|
69
|
+
;(e.currentTarget as HTMLInputElement).style.borderColor = ''
|
70
70
|
}
|
71
71
|
//插入网络图片
|
72
72
|
const insertRemoteImage = () => {
|
@@ -74,7 +74,7 @@ const insertRemoteImage = () => {
|
|
74
74
|
}
|
75
75
|
//选择文件
|
76
76
|
const selectFile = async (e: Event) => {
|
77
|
-
const inputEle =
|
77
|
+
const inputEle = e.currentTarget as HTMLInputElement
|
78
78
|
const files = inputEle.files
|
79
79
|
if (!files || !files.length) {
|
80
80
|
return
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<template>
|
2
2
|
<div class="editify-link">
|
3
3
|
<div class="editify-link-label">{{ $editTrans('linkAddress') }}</div>
|
4
|
-
<input @focus="handleInputFocus" @blur="handleInputBlur" :placeholder="$editTrans('linkTextEnterPlaceholder')" v-model.trim="
|
5
|
-
<input @focus="handleInputFocus" @blur="handleInputBlur" :placeholder="$editTrans('linkUrlEnterPlaceholder')" v-model.trim="
|
4
|
+
<input @focus="handleInputFocus" @blur="handleInputBlur" :placeholder="$editTrans('linkTextEnterPlaceholder')" v-model.trim="text" type="text" />
|
5
|
+
<input @focus="handleInputFocus" @blur="handleInputBlur" :placeholder="$editTrans('linkUrlEnterPlaceholder')" v-model.trim="url" type="url" />
|
6
6
|
<div class="editify-link-footer">
|
7
7
|
<Checkbox v-model="newOpen" :label="$editTrans('newWindowOpen')" :color="color" :size="10"></Checkbox>
|
8
8
|
<div class="editify-link-operations">
|
@@ -13,7 +13,7 @@
|
|
13
13
|
</template>
|
14
14
|
<script setup lang="ts">
|
15
15
|
import { inject, ref, watch } from 'vue'
|
16
|
-
import Checkbox from '@/components/checkbox
|
16
|
+
import { Checkbox } from '@/components/checkbox'
|
17
17
|
import { InsertLinkProps } from './props'
|
18
18
|
|
19
19
|
defineOptions({
|
@@ -25,16 +25,16 @@ const emits = defineEmits(['insert'])
|
|
25
25
|
const $editTrans = inject<(key: string) => any>('$editTrans')!
|
26
26
|
|
27
27
|
//链接地址
|
28
|
-
const
|
28
|
+
const url = ref<string>('')
|
29
29
|
//链接文本
|
30
|
-
const
|
30
|
+
const text = ref<string>('')
|
31
31
|
//是否新窗口打开
|
32
32
|
const newOpen = ref<boolean>(false)
|
33
33
|
|
34
34
|
watch(
|
35
|
-
() => props.
|
35
|
+
() => props.presetText,
|
36
36
|
newVal => {
|
37
|
-
|
37
|
+
text.value = newVal || ''
|
38
38
|
},
|
39
39
|
{
|
40
40
|
immediate: true
|
@@ -43,16 +43,16 @@ watch(
|
|
43
43
|
//输入框获取焦点
|
44
44
|
const handleInputFocus = (e: Event) => {
|
45
45
|
if (props.color) {
|
46
|
-
;(
|
46
|
+
;(e.currentTarget as HTMLInputElement).style.borderColor = props.color
|
47
47
|
}
|
48
48
|
}
|
49
49
|
//输入框失去焦点
|
50
50
|
const handleInputBlur = (e: Event) => {
|
51
|
-
;(
|
51
|
+
;(e.currentTarget as HTMLInputElement).style.borderColor = ''
|
52
52
|
}
|
53
53
|
//插入链接
|
54
54
|
const insertLink = () => {
|
55
|
-
emits('insert',
|
55
|
+
emits('insert', text.value, url.value, newOpen.value)
|
56
56
|
}
|
57
57
|
</script>
|
58
58
|
<style scoped src="./insertLink.less"></style>
|
@@ -1,13 +1,13 @@
|
|
1
|
-
import { ExtractPublicPropTypes
|
1
|
+
import { ExtractPublicPropTypes } from 'vue'
|
2
2
|
|
3
3
|
export const InsertLinkProps = {
|
4
4
|
//主题色
|
5
5
|
color: {
|
6
|
-
type: String
|
6
|
+
type: String,
|
7
7
|
default: ''
|
8
8
|
},
|
9
9
|
//预置的链接文本值
|
10
|
-
|
10
|
+
presetText: {
|
11
11
|
type: String,
|
12
12
|
default: ''
|
13
13
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ExtractPublicPropTypes
|
1
|
+
import { ExtractPublicPropTypes } from 'vue'
|
2
2
|
|
3
3
|
export type InsertTableGridType = {
|
4
4
|
x: number
|
@@ -9,7 +9,7 @@ export type InsertTableGridType = {
|
|
9
9
|
export const InsertTableProps = {
|
10
10
|
//主题色
|
11
11
|
color: {
|
12
|
-
type: String
|
12
|
+
type: String,
|
13
13
|
default: ''
|
14
14
|
},
|
15
15
|
//最大行数
|
@@ -20,10 +20,10 @@
|
|
20
20
|
</div>
|
21
21
|
</template>
|
22
22
|
<script setup lang="ts">
|
23
|
-
import { file as DapFile } from 'dap-util'
|
24
23
|
import { computed, inject, ref, watch } from 'vue'
|
24
|
+
import { file as DapFile } from 'dap-util'
|
25
25
|
import { ObjectType } from '@/core/tool'
|
26
|
-
import Icon from '@/components/icon
|
26
|
+
import { Icon } from '@/components/icon'
|
27
27
|
import { InsertVideoProps } from './props'
|
28
28
|
|
29
29
|
defineOptions({
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<template>
|
2
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)">
|
3
|
+
<Transition :name="animation ? 'editify-layer-' + animation : 'editify-layer'" @enter="handleEnter" @after-enter="(el:Element) => emits('shown', el)" @after-leave="(el:Element) => emits('hidden', el)">
|
4
4
|
<div v-if="modelValue" class="editify-layer" :data-editify-placement="realPlacement || null" :style="{ zIndex: zIndex }" ref="elRef">
|
5
5
|
<Triangle v-if="showTriangle" :color="border && borderColor ? borderColor : background" :background="background" :placement="triPlacement" ref="triangleRef" />
|
6
6
|
<div ref="wrapRef" class="editify-layer-wrap" :class="{ 'editify-border': border }" :style="wrapStyle">
|
@@ -11,11 +11,10 @@
|
|
11
11
|
</Teleport>
|
12
12
|
</template>
|
13
13
|
<script setup lang="ts">
|
14
|
-
import { computed, getCurrentInstance, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
|
14
|
+
import { computed, getCurrentInstance, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
15
15
|
import { element as DapElement, event as DapEvent } from 'dap-util'
|
16
|
-
import Triangle from '@/components/triangle/triangle.vue'
|
17
|
-
import { TrianglePlacementType } from '@/components/triangle/props'
|
18
16
|
import { ObjectType } from '@/core/tool'
|
17
|
+
import { Triangle, TrianglePlacementType } from '@/components/triangle'
|
19
18
|
import { LayerPlacementType, LayerProps } from './props'
|
20
19
|
|
21
20
|
defineOptions({
|
@@ -572,6 +571,30 @@ const handleResize = () => {
|
|
572
571
|
emits('update:modelValue', false)
|
573
572
|
}
|
574
573
|
}
|
574
|
+
//有元素滚动
|
575
|
+
const handleScroll = () => {
|
576
|
+
const setScroll = (el: HTMLElement) => {
|
577
|
+
DapEvent.on(el, `scroll.editify_layer_${instance.uid}`, () => {
|
578
|
+
if (props.modelValue) {
|
579
|
+
emits('update:modelValue', false)
|
580
|
+
}
|
581
|
+
})
|
582
|
+
if (el.parentNode) {
|
583
|
+
setScroll(el.parentNode as HTMLElement)
|
584
|
+
}
|
585
|
+
}
|
586
|
+
setScroll(getNode()! || getScrollNode()!)
|
587
|
+
}
|
588
|
+
//移除上述滚动事件的监听
|
589
|
+
const removeScrollHandle = () => {
|
590
|
+
const removeScroll = (el: HTMLElement) => {
|
591
|
+
DapEvent.off(el, `scroll.editify_layer_${instance.uid}`)
|
592
|
+
if (el.parentNode) {
|
593
|
+
removeScroll(el.parentNode as HTMLElement)
|
594
|
+
}
|
595
|
+
}
|
596
|
+
removeScroll(getNode()! || getScrollNode()!)
|
597
|
+
}
|
575
598
|
//点击定位元素和自身以外的元素关闭浮层
|
576
599
|
const handleClick = (e: Event) => {
|
577
600
|
if (!DapElement.isElement(elRef.value)) {
|
@@ -595,6 +618,20 @@ const handleClick = (e: Event) => {
|
|
595
618
|
}
|
596
619
|
}
|
597
620
|
|
621
|
+
watch(
|
622
|
+
() => props.modelValue,
|
623
|
+
newVal => {
|
624
|
+
if (newVal) {
|
625
|
+
nextTick(() => {
|
626
|
+
handleScroll()
|
627
|
+
})
|
628
|
+
}
|
629
|
+
},
|
630
|
+
{
|
631
|
+
immediate: true
|
632
|
+
}
|
633
|
+
)
|
634
|
+
|
598
635
|
onMounted(() => {
|
599
636
|
if (props.modelValue) {
|
600
637
|
setPosition()
|
@@ -604,6 +641,7 @@ onMounted(() => {
|
|
604
641
|
})
|
605
642
|
|
606
643
|
onBeforeUnmount(() => {
|
644
|
+
removeScrollHandle()
|
607
645
|
DapEvent.off(window, `mousedown.editify_layer_${instance.uid} resize.editify_layer_${instance.uid}`)
|
608
646
|
})
|
609
647
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { ExtractPublicPropTypes } from 'vue'
|
2
|
+
|
3
|
+
export const UpdateLinkProps = {
|
4
|
+
//主题色
|
5
|
+
color: {
|
6
|
+
type: String,
|
7
|
+
default: ''
|
8
|
+
},
|
9
|
+
//预置链接值
|
10
|
+
presetUrl: {
|
11
|
+
type: String,
|
12
|
+
default: ''
|
13
|
+
},
|
14
|
+
//预置是否新窗口打开
|
15
|
+
presetNewOpen: {
|
16
|
+
type: Boolean,
|
17
|
+
default: false
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
export type UpdateLinkPropsType = ExtractPublicPropTypes<typeof UpdateLinkProps>
|
@@ -1,20 +1,9 @@
|
|
1
|
-
.editify-
|
2
|
-
display: flex;
|
3
|
-
justify-content: flex-start;
|
4
|
-
align-items: center;
|
5
|
-
padding: 6px 10px;
|
6
|
-
|
7
|
-
.editify-icon-rotate {
|
8
|
-
transform: rotate(180deg);
|
9
|
-
}
|
10
|
-
}
|
11
|
-
|
12
|
-
.editify-toolbar-link {
|
1
|
+
.editify-link {
|
13
2
|
display: block;
|
14
3
|
width: 280px;
|
15
4
|
padding: 4px;
|
16
5
|
|
17
|
-
.editify-
|
6
|
+
.editify-link-label {
|
18
7
|
display: block;
|
19
8
|
text-align: left;
|
20
9
|
margin-bottom: 10px;
|
@@ -46,14 +35,9 @@
|
|
46
35
|
font-size: inherit;
|
47
36
|
vertical-align: middle;
|
48
37
|
}
|
49
|
-
|
50
|
-
&[disabled] {
|
51
|
-
background-color: transparent;
|
52
|
-
opacity: 0.6;
|
53
|
-
}
|
54
38
|
}
|
55
39
|
|
56
|
-
.editify-
|
40
|
+
.editify-link-footer {
|
57
41
|
display: flex;
|
58
42
|
justify-content: space-between;
|
59
43
|
align-items: center;
|
@@ -61,7 +45,7 @@
|
|
61
45
|
font-size: var(--editify-font-size);
|
62
46
|
color: var(--editify-font-color-light);
|
63
47
|
|
64
|
-
.editify-
|
48
|
+
.editify-link-operations {
|
65
49
|
display: flex;
|
66
50
|
justify-content: flex-start;
|
67
51
|
align-items: center;
|
@@ -0,0 +1,74 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="editify-link">
|
3
|
+
<div class="editify-link-label">{{ $editTrans('linkAddress') }}</div>
|
4
|
+
<input @change="modifyLink" @focus="handleInputFocus" @blur="handleInputBlur" :placeholder="$editTrans('linkUrlEnterPlaceholder')" v-model.trim="url" type="url" />
|
5
|
+
<div class="editify-link-footer">
|
6
|
+
<Checkbox @change="modifyLink" v-model="newOpen" :label="$editTrans('newWindowOpen')" :color="color" :size="10"></Checkbox>
|
7
|
+
<div class="editify-link-operations">
|
8
|
+
<span @click="removeLink">{{ $editTrans('removeLink') }}</span>
|
9
|
+
<a :href="url" target="_blank" :style="{ color: color || '' }">{{ $editTrans('viewLink') }}</a>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
</template>
|
14
|
+
<script setup lang="ts">
|
15
|
+
import { inject, onBeforeUnmount, ref, watch } from 'vue'
|
16
|
+
import { Checkbox } from '@/components/checkbox'
|
17
|
+
import { UpdateLinkProps } from './props'
|
18
|
+
|
19
|
+
defineOptions({
|
20
|
+
name: 'UpdateLink'
|
21
|
+
})
|
22
|
+
const props = defineProps(UpdateLinkProps)
|
23
|
+
const emits = defineEmits(['remove', 'modify'])
|
24
|
+
|
25
|
+
const $editTrans = inject<(key: string) => any>('$editTrans')!
|
26
|
+
|
27
|
+
//链接地址
|
28
|
+
const url = ref<string>('')
|
29
|
+
//是否新窗口打开
|
30
|
+
const newOpen = ref<boolean>(false)
|
31
|
+
|
32
|
+
watch(
|
33
|
+
() => props.presetNewOpen,
|
34
|
+
newVal => {
|
35
|
+
newOpen.value = !!newVal
|
36
|
+
},
|
37
|
+
{
|
38
|
+
immediate: true
|
39
|
+
}
|
40
|
+
)
|
41
|
+
watch(
|
42
|
+
() => props.presetUrl,
|
43
|
+
newVal => {
|
44
|
+
url.value = newVal || ''
|
45
|
+
},
|
46
|
+
{
|
47
|
+
immediate: true
|
48
|
+
}
|
49
|
+
)
|
50
|
+
//输入框获取焦点
|
51
|
+
const handleInputFocus = (e: Event) => {
|
52
|
+
if (props.color) {
|
53
|
+
;(e.currentTarget as HTMLInputElement).style.borderColor = props.color
|
54
|
+
}
|
55
|
+
}
|
56
|
+
//输入框失去焦点
|
57
|
+
const handleInputBlur = (e: Event) => {
|
58
|
+
;(e.currentTarget as HTMLInputElement).style.borderColor = ''
|
59
|
+
}
|
60
|
+
//移除链接
|
61
|
+
const removeLink = () => {
|
62
|
+
emits('remove')
|
63
|
+
}
|
64
|
+
//修改链接
|
65
|
+
const modifyLink = () => {
|
66
|
+
emits('modify', url.value, newOpen.value)
|
67
|
+
}
|
68
|
+
|
69
|
+
//组件销毁前触发修改,解决组件销毁时change事件触发不了emits的问题
|
70
|
+
onBeforeUnmount(() => {
|
71
|
+
emits('modify', url.value, newOpen.value)
|
72
|
+
})
|
73
|
+
</script>
|
74
|
+
<style scoped src="./updateLink.less"></style>
|