Demo:富文本模式支持设置节点文本的对齐方式

This commit is contained in:
街角小林 2025-01-16 18:17:00 +08:00
parent 4435feb014
commit fdecf8a308
13 changed files with 139 additions and 17 deletions

View File

@ -1,8 +1,8 @@
@font-face { @font-face {
font-family: "iconfont"; /* Project id 2479351 */ font-family: "iconfont"; /* Project id 2479351 */
src: url('iconfont.woff2?t=1726022313538') format('woff2'), src: url('iconfont.woff2?t=1737022296799') format('woff2'),
url('iconfont.woff?t=1726022313538') format('woff'), url('iconfont.woff?t=1737022296799') format('woff'),
url('iconfont.ttf?t=1726022313538') format('truetype'); url('iconfont.ttf?t=1737022296799') format('truetype');
} }
.iconfont { .iconfont {
@ -13,6 +13,10 @@
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
.iconjuzhongduiqi:before {
content: "\ec80";
}
.iconfile-excel:before { .iconfile-excel:before {
content: "\e7b7"; content: "\e7b7";
} }

View File

@ -626,3 +626,19 @@ export const linearGradientDirList = [
end: [0, 0] end: [0, 0]
} }
] ]
// 文本对齐方式
export const alignList = [
{
name: 'Align left',
value: 'left'
},
{
name: 'Align center',
value: 'center'
},
{
name: 'Align right',
value: 'right'
}
]

View File

@ -21,7 +21,8 @@ import {
lineStyleMap as lineStyleMapZh, lineStyleMap as lineStyleMapZh,
numberTypeList as numberTypeListZh, numberTypeList as numberTypeListZh,
numberLevelList as numberLevelListZh, numberLevelList as numberLevelListZh,
linearGradientDirList as linearGradientDirListZh linearGradientDirList as linearGradientDirListZh,
alignList as alignListZh
} from './zh' } from './zh'
import { import {
fontFamilyList as fontFamilyListEn, fontFamilyList as fontFamilyListEn,
@ -37,7 +38,8 @@ import {
downTypeList as downTypeListEn, downTypeList as downTypeListEn,
numberTypeList as numberTypeListEn, numberTypeList as numberTypeListEn,
numberLevelList as numberLevelListEn, numberLevelList as numberLevelListEn,
linearGradientDirList as linearGradientDirListEn linearGradientDirList as linearGradientDirListEn,
alignList as alignListEn
} from './en' } from './en'
import { import {
fontFamilyList as fontFamilyListZhtw, fontFamilyList as fontFamilyListZhtw,
@ -53,7 +55,8 @@ import {
downTypeList as downTypeListZhtw, downTypeList as downTypeListZhtw,
numberTypeList as numberTypeListZhtw, numberTypeList as numberTypeListZhtw,
numberLevelList as numberLevelListZhtw, numberLevelList as numberLevelListZhtw,
linearGradientDirList as linearGradientDirListZhtw linearGradientDirList as linearGradientDirListZhtw,
alignList as alignListZhtw
} from './zhtw' } from './zhtw'
const fontFamilyList = { const fontFamilyList = {
@ -152,6 +155,12 @@ const linearGradientDirList = {
zhtw: linearGradientDirListZhtw zhtw: linearGradientDirListZhtw
} }
const alignList = {
zh: alignListZh,
en: alignListEn,
zhtw: alignListZhtw
}
export { export {
fontSizeList, fontSizeList,
borderWidthList, borderWidthList,
@ -175,5 +184,6 @@ export {
downTypeList, downTypeList,
numberTypeList, numberTypeList,
numberLevelList, numberLevelList,
linearGradientDirList linearGradientDirList,
alignList
} }

View File

@ -721,3 +721,19 @@ export const linearGradientDirList = [
end: [0, 0] end: [0, 0]
} }
] ]
// 文本对齐方式
export const alignList = [
{
name: '左对齐',
value: 'left'
},
{
name: '居中对齐',
value: 'center'
},
{
name: '右对齐',
value: 'right'
}
]

View File

@ -626,3 +626,19 @@ export const linearGradientDirList = [
end: [0, 0] end: [0, 0]
} }
] ]
// 文本对齐方式
export const alignList = [
{
name: '左對齊',
value: 'left'
},
{
name: '居中對齊',
value: 'center'
},
{
name: '右對齊',
value: 'right'
}
]

View File

