UNPKG

@tarojs/components

Version:
1 lines 1.34 kB
import{r as e,h as t,H as r}from"./p-d0cabaaa.js";const s=class{constructor(r){e(this,r),this.renderNode=e=>{if("type"in e&&"text"===e.type)return(e.text||"").replace(/ /g," ");if("name"in e&&e.name){const{name:r,attrs:s,children:c}=e,o={};let n=[];if(s&&"object"==typeof s)for(const e in s){const t=s[e];if("style"!==e||"string"!=typeof t)o[e]=t;else{const e=t.split(";").map((e=>e.trim())).filter((e=>e)),r={};e.forEach((e=>{if(!e)return;const t=/(.+): *(.+)/g.exec(e);if(!t)return;const[,s,c]=t,o=s.replace(/-([a-z])/g,((...e)=>e[1].toUpperCase()));r[o]=c})),Object.keys(r).length&&(o.style=r)}}return c&&c.length&&(n=c.map((e=>this.renderNode(e)))),t(r,o,n)}return null},this.nodes=void 0,this.selectable=!1,this.userSelect=!1,this.space=void 0}render(){const{nodes:e,renderNode:s}=this;return Array.isArray(e)?t(r,null,e.map((e=>s(e)))):t(r,{innerHTML:e})}};s.style="taro-rich-text-core{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}taro-rich-text-core[selectable=true],taro-rich-text-core[user-select=true]{-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;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}