mirror of
https://github.com/palxiao/poster-design.git
synced 2025-07-15 16:02:19 +08:00
feat&fix: Text Settings
This commit is contained in:
parent
e07a5cefe1
commit
a203c41ea4
@ -2,8 +2,8 @@
|
|||||||
* @Author: ShawnPhang
|
* @Author: ShawnPhang
|
||||||
* @Date: 2021-08-02 18:27:27
|
* @Date: 2021-08-02 18:27:27
|
||||||
* @Description:
|
* @Description:
|
||||||
* @LastEditors: ShawnPhang, Jeremy Yu <https://github.com/JeremyYu-cn>
|
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
||||||
* @LastEditTime: 2024-03-01 20:55:51
|
* @LastEditTime: 2024-11-14 16:41:19
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AlignListData } from "./AlignListData"
|
import { AlignListData } from "./AlignListData"
|
||||||
@ -92,6 +92,13 @@ export const styleIconList2 = [
|
|||||||
value: 'justify',
|
value: 'justify',
|
||||||
select: false,
|
select: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'textAlignLast',
|
||||||
|
icon: 'icon-align-justify-text',
|
||||||
|
tip: '分散对齐',
|
||||||
|
value: 'justify',
|
||||||
|
select: false,
|
||||||
|
},
|
||||||
] as TStyleIconData2[]
|
] as TStyleIconData2[]
|
||||||
|
|
||||||
export const alignIconList = [
|
export const alignIconList = [
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
* @Date: 2021-07-29 18:31:27
|
* @Date: 2021-07-29 18:31:27
|
||||||
* @Description:
|
* @Description:
|
||||||
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
* @LastEditors: ShawnPhang <https://m.palxp.cn>
|
||||||
* @LastEditTime: 2024-04-10 07:36:58
|
* @LastEditTime: 2024-11-14 16:48:06
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<div class="icon-item-select">
|
<div class="icon-item-select">
|
||||||
<span v-if="label" class="label">{{ label }}</span>
|
<span v-if="label" class="label">{{ label }}</span>
|
||||||
<ul class="list btn__bar flex">
|
<ul v-if="data" class="list btn__bar flex">
|
||||||
<el-tooltip v-for="(item, index) in data" :key="index" class="item" effect="dark" :content="item.tip" placement="top" :show-after="300" >
|
<el-tooltip v-for="(item, index) in data" :key="index" class="item" effect="dark" :content="item.tip" placement="top" :show-after="300" >
|
||||||
<li :class="{ 'list-item': true, active: item.select }" @click="selectItem(item)">
|
<li :class="{ 'list-item': true, active: item.select }" @click="selectItem(item)">
|
||||||
<i :class="`${item.extraIcon ? 'icon' : 'iconfont'} ${item.icon}`"></i>
|
<i :class="`${item.extraIcon ? 'icon' : 'iconfont'} ${item.icon}`"></i>
|
||||||
@ -52,6 +52,8 @@ function selectItem(item: TIconItemSelectData) {
|
|||||||
item.select = !item.select
|
item.select = !item.select
|
||||||
}
|
}
|
||||||
emit('finish', item)
|
emit('finish', item)
|
||||||
|
// text-align非独立选项,恢复选中状态
|
||||||
|
item.key === 'textAlign' && (item.select = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
fontSize: params.fontSize + 'px',
|
fontSize: params.fontSize + 'px',
|
||||||
color: params.color,
|
color: params.color,
|
||||||
textAlign: params.textAlign,
|
textAlign: params.textAlign,
|
||||||
|
textAlignLast: params.textAlignLast,
|
||||||
fontWeight: params.fontWeight,
|
fontWeight: params.fontWeight,
|
||||||
fontStyle: params.fontStyle,
|
fontStyle: params.fontStyle,
|
||||||
textDecoration: params.textDecoration,
|
textDecoration: params.textDecoration,
|
||||||
@ -188,7 +189,7 @@ function writeDone(e: Event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function dblclickText(_: MouseEvent) {
|
function dblclickText(_: MouseEvent) {
|
||||||
// store.commit('setShowMoveable', false)
|
if (state.editable) return
|
||||||
state.editable = true
|
state.editable = true
|
||||||
const el = editWrap.value || widget.value
|
const el = editWrap.value || widget.value
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -25,6 +25,7 @@ export type TwTextData = {
|
|||||||
textDecoration: string
|
textDecoration: string
|
||||||
color: string
|
color: string
|
||||||
textAlign: StyleProperty.TextAlign
|
textAlign: StyleProperty.TextAlign
|
||||||
|
textAlignLast: StyleProperty.TextAlign
|
||||||
text: string
|
text: string
|
||||||
opacity: number
|
opacity: number
|
||||||
backgroundColor: string
|
backgroundColor: string
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
<value-select v-model="state.innerElement.fontSize" label="大小" suffix="px" :data="state.fontSizeList" @finish="(value) => finish('fontSize', value)" />
|
<value-select v-model="state.innerElement.fontSize" label="大小" suffix="px" :data="state.fontSizeList" @finish="(value) => finish('fontSize', value)" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<icon-item-select class="style-item" :data="styleIconList1" @finish="textStyleAction" />
|
<icon-item-select class="style-item" :data="state.styleIconList1" @finish="textStyleAction" />
|
||||||
<icon-item-select class="style-item" :data="styleIconList2" @finish="textStyleAction" />
|
<icon-item-select class="style-item" :data="state.styleIconList2" @finish="textStyleAction" />
|
||||||
|
|
||||||
<!-- <div style="flex-wrap: nowrap" class="line-layout style-item">
|
<!-- <div style="flex-wrap: nowrap" class="line-layout style-item">
|
||||||
<value-select v-model="innerElement.lineHeight" label="行距" suffix="倍" :data="lineHeightList" @finish="(value) => finish('lineHeight', value)" />
|
<value-select v-model="innerElement.lineHeight" label="行距" suffix="倍" :data="lineHeightList" @finish="(value) => finish('lineHeight', value)" />
|
||||||
@ -213,13 +213,16 @@ function layerAction(item: TIconItemSelectData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function textStyleAction(item: TIconItemSelectData) {
|
async function textStyleAction(item: TIconItemSelectData) {
|
||||||
let value = item.key === 'textAlign' ? item.value : (item.value as number[])[item.select ? 1 : 0]
|
const innerText = state.innerElement as Record<string, any>
|
||||||
;(state.innerElement as Record<string, any>)[item.key || ''] = value
|
let value = ['textAlign', 'textAlignLast'].includes(item.key || '') ? item.value : (item.value as number[])[item.select ? 1 : 0]
|
||||||
// TODO: 对竖版文字的特殊处理
|
// 分散对齐判断是否选中,选中时则为抹去属性
|
||||||
|
item.key === 'textAlignLast' && innerText[item.key] === value && (value = undefined)
|
||||||
|
// 设置属性
|
||||||
|
item.key && (innerText[item.key] = value)
|
||||||
|
// 对竖版文字特殊处理
|
||||||
item.key === 'writingMode' && relationChange()
|
item.key === 'writingMode' && relationChange()
|
||||||
await nextTick()
|
await nextTick()
|
||||||
forceStore.setUpdateRect()
|
forceStore.setUpdateRect()
|
||||||
// store.commit('updateRect')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function alignAction(item: TIconItemSelectData) {
|
async function alignAction(item: TIconItemSelectData) {
|
||||||
@ -259,7 +262,7 @@ function changeStyleIconList() {
|
|||||||
for (let i = 0; i < state.styleIconList2.length; i++) {
|
for (let i = 0; i < state.styleIconList2.length; i++) {
|
||||||
let key = state.styleIconList2[i].key
|
let key = state.styleIconList2[i].key
|
||||||
state.styleIconList2[i].select = false
|
state.styleIconList2[i].select = false
|
||||||
if (key === 'textAlign' && state.innerElement[key] === state.styleIconList2[i].value) {
|
if (['textAlign', 'textAlignLast'].includes(key || '') && state.innerElement[key] === state.styleIconList2[i].value) {
|
||||||
state.styleIconList2[i].select = true
|
state.styleIconList2[i].select = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
2
src/types/style.d.ts
vendored
2
src/types/style.d.ts
vendored
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace StyleProperty {
|
namespace StyleProperty {
|
||||||
type TextAlign = "center" | "end" | "left" | "right" | "start";
|
type TextAlign = "center" | "end" | "left" | "right" | "start" | "justify";
|
||||||
type WritingMode = Globals | "horizontal-tb" | "sideways-lr" | "sideways-rl" | "vertical-lr" | "vertical-rl";
|
type WritingMode = Globals | "horizontal-tb" | "sideways-lr" | "sideways-rl" | "vertical-lr" | "vertical-rl";
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user