@ -368,7 +368,8 @@ export default {
fontSize: 'Font size', fontSize: 'Font size',
color: 'Color', color: 'Color',
backgroundColor: 'Background color', backgroundColor: 'Background color',
removeFormat: 'Clear Style' removeFormat: 'Clear Style',
textAlign: 'Text align'
}, },
other: { other: {
loading: 'Loading, please wait...' loading: 'Loading, please wait...'

View File

@ -358,7 +358,8 @@ export default {
fontSize: '字号', fontSize: '字号',
color: '字体颜色', color: '字体颜色',
backgroundColor: '背景颜色', backgroundColor: '背景颜色',
removeFormat: '清除样式' removeFormat: '清除样式',
textAlign: '对齐方式'
}, },
other: { other: {
loading: '正在加载,请稍后...' loading: '正在加载,请稍后...'

View File

@ -357,7 +357,8 @@ export default {
fontSize: '字型大小', fontSize: '字型大小',
color: '字型顏色', color: '字型顏色',
backgroundColor: '背景顏色', backgroundColor: '背景顏色',
removeFormat: '清除樣式' removeFormat: '清除樣式',
textAlign: '對齊方式'
}, },
other: { other: {
loading: '載入中,請稍候...' loading: '載入中,請稍候...'

View File

@ -110,6 +110,25 @@
</el-popover> </el-popover>
</el-tooltip> </el-tooltip>
<el-tooltip :content="$t('richTextToolbar.textAlign')" placement="top">
<el-popover placement="bottom" trigger="hover">
<div class="fontOptionsList" :class="{ isDark: isDark }">
<div
class="fontOptionItem"
v-for="item in alignList"
:key="item.value"
:class="{ active: formatInfo.align === item.value }"
@click="changeTextAlign(item.value)"
>
{{ item.name }}
</div>
</div>
<div class="btn" slot="reference">
<span class="icon iconfont iconjuzhongduiqi"></span>
</div>
</el-popover>
</el-tooltip>
<el-tooltip :content="$t('richTextToolbar.removeFormat')" placement="top"> <el-tooltip :content="$t('richTextToolbar.removeFormat')" placement="top">
<div class="btn" @click="removeFormat"> <div class="btn" @click="removeFormat">
<span class="icon iconfont iconqingchu"></span> <span class="icon iconfont iconqingchu"></span>
@ -119,7 +138,7 @@
</template> </template>
<script> <script>
import { fontFamilyList, fontSizeList } from '@/config' import { fontFamilyList, fontSizeList, alignList } from '@/config'
import Color from './Color' import Color from './Color'
import { mapState } from 'vuex' import { mapState } from 'vuex'
@ -153,6 +172,10 @@ export default {
fontFamilyList() { fontFamilyList() {
return fontFamilyList[this.$i18n.locale] || fontFamilyList.zh return fontFamilyList[this.$i18n.locale] || fontFamilyList.zh
},
alignList() {
return alignList[this.$i18n.locale] || alignList.zh
} }
}, },
created() { created() {
@ -230,6 +253,13 @@ export default {
}) })
}, },
changeTextAlign(align) {
this.formatInfo.align = align
this.mindMap.richText.formatText({
align
})
},
removeFormat() { removeFormat() {
this.mindMap.richText.removeFormat() this.mindMap.richText.removeFormat()
} }

View File

@ -10,7 +10,9 @@
<div class="title noTop">{{ $t('style.text') }}</div> <div class="title noTop">{{ $t('style.text') }}</div>
<div class="row"> <div class="row">
<div class="rowItem"> <div class="rowItem">
<span class="name">{{ $t('style.fontFamily') }}</span> <span class="name" v-if="!openNodeRichText">{{
$t('style.fontFamily')
}}</span>
<el-select <el-select
size="mini" size="mini"
style="width: 100px" style="width: 100px"
@ -29,10 +31,12 @@
</el-select> </el-select>
</div> </div>
<div class="rowItem"> <div class="rowItem">
<span class="name">{{ $t('style.fontSize') }}</span> <span class="name" v-if="!openNodeRichText">{{
$t('style.fontSize')
}}</span>
<el-select <el-select
size="mini" size="mini"
style="width: 80px" style="width: 60px"
v-model="style.fontSize" v-model="style.fontSize"
placeholder="" placeholder=""
@change="update('fontSize')" @change="update('fontSize')"
@ -47,6 +51,23 @@
</el-option> </el-option>
</el-select> </el-select>
</div> </div>
<div class="rowItem" v-if="openNodeRichText">
<el-select
size="mini"
style="width: 80px"
v-model="style.textAlign"
placeholder=""
@change="update('textAlign')"
>
<el-option
v-for="item in alignList"
:key="item.value"
:label="item.name"
:value="item.value"
>
</el-option>
</el-select>
</div>
</div> </div>
<div class="row"> <div class="row">
<div class="btnGroup"> <div class="btnGroup">
@ -500,7 +521,8 @@ import {
borderRadiusList, borderRadiusList,
shapeList, shapeList,
shapeListMap, shapeListMap,
linearGradientDirList linearGradientDirList,
alignList
} from '@/config' } from '@/config'
import { mapState } from 'vuex' import { mapState } from 'vuex'
@ -546,7 +568,8 @@ export default {
linearGradientDir: '', linearGradientDir: '',
lineFlow: false, lineFlow: false,
lineFlowForward: true, lineFlowForward: true,
lineFlowDuration: 1 lineFlowDuration: 1,
textAlign: ''
} }
} }
}, },
@ -554,7 +577,8 @@ export default {
...mapState({ ...mapState({
isDark: state => state.localConfig.isDark, isDark: state => state.localConfig.isDark,
activeSidebar: state => state.activeSidebar, activeSidebar: state => state.activeSidebar,
supportLineFlow: state => state.supportLineFlow supportLineFlow: state => state.supportLineFlow,
openNodeRichText: state => state.localConfig.openNodeRichText
}), }),
fontFamilyList() { fontFamilyList() {
return fontFamilyList[this.$i18n.locale] || fontFamilyList.zh return fontFamilyList[this.$i18n.locale] || fontFamilyList.zh
@ -572,6 +596,9 @@ export default {
return ( return (
linearGradientDirList[this.$i18n.locale] || linearGradientDirList.zh linearGradientDirList[this.$i18n.locale] || linearGradientDirList.zh
) )
},
alignList() {
return alignList[this.$i18n.locale] || alignList.zh
} }
}, },
watch: { watch: {