Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setDOM = () => {
const {
className,
collapsed,
showMoreText,
lessHeight,
showMoreElement,
showLessElement,
} = this.props;
if (collapsed) {
shave(this.root, lessHeight, {
classname: className,
character: showMoreText,
spaces: false,
});
const shaveChar = this.root.querySelector(`.${jsShaveCharClassName}`);
if (shaveChar && showMoreElement) {
// 如果不需要 ellipse,则没有 `shaveChar`
render(showMoreElement, shaveChar);
}
} else {
const hasShowLess = !!this.root.querySelector(
`.${showLessTextClassName}`
);
if (
this.root.offsetHeight > lessHeight &&
showLessElement &&
handleUpdate() {
// TODO make "View Less" disappear when user expands window
// and text isn't truncated any more.
shave(this.$refs.shaveEl, this.maxHeight);
this.$nextTick(() => {
this.textIsTruncated = Boolean(this.$el.querySelector('.js-shave'));
});
},
},
function truncateTextBasedOnMaxHeight(excerpt: Element) {
const maxHeight = parseInt(getComputedStyle(excerpt)["max-height"], 10);
if (maxHeight && maxHeight > 0) {
shave(excerpt, maxHeight);
}
}
const truncate = useCallback(() => {
const maxHeight = lineHeight * lines
shave(elRef.current, maxHeight, { character: character })
}, [lineHeight, lines, character])
useEffect(() => {
useEffect(() => {
shave('.conversation-snippet', 20);
})
private truncateTextBasedOnMaxHeight() {
const element = this.ref.current!;
const maxHeight = parseInt(getComputedStyle(element)["max-height"], 10);
if (maxHeight && maxHeight > 0) {
shave(element, maxHeight);
}
}
export function truncateTextBasedOnMaxHeight(excerpt: Element) {
const maxHeight = parseInt(getComputedStyle(excerpt)["max-height"], 10);
if (maxHeight && maxHeight > 0) {
shave(excerpt, maxHeight);
}
}
private truncateBasedOnLines() {
const lineHeight = this.calculateLineHeight();
if (lineHeight !== null) {
const maxHeight = this.props.lines! * lineHeight;
shave(this.ref.current!, maxHeight);
}
}
private shaveTexts() {
if (!!this.summaryElement) {
shave(this.summaryElement, 40);
}
}
private shaveTexts() {
if (!!this.abstractElement) {
shave(this.abstractElement, 88);
}
}