@tarojs/components
Version:
1 lines • 1.2 kB
JavaScript
import{r as t,h as e,H as r}from"./p-d0cabaaa.js";const s=class{constructor(r){t(this,r),this.renderNode=t=>{if("type"in t&&"text"===t.type)return(t.text||"").replace(/ /g," ");if("name"in t&&t.name){const{name:r,attrs:s,children:c}=t,o={};let n=[];if(s&&"object"==typeof s)for(const t in s){const e=s[t];if("style"!==t||"string"!=typeof e)o[t]=e;else{const t=e.split(";").map((t=>t.trim())).filter((t=>t)),r={};t.forEach((t=>{if(!t)return;const e=/(.+): *(.+)/g.exec(t);if(!e)return;const[,s,c]=e,o=s.replace(/-([a-z])/g,((...t)=>t[1].toUpperCase()));r[o]=c})),Object.keys(r).length&&(o.style=r)}}return c&&c.length&&(n=c.map((t=>this.renderNode(t)))),e(r,o,n)}return null},this.nodes=void 0,this.selectable=!1,this.userSelect=!1,this.space=void 0}render(){const{nodes:t,renderNode:s}=this;return Array.isArray(t)?e(r,null,t.map((t=>s(t)))):e(r,{innerHTML:t})}};s.style="taro-rich-text-core{user-select:none}taro-rich-text-core[selectable=true],taro-rich-text-core[user-select=true]{user-select:text;display:block}taro-rich-text-core[space]{white-space:pre-wrap}taro-rich-text-core[space=ensp]{word-spacing:.5em}taro-rich-text-core[space=nbsp]{word-spacing:1em}";export{s as taro_rich_text_core}