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 || []
|
||||
}
|
||||
|
||||
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) {
|
||||
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'
|
||||
|
||||
interface DefaultAttrs {
|
||||
color?: string
|
||||
backcolor?: string
|
||||
fontsize?: string
|
||||
fontname?: string
|
||||
align?: Align
|
||||
color: string
|
||||
backcolor: string
|
||||
fontsize: string
|
||||
fontname: string
|
||||
align: Align
|
||||
}
|
||||
const _defaultAttrs: DefaultAttrs = {
|
||||
color: '#000',
|
||||
@ -175,8 +175,8 @@ const _defaultAttrs: DefaultAttrs = {
|
||||
fontname: '微软雅黑',
|
||||
align: 'left',
|
||||
}
|
||||
export const getTextAttrs = (view: EditorView, defaultAttrs: DefaultAttrs = {}) => {
|
||||
defaultAttrs = { ..._defaultAttrs, ...defaultAttrs }
|
||||
export const getTextAttrs = (view: EditorView, attrs: Partial<DefaultAttrs> = {}) => {
|
||||
const defaultAttrs: DefaultAttrs = { ..._defaultAttrs, ...attrs }
|
||||
|
||||
const marks = getMarkAttrs(view)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user