|
@@ -1,14 +1,39 @@
|
|
|
<template>
|
|
|
<el-dialog
|
|
|
:visible="visible"
|
|
|
- width="260px"
|
|
|
+ width="400px"
|
|
|
top="38vh"
|
|
|
:show-close="false"
|
|
|
:close-on-click-modal="false"
|
|
|
@close="dialogClose"
|
|
|
>
|
|
|
- <span class="tone-pinyin">{{ tonePinyin }}</span>
|
|
|
- <span class="content-text">{{ selectContent }}</span>
|
|
|
+ <div ref="toolbarMenu" class="toolbar">
|
|
|
+ <el-select v-model="dataContent.activeTextStyle.fontFamily" placeholder="请选择">
|
|
|
+ <el-option v-for="item in fontFamilyOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
+ </el-select>
|
|
|
+ <el-select v-model="dataContent.activeTextStyle.fontSize" placeholder="请选择">
|
|
|
+ <el-option v-for="item in fontSizeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
+ </el-select>
|
|
|
+ <span class="picker-area">
|
|
|
+ <el-color-picker
|
|
|
+ ref="colorPicker"
|
|
|
+ v-model="dataContent.activeTextStyle.color"
|
|
|
+ @click="dataContent.activeTextStyle.color = dataContent.activeTextStyle.color"
|
|
|
+ />
|
|
|
+ <SvgIcon icon-class="fontcolor" title="字体颜色" size="18" />
|
|
|
+ </span>
|
|
|
+ <span>
|
|
|
+ <SvgIcon icon-class="underline" title="下划线" size="18" @click="setActiveTextStyle('underline')" />
|
|
|
+ </span>
|
|
|
+ <span>
|
|
|
+ <SvgIcon icon-class="bold" title="加粗" size="20" @click="setActiveTextStyle('bold')" />
|
|
|
+ </span>
|
|
|
+ <span>
|
|
|
+ <SvgIcon icon-class="strikethrough" title="删除线" size="20" @click="setActiveTextStyle('line-through')" />
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <span class="tone-pinyin">{{ dataContent.pinyin }}</span>
|
|
|
+ <span class="content-text" :style="dataContent.activeTextStyle">{{ dataContent.text }}</span>
|
|
|
<el-input v-model="numberPinyin" autocomplete="off" placeholder="请输入正确的拼音" @blur="convertTonePinyin" />
|
|
|
<span class="tips">一到四声分别用数字1-4表示,轻声用0表示,拼音间用空格隔开。</span>
|
|
|
<template slot="footer">
|
|
@@ -28,20 +53,85 @@ export default {
|
|
|
required: true,
|
|
|
},
|
|
|
selectContent: {
|
|
|
- type: String,
|
|
|
+ type: Object,
|
|
|
required: true,
|
|
|
},
|
|
|
},
|
|
|
+
|
|
|
data() {
|
|
|
return {
|
|
|
- tonePinyin: '',
|
|
|
numberPinyin: '',
|
|
|
+ fontFamilyOptions: [
|
|
|
+ {
|
|
|
+ value: '楷体',
|
|
|
+ label: '中文',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'Sans-GBNPC',
|
|
|
+ label: '拼音',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'robot',
|
|
|
+ label: '英文',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif, alabo',
|
|
|
+ label: '系统字体',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ fontSizeOptions: [
|
|
|
+ { value: '12px', label: '12px' },
|
|
|
+ { value: '14px', label: '14px' },
|
|
|
+ { value: '16px', label: '16px' },
|
|
|
+ { value: '18px', label: '18px' },
|
|
|
+ { value: '20px', label: '20px' },
|
|
|
+ { value: '22px', label: '22px' },
|
|
|
+ { value: '24px', label: '24px' },
|
|
|
+ { value: '26px', label: '26px' },
|
|
|
+ { value: '28px', label: '28px' },
|
|
|
+ { value: '30px', label: '30px' },
|
|
|
+ ],
|
|
|
+ activeTextStyle: {
|
|
|
+ fontFamily: 'Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif, alabo',
|
|
|
+ fontSize: '24px',
|
|
|
+ color: 'black',
|
|
|
+ textDecoration: '',
|
|
|
+ fontWeight: '',
|
|
|
+ },
|
|
|
+ toolbarIconList: [
|
|
|
+ { icon: 'fontcolor', title: '字体颜色', handle: '', size: '18' },
|
|
|
+ { icon: 'underline', title: '下划线', handle: 'openMindMap', size: '18' },
|
|
|
+ { icon: 'bold', title: '加粗', handle: '', size: '20' },
|
|
|
+ { icon: 'strikethrough', title: '删除线', handle: 'openBaseFileList', type: '1', size: '20' },
|
|
|
+ ],
|
|
|
+ pickerStyle: {
|
|
|
+ top: 0,
|
|
|
+ left: 0,
|
|
|
+ },
|
|
|
+ dataContent: { activeTextStyle: {} },
|
|
|
};
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ visible: {
|
|
|
+ handler(val) {
|
|
|
+ if (!val) return;
|
|
|
+ this.dataContent = _.cloneDeep(this.selectContent);
|
|
|
+ let style = this.dataContent.activeTextStyle || {};
|
|
|
+ for (const key in this.activeTextStyle) {
|
|
|
+ if (style[key] === undefined || style[key] === null || style[key] === '') {
|
|
|
+ this.$set(style, key, this.activeTextStyle[key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$set(this.dataContent, 'activeTextStyle', style);
|
|
|
+ // console.info(this.dataContent);
|
|
|
+ },
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
methods: {
|
|
|
// 将数字拼音转换为声调拼音
|
|
|
convertTonePinyin() {
|
|
|
- this.tonePinyin = this.numberPinyin
|
|
|
+ this.dataContent.pinyin = this.numberPinyin
|
|
|
.trim()
|
|
|
.split(/\s+/)
|
|
|
.map((item) => {
|
|
@@ -55,15 +145,27 @@ export default {
|
|
|
},
|
|
|
dialogClose() {
|
|
|
this.$emit('update:visible', false);
|
|
|
- this.tonePinyin = '';
|
|
|
this.numberPinyin = '';
|
|
|
},
|
|
|
confirm() {
|
|
|
this.$emit('update:visible', false);
|
|
|
- this.$emit('fillTonePinyin', this.tonePinyin);
|
|
|
- this.tonePinyin = '';
|
|
|
+ this.$emit('fillTonePinyin', this.dataContent);
|
|
|
this.numberPinyin = '';
|
|
|
},
|
|
|
+ // 设置样式
|
|
|
+ setActiveTextStyle(type) {
|
|
|
+ let style = this.dataContent.activeTextStyle;
|
|
|
+ if (type === 'line-through') {
|
|
|
+ style.textDecoration = style.textDecoration === 'line-through' ? '' : 'line-through';
|
|
|
+ this.$set(this.dataContent.activeTextStyle, 'textDecoration', style.textDecoration);
|
|
|
+ } else if (type === 'bold') {
|
|
|
+ style.fontWeight = style.fontWeight === 'bold' ? '' : 'bold';
|
|
|
+ this.$set(this.dataContent.activeTextStyle, 'fontWeight', style.fontWeight);
|
|
|
+ } else if (type === 'underline') {
|
|
|
+ style.textDecoration = style.textDecoration === 'underline' ? '' : 'underline';
|
|
|
+ this.$set(this.dataContent.activeTextStyle, 'textDecoration', style.textDecoration);
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
@@ -74,6 +176,37 @@ export default {
|
|
|
padding: 0;
|
|
|
}
|
|
|
|
|
|
+ .toolbar {
|
|
|
+ display: flex;
|
|
|
+ column-gap: 10px;
|
|
|
+ align-items: center;
|
|
|
+ cursor: pointer;
|
|
|
+
|
|
|
+ .picker-area {
|
|
|
+ position: relative;
|
|
|
+
|
|
|
+ :deep .el-color-picker {
|
|
|
+ position: absolute;
|
|
|
+
|
|
|
+ &__trigger {
|
|
|
+ border: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ &__color {
|
|
|
+ border: none !important;
|
|
|
+
|
|
|
+ &-inner {
|
|
|
+ background-color: rgba(0, 0, 0, 0%) !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &__icon {
|
|
|
+ display: none !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
:deep &__body {
|
|
|
display: flex;
|
|
|
flex-direction: column;
|