mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
fix: 修复富文本默认属性类型
This commit is contained in:
parent
3f46b094a4
commit
6b87ef49ff
@ -123,7 +123,7 @@ export const getMarkAttrs = (view: EditorView) => {
|
|||||||
return node?.marks || []
|
return node?.marks || []
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getAttrValue = (marks: readonly Mark[], markType: string, attr: string) => {
|
export const getAttrValue = (marks: readonly Mark[], markType: string, attr: string): string | null => {
|
||||||
for (const mark of marks) {
|
for (const mark of marks) {
|
||||||
if (mark.type.name === markType && mark.attrs[attr]) return mark.attrs[attr]
|
if (mark.type.name === markType && mark.attrs[attr]) return mark.attrs[attr]
|
||||||
}
|
}
|
||||||
@ -162,11 +162,11 @@ export const getAttrValueInSelection = (view: EditorView, attr: string) => {
|
|||||||
type Align = 'left' | 'right' | 'center'
|
type Align = 'left' | 'right' | 'center'
|
||||||
|
|
||||||
interface DefaultAttrs {
|
interface DefaultAttrs {
|
||||||
color?: string
|
color: string
|
||||||
backcolor?: string
|
backcolor: string
|
||||||
fontsize?: string
|
fontsize: string
|
||||||
fontname?: string
|
fontname: string
|
||||||
align?: Align
|
align: Align
|
||||||
}
|
}
|
||||||
const _defaultAttrs: DefaultAttrs = {
|
const _defaultAttrs: DefaultAttrs = {
|
||||||
color: '#000',
|
color: '#000',
|
||||||
@ -175,8 +175,8 @@ const _defaultAttrs: DefaultAttrs = {
|
|||||||
fontname: '微软雅黑',
|
fontname: '微软雅黑',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
}
|
}
|
||||||
export const getTextAttrs = (view: EditorView, defaultAttrs: DefaultAttrs = {}) => {
|
export const getTextAttrs = (view: EditorView, attrs: Partial<DefaultAttrs> = {}) => {
|
||||||
defaultAttrs = { ..._defaultAttrs, ...defaultAttrs }
|
const defaultAttrs: DefaultAttrs = { ..._defaultAttrs, ...attrs }
|
||||||
|
|
||||||
const marks = getMarkAttrs(view)
|
const marks = getMarkAttrs(view)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user