fix: typography #6244
parent
82c4c8f0d3
commit
197e209b4e
|
@ -31,6 +31,7 @@ import type { EventHandler } from '../_util/EventInterface';
|
||||||
import omit from '../_util/omit';
|
import omit from '../_util/omit';
|
||||||
import type { AutoSizeType } from '../input/inputProps';
|
import type { AutoSizeType } from '../input/inputProps';
|
||||||
import useMergedState from '../_util/hooks/useMergedState';
|
import useMergedState from '../_util/hooks/useMergedState';
|
||||||
|
import { findDOMNode } from '../_util/props-util';
|
||||||
|
|
||||||
export type BaseType = 'secondary' | 'success' | 'warning' | 'danger';
|
export type BaseType = 'secondary' | 'success' | 'warning' | 'danger';
|
||||||
|
|
||||||
|
@ -198,7 +199,9 @@ const Base = defineComponent({
|
||||||
});
|
});
|
||||||
|
|
||||||
function getChildrenText(): string {
|
function getChildrenText(): string {
|
||||||
return props.ellipsis || props.editable ? props.content : contentRef.value?.$el?.innerText;
|
return props.ellipsis || props.editable
|
||||||
|
? props.content
|
||||||
|
: findDOMNode(contentRef.value)?.innerText;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============== Expand ===============
|
// =============== Expand ===============
|
||||||
|
@ -324,7 +327,7 @@ const Base = defineComponent({
|
||||||
if (
|
if (
|
||||||
!rows ||
|
!rows ||
|
||||||
rows < 0 ||
|
rows < 0 ||
|
||||||
!contentRef.value?.$el ||
|
!findDOMNode(contentRef.value) ||
|
||||||
state.expanded ||
|
state.expanded ||
|
||||||
props.content === undefined
|
props.content === undefined
|
||||||
)
|
)
|
||||||
|
@ -338,7 +341,7 @@ const Base = defineComponent({
|
||||||
text,
|
text,
|
||||||
ellipsis: ell,
|
ellipsis: ell,
|
||||||
} = measure(
|
} = measure(
|
||||||
contentRef.value?.$el,
|
findDOMNode(contentRef.value),
|
||||||
{ rows, suffix },
|
{ rows, suffix },
|
||||||
props.content,
|
props.content,
|
||||||
renderOperations(true),
|
renderOperations(true),
|
||||||
|
|
|
@ -8,7 +8,7 @@ const TITLE_ELE_LIST = tupleNum(1, 2, 3, 4, 5);
|
||||||
|
|
||||||
export const titleProps = () => ({
|
export const titleProps = () => ({
|
||||||
...omit(baseProps(), ['component', 'strong']),
|
...omit(baseProps(), ['component', 'strong']),
|
||||||
level: Number as PropType<typeof TITLE_ELE_LIST[number]>,
|
level: Number as PropType<(typeof TITLE_ELE_LIST)[number]>,
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TitleProps = Partial<ExtractPropTypes<ReturnType<typeof titleProps>>>;
|
export type TitleProps = Partial<ExtractPropTypes<ReturnType<typeof titleProps>>>;
|
||||||
|
@ -16,7 +16,7 @@ export type TitleProps = Partial<ExtractPropTypes<ReturnType<typeof titleProps>>
|
||||||
const Title: FunctionalComponent<TitleProps> = (props, { slots, attrs }) => {
|
const Title: FunctionalComponent<TitleProps> = (props, { slots, attrs }) => {
|
||||||
const { level = 1, ...restProps } = props;
|
const { level = 1, ...restProps } = props;
|
||||||
let component: string;
|
let component: string;
|
||||||
if (TITLE_ELE_LIST.indexOf(level) !== -1) {
|
if (TITLE_ELE_LIST.includes(level)) {
|
||||||
component = `h${level}`;
|
component = `h${level}`;
|
||||||
} else {
|
} else {
|
||||||
warning(false, 'Typography', 'Title only accept `1 | 2 | 3 | 4 | 5` as `level` value.');
|
warning(false, 'Typography', 'Title only accept `1 | 2 | 3 | 4 | 5` as `level` value.');
|
||||||
|
|
|
@ -3,7 +3,7 @@ category: Components
|
||||||
type: General
|
type: General
|
||||||
title: Typography
|
title: Typography
|
||||||
cols: 1
|
cols: 1
|
||||||
cover: https://gw.alipayobjects.com/zos/alicdn/GOM1KQ24O/Typography.svg
|
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*MLt3R6m9huoAAAAAAAAAAAAADrJ8AQ/original
|
||||||
---
|
---
|
||||||
|
|
||||||
Basic text writing, including headings, body text, lists, and more.
|
Basic text writing, including headings, body text, lists, and more.
|
||||||
|
|
|
@ -4,7 +4,7 @@ subtitle: 排版
|
||||||
type: 通用
|
type: 通用
|
||||||
title: Typography
|
title: Typography
|
||||||
cols: 1
|
cols: 1
|
||||||
cover: https://gw.alipayobjects.com/zos/alicdn/GOM1KQ24O/Typography.svg
|
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*MLt3R6m9huoAAAAAAAAAAAAADrJ8AQ/original
|
||||||
---
|
---
|
||||||
|
|
||||||
文本的基本格式。
|
文本的基本格式。
|
||||||
|
|
Loading…
Reference in New Issue