1 Commits

Author SHA1 Message Date
81c5550311 release(content-suggestions): v0.1.2 2026-03-11 17:46:03 +03:00
8 changed files with 33 additions and 18 deletions

View File

@@ -374,6 +374,9 @@ var AngularContentTextRenderer = class {
}
return cutoff;
}
hasVerticalOverflow(element) {
return element.scrollHeight - element.clientHeight > 1;
}
render() {
if (!this.host) {
return;
@@ -409,13 +412,13 @@ var AngularContentTextRenderer = class {
paragraph.style.setProperty("-webkit-box-orient", "vertical");
paragraph.style.setProperty("-webkit-line-clamp", String(ellipsisConfig.rows));
paragraph.style.overflow = "hidden";
if (ellipsisConfig.expandable) {
wrapper.append(paragraph);
wrapper.append(paragraph);
this.host.replaceChildren(wrapper);
if (ellipsisConfig.expandable && this.hasVerticalOverflow(paragraph)) {
wrapper.append(this.buildReadMoreButton(ellipsisConfig.symbol));
this.host.replaceChildren(wrapper);
this.emitOnViewIfNeeded(mergedExpanded);
return;
}
this.emitOnViewIfNeeded(mergedExpanded);
return;
}
}
wrapper.append(paragraph);

File diff suppressed because one or more lines are too long

View File

@@ -99,6 +99,7 @@ declare class AngularContentTextRenderer {
private buildReadMoreButton;
private handleExpand;
private computeEntitySafeCutoff;
private hasVerticalOverflow;
private render;
private initObserver;
private emitOnViewIfNeeded;

View File

@@ -99,6 +99,7 @@ declare class AngularContentTextRenderer {
private buildReadMoreButton;
private handleExpand;
private computeEntitySafeCutoff;
private hasVerticalOverflow;
private render;
private initObserver;
private emitOnViewIfNeeded;

View File

@@ -372,6 +372,9 @@ var AngularContentTextRenderer = class {
}
return cutoff;
}
hasVerticalOverflow(element) {
return element.scrollHeight - element.clientHeight > 1;
}
render() {
if (!this.host) {
return;
@@ -407,13 +410,13 @@ var AngularContentTextRenderer = class {
paragraph.style.setProperty("-webkit-box-orient", "vertical");
paragraph.style.setProperty("-webkit-line-clamp", String(ellipsisConfig.rows));
paragraph.style.overflow = "hidden";
if (ellipsisConfig.expandable) {
wrapper.append(paragraph);
wrapper.append(paragraph);
this.host.replaceChildren(wrapper);
if (ellipsisConfig.expandable && this.hasVerticalOverflow(paragraph)) {
wrapper.append(this.buildReadMoreButton(ellipsisConfig.symbol));
this.host.replaceChildren(wrapper);
this.emitOnViewIfNeeded(mergedExpanded);
return;
}
this.emitOnViewIfNeeded(mergedExpanded);
return;
}
}
wrapper.append(paragraph);

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "@hublib-web/content-suggestions",
"version": "0.1.1",
"version": "0.1.2",
"description": "Content text/title with mentions, tags and links for React and Angular",
"license": "MIT",
"type": "module",

View File

@@ -504,6 +504,10 @@ export class AngularContentTextRenderer {
return cutoff;
}
private hasVerticalOverflow(element: HTMLElement): boolean {
return element.scrollHeight - element.clientHeight > 1;
}
private render(): void {
if (!this.host) {
return;
@@ -549,13 +553,16 @@ export class AngularContentTextRenderer {
paragraph.style.setProperty("-webkit-line-clamp", String(ellipsisConfig.rows));
paragraph.style.overflow = "hidden";
if (ellipsisConfig.expandable) {
wrapper.append(paragraph);
// Важно: сначала рендерим paragraph в DOM, потом меряем реальный overflow.
wrapper.append(paragraph);
this.host.replaceChildren(wrapper);
if (ellipsisConfig.expandable && this.hasVerticalOverflow(paragraph)) {
wrapper.append(this.buildReadMoreButton(ellipsisConfig.symbol));
this.host.replaceChildren(wrapper);
this.emitOnViewIfNeeded(mergedExpanded);
return;
}
this.emitOnViewIfNeeded(mergedExpanded);
return;
}
}