tdesign-miniprogram
Version:
TDesign Component for miniprogram
1 lines • 804 B
JavaScript
import{__decorate}from"tslib";import{Lexer}from"marked";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import props from"./props";const{prefix:prefix}=config,name=`${prefix}-chat-markdown`;let ChatMarkdown=class extends SuperComponent{constructor(){super(...arguments),this.options={multipleSlots:!0},this.properties=props,this.data={classPrefix:name,nodes:[],name:name},this.observers={content:function(o){this.parseMarkdown(o)}},this.methods={parseMarkdown(o){try{const t=new Lexer(this.data.options).lex(o);this.setData({nodes:t})}catch(t){console.error("Markdown parsing error:",t),this.setData({nodes:[{type:"text",raw:o,text:o}]})}}},this.lifetimes={attached(){}}}};ChatMarkdown=__decorate([wxComponent()],ChatMarkdown);export default ChatMarkdown;