feat: web text support iconfont

This commit is contained in:
钱泽虹 2023-08-30 20:09:31 +08:00 committed by osborn
parent bb6840cc40
commit af2072ef25
3 changed files with 19 additions and 5 deletions

View File

@ -7202,6 +7202,13 @@ var doric_web = (function (exports, axios, sandbox) {
v.style.alignItems = "center";
}
break;
case "font":
const fontLink = document.createElement('link');
fontLink.rel = 'stylesheet';
fontLink.href = `${prop}.css`;
document.head.appendChild(fontLink);
this.view.classList.add(prop);
break;
case "fontStyle":
switch (prop) {
case "bold":
@ -7245,7 +7252,7 @@ var doric_web = (function (exports, axios, sandbox) {
this.view.style.height = toPixelString(maxHeight);
this.view.style.alignItems = "flex-start";
this.view.style.overflow = 'hidden';
this.view.textContent = this.getTruncationText(computedStyle, maxHeight);
this.textElement.innerText = this.getTruncationText(computedStyle, maxHeight);
}
}
}
@ -7259,7 +7266,7 @@ var doric_web = (function (exports, axios, sandbox) {
return lineHeight;
}
getTruncationText(style, maxHeight) {
const originalText = this.view.textContent;
const originalText = this.textElement.innerText;
let start = 0, end = originalText.length;
const tempEle = document.createElement('div');
tempEle.style.cssText = style.cssText;

File diff suppressed because one or more lines are too long

View File

@ -42,6 +42,13 @@ export class DoricTextNode extends DoricViewNode {
v.style.alignItems = "center"
}
break
case "font":
const fontLink = document.createElement('link')
fontLink.rel = 'stylesheet'
fontLink.href = `${prop}.css`
document.head.appendChild(fontLink)
this.view.classList.add(prop)
break
case "fontStyle":
switch (prop) {
case "bold":
@ -87,7 +94,7 @@ export class DoricTextNode extends DoricViewNode {
this.view.style.height = toPixelString(maxHeight)
this.view.style.alignItems = "flex-start"
this.view.style.overflow = 'hidden'
this.view.textContent = this.getTruncationText(computedStyle, maxHeight)
this.textElement.innerText = this.getTruncationText(computedStyle, maxHeight)
}
}
}
@ -103,7 +110,7 @@ export class DoricTextNode extends DoricViewNode {
}
getTruncationText(style:CSSStyleDeclaration, maxHeight:number) {
const originalText = this.view.textContent!
const originalText = this.textElement.innerText
let start = 0, end = originalText.length
const tempEle = document.createElement('div')