vue-editify 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +3 -0
- package/examples/App.vue +80 -0
- package/examples/main.js +4 -0
- package/lib/editify.es.js +22457 -0
- package/lib/editify.umd.js +1 -0
- package/lib/style.css +1 -0
- package/package.json +38 -0
- package/src/Editify.vue +1880 -0
- package/src/components/base/Button.vue +440 -0
- package/src/components/base/Checkbox.vue +196 -0
- package/src/components/base/Icon.vue +31 -0
- package/src/components/base/Layer.vue +712 -0
- package/src/components/base/Tooltip.vue +82 -0
- package/src/components/base/Triangle.vue +159 -0
- package/src/components/bussiness/Colors.vue +138 -0
- package/src/components/bussiness/InsertImage.vue +316 -0
- package/src/components/bussiness/InsertLink.vue +136 -0
- package/src/components/bussiness/InsertTable.vue +113 -0
- package/src/components/bussiness/InsertVideo.vue +316 -0
- package/src/components/bussiness/Menu.vue +1460 -0
- package/src/components/bussiness/Toolbar.vue +1123 -0
- package/src/core/index.js +1278 -0
- package/src/css/base.less +30 -0
- package/src/css/hljs.less +54 -0
- package/src/hljs/index.js +60 -0
- package/src/icon/iconfont.css +211 -0
- package/src/icon/iconfont.ttf +0 -0
- package/src/icon/iconfont.woff +0 -0
- package/src/index.js +22 -0
- package/src/locale/en_US.js +84 -0
- package/src/locale/index.js +14 -0
- package/src/locale/zh_CN.js +84 -0
@@ -0,0 +1,1123 @@
|
|
1
|
+
<template>
|
2
|
+
<Layer v-model="show" ref="layer" :node="node" border placement="bottom-start" @show="layerShow" :useRange="type == 'text'">
|
3
|
+
<div class="editify-toolbar" ref="toolbar" :style="config.style">
|
4
|
+
<!-- 链接工具条 -->
|
5
|
+
<template v-if="type == 'link'">
|
6
|
+
<div class="editify-toolbar-link">
|
7
|
+
<div class="editify-toolbar-link-label">{{ $editTrans('linkAddress') }}</div>
|
8
|
+
<input @input="modifyLink" @focus="handleInputFocus" @blur="handleInputBlur" :placeholder="$editTrans('linkUrlEnterPlaceholder')" v-model.trim="linkConfig.url" type="url" />
|
9
|
+
<div class="editify-toolbar-link-footer">
|
10
|
+
<Checkbox @change="modifyLink" v-model="linkConfig.newOpen" :label="$editTrans('newWindowOpen')" :color="$parent.color" :size="10"></Checkbox>
|
11
|
+
<div class="editify-toolbar-link-operations">
|
12
|
+
<span @click="$parent.removeLink">{{ $editTrans('removeLink') }}</span>
|
13
|
+
<a :href="linkConfig.url" target="_blank" :style="{ color: $parent.color }">{{ $editTrans('viewLink') }}</a>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
</template>
|
18
|
+
<!-- 图片工具条 -->
|
19
|
+
<template v-else-if="type == 'image'">
|
20
|
+
<!-- 设置宽度30% -->
|
21
|
+
<Button @operate="setWidth('30%')" name="set30Width" :title="$editTrans('width30')" :tooltip="config.tooltip" :color="$parent.color"> 30% </Button>
|
22
|
+
<!-- 设置宽度50% -->
|
23
|
+
<Button @operate="setWidth('50%')" name="set50Width" :title="$editTrans('width50')" :tooltip="config.tooltip" :color="$parent.color"> 50% </Button>
|
24
|
+
<!-- 设置宽度100% -->
|
25
|
+
<Button rightBorder @operate="setWidth('100%')" name="set100Width" :title="$editTrans('width100')" :tooltip="config.tooltip" :color="$parent.color"> 100% </Button>
|
26
|
+
<!-- 删除图片 -->
|
27
|
+
<Button @operate="$parent.deleteByParsedom('img')" name="deleteImage" :title="$editTrans('deleteImage')" :tooltip="config.tooltip" :color="$parent.color">
|
28
|
+
<Icon value="delete"></Icon>
|
29
|
+
</Button>
|
30
|
+
</template>
|
31
|
+
<!-- 视频工具条 -->
|
32
|
+
<template v-else-if="type == 'video'">
|
33
|
+
<!-- 设置宽度30% -->
|
34
|
+
<Button @operate="setWidth('30%')" name="set30Width" :title="$editTrans('width30')" :tooltip="config.tooltip" :color="$parent.color"> 30% </Button>
|
35
|
+
<!-- 设置宽度50% -->
|
36
|
+
<Button @operate="setWidth('50%')" name="set50Width" :title="$editTrans('width50')" :tooltip="config.tooltip" :color="$parent.color"> 50% </Button>
|
37
|
+
<!-- 设置宽度100% -->
|
38
|
+
<Button rightBorder @operate="setWidth('100%')" name="set100Width" :title="$editTrans('width100')" :tooltip="config.tooltip" :color="$parent.color"> 100% </Button>
|
39
|
+
<!-- 自动播放 -->
|
40
|
+
<Button @operate="setVideo" name="autoplay" :title="videoConfig.autoplay ? $editTrans('disabledAutoplay') : $editTrans('autoplay')" :tooltip="config.tooltip" :color="$parent.color">
|
41
|
+
<Icon :value="videoConfig.autoplay ? 'autoplay' : 'stop'"></Icon>
|
42
|
+
</Button>
|
43
|
+
<!-- 循环播放 -->
|
44
|
+
<Button @operate="setVideo" name="loop" :title="videoConfig.loop ? $editTrans('disabledLoop') : $editTrans('loop')" :tooltip="config.tooltip" :color="$parent.color">
|
45
|
+
<Icon :value="videoConfig.loop ? 'loop' : 'single'"></Icon>
|
46
|
+
</Button>
|
47
|
+
<!-- 是否静音 -->
|
48
|
+
<Button @operate="setVideo" name="muted" :title="videoConfig.muted ? $editTrans('unmuted') : $editTrans('muted')" :tooltip="config.tooltip" :color="$parent.color">
|
49
|
+
<Icon :value="videoConfig.muted ? 'muted' : 'unmuted'"></Icon>
|
50
|
+
</Button>
|
51
|
+
<!-- 是否显示控制器 -->
|
52
|
+
<Button leftBorder @operate="setVideo" name="controls" :title="$editTrans('controls')" :tooltip="config.tooltip" :color="$parent.color">
|
53
|
+
<Icon value="controls"></Icon>
|
54
|
+
</Button>
|
55
|
+
<!-- 删除视频 -->
|
56
|
+
<Button @operate="$parent.deleteByParsedom('video')" name="deleteVideo" :title="$editTrans('deleteVideo')" :tooltip="config.tooltip" :color="$parent.color">
|
57
|
+
<Icon value="delete"></Icon>
|
58
|
+
</Button>
|
59
|
+
</template>
|
60
|
+
<!-- 表格工具条 -->
|
61
|
+
<template v-else-if="type == 'table'">
|
62
|
+
<!-- 表格前插入段落 -->
|
63
|
+
<Button @operate="insertParagraphWithTable('up')" name="textWrapUp" :title="$editTrans('textWrapUp')" :tooltip="config.tooltip" :color="$parent.color">
|
64
|
+
<Icon value="text-wrap" class="editify-icon-rotate"></Icon>
|
65
|
+
</Button>
|
66
|
+
<!-- 表格后插入段落 -->
|
67
|
+
<Button @operate="insertParagraphWithTable('down')" rightBorder name="textWrapDown" :title="$editTrans('textWrapDown')" :tooltip="config.tooltip" :color="$parent.color">
|
68
|
+
<Icon value="text-wrap"></Icon>
|
69
|
+
</Button>
|
70
|
+
<!-- 向前插入行 -->
|
71
|
+
<Button @operate="insertTableRow('up')" name="insertRowTop" :title="$editTrans('insertRowTop')" :tooltip="config.tooltip" :color="$parent.color">
|
72
|
+
<Icon value="insert-row-top"></Icon>
|
73
|
+
</Button>
|
74
|
+
<!-- 向后插入行 -->
|
75
|
+
<Button @operate="insertTableRow('down')" name="insertRowBottom" :title="$editTrans('insertRowBottom')" :tooltip="config.tooltip" :color="$parent.color">
|
76
|
+
<Icon value="insert-row-bottom"></Icon>
|
77
|
+
</Button>
|
78
|
+
<!-- 删除行 -->
|
79
|
+
<Button @operate="deleteTableRow" rightBorder name="deleteRow" :title="$editTrans('deleteRow')" :tooltip="config.tooltip" :color="$parent.color">
|
80
|
+
<Icon value="delete-row"></Icon>
|
81
|
+
</Button>
|
82
|
+
<!-- 向前插入列 -->
|
83
|
+
<Button @operate="insertTableColumn('left')" name="insertColumnLeft" :title="$editTrans('insertColumnLeft')" :tooltip="config.tooltip" :color="$parent.color">
|
84
|
+
<Icon value="insert-column-left"></Icon>
|
85
|
+
</Button>
|
86
|
+
<!-- 向后插入列 -->
|
87
|
+
<Button @operate="insertTableColumn('right')" name="insertColumnRight" :title="$editTrans('insertColumnRight')" :tooltip="config.tooltip" :color="$parent.color">
|
88
|
+
<Icon value="insert-column-right"></Icon>
|
89
|
+
</Button>
|
90
|
+
<!-- 删除列 -->
|
91
|
+
<Button @operate="deleteTableColumn" rightBorder name="deleteColumn" :title="$editTrans('deleteColumn')" :tooltip="config.tooltip" :color="$parent.color">
|
92
|
+
<Icon value="delete-column"></Icon>
|
93
|
+
</Button>
|
94
|
+
<!-- 删除表格 -->
|
95
|
+
<Button @operate="$parent.deleteByParsedom('table')" name="deleteTable" :title="$editTrans('deleteTable')" :tooltip="config.tooltip" :color="$parent.color">
|
96
|
+
<Icon value="delete-table"></Icon>
|
97
|
+
</Button>
|
98
|
+
</template>
|
99
|
+
<!-- 代码块工具条 -->
|
100
|
+
<template v-if="type == 'codeBlock'">
|
101
|
+
<!-- 代码块前插入段落 -->
|
102
|
+
<Button @operate="insertParagraphWithPre('up')" name="textWrapUp" :title="$editTrans('textWrapUp')" :tooltip="config.tooltip" :color="$parent.color">
|
103
|
+
<Icon value="text-wrap" class="editify-icon-rotate"></Icon>
|
104
|
+
</Button>
|
105
|
+
<!-- 代码块后插入段落 -->
|
106
|
+
<Button @operate="insertParagraphWithPre('down')" name="textWrapDown" :title="$editTrans('textWrapDown')" :tooltip="config.tooltip" :color="$parent.color">
|
107
|
+
<Icon value="text-wrap"></Icon>
|
108
|
+
</Button>
|
109
|
+
<!-- 代码块语言选择 -->
|
110
|
+
<Button v-if="languageConfig.show" name="languages" type="display" :title="$editTrans('selectLanguages')" :tooltip="config.tooltip" :leftBorder="languageConfig.leftBorder" :rightBorder="languageConfig.rightBorder" :display-config="languageConfig.displayConfig" :color="$parent.color" :active="languageConfig.active" :disabled="languageConfig.disabled" @operate="selectLanguage"></Button>
|
111
|
+
</template>
|
112
|
+
<!-- 文本工具条 -->
|
113
|
+
<template v-else-if="type == 'text'">
|
114
|
+
<!-- 设置段落和标题 -->
|
115
|
+
<Button v-if="headingConfig.show" name="heading" type="display" :title="$editTrans('heading')" :tooltip="config.tooltip" :display-config="headingConfig.displayConfig" :leftBorder="headingConfig.leftBorder" :rightBorder="headingConfig.rightBorder" :color="$parent.color" :active="headingConfig.active" :disabled="headingConfig.disabled" @operate="setHeading"></Button>
|
116
|
+
<!-- 对齐方式 -->
|
117
|
+
<Button v-if="alignConfig.show" name="align" type="select" :title="$editTrans('align')" :tooltip="config.tooltip" :select-config="alignConfig.selectConfig" :leftBorder="alignConfig.leftBorder" :rightBorder="alignConfig.rightBorder" :color="$parent.color" :active="alignConfig.active" :disabled="alignConfig.disabled" @operate="setAlign">
|
118
|
+
<Icon value="align-left"></Icon>
|
119
|
+
</Button>
|
120
|
+
<!-- 有序列表 -->
|
121
|
+
<Button v-if="orderListConfig.show" name="orderList" :title="$editTrans('orderList')" :tooltip="config.tooltip" :leftBorder="orderListConfig.leftBorder" :rightBorder="orderListConfig.rightBorder" :color="$parent.color" :active="orderListConfig.active" :disabled="orderListConfig.disabled" @operate="setList">
|
122
|
+
<Icon value="list-ordered"></Icon>
|
123
|
+
</Button>
|
124
|
+
<!-- 无序列表 -->
|
125
|
+
<Button v-if="unorderListConfig.show" name="unorderList" :title="$editTrans('unorderList')" :tooltip="config.tooltip" :leftBorder="unorderListConfig.leftBorder" :rightBorder="unorderListConfig.rightBorder" :color="$parent.color" :active="unorderListConfig.active" :disabled="unorderListConfig.disabled" @operate="setList">
|
126
|
+
<Icon value="list-unordered"></Icon>
|
127
|
+
</Button>
|
128
|
+
<!-- 任务列表 -->
|
129
|
+
<Button v-if="taskConfig.show" name="task" :title="$editTrans('task')" :tooltip="config.tooltip" :leftBorder="taskConfig.leftBorder" :rightBorder="taskConfig.rightBorder" :color="$parent.color" :active="taskConfig.active" :disabled="taskConfig.disabled" @operate="setTask">
|
130
|
+
<Icon value="task"></Icon>
|
131
|
+
</Button>
|
132
|
+
<!-- 加粗 -->
|
133
|
+
<Button v-if="boldConfig.show" name="bold" :title="$editTrans('bold')" :tooltip="config.tooltip" :leftBorder="boldConfig.leftBorder" :rightBorder="boldConfig.rightBorder" :color="$parent.color" :active="boldConfig.active" :disabled="boldConfig.disabled" @operate="setBold">
|
134
|
+
<Icon value="bold"></Icon>
|
135
|
+
</Button>
|
136
|
+
<!-- 斜体 -->
|
137
|
+
<Button v-if="italicConfig.show" name="italic" :title="$editTrans('italic')" :tooltip="config.tooltip" :leftBorder="italicConfig.leftBorder" :rightBorder="italicConfig.rightBorder" :color="$parent.color" :active="italicConfig.active" :disabled="italicConfig.disabled" @operate="setItalic">
|
138
|
+
<Icon value="italic"></Icon>
|
139
|
+
</Button>
|
140
|
+
<!-- 删除线 -->
|
141
|
+
<Button v-if="strikethroughConfig.show" name="strikethrough" :title="$editTrans('strikethrough')" :tooltip="config.tooltip" :leftBorder="strikethroughConfig.leftBorder" :rightBorder="strikethroughConfig.rightBorder" :color="$parent.color" :active="strikethroughConfig.active" :disabled="strikethroughConfig.disabled" @operate="setStrikethrough">
|
142
|
+
<Icon value="strikethrough"></Icon>
|
143
|
+
</Button>
|
144
|
+
<!-- 下划线 -->
|
145
|
+
<Button v-if="underlineConfig.show" name="underline" :title="$editTrans('underline')" :tooltip="config.tooltip" :leftBorder="underlineConfig.leftBorder" :rightBorder="underlineConfig.rightBorder" :color="$parent.color" :active="underlineConfig.active" :disabled="underlineConfig.disabled" @operate="setUnderline">
|
146
|
+
<Icon value="underline"></Icon>
|
147
|
+
</Button>
|
148
|
+
<!-- 行内代码块 -->
|
149
|
+
<Button v-if="codeConfig.show" name="code" :title="$editTrans('code')" :tooltip="config.tooltip" :leftBorder="codeConfig.leftBorder" :rightBorder="codeConfig.rightBorder" :color="$parent.color" :active="codeConfig.active" :disabled="codeConfig.disabled" @operate="setCodeStyle">
|
150
|
+
<Icon value="code"></Icon>
|
151
|
+
</Button>
|
152
|
+
<!-- 上标 -->
|
153
|
+
<Button v-if="superConfig.show" name="superscript" :title="$editTrans('superscript')" :tooltip="config.tooltip" :leftBorder="superConfig.leftBorder" :rightBorder="superConfig.rightBorder" :color="$parent.color" :active="superConfig.active" :disabled="superConfig.disabled" @operate="setSuperscript">
|
154
|
+
<Icon value="superscript"></Icon>
|
155
|
+
</Button>
|
156
|
+
<!-- 下标 -->
|
157
|
+
<Button v-if="subConfig.show" name="subscript" :title="$editTrans('subscript')" :tooltip="config.tooltip" :leftBorder="subConfig.leftBorder" :rightBorder="subConfig.rightBorder" :color="$parent.color" :active="subConfig.active" :disabled="subConfig.disabled" @operate="setSubscript">
|
158
|
+
<Icon value="subscript"></Icon>
|
159
|
+
</Button>
|
160
|
+
<!-- 字号大小 -->
|
161
|
+
<Button v-if="fontSizeConfig.show" name="fontSize" type="display" :title="$editTrans('fontSize')" :tooltip="config.tooltip" :display-config="fontSizeConfig.displayConfig" :leftBorder="fontSizeConfig.leftBorder" :rightBorder="fontSizeConfig.rightBorder" :color="$parent.color" :active="fontSizeConfig.active" :disabled="fontSizeConfig.disabled" @operate="setFontSize"></Button>
|
162
|
+
<!-- 字体 -->
|
163
|
+
<Button v-if="fontFamilyConfig.show" name="fontFamily" type="display" :title="$editTrans('fontFamily')" :tooltip="config.tooltip" :display-config="fontFamilyConfig.displayConfig" :leftBorder="fontFamilyConfig.leftBorder" :rightBorder="fontFamilyConfig.rightBorder" :color="$parent.color" :active="fontFamilyConfig.active" :disabled="fontFamilyConfig.disabled" @operate="setFontFamily"></Button>
|
164
|
+
<!-- 行高 -->
|
165
|
+
<Button v-if="lineHeightConfig.show" name="lineHeight" type="display" :title="$editTrans('lineHeight')" :tooltip="config.tooltip" :display-config="lineHeightConfig.displayConfig" :leftBorder="lineHeightConfig.leftBorder" :rightBorder="lineHeightConfig.rightBorder" :color="$parent.color" :active="lineHeightConfig.active" :disabled="lineHeightConfig.disabled" @operate="setLineHeight"></Button>
|
166
|
+
<!-- 前景色 -->
|
167
|
+
<Button v-if="foreColorConfig.show" name="foreColor" type="select" :title="$editTrans('foreColor')" :tooltip="config.tooltip" :select-config="foreColorConfig.selectConfig" :leftBorder="foreColorConfig.leftBorder" :rightBorder="foreColorConfig.rightBorder" :color="$parent.color" :active="foreColorConfig.active" :disabled="foreColorConfig.disabled" hideScroll ref="foreColor">
|
168
|
+
<Icon value="font-color"></Icon>
|
169
|
+
<template #layer="{ options }">
|
170
|
+
<Colors :tooltip="config.tooltip" :color="$parent.color" :value="foreColorConfig.value" @change="setForeColor" :data="options"></Colors>
|
171
|
+
</template>
|
172
|
+
</Button>
|
173
|
+
<!-- 背景色 -->
|
174
|
+
<Button v-if="backColorConfig.show" name="backColor" type="select" :title="$editTrans('backColor')" :tooltip="config.tooltip" :select-config="backColorConfig.selectConfig" :leftBorder="backColorConfig.leftBorder" :rightBorder="backColorConfig.rightBorder" :color="$parent.color" :active="backColorConfig.active" :disabled="backColorConfig.disabled" hideScroll ref="backColor">
|
175
|
+
<Icon value="brush"></Icon>
|
176
|
+
<template #layer="{ options }">
|
177
|
+
<Colors :tooltip="config.tooltip" :color="$parent.color" :value="backColorConfig.value" @change="setBackColor" :data="options"></Colors>
|
178
|
+
</template>
|
179
|
+
</Button>
|
180
|
+
<!-- 清除样式 -->
|
181
|
+
<Button v-if="formatClearConfig.show" name="formatClear" :title="$editTrans('formatClear')" :tooltip="config.tooltip" :leftBorder="formatClearConfig.leftBorder" :rightBorder="formatClearConfig.rightBorder" :color="$parent.color" :active="formatClearConfig.active" :disabled="formatClearConfig.disabled" @operate="clearFormat">
|
182
|
+
<Icon value="format-clear"></Icon>
|
183
|
+
</Button>
|
184
|
+
</template>
|
185
|
+
</div>
|
186
|
+
</Layer>
|
187
|
+
</template>
|
188
|
+
<script>
|
189
|
+
import Layer from '../base/Layer'
|
190
|
+
import Tooltip from '../base/Tooltip'
|
191
|
+
import Button from '../base/Button'
|
192
|
+
import Icon from '../base/Icon'
|
193
|
+
import Checkbox from '../base/Checkbox'
|
194
|
+
import Colors from './Colors'
|
195
|
+
import { AlexElement } from 'alex-editor'
|
196
|
+
import { blockIsList, blockIsTask } from '../../core'
|
197
|
+
import Dap from 'dap-util'
|
198
|
+
export default {
|
199
|
+
name: 'Toolbar',
|
200
|
+
emits: ['update:modelValue'],
|
201
|
+
props: {
|
202
|
+
//是否显示
|
203
|
+
modelValue: {
|
204
|
+
type: Boolean,
|
205
|
+
default: false
|
206
|
+
},
|
207
|
+
//关联元素
|
208
|
+
node: {
|
209
|
+
type: [String, Node],
|
210
|
+
default: null
|
211
|
+
},
|
212
|
+
//类型
|
213
|
+
type: {
|
214
|
+
type: String,
|
215
|
+
default: 'text',
|
216
|
+
validator(value) {
|
217
|
+
return ['text', 'table', 'link', 'codeBlock', 'image', 'video'].includes(value)
|
218
|
+
}
|
219
|
+
},
|
220
|
+
//工具条配置
|
221
|
+
config: {
|
222
|
+
type: Object,
|
223
|
+
default: null
|
224
|
+
}
|
225
|
+
},
|
226
|
+
data() {
|
227
|
+
return {
|
228
|
+
//链接参数配置
|
229
|
+
linkConfig: {
|
230
|
+
//链接地址
|
231
|
+
url: '',
|
232
|
+
//链接是否新窗口打开
|
233
|
+
newOpen: false
|
234
|
+
},
|
235
|
+
//视频参数配置
|
236
|
+
videoConfig: {
|
237
|
+
//是否显示控制器
|
238
|
+
controls: false,
|
239
|
+
//是否循环
|
240
|
+
loop: false,
|
241
|
+
//是否自动播放
|
242
|
+
autoplay: false,
|
243
|
+
//是否静音
|
244
|
+
muted: false
|
245
|
+
},
|
246
|
+
//代码块选择语言按钮配置
|
247
|
+
languageConfig: {
|
248
|
+
show: this.config.codeBlock.languages.show,
|
249
|
+
displayConfig: {
|
250
|
+
options: this.config.codeBlock.languages.options,
|
251
|
+
value: '',
|
252
|
+
width: this.config.codeBlock.languages.width,
|
253
|
+
maxHeight: this.config.codeBlock.languages.maxHeight
|
254
|
+
},
|
255
|
+
leftBorder: this.config.codeBlock.languages.leftBorder,
|
256
|
+
rightBorder: this.config.codeBlock.languages.rightBorder,
|
257
|
+
active: false,
|
258
|
+
disabled: false
|
259
|
+
},
|
260
|
+
//标题按钮配置
|
261
|
+
headingConfig: {
|
262
|
+
show: this.config.text.heading.show,
|
263
|
+
displayConfig: {
|
264
|
+
options: this.config.text.heading.options,
|
265
|
+
value: '',
|
266
|
+
width: this.config.text.heading.width,
|
267
|
+
maxHeight: this.config.text.heading.maxHeight
|
268
|
+
},
|
269
|
+
defaultValue: this.config.text.heading.defaultValue,
|
270
|
+
leftBorder: this.config.text.heading.leftBorder,
|
271
|
+
rightBorder: this.config.text.heading.rightBorder,
|
272
|
+
active: false,
|
273
|
+
disabled: false
|
274
|
+
},
|
275
|
+
//对齐方式按钮配置
|
276
|
+
alignConfig: {
|
277
|
+
show: this.config.text.align.show,
|
278
|
+
selectConfig: {
|
279
|
+
options: this.config.text.align.options,
|
280
|
+
width: this.config.text.align.width,
|
281
|
+
maxHeight: this.config.text.align.maxHeight
|
282
|
+
},
|
283
|
+
leftBorder: this.config.text.align.leftBorder,
|
284
|
+
rightBorder: this.config.text.align.rightBorder,
|
285
|
+
active: false,
|
286
|
+
disabled: false
|
287
|
+
},
|
288
|
+
//有序列表按钮配置
|
289
|
+
orderListConfig: {
|
290
|
+
show: this.config.text.orderList.show,
|
291
|
+
leftBorder: this.config.text.orderList.leftBorder,
|
292
|
+
rightBorder: this.config.text.orderList.rightBorder,
|
293
|
+
active: false,
|
294
|
+
disabled: false
|
295
|
+
},
|
296
|
+
//无序列表按钮配置
|
297
|
+
unorderListConfig: {
|
298
|
+
show: this.config.text.unorderList.show,
|
299
|
+
leftBorder: this.config.text.unorderList.leftBorder,
|
300
|
+
rightBorder: this.config.text.unorderList.rightBorder,
|
301
|
+
active: false,
|
302
|
+
disabled: false
|
303
|
+
},
|
304
|
+
//任务列表按钮配置
|
305
|
+
taskConfig: {
|
306
|
+
show: this.config.text.task.show,
|
307
|
+
leftBorder: this.config.text.task.leftBorder,
|
308
|
+
rightBorder: this.config.text.task.rightBorder,
|
309
|
+
active: false,
|
310
|
+
disabled: false
|
311
|
+
},
|
312
|
+
//粗体按钮配置
|
313
|
+
boldConfig: {
|
314
|
+
show: this.config.text.bold.show,
|
315
|
+
leftBorder: this.config.text.bold.leftBorder,
|
316
|
+
rightBorder: this.config.text.bold.rightBorder,
|
317
|
+
active: false,
|
318
|
+
disabled: false
|
319
|
+
},
|
320
|
+
//斜体按钮配置
|
321
|
+
italicConfig: {
|
322
|
+
show: this.config.text.italic.show,
|
323
|
+
leftBorder: this.config.text.italic.leftBorder,
|
324
|
+
rightBorder: this.config.text.italic.rightBorder,
|
325
|
+
active: false,
|
326
|
+
disabled: false
|
327
|
+
},
|
328
|
+
//删除线按钮配置
|
329
|
+
strikethroughConfig: {
|
330
|
+
show: this.config.text.strikethrough.show,
|
331
|
+
leftBorder: this.config.text.strikethrough.leftBorder,
|
332
|
+
rightBorder: this.config.text.strikethrough.rightBorder,
|
333
|
+
active: false,
|
334
|
+
disabled: false
|
335
|
+
},
|
336
|
+
//下划线按钮配置
|
337
|
+
underlineConfig: {
|
338
|
+
show: this.config.text.underline.show,
|
339
|
+
leftBorder: this.config.text.underline.leftBorder,
|
340
|
+
rightBorder: this.config.text.underline.rightBorder,
|
341
|
+
active: false,
|
342
|
+
disabled: false
|
343
|
+
},
|
344
|
+
//行内代码块按钮配置
|
345
|
+
codeConfig: {
|
346
|
+
show: this.config.text.code.show,
|
347
|
+
leftBorder: this.config.text.code.leftBorder,
|
348
|
+
rightBorder: this.config.text.code.rightBorder,
|
349
|
+
active: false,
|
350
|
+
disabled: false
|
351
|
+
},
|
352
|
+
//上标按钮配置
|
353
|
+
superConfig: {
|
354
|
+
show: this.config.text.super.show,
|
355
|
+
leftBorder: this.config.text.super.leftBorder,
|
356
|
+
rightBorder: this.config.text.super.rightBorder,
|
357
|
+
active: false,
|
358
|
+
disabled: false
|
359
|
+
},
|
360
|
+
//下标按钮配置
|
361
|
+
subConfig: {
|
362
|
+
show: this.config.text.sub.show,
|
363
|
+
leftBorder: this.config.text.sub.leftBorder,
|
364
|
+
rightBorder: this.config.text.sub.rightBorder,
|
365
|
+
active: false,
|
366
|
+
disabled: false
|
367
|
+
},
|
368
|
+
//字号按钮配置
|
369
|
+
fontSizeConfig: {
|
370
|
+
show: this.config.text.fontSize.show,
|
371
|
+
displayConfig: {
|
372
|
+
options: this.config.text.fontSize.options,
|
373
|
+
value: '',
|
374
|
+
width: this.config.text.fontSize.width,
|
375
|
+
maxHeight: this.config.text.fontSize.maxHeight
|
376
|
+
},
|
377
|
+
defaultValue: this.config.text.fontSize.defaultValue,
|
378
|
+
leftBorder: this.config.text.fontSize.leftBorder,
|
379
|
+
rightBorder: this.config.text.fontSize.rightBorder,
|
380
|
+
active: false,
|
381
|
+
disabled: false
|
382
|
+
},
|
383
|
+
//字体按钮配置
|
384
|
+
fontFamilyConfig: {
|
385
|
+
show: this.config.text.fontFamily.show,
|
386
|
+
displayConfig: {
|
387
|
+
options: this.config.text.fontFamily.options,
|
388
|
+
value: '',
|
389
|
+
width: this.config.text.fontFamily.width,
|
390
|
+
maxHeight: this.config.text.fontFamily.maxHeight
|
391
|
+
},
|
392
|
+
defaultValue: this.config.text.fontFamily.defaultValue,
|
393
|
+
leftBorder: this.config.text.fontFamily.leftBorder,
|
394
|
+
rightBorder: this.config.text.fontFamily.rightBorder,
|
395
|
+
active: false,
|
396
|
+
disabled: false
|
397
|
+
},
|
398
|
+
//行高按钮配置
|
399
|
+
lineHeightConfig: {
|
400
|
+
show: this.config.text.lineHeight.show,
|
401
|
+
displayConfig: {
|
402
|
+
options: this.config.text.lineHeight.options,
|
403
|
+
value: '',
|
404
|
+
width: this.config.text.lineHeight.width,
|
405
|
+
maxHeight: this.config.text.lineHeight.maxHeight
|
406
|
+
},
|
407
|
+
defaultValue: this.config.text.lineHeight.defaultValue,
|
408
|
+
leftBorder: this.config.text.lineHeight.leftBorder,
|
409
|
+
rightBorder: this.config.text.lineHeight.rightBorder,
|
410
|
+
active: false,
|
411
|
+
disabled: false
|
412
|
+
},
|
413
|
+
//前景颜色按钮配置
|
414
|
+
foreColorConfig: {
|
415
|
+
show: this.config.text.foreColor.show,
|
416
|
+
selectConfig: {
|
417
|
+
options: this.config.text.foreColor.options
|
418
|
+
},
|
419
|
+
leftBorder: this.config.text.foreColor.leftBorder,
|
420
|
+
rightBorder: this.config.text.foreColor.rightBorder,
|
421
|
+
value: '', //选择的颜色值
|
422
|
+
active: false,
|
423
|
+
disabled: false
|
424
|
+
},
|
425
|
+
//背景颜色按钮配置
|
426
|
+
backColorConfig: {
|
427
|
+
show: this.config.text.backColor.show,
|
428
|
+
selectConfig: {
|
429
|
+
options: this.config.text.backColor.options
|
430
|
+
},
|
431
|
+
leftBorder: this.config.text.backColor.leftBorder,
|
432
|
+
rightBorder: this.config.text.backColor.rightBorder,
|
433
|
+
value: '', //选择的颜色值
|
434
|
+
active: false,
|
435
|
+
disabled: false
|
436
|
+
},
|
437
|
+
//清除格式按钮配置
|
438
|
+
formatClearConfig: {
|
439
|
+
show: this.config.text.formatClear.show,
|
440
|
+
leftBorder: this.config.text.formatClear.leftBorder,
|
441
|
+
rightBorder: this.config.text.formatClear.rightBorder,
|
442
|
+
active: false,
|
443
|
+
disabled: false
|
444
|
+
}
|
445
|
+
}
|
446
|
+
},
|
447
|
+
computed: {
|
448
|
+
//是否显示
|
449
|
+
show: {
|
450
|
+
get() {
|
451
|
+
return this.modelValue
|
452
|
+
},
|
453
|
+
set(val) {
|
454
|
+
this.$emit('update:modelValue', val)
|
455
|
+
}
|
456
|
+
}
|
457
|
+
},
|
458
|
+
components: {
|
459
|
+
Layer,
|
460
|
+
Tooltip,
|
461
|
+
Button,
|
462
|
+
Icon,
|
463
|
+
Checkbox,
|
464
|
+
Colors
|
465
|
+
},
|
466
|
+
inject: ['$editTrans'],
|
467
|
+
methods: {
|
468
|
+
//清除格式
|
469
|
+
clearFormat() {
|
470
|
+
this.$parent.formatText()
|
471
|
+
},
|
472
|
+
//设置背景色
|
473
|
+
setBackColor(value) {
|
474
|
+
this.$parent.setTextStyle('background-color', value)
|
475
|
+
this.$refs.backColor.hideLayer()
|
476
|
+
},
|
477
|
+
//设置前景色
|
478
|
+
setForeColor(value) {
|
479
|
+
this.$parent.setTextStyle('color', value)
|
480
|
+
this.$refs.foreColor.hideLayer()
|
481
|
+
},
|
482
|
+
//设置行高
|
483
|
+
setLineHeight(name, value) {
|
484
|
+
this.$parent.setLineHeight(value)
|
485
|
+
},
|
486
|
+
//设置字体
|
487
|
+
setFontFamily(name, value) {
|
488
|
+
this.$parent.setTextStyle('font-family', value)
|
489
|
+
},
|
490
|
+
//设置字号
|
491
|
+
setFontSize(name, value) {
|
492
|
+
this.$parent.setTextStyle('font-size', value)
|
493
|
+
},
|
494
|
+
//设置上标
|
495
|
+
setSuperscript() {
|
496
|
+
this.$parent.setTextStyle('vertical-align', 'super')
|
497
|
+
},
|
498
|
+
//设置下标
|
499
|
+
setSubscript() {
|
500
|
+
this.$parent.setTextStyle('vertical-align', 'sub')
|
501
|
+
},
|
502
|
+
//设置行内代码样式
|
503
|
+
setCodeStyle() {
|
504
|
+
this.$parent.setTextMark('data-editify-code', true)
|
505
|
+
},
|
506
|
+
//设置下划线
|
507
|
+
setUnderline() {
|
508
|
+
this.$parent.setTextStyle('text-decoration', 'underline')
|
509
|
+
},
|
510
|
+
//设置删除线
|
511
|
+
setStrikethrough() {
|
512
|
+
this.$parent.setTextStyle('text-decoration', 'line-through')
|
513
|
+
},
|
514
|
+
//设置列表
|
515
|
+
setList(name) {
|
516
|
+
this.$parent.setList(name == 'orderList')
|
517
|
+
},
|
518
|
+
//设置任务列表
|
519
|
+
setTask() {
|
520
|
+
this.$parent.setTask()
|
521
|
+
},
|
522
|
+
//斜体
|
523
|
+
setItalic() {
|
524
|
+
this.$parent.setTextStyle('font-style', 'italic')
|
525
|
+
},
|
526
|
+
//加粗
|
527
|
+
setBold() {
|
528
|
+
this.$parent.setTextStyle('font-weight', 'bold')
|
529
|
+
},
|
530
|
+
//设置标题
|
531
|
+
setHeading(name, value) {
|
532
|
+
this.$parent.setHeading(value)
|
533
|
+
},
|
534
|
+
//设置对齐方式
|
535
|
+
setAlign(name, value) {
|
536
|
+
this.$parent.setAlign(value)
|
537
|
+
},
|
538
|
+
//设置视频
|
539
|
+
setVideo(prop) {
|
540
|
+
if (this.$parent.disabled) {
|
541
|
+
return
|
542
|
+
}
|
543
|
+
const video = this.$parent.getCurrentParsedomElement('video')
|
544
|
+
if (video) {
|
545
|
+
//当前是拥有该属性
|
546
|
+
if (this.videoConfig[prop]) {
|
547
|
+
delete video.marks[prop]
|
548
|
+
}
|
549
|
+
//当前无该属性
|
550
|
+
else {
|
551
|
+
video.marks[prop] = true
|
552
|
+
}
|
553
|
+
this.videoConfig[prop] = !this.videoConfig[prop]
|
554
|
+
this.$parent.editor.domRender()
|
555
|
+
this.$parent.editor.rangeRender()
|
556
|
+
}
|
557
|
+
},
|
558
|
+
//设置宽度
|
559
|
+
setWidth(value) {
|
560
|
+
if (this.$parent.disabled) {
|
561
|
+
return
|
562
|
+
}
|
563
|
+
const element = this.$parent.getCurrentParsedomElement('img') || this.$parent.getCurrentParsedomElement('video')
|
564
|
+
if (element) {
|
565
|
+
const styles = {
|
566
|
+
width: value
|
567
|
+
}
|
568
|
+
if (element.hasStyles()) {
|
569
|
+
element.styles = Object.assign(element.styles, styles)
|
570
|
+
} else {
|
571
|
+
element.styles = styles
|
572
|
+
}
|
573
|
+
this.$parent.editor.formatElementStack()
|
574
|
+
this.$parent.editor.domRender()
|
575
|
+
this.$parent.editor.rangeRender()
|
576
|
+
//更新工具条位置
|
577
|
+
setTimeout(() => {
|
578
|
+
this.$refs.layer.setPosition()
|
579
|
+
}, 0)
|
580
|
+
}
|
581
|
+
},
|
582
|
+
//修改链接
|
583
|
+
modifyLink() {
|
584
|
+
if (this.$parent.disabled) {
|
585
|
+
return
|
586
|
+
}
|
587
|
+
if (!this.linkConfig.url) {
|
588
|
+
return
|
589
|
+
}
|
590
|
+
const link = this.$parent.getCurrentParsedomElement('a')
|
591
|
+
if (link) {
|
592
|
+
link.marks.href = this.linkConfig.url
|
593
|
+
if (this.linkConfig.newOpen) {
|
594
|
+
link.marks.target = '_blank'
|
595
|
+
} else {
|
596
|
+
delete link.marks.target
|
597
|
+
}
|
598
|
+
}
|
599
|
+
this.$parent.editor.formatElementStack()
|
600
|
+
this.$parent.editor.domRender()
|
601
|
+
},
|
602
|
+
//输入框获取焦点
|
603
|
+
handleInputFocus(e) {
|
604
|
+
if (this.$parent.disabled) {
|
605
|
+
return
|
606
|
+
}
|
607
|
+
if (this.$parent.color) {
|
608
|
+
e.currentTarget.style.borderColor = this.$parent.color
|
609
|
+
}
|
610
|
+
},
|
611
|
+
//输入框失去焦点
|
612
|
+
handleInputBlur(e) {
|
613
|
+
if (this.$parent.disabled) {
|
614
|
+
return
|
615
|
+
}
|
616
|
+
e.currentTarget.style.borderColor = ''
|
617
|
+
},
|
618
|
+
//选择代码语言
|
619
|
+
selectLanguage(name, value) {
|
620
|
+
if (this.$parent.disabled) {
|
621
|
+
return
|
622
|
+
}
|
623
|
+
const pre = this.$parent.getCurrentParsedomElement('pre')
|
624
|
+
if (pre) {
|
625
|
+
Object.assign(pre.marks, {
|
626
|
+
'data-editify-hljs': value
|
627
|
+
})
|
628
|
+
this.$parent.editor.formatElementStack()
|
629
|
+
this.$parent.editor.domRender()
|
630
|
+
this.$parent.editor.rangeRender()
|
631
|
+
}
|
632
|
+
},
|
633
|
+
//代码块前后插入段落
|
634
|
+
insertParagraphWithPre(type = 'up') {
|
635
|
+
if (this.$parent.disabled) {
|
636
|
+
return
|
637
|
+
}
|
638
|
+
if (!this.$parent.editor.range.anchor.isEqual(this.$parent.editor.range.focus)) {
|
639
|
+
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element
|
640
|
+
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset
|
641
|
+
}
|
642
|
+
const pre = this.$parent.getCurrentParsedomElement('pre')
|
643
|
+
if (pre) {
|
644
|
+
const paragraph = new AlexElement('block', AlexElement.BLOCK_NODE, null, null, null)
|
645
|
+
const breakEl = new AlexElement('closed', 'br', null, null, null)
|
646
|
+
this.$parent.editor.addElementTo(breakEl, paragraph)
|
647
|
+
if (type == 'up') {
|
648
|
+
this.$parent.editor.addElementBefore(paragraph, pre)
|
649
|
+
} else {
|
650
|
+
this.$parent.editor.addElementAfter(paragraph, pre)
|
651
|
+
}
|
652
|
+
this.$parent.editor.range.anchor.moveToEnd(paragraph)
|
653
|
+
this.$parent.editor.range.focus.moveToEnd(paragraph)
|
654
|
+
this.$parent.editor.formatElementStack()
|
655
|
+
this.$parent.editor.domRender()
|
656
|
+
this.$parent.editor.rangeRender()
|
657
|
+
}
|
658
|
+
},
|
659
|
+
//表格前后插入列
|
660
|
+
insertTableColumn(type = 'left') {
|
661
|
+
if (this.$parent.disabled) {
|
662
|
+
return
|
663
|
+
}
|
664
|
+
if (!this.$parent.editor.range.anchor.isEqual(this.$parent.editor.range.focus)) {
|
665
|
+
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element
|
666
|
+
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset
|
667
|
+
}
|
668
|
+
const table = this.$parent.getCurrentParsedomElement('table')
|
669
|
+
const column = this.$parent.getCurrentParsedomElement('td')
|
670
|
+
const tbody = this.$parent.getCurrentParsedomElement('tbody')
|
671
|
+
if (column && table && tbody) {
|
672
|
+
const rows = tbody.children
|
673
|
+
const index = column.parent.children.findIndex(item => {
|
674
|
+
return item.isEqual(column)
|
675
|
+
})
|
676
|
+
//插入列
|
677
|
+
rows.forEach(row => {
|
678
|
+
const newColumn = column.clone(false)
|
679
|
+
const breakEl = new AlexElement('closed', 'br', null, null, null)
|
680
|
+
this.$parent.editor.addElementTo(breakEl, newColumn)
|
681
|
+
if (type == 'left') {
|
682
|
+
this.$parent.editor.addElementTo(newColumn, row, index)
|
683
|
+
} else {
|
684
|
+
this.$parent.editor.addElementTo(newColumn, row, index + 1)
|
685
|
+
}
|
686
|
+
})
|
687
|
+
//插入col
|
688
|
+
const colgroup = table.children.find(item => {
|
689
|
+
return item.parsedom == 'colgroup'
|
690
|
+
})
|
691
|
+
const col = new AlexElement('closed', 'col', null, null, null)
|
692
|
+
if (type == 'left') {
|
693
|
+
this.$parent.editor.addElementTo(col, colgroup, index)
|
694
|
+
} else {
|
695
|
+
this.$parent.editor.addElementTo(col, colgroup, index + 1)
|
696
|
+
}
|
697
|
+
//渲染
|
698
|
+
this.$parent.editor.formatElementStack()
|
699
|
+
if (type == 'left') {
|
700
|
+
const previousColumn = this.$parent.editor.getPreviousElement(column)
|
701
|
+
this.$parent.editor.range.anchor.moveToStart(previousColumn)
|
702
|
+
this.$parent.editor.range.focus.moveToStart(previousColumn)
|
703
|
+
} else {
|
704
|
+
const nextColumn = this.$parent.editor.getNextElement(column)
|
705
|
+
this.$parent.editor.range.anchor.moveToStart(nextColumn)
|
706
|
+
this.$parent.editor.range.focus.moveToStart(nextColumn)
|
707
|
+
}
|
708
|
+
this.$parent.editor.domRender()
|
709
|
+
this.$parent.editor.rangeRender()
|
710
|
+
}
|
711
|
+
},
|
712
|
+
//表格插入前后插入行
|
713
|
+
insertTableRow(type = 'up') {
|
714
|
+
if (this.$parent.disabled) {
|
715
|
+
return
|
716
|
+
}
|
717
|
+
if (!this.$parent.editor.range.anchor.isEqual(this.$parent.editor.range.focus)) {
|
718
|
+
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element
|
719
|
+
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset
|
720
|
+
}
|
721
|
+
const table = this.$parent.getCurrentParsedomElement('table')
|
722
|
+
const row = this.$parent.getCurrentParsedomElement('tr')
|
723
|
+
if (table && row) {
|
724
|
+
const newRow = row.clone()
|
725
|
+
newRow.children.forEach(column => {
|
726
|
+
column.children = []
|
727
|
+
const breakEl = new AlexElement('closed', 'br', null, null, null)
|
728
|
+
this.$parent.editor.addElementTo(breakEl, column)
|
729
|
+
})
|
730
|
+
if (type == 'up') {
|
731
|
+
this.$parent.editor.addElementBefore(newRow, row)
|
732
|
+
} else {
|
733
|
+
this.$parent.editor.addElementAfter(newRow, row)
|
734
|
+
}
|
735
|
+
this.$parent.editor.formatElementStack()
|
736
|
+
this.$parent.editor.range.anchor.moveToStart(newRow)
|
737
|
+
this.$parent.editor.range.focus.moveToStart(newRow)
|
738
|
+
this.$parent.editor.domRender()
|
739
|
+
this.$parent.editor.rangeRender()
|
740
|
+
//更新工具条位置
|
741
|
+
setTimeout(() => {
|
742
|
+
this.$refs.layer.setPosition()
|
743
|
+
}, 0)
|
744
|
+
}
|
745
|
+
},
|
746
|
+
//表格前后插入段落
|
747
|
+
insertParagraphWithTable(type = 'up') {
|
748
|
+
if (this.$parent.disabled) {
|
749
|
+
return
|
750
|
+
}
|
751
|
+
const table = this.$parent.getCurrentParsedomElement('table')
|
752
|
+
if (table) {
|
753
|
+
const paragraph = new AlexElement('block', AlexElement.BLOCK_NODE, null, null, null)
|
754
|
+
const breakEl = new AlexElement('closed', 'br', null, null, null)
|
755
|
+
this.$parent.editor.addElementTo(breakEl, paragraph)
|
756
|
+
if (type == 'up') {
|
757
|
+
this.$parent.editor.addElementBefore(paragraph, table)
|
758
|
+
} else {
|
759
|
+
this.$parent.editor.addElementAfter(paragraph, table)
|
760
|
+
}
|
761
|
+
this.$parent.editor.range.anchor.moveToEnd(paragraph)
|
762
|
+
this.$parent.editor.range.focus.moveToEnd(paragraph)
|
763
|
+
this.$parent.editor.formatElementStack()
|
764
|
+
this.$parent.editor.domRender()
|
765
|
+
this.$parent.editor.rangeRender()
|
766
|
+
}
|
767
|
+
},
|
768
|
+
//删除表格行
|
769
|
+
deleteTableRow() {
|
770
|
+
if (this.$parent.disabled) {
|
771
|
+
return
|
772
|
+
}
|
773
|
+
if (!this.$parent.editor.range.anchor.isEqual(this.$parent.editor.range.focus)) {
|
774
|
+
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element
|
775
|
+
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset
|
776
|
+
}
|
777
|
+
const table = this.$parent.getCurrentParsedomElement('table')
|
778
|
+
const row = this.$parent.getCurrentParsedomElement('tr')
|
779
|
+
if (table && row) {
|
780
|
+
const parent = row.parent
|
781
|
+
if (parent.children.length == 1) {
|
782
|
+
this.$parent.deleteByParsedom('table')
|
783
|
+
return
|
784
|
+
}
|
785
|
+
const previousRow = this.$parent.editor.getPreviousElement(row)
|
786
|
+
const nextRow = this.$parent.editor.getNextElement(row)
|
787
|
+
row.toEmpty()
|
788
|
+
this.$parent.editor.formatElementStack()
|
789
|
+
if (previousRow) {
|
790
|
+
this.$parent.editor.range.anchor.moveToEnd(previousRow.children[0])
|
791
|
+
this.$parent.editor.range.focus.moveToEnd(previousRow.children[0])
|
792
|
+
} else {
|
793
|
+
this.$parent.editor.range.anchor.moveToEnd(nextRow.children[0])
|
794
|
+
this.$parent.editor.range.focus.moveToEnd(nextRow.children[0])
|
795
|
+
}
|
796
|
+
this.$parent.editor.domRender()
|
797
|
+
this.$parent.editor.rangeRender()
|
798
|
+
//更新工具条位置
|
799
|
+
setTimeout(() => {
|
800
|
+
this.$refs.layer.setPosition()
|
801
|
+
}, 0)
|
802
|
+
}
|
803
|
+
},
|
804
|
+
//删除表格列
|
805
|
+
deleteTableColumn() {
|
806
|
+
if (this.$parent.disabled) {
|
807
|
+
return
|
808
|
+
}
|
809
|
+
if (!this.$parent.editor.range.anchor.isEqual(this.$parent.editor.range.focus)) {
|
810
|
+
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element
|
811
|
+
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset
|
812
|
+
}
|
813
|
+
const column = this.$parent.getCurrentParsedomElement('td')
|
814
|
+
const tbody = this.$parent.getCurrentParsedomElement('tbody')
|
815
|
+
const table = this.$parent.getCurrentParsedomElement('table')
|
816
|
+
if (column && table && tbody) {
|
817
|
+
const rows = tbody.children
|
818
|
+
const parent = column.parent
|
819
|
+
if (parent.children.length == 1) {
|
820
|
+
this.$parent.deleteByParsedom('table')
|
821
|
+
return
|
822
|
+
}
|
823
|
+
const previousColumn = this.$parent.editor.getPreviousElement(column)
|
824
|
+
const nextColumn = this.$parent.editor.getNextElement(column)
|
825
|
+
const index = column.parent.children.findIndex(item => {
|
826
|
+
return item.isEqual(column)
|
827
|
+
})
|
828
|
+
//删除列
|
829
|
+
rows.forEach(row => {
|
830
|
+
row.children[index].toEmpty()
|
831
|
+
})
|
832
|
+
//删除col
|
833
|
+
const colgroup = table.children.find(item => {
|
834
|
+
return item.parsedom == 'colgroup'
|
835
|
+
})
|
836
|
+
colgroup.children[index].toEmpty()
|
837
|
+
//渲染
|
838
|
+
this.$parent.editor.formatElementStack()
|
839
|
+
if (previousColumn) {
|
840
|
+
this.$parent.editor.range.anchor.moveToEnd(previousColumn)
|
841
|
+
this.$parent.editor.range.focus.moveToEnd(previousColumn)
|
842
|
+
} else {
|
843
|
+
this.$parent.editor.range.anchor.moveToEnd(nextColumn)
|
844
|
+
this.$parent.editor.range.focus.moveToEnd(nextColumn)
|
845
|
+
}
|
846
|
+
this.$parent.editor.domRender()
|
847
|
+
this.$parent.editor.rangeRender()
|
848
|
+
}
|
849
|
+
},
|
850
|
+
//浮层显示时
|
851
|
+
layerShow() {
|
852
|
+
//代码块初始化展示设置
|
853
|
+
if (this.type == 'codeBlock') {
|
854
|
+
const pre = this.$parent.getCurrentParsedomElement('pre')
|
855
|
+
if (pre) {
|
856
|
+
this.languageConfig.displayConfig.value = pre.marks['data-editify-hljs'] || ''
|
857
|
+
}
|
858
|
+
}
|
859
|
+
//链接初始化展示
|
860
|
+
else if (this.type == 'link') {
|
861
|
+
const link = this.$parent.getCurrentParsedomElement('a')
|
862
|
+
if (link) {
|
863
|
+
this.linkConfig.url = link.marks['href']
|
864
|
+
this.linkConfig.newOpen = link.marks['target'] == '_blank'
|
865
|
+
}
|
866
|
+
}
|
867
|
+
//视频初始化显示
|
868
|
+
else if (this.type == 'video') {
|
869
|
+
const video = this.$parent.getCurrentParsedomElement('video')
|
870
|
+
if (video) {
|
871
|
+
this.videoConfig.autoplay = !!video.marks['autoplay']
|
872
|
+
this.videoConfig.loop = !!video.marks['loop']
|
873
|
+
this.videoConfig.controls = !!video.marks['controls']
|
874
|
+
this.videoConfig.muted = !!video.marks['muted']
|
875
|
+
}
|
876
|
+
}
|
877
|
+
//文本工具条初始化显示
|
878
|
+
else if (this.type == 'text') {
|
879
|
+
//额外禁用判定
|
880
|
+
const extraDisabled = name => {
|
881
|
+
if (typeof this.config.extraDisabled == 'function') {
|
882
|
+
return this.config.extraDisabled.apply(this.$parent, [name]) || false
|
883
|
+
}
|
884
|
+
return false
|
885
|
+
}
|
886
|
+
|
887
|
+
//获取选区的元素
|
888
|
+
const result = this.$parent.editor.getElementsByRange(true, false)
|
889
|
+
|
890
|
+
//显示已设置标题
|
891
|
+
const findHeadingItem = this.headingConfig.displayConfig.options.find(item => {
|
892
|
+
let val = item
|
893
|
+
if (Dap.common.isObject(item)) {
|
894
|
+
val = item.value
|
895
|
+
}
|
896
|
+
return result.every(el => {
|
897
|
+
if (el.element.isBlock()) {
|
898
|
+
return el.element.parsedom == val
|
899
|
+
}
|
900
|
+
return el.element.getBlock().parsedom == val
|
901
|
+
})
|
902
|
+
})
|
903
|
+
this.headingConfig.displayConfig.value = findHeadingItem ? (Dap.common.isObject(findHeadingItem) ? findHeadingItem.value : findHeadingItem) : this.headingConfig.defaultValue
|
904
|
+
//标题禁用
|
905
|
+
this.headingConfig.disabled = extraDisabled('heading')
|
906
|
+
|
907
|
+
//对齐方式禁用
|
908
|
+
this.alignConfig.disabled = extraDisabled('align')
|
909
|
+
|
910
|
+
//有序列表按钮激活
|
911
|
+
this.orderListConfig.active = this.$parent.inList(true)
|
912
|
+
//有序列表按钮禁用
|
913
|
+
this.orderListConfig.disabled = extraDisabled('orderList')
|
914
|
+
|
915
|
+
//无序列表按钮激活
|
916
|
+
this.unorderListConfig.active = this.$parent.inList(false)
|
917
|
+
//无序列表按钮禁用
|
918
|
+
this.unorderListConfig.disabled = extraDisabled('unorderList')
|
919
|
+
|
920
|
+
//任务列表按钮激活
|
921
|
+
this.taskConfig.active = this.$parent.inTask()
|
922
|
+
//任务列表按钮禁用
|
923
|
+
this.taskConfig.disabled = extraDisabled('task')
|
924
|
+
|
925
|
+
//粗体按钮激活
|
926
|
+
this.boldConfig.active = this.$parent.queryTextStyle('font-weight', 'bold')
|
927
|
+
//粗体按钮禁用
|
928
|
+
this.boldConfig.disabled = extraDisabled('bold')
|
929
|
+
|
930
|
+
//斜体按钮激活
|
931
|
+
this.italicConfig.active = this.$parent.queryTextStyle('font-style', 'italic', true)
|
932
|
+
//斜体按钮禁用
|
933
|
+
this.italicConfig.disabled = extraDisabled('italic')
|
934
|
+
|
935
|
+
//删除线按钮激活
|
936
|
+
this.strikethroughConfig.active = this.$parent.queryTextStyle('text-decoration', 'line-through', true)
|
937
|
+
//删除线按钮禁用
|
938
|
+
this.strikethroughConfig.disabled = extraDisabled('strikethrough')
|
939
|
+
|
940
|
+
//下划线按钮激活
|
941
|
+
this.underlineConfig.active = this.$parent.queryTextStyle('text-decoration', 'underline', true)
|
942
|
+
//下划线按钮禁用
|
943
|
+
this.underlineConfig.disabled = extraDisabled('underline')
|
944
|
+
|
945
|
+
//行内代码按钮激活
|
946
|
+
this.codeConfig.active = this.$parent.queryTextMark('data-editify-code')
|
947
|
+
//行内代码按钮禁用
|
948
|
+
this.codeConfig.disabled = extraDisabled('code')
|
949
|
+
|
950
|
+
//上标按钮激活
|
951
|
+
this.superConfig.active = this.$parent.queryTextStyle('vertical-align', 'super', true)
|
952
|
+
//上标按钮禁用
|
953
|
+
this.superConfig.disabled = extraDisabled('super')
|
954
|
+
|
955
|
+
//下标按钮激活
|
956
|
+
this.subConfig.active = this.$parent.queryTextStyle('vertical-align', 'sub', true)
|
957
|
+
//下标按钮禁用
|
958
|
+
this.subConfig.disabled = extraDisabled('sub')
|
959
|
+
|
960
|
+
//显示已选择字号
|
961
|
+
const findFontItem = this.fontSizeConfig.displayConfig.options.find(item => {
|
962
|
+
if (Dap.common.isObject(item)) {
|
963
|
+
return this.$parent.queryTextStyle('font-size', item.value, true)
|
964
|
+
}
|
965
|
+
return this.$parent.queryTextStyle('font-size', item, true)
|
966
|
+
})
|
967
|
+
this.fontSizeConfig.displayConfig.value = findFontItem ? (Dap.common.isObject(findFontItem) ? findFontItem.value : findFontItem) : this.fontSizeConfig.defaultValue
|
968
|
+
//字号按钮禁用
|
969
|
+
this.fontSizeConfig.disabled = extraDisabled('fontSize')
|
970
|
+
|
971
|
+
//显示已选择字体
|
972
|
+
const findFamilyItem = this.fontFamilyConfig.displayConfig.options.find(item => {
|
973
|
+
if (Dap.common.isObject(item)) {
|
974
|
+
return this.$parent.queryTextStyle('font-family', item.value, true)
|
975
|
+
}
|
976
|
+
return this.$parent.queryTextStyle('font-family', item, true)
|
977
|
+
})
|
978
|
+
this.fontFamilyConfig.displayConfig.value = findFamilyItem ? (Dap.common.isObject(findFamilyItem) ? findFamilyItem.value : findFamilyItem) : this.fontFamilyConfig.defaultValue
|
979
|
+
//字体按钮禁用
|
980
|
+
this.fontFamilyConfig.disabled = extraDisabled('fontFamily')
|
981
|
+
|
982
|
+
//显示已设置行高
|
983
|
+
const findHeightItem = this.lineHeightConfig.displayConfig.options.find(item => {
|
984
|
+
let val = item
|
985
|
+
if (Dap.common.isObject(item)) {
|
986
|
+
val = item.value
|
987
|
+
}
|
988
|
+
return result.every(el => {
|
989
|
+
if (el.element.isBlock() || el.element.isInblock()) {
|
990
|
+
return el.element.hasStyles() && el.element.styles['line-height'] == val
|
991
|
+
}
|
992
|
+
const block = el.element.getBlock()
|
993
|
+
const inblock = el.element.getInblock()
|
994
|
+
if (inblock) {
|
995
|
+
return inblock.hasStyles() && inblock.styles['line-height'] == val
|
996
|
+
}
|
997
|
+
return block.hasStyles() && block.styles['line-height'] == val
|
998
|
+
})
|
999
|
+
})
|
1000
|
+
this.lineHeightConfig.displayConfig.value = findHeightItem ? (Dap.common.isObject(findHeightItem) ? findHeightItem.value : findHeightItem) : this.lineHeightConfig.defaultValue
|
1001
|
+
//行高按钮禁用
|
1002
|
+
this.lineHeightConfig.disabled = extraDisabled('lineHeight')
|
1003
|
+
|
1004
|
+
//显示已选择的前景色
|
1005
|
+
const findForeColorItem = this.foreColorConfig.selectConfig.options.find(item => {
|
1006
|
+
if (Dap.common.isObject(item)) {
|
1007
|
+
return this.$parent.queryTextStyle('color', item.value, true)
|
1008
|
+
}
|
1009
|
+
return this.$parent.queryTextStyle('color', item, true)
|
1010
|
+
})
|
1011
|
+
this.foreColorConfig.value = findForeColorItem ? (Dap.common.isObject(findForeColorItem) ? findForeColorItem.value : findForeColorItem) : ''
|
1012
|
+
//前景色按钮禁用
|
1013
|
+
this.foreColorConfig.disabled = extraDisabled('foreColor')
|
1014
|
+
|
1015
|
+
//显示已选择的背景色
|
1016
|
+
const findBackColorItem = this.backColorConfig.selectConfig.options.find(item => {
|
1017
|
+
if (Dap.common.isObject(item)) {
|
1018
|
+
return this.$parent.queryTextStyle('background-color', item.value, true)
|
1019
|
+
}
|
1020
|
+
return this.$parent.queryTextStyle('background-color', item, true)
|
1021
|
+
})
|
1022
|
+
this.backColorConfig.value = findBackColorItem ? (Dap.common.isObject(findBackColorItem) ? findBackColorItem.value : findBackColorItem) : ''
|
1023
|
+
//背景色按钮禁用
|
1024
|
+
this.backColorConfig.disabled = extraDisabled('backColor')
|
1025
|
+
|
1026
|
+
//清除格式按钮禁用
|
1027
|
+
this.formatClearConfig.disabled = extraDisabled('formatClear')
|
1028
|
+
}
|
1029
|
+
}
|
1030
|
+
}
|
1031
|
+
}
|
1032
|
+
</script>
|
1033
|
+
<style lang="less" scoped>
|
1034
|
+
.editify-toolbar {
|
1035
|
+
display: flex;
|
1036
|
+
justify-content: flex-start;
|
1037
|
+
align-items: center;
|
1038
|
+
padding: 6px 10px;
|
1039
|
+
|
1040
|
+
.editify-icon-rotate {
|
1041
|
+
transform: rotate(180deg);
|
1042
|
+
}
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
.editify-toolbar-link {
|
1046
|
+
display: block;
|
1047
|
+
width: 280px;
|
1048
|
+
padding: 4px;
|
1049
|
+
|
1050
|
+
.editify-toolbar-link-label {
|
1051
|
+
display: block;
|
1052
|
+
text-align: left;
|
1053
|
+
margin-bottom: 10px;
|
1054
|
+
font-size: @font-size;
|
1055
|
+
color: @font-color;
|
1056
|
+
}
|
1057
|
+
|
1058
|
+
input {
|
1059
|
+
appearance: none;
|
1060
|
+
-webkit-appearance: none;
|
1061
|
+
-moz-appearance: none;
|
1062
|
+
display: block;
|
1063
|
+
width: 100%;
|
1064
|
+
margin: 0 0 10px 0;
|
1065
|
+
padding: 4px 2px;
|
1066
|
+
border: none;
|
1067
|
+
font-size: @font-size;
|
1068
|
+
color: @font-color;
|
1069
|
+
border-bottom: 1px solid @border-color;
|
1070
|
+
line-height: 1.5;
|
1071
|
+
transition: all 500ms;
|
1072
|
+
background-color: transparent;
|
1073
|
+
outline: none;
|
1074
|
+
|
1075
|
+
&::-webkit-input-placeholder,
|
1076
|
+
&::placeholder {
|
1077
|
+
color: @font-color-disabled;
|
1078
|
+
font-family: inherit;
|
1079
|
+
font-size: inherit;
|
1080
|
+
vertical-align: middle;
|
1081
|
+
}
|
1082
|
+
|
1083
|
+
&[disabled] {
|
1084
|
+
background-color: transparent;
|
1085
|
+
opacity: 0.6;
|
1086
|
+
}
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
.editify-toolbar-link-footer {
|
1090
|
+
display: flex;
|
1091
|
+
justify-content: space-between;
|
1092
|
+
align-items: center;
|
1093
|
+
width: 100%;
|
1094
|
+
font-size: @font-size;
|
1095
|
+
color: @font-color-light;
|
1096
|
+
|
1097
|
+
.editify-toolbar-link-operations {
|
1098
|
+
display: flex;
|
1099
|
+
justify-content: flex-start;
|
1100
|
+
align-items: center;
|
1101
|
+
|
1102
|
+
& > span,
|
1103
|
+
& > a {
|
1104
|
+
cursor: pointer;
|
1105
|
+
opacity: 0.8;
|
1106
|
+
transition: all 200ms;
|
1107
|
+
|
1108
|
+
&:hover {
|
1109
|
+
opacity: 1;
|
1110
|
+
}
|
1111
|
+
}
|
1112
|
+
|
1113
|
+
& > span {
|
1114
|
+
margin-right: 15px;
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
& > a {
|
1118
|
+
text-decoration: none;
|
1119
|
+
}
|
1120
|
+
}
|
1121
|
+
}
|
1122
|
+
}
|
1123
|
+
</style>
|