优化markdown渲染
This commit is contained in:
parent
9f95144c25
commit
41837cd821
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ __pycache__/
|
||||
cookie*.json
|
||||
env
|
||||
config.json
|
||||
node_modules/
|
||||
|
||||
3
bingchat/.vscode/settings.json
vendored
Normal file
3
bingchat/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"git.ignoreLimitWarning": true
|
||||
}
|
||||
@ -18,5 +18,6 @@
|
||||
"networkTimeout": {
|
||||
"request": 1800000
|
||||
},
|
||||
"resizable": true
|
||||
"resizable": true,
|
||||
"lazyCodeLoading": "requiredComponents"
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"wemark": "../wemark/wemark"
|
||||
"mp-html": "mp-html"
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
<wxs src="../../tools.wxs" module="tools" />
|
||||
<!-- <wxs src="../../tools.wxs" module="tools" /> -->
|
||||
<view wx:if="{{chatList.length == 0}}" style="text-align:center;color: rgb(180, 187, 196);font-size: 28rpx;">输入问题开始和New Bing聊天吧~</view>
|
||||
<scroll-view class="chat" scroll-y="true" scroll-into-view="{{scrollId}}" style="height:{{systemInfo.windowHeight - 70}}px;" enable-back-to-top="{{true}}" scroll-anchoring="{{true}}" enhanced="{{true}}" enable-flex="{{true}}">
|
||||
<view wx:for="{{chatList}}" wx:key="index" wx:for-item="item" id="{{'item'+index}}">
|
||||
@ -7,12 +7,7 @@
|
||||
<view class="chat-box" style="margin-left: 20rpx;">
|
||||
<text class="dt">{{item.dt}}</text>
|
||||
<view class="content bg-white" bindlongpress="copyContent" data-index="{{index}}">
|
||||
<view class="{{item.blink ? 'blinking': ''}}">
|
||||
<wemark md="{{item.originContent}}" link="{{false}}" highlight type="wemark" wx:if="{{tools.indexOf(item.originContent, '`') || tools.indexOf(item.originContent, '**')}}">
|
||||
</wemark>
|
||||
<text user-select decode space wx:else>{{item.originContent}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="{{item.blink ? 'blinking': ''}}"><mp-html content="{{item.originContent}}" preview-img markdown="{{true}}" img-cache="{{true}}" lazy-load="{{true}}" container-style="margin-top: -1em;margin-bottom:-1em;"/></view></view>
|
||||
<view class="suggest">
|
||||
<view hover-class="suggest-item-hover" class="suggest-item" bindtap="suggestSubmit" data-suggest="{{suggest}}" wx:for="{{item.suggests}}" wx:for-item="suggest">{{suggest}}</view>
|
||||
</view>
|
||||
|
||||
@ -1,262 +0,0 @@
|
||||
var Remarkable = require('./remarkable');
|
||||
var parser = new Remarkable({
|
||||
html: true
|
||||
});
|
||||
var prism = require('./prism');
|
||||
|
||||
function parse(md, options){
|
||||
if(!options) options = {};
|
||||
var tokens = parser.parse(md, {});
|
||||
|
||||
// markdwon渲染列表
|
||||
var renderList = [];
|
||||
|
||||
var env = [];
|
||||
// 记录当前list深度
|
||||
var listLevel = 0;
|
||||
// 记录第N级ol的顺序
|
||||
var orderNum = [0, 0];
|
||||
var tmp;
|
||||
|
||||
// 获取inline内容
|
||||
var getInlineContent = function(inlineToken){
|
||||
var ret = [];
|
||||
var env;
|
||||
var tokenData = {};
|
||||
|
||||
if(inlineToken.type === 'htmlblock'){
|
||||
// 匹配video
|
||||
// 兼容video[src]和video > source[src]
|
||||
var videoRegExp = /<video.*?src\s*=\s*['"]*([^\s^'^"]+).*?(poster\s*=\s*['"]*([^\s^'^"]+).*?)?(?:\/\s*>|<\/video>)/g;
|
||||
|
||||
var match;
|
||||
var html = inlineToken.content.replace(/\n/g, '');
|
||||
while(match = videoRegExp.exec(html)){
|
||||
if(match[1]){
|
||||
var retParam = {
|
||||
type: 'video',
|
||||
src: match[1]
|
||||
};
|
||||
|
||||
if(match[3]) {
|
||||
retParam.poster = match[3];
|
||||
}
|
||||
|
||||
ret.push(retParam);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// console.log(inlineToken);
|
||||
inlineToken.children && inlineToken.children.forEach(function(token, index){
|
||||
if(['text', 'code'].indexOf(token.type) > -1){
|
||||
ret.push({
|
||||
type: env || token.type,
|
||||
content: token.content,
|
||||
data: tokenData
|
||||
});
|
||||
env = '';
|
||||
tokenData = {};
|
||||
}else if(token.type === 'del_open'){
|
||||
env = 'deleted';
|
||||
}else if (token.type === 'softbreak') {
|
||||
// todo:处理li的问题
|
||||
/* ret.push({
|
||||
type: 'text',
|
||||
content: ' '
|
||||
}); */
|
||||
}else if (token.type === 'hardbreak') {
|
||||
ret.push({
|
||||
type: 'text',
|
||||
content: '\n'
|
||||
});
|
||||
}else if(token.type === 'strong_open'){
|
||||
if(env === 'em') {
|
||||
env = 'strong_em';
|
||||
}else {
|
||||
env = 'strong';
|
||||
}
|
||||
}else if (token.type === 'em_open') {
|
||||
if(env === 'strong') {
|
||||
env = 'strong_em';
|
||||
}else {
|
||||
env = 'em';
|
||||
}
|
||||
}else if (token.type === 'link_open') {
|
||||
if(options.link){
|
||||
env = 'link';
|
||||
tokenData = {
|
||||
href: token.href
|
||||
};
|
||||
}
|
||||
}else if(token.type === 'image'){
|
||||
ret.push({
|
||||
type: token.type,
|
||||
src: token.src
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
var getBlockContent = function(blockToken, index, firstInLi){
|
||||
|
||||
if(blockToken.type === 'htmlblock'){
|
||||
return getInlineContent(blockToken);
|
||||
}else if(blockToken.type === 'heading_open'){
|
||||
return {
|
||||
type: 'h' + blockToken.hLevel,
|
||||
content: getInlineContent(tokens[index+1])
|
||||
};
|
||||
}else if(blockToken.type === 'paragraph_open'){
|
||||
// var type = 'p';
|
||||
var prefix = '';
|
||||
if(env.length){
|
||||
prefix = env.join('_') + '_';
|
||||
}
|
||||
|
||||
var content = getInlineContent(tokens[index+1]);
|
||||
|
||||
// 处理ol前的数字
|
||||
if(env[env.length - 1] === 'li' && env[env.length - 2] === 'ol'){
|
||||
let prefix = ' ';
|
||||
if (firstInLi){
|
||||
prefix = orderNum[listLevel - 1] + '. ';
|
||||
}
|
||||
content.unshift({
|
||||
type:'text',
|
||||
content: prefix
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
type: prefix + 'p',
|
||||
content: content
|
||||
};
|
||||
}else if(blockToken.type === 'fence' || blockToken.type === 'code'){
|
||||
content = blockToken.content;
|
||||
var highlight = false;
|
||||
if(options.highlight && blockToken.params && prism.languages[blockToken.params]){
|
||||
content = prism.tokenize(content, prism.languages[blockToken.params]);
|
||||
highlight = true;
|
||||
}
|
||||
|
||||
const flattenTokens = (tokensArr, result = [], parentType = '') => {
|
||||
if (Array.isArray(tokensArr)) {
|
||||
tokensArr.forEach(el => {
|
||||
if (typeof el === 'object') {
|
||||
// el.type = parentType + ' wemark_inline_code_' + el.type;
|
||||
if(Array.isArray(el.content)){
|
||||
flattenTokens(el.content, result, el.type);
|
||||
}else{
|
||||
flattenTokens(el, result, el.type);
|
||||
}
|
||||
} else {
|
||||
const obj = {};
|
||||
obj.type = parentType || 'text';
|
||||
// obj.type = parentType + ' wemark_inline_code_';
|
||||
obj.content = el;
|
||||
result.push(obj);
|
||||
}
|
||||
})
|
||||
return result
|
||||
} else {
|
||||
result.push(tokensArr)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
if(highlight){
|
||||
var tokenList = content;
|
||||
content = [];
|
||||
tokenList.forEach((token) => {
|
||||
// let contentListForToken = [];
|
||||
if(Array.isArray(token.content)){
|
||||
content = content.concat(flattenTokens(token.content, [], ''));
|
||||
}else{
|
||||
content.push(token);
|
||||
}
|
||||
});
|
||||
}
|
||||
// flatten nested tokens in html
|
||||
// if (blockToken.params === 'html') {
|
||||
// content = flattenTokens(content)
|
||||
// }
|
||||
// console.log(content);
|
||||
|
||||
return {
|
||||
type: 'code',
|
||||
highlight: highlight,
|
||||
content: content
|
||||
};
|
||||
}else if(blockToken.type === 'bullet_list_open'){
|
||||
env.push('ul');
|
||||
listLevel++;
|
||||
}else if(blockToken.type === 'ordered_list_open'){
|
||||
env.push('ol');
|
||||
listLevel++;
|
||||
}else if(blockToken.type === 'list_item_open'){
|
||||
env.push('li');
|
||||
if(env[env.length - 2] === 'ol' ){
|
||||
orderNum[listLevel - 1]++;
|
||||
}
|
||||
}else if(blockToken.type === 'list_item_close'){
|
||||
env.pop();
|
||||
}else if(blockToken.type === 'bullet_list_close'){
|
||||
env.pop();
|
||||
listLevel--;
|
||||
}else if(blockToken.type === 'ordered_list_close'){
|
||||
env.pop();
|
||||
listLevel--;
|
||||
orderNum[listLevel] = 0;
|
||||
}else if(blockToken.type === 'blockquote_open'){
|
||||
env.push('blockquote');
|
||||
}else if(blockToken.type === 'blockquote_close'){
|
||||
env.pop();
|
||||
}else if(blockToken.type === 'tr_open'){
|
||||
tmp = {
|
||||
type: 'table_tr',
|
||||
content:[]
|
||||
};
|
||||
return tmp;
|
||||
}else if(blockToken.type === 'th_open'){
|
||||
tmp.content.push({
|
||||
type: 'table_th',
|
||||
content: getInlineContent(tokens[index+1]).map(function(inline){return inline.content;}).join('')
|
||||
});
|
||||
}else if(blockToken.type === 'td_open'){
|
||||
tmp.content.push({
|
||||
type: 'table_td',
|
||||
content: getInlineContent(tokens[index+1]).map(function(inline){return inline.content;}).join('')
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
tokens.forEach(function(token, index){
|
||||
// 标记是否刚进入li,如果刚进入,可以加符号/序号,否则不加
|
||||
var firstInLi = false;
|
||||
if(token.type === 'paragraph_open' && tokens[index-1] && tokens[index-1].type === 'list_item_open'){
|
||||
firstInLi = true;
|
||||
}
|
||||
var blockContent = getBlockContent(token, index, firstInLi);
|
||||
if(!blockContent) return;
|
||||
if(!Array.isArray(blockContent)){
|
||||
blockContent = [blockContent];
|
||||
}
|
||||
blockContent.forEach(function(block){
|
||||
if(Array.isArray(block.content)){
|
||||
block.isArray = true;
|
||||
}else{
|
||||
block.isArray = false;
|
||||
}
|
||||
renderList.push(block);
|
||||
});
|
||||
});
|
||||
|
||||
return renderList;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
parse: parse
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@ -1,81 +0,0 @@
|
||||
/* PrismJS 1.15.0
|
||||
https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+basic+markup-templating+go+java+json+php+sql+python+typescript */
|
||||
/**
|
||||
* prism.js default theme for JavaScript, CSS and HTML
|
||||
* Based on dabblet (http://dabblet.com)
|
||||
* @author Lea Verou
|
||||
*/
|
||||
|
||||
.wemark_inline_code_comment,
|
||||
.wemark_inline_code_prolog,
|
||||
.wemark_inline_code_doctype,
|
||||
.wemark_inline_code_cdata {
|
||||
color: slategray;
|
||||
}
|
||||
|
||||
.wemark_inline_code_punctuation,
|
||||
.wemark_inline_code_interpolation-punctuation {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.wemark_inline_code_namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.wemark_inline_code_property,
|
||||
.wemark_inline_code_tag,
|
||||
.wemark_inline_code_boolean,
|
||||
.wemark_inline_code_number,
|
||||
.wemark_inline_code_constant,
|
||||
.wemark_inline_code_symbol,
|
||||
.wemark_inline_code_deleted {
|
||||
color: #905;
|
||||
}
|
||||
|
||||
.wemark_inline_code_selector,
|
||||
.wemark_inline_code_attr-name,
|
||||
.wemark_inline_code_string,
|
||||
.wemark_inline_code_char,
|
||||
.wemark_inline_code_builtin,
|
||||
.wemark_inline_code_inserted {
|
||||
color: #690;
|
||||
}
|
||||
|
||||
.wemark_inline_code_operator,
|
||||
.wemark_inline_code_entity,
|
||||
.wemark_inline_code_url,
|
||||
.language-css .wemark_inline_code_string,
|
||||
.style .wemark_inline_code_string {
|
||||
color: #9a6e3a;
|
||||
background: hsla(0, 0%, 100%, .5);
|
||||
}
|
||||
|
||||
.wemark_inline_code_atrule,
|
||||
.wemark_inline_code_attr-value,
|
||||
.wemark_inline_code_keyword {
|
||||
color: #07a;
|
||||
}
|
||||
|
||||
.wemark_inline_code_function,
|
||||
.wemark_inline_code_class-name {
|
||||
color: #DD4A68;
|
||||
}
|
||||
|
||||
.wemark_inline_code_regex,
|
||||
.wemark_inline_code_important,
|
||||
.wemark_inline_code_variable,
|
||||
.wemark_inline_code_interpolation {
|
||||
color: #e90;
|
||||
}
|
||||
|
||||
.wemark_inline_code_important,
|
||||
.wemark_inline_code_bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.wemark_inline_code_italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.wemark_inline_code_entity {
|
||||
cursor: help;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@ -1,155 +0,0 @@
|
||||
exports.getRichTextNodes = function(parsedData){
|
||||
|
||||
var richTextNodes = [];
|
||||
|
||||
var getNodeName = (function(){
|
||||
var stack = [];
|
||||
return function(type, nodeType = 'inline'){
|
||||
if(type === 'table_tr'){
|
||||
return 'tr';
|
||||
}else{
|
||||
// 有多级的,block返回第一级,inline返回最后一级
|
||||
if(type.indexOf('_') > -1){
|
||||
var typePart = type.split('_');
|
||||
if(nodeType === 'inline'){
|
||||
return typePart.pop();
|
||||
}else{
|
||||
return typePart[0];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return type;
|
||||
};
|
||||
})();
|
||||
|
||||
var getBlockNode = function(node){
|
||||
var nodeType = node.type;
|
||||
// console.log('nodeType:', nodeType);
|
||||
var richTextNode = {
|
||||
name: getNodeName(nodeType, 'inline'),
|
||||
attrs: {
|
||||
class: 'wemark_block_' + nodeType
|
||||
},
|
||||
children: []
|
||||
};
|
||||
if(node.isArray){
|
||||
node.content.forEach((childNode) => {
|
||||
if(['text','code','strong','deleted','em'].indexOf(childNode.type) > -1){
|
||||
richTextNode.children.push({
|
||||
name: 'span',
|
||||
attrs: {
|
||||
class: 'wemark_inline_' + childNode.type
|
||||
},
|
||||
children:[{
|
||||
type: 'text',
|
||||
text: childNode.content
|
||||
}]
|
||||
});
|
||||
}else if(node.highlight){
|
||||
if(typeof childNode === 'string'){
|
||||
richTextNode.children.push({
|
||||
name: 'span',
|
||||
attrs: {
|
||||
class: 'wemark_inline_code_text'
|
||||
},
|
||||
children: [{
|
||||
type: 'text',
|
||||
text: childNode
|
||||
}]
|
||||
});
|
||||
}else{
|
||||
richTextNode.children.push({
|
||||
name: 'span',
|
||||
attrs: {
|
||||
class: 'wemark_inline_code_' + childNode.type
|
||||
},
|
||||
children: [{
|
||||
type: 'text',
|
||||
text: childNode.content
|
||||
}]
|
||||
});
|
||||
}
|
||||
}else if(childNode.type === 'link'){
|
||||
richTextNode.children.push({
|
||||
name: 'a',
|
||||
attrs: {
|
||||
class: 'wemark_inline_link',
|
||||
href: childNode.data.href
|
||||
},
|
||||
children:[{
|
||||
type: 'text',
|
||||
text: childNode.content
|
||||
}]
|
||||
});
|
||||
}else if(childNode.type === 'image'){
|
||||
richTextNode.children.push({
|
||||
name: 'img',
|
||||
attrs: {
|
||||
mode: 'widthFix',
|
||||
class: 'wemark_inline_image',
|
||||
src: childNode.src
|
||||
}
|
||||
});
|
||||
}else if(childNode.type === 'table_th'){
|
||||
richTextNode.children.push({
|
||||
name: 'th',
|
||||
attrs: {
|
||||
class: 'wemark_inline_table_th',
|
||||
},
|
||||
children: [{
|
||||
type: 'text',
|
||||
text: childNode.content
|
||||
}]
|
||||
});
|
||||
}else if(childNode.type === 'table_td'){
|
||||
richTextNode.children.push({
|
||||
name: 'td',
|
||||
attrs: {
|
||||
class: 'wemark_inline_table_td',
|
||||
},
|
||||
children: [{
|
||||
type: 'text',
|
||||
text: childNode.content
|
||||
}]
|
||||
});
|
||||
}
|
||||
});
|
||||
}else if(node.type === 'code'){
|
||||
|
||||
richTextNode.children = [{
|
||||
name: 'code',
|
||||
children: [{
|
||||
type: 'text',
|
||||
text: node.content
|
||||
}]
|
||||
}];
|
||||
}
|
||||
return richTextNode;
|
||||
}
|
||||
|
||||
for(var i=0; i<parsedData.length;i++){
|
||||
var node = parsedData[i];
|
||||
if(node.type === 'table_tr'){
|
||||
var tableNode = {
|
||||
name: 'table',
|
||||
attrs: {
|
||||
class: 'wemark_block_table'
|
||||
},
|
||||
children: []
|
||||
};
|
||||
var tmpNode = node;
|
||||
while(tmpNode.type === 'table_tr'){
|
||||
tableNode.children.push(getBlockNode(tmpNode));
|
||||
tmpNode = parsedData[++i];
|
||||
}
|
||||
richTextNodes.push(tableNode);
|
||||
}else{
|
||||
richTextNodes.push(getBlockNode(node));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return richTextNodes;
|
||||
|
||||
}
|
||||
@ -1,71 +0,0 @@
|
||||
const parser = require('./parser');
|
||||
const getRichTextNodes = require('./richtext').getRichTextNodes;
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
md: {
|
||||
type: String,
|
||||
value: '',
|
||||
observer(){
|
||||
this.parseMd();
|
||||
}
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
value: 'wemark'
|
||||
},
|
||||
link: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
highlight: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
}
|
||||
},
|
||||
data: {
|
||||
parsedData: {},
|
||||
richTextNodes: []
|
||||
},
|
||||
methods: {
|
||||
parseMd(){
|
||||
if (this.data.md) {
|
||||
var parsedData = parser.parse(this.data.md, {
|
||||
link: this.data.link,
|
||||
highlight: this.data.highlight
|
||||
});
|
||||
// console.log('parsedData:', parsedData);
|
||||
if(this.data.type === 'wemark'){
|
||||
this.setData({
|
||||
parsedData
|
||||
});
|
||||
}else{
|
||||
// var inTable = false;
|
||||
var richTextNodes = getRichTextNodes(parsedData);
|
||||
|
||||
// console.log('richTextNodes:', richTextNodes);
|
||||
|
||||
this.setData({
|
||||
richTextNodes
|
||||
});
|
||||
|
||||
/* // 分批更新
|
||||
var update = {};
|
||||
var batchLength = 1000;
|
||||
console.log(batchLength);
|
||||
for(var i=0; i<richTextNodes.length; i++){
|
||||
update['richTextNodes.' + i] = richTextNodes[i];
|
||||
if(i%batchLength === batchLength - 1){
|
||||
console.log(update);
|
||||
this.setData(update);
|
||||
update = {};
|
||||
}
|
||||
}
|
||||
this.setData(update);
|
||||
update = {}; */
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
<view class="wemark_wrapper">
|
||||
<block wx:if="{{type === 'wemark'}}" wx:for="{{parsedData}}" wx:key="blockIndex" wx:for-index="blockIndex" wx:for-item="renderBlock">
|
||||
<view class="wemark_block_{{renderBlock.type}}">
|
||||
<block wx:if="{{renderBlock.isArray}}" wx:for="{{renderBlock.content}}" wx:key="inlineIndex" wx:for-index="inlineIndex" wx:for-item="renderInline">
|
||||
<text class="wemark_inline_{{renderInline.type}}" wx:if="{{renderInline.type === 'text' || renderInline.type === 'code' || renderInline.type === 'strong' || renderInline.type === 'strong_em' || renderInline.type === 'deleted' || renderInline.type === 'em' || renderInline.type === 'table_th' || renderInline.type === 'table_td'}}">{{renderInline.content}}</text>
|
||||
<!-- 代码高亮 -->
|
||||
<text class="wemark_inline_code_{{renderInline.type}}" wx:if="{{renderInline.type&&renderBlock.highlight}}">{{renderInline.content}}</text>
|
||||
<text class="wemark_inline_code_text" wx:if="{{!renderInline.type}}">{{renderInline}}</text>
|
||||
<navigator class="wemark_inline_link" url="{{renderInline.data.href}}" wx:if="{{renderInline.type === 'link'}}">{{renderInline.content}}</navigator>
|
||||
<image mode="widthFix" class="wemark_inline_image" src="{{renderInline.src}}" wx:if="{{renderInline.type === 'image'}}"></image>
|
||||
</block>
|
||||
<block wx:if="{{!renderBlock.isArray}}">
|
||||
<view wx:if="{{renderBlock.type === 'code'}}">{{renderBlock.content}}</view>
|
||||
<video wx:if="{{renderBlock.type == 'video'}}" class="wemark_block_video" src="{{renderBlock.src}}" poster="{{renderBlock.poster}}" controls></video>
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
<rich-text class="wemark_wrapper_richtext" wx:if="{{type === 'rich-text'}}" nodes="{{richTextNodes}}"></rich-text>
|
||||
</view>
|
||||
@ -1,148 +0,0 @@
|
||||
@import "prism.wxss";
|
||||
|
||||
.wemark_wrapper{
|
||||
/* margin:10px 0;
|
||||
font-size:32rpx;
|
||||
line-height: 1.8em; */
|
||||
}
|
||||
.wemark_block_h1{
|
||||
font-size:40rpx;
|
||||
text-align: center;
|
||||
margin-bottom:1em;
|
||||
}
|
||||
.wemark_block_h2{
|
||||
font-size:40rpx;
|
||||
padding-bottom:.5em;
|
||||
margin-top:1em;
|
||||
margin-bottom:1em;
|
||||
border-bottom:1px solid #f8f8f8;
|
||||
}
|
||||
.wemark_block_h3{
|
||||
font-size:36rpx;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.wemark_block_h4,
|
||||
.wemark_block_h5,
|
||||
.wemark_block_h6{
|
||||
font-weight: bold;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.wemark_block_p{
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.wemark_block_video{
|
||||
margin-top:1em;
|
||||
margin-bottom:1em;
|
||||
width:100%;
|
||||
}
|
||||
.wemark_block_blockquote_p{
|
||||
margin-top:1em;
|
||||
margin-bottom:1em;
|
||||
padding:10px 0 10px 1em;
|
||||
font-size:28rpx;
|
||||
background:#f8f8f8;
|
||||
border-left:5px solid #e0e0e0;
|
||||
}
|
||||
.wemark_block_ul_li_p::before{
|
||||
content:'• ';
|
||||
}
|
||||
.wemark_block_ul_li_ul_li_p::before,
|
||||
.wemark_block_ol_li_ul_li_p::before{
|
||||
content:'◦ ';
|
||||
}
|
||||
.wemark_block_ul_li_ul_li_p,
|
||||
.wemark_block_ul_li_ol_li_p,
|
||||
.wemark_block_ol_li_ul_li_p,
|
||||
.wemark_block_ol_li_ol_li_p{
|
||||
padding-left: 1em;
|
||||
}
|
||||
.wemark_block_ul_li_p:last{
|
||||
margin-bottom:1em;
|
||||
}
|
||||
.wemark_block_code{
|
||||
display: block;
|
||||
padding:10px;
|
||||
font-size:28rpx;
|
||||
line-height: 1.5em;
|
||||
border-radius: 10rpx;
|
||||
white-space: pre;
|
||||
overflow: auto;
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
.wemark_block_table{
|
||||
width: 100%;
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
/* border-left: 1px solid #e0e0e0; */
|
||||
/* border-top: 1px solid #e0e0e0; */
|
||||
}
|
||||
.wemark_block_table_tr{
|
||||
display: flex;
|
||||
}
|
||||
.wemark_wrapper_richtext .wemark_block_table_tr{
|
||||
display: table-row;
|
||||
}
|
||||
.wemark_inline_table_th,
|
||||
.wemark_inline_table_td{
|
||||
flex:1;
|
||||
padding:5px;
|
||||
font-size:28rpx;
|
||||
word-break: break-all;
|
||||
border: 1px solid #e0e0e0;
|
||||
}
|
||||
.wemark_wrapper_richtext .wemark_inline_table_th,
|
||||
.wemark_wrapper_richtext .wemark_inline_table_td{
|
||||
display: table-cell;
|
||||
/* background:red;
|
||||
border-right:1px solid #e0e0e0;
|
||||
border-bottom:1px solid #e0e0e0; */
|
||||
}
|
||||
.wemark_inline_table_td:last{
|
||||
/* border-top:1px solid #e0e0e0; */
|
||||
}
|
||||
.wemark_inline_table_th{
|
||||
background:#f8f8f8;
|
||||
/* border-top:1px solid #e0e0e0; */
|
||||
}
|
||||
.wemark_inline_strong{
|
||||
font-weight: bold;
|
||||
padding:0 5px;
|
||||
word-wrap:break-word;
|
||||
}
|
||||
.wemark_inline_em{
|
||||
font-style: italic;
|
||||
padding:0 5px;
|
||||
word-wrap:break-word;
|
||||
}
|
||||
.wemark_inline_strong_em{
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
padding:0 5px;
|
||||
word-wrap:break-word;
|
||||
}
|
||||
.wemark_inline_deleted{
|
||||
text-decoration: line-through;
|
||||
padding:0 5px;
|
||||
word-wrap:break-word;
|
||||
}
|
||||
.wemark_inline_image{
|
||||
width:100%;
|
||||
height:auto;
|
||||
}
|
||||
.wemark_inline_code{
|
||||
background-color: #fff5f5;
|
||||
padding: 3px;
|
||||
word-wrap:break-word;
|
||||
border-radius: 5px;
|
||||
color: #ff502c;
|
||||
}
|
||||
.wemark_inline_text{
|
||||
word-wrap:break-word;
|
||||
}
|
||||
.wemark_inline_link{
|
||||
display: inline;
|
||||
color: blue;
|
||||
word-wrap:break-word;
|
||||
}
|
||||
1
bingchat/miniprogram_npm/mp-html/emoji/index.js
Normal file
1
bingchat/miniprogram_npm/mp-html/emoji/index.js
Normal file
@ -0,0 +1 @@
|
||||
"use strict";function t(){}var e=/\[(\S+?)\]/g,n={"笑脸":"😄","生病":"😷","破涕为笑":"😂","吐舌":"😝","脸红":"😳","恐惧":"😱","失望":"😔","无语":"😒","眨眼":"😉","酷":"😎","哭":"😭","痴迷":"😍","吻":"😘","思考":"🤔","困惑":"😕","颠倒":"🙃","钱":"🤑","惊讶":"😲","白眼":"🙄","叹气":"😤","睡觉":"😴","书呆子":"🤓","愤怒":"😡","面无表情":"😑","张嘴":"😮","量体温":"🤒","呕吐":"🤮","光环":"😇","幽灵":"👻","外星人":"👽","机器人":"🤖","捂眼镜":"🙈","捂耳朵":"🙉","捂嘴":"🙊","婴儿":"👶","男孩":"👦","女孩":"👧","男人":"👨","女人":"👩","老人":"👴","老妇人":"👵","警察":"👮","王子":"🤴","公主":"🤴","举手":"🙋","跑步":"🏃","家庭":"👪","眼睛":"👀","鼻子":"👃","耳朵":"👂","舌头":"👅","嘴":"👄","心":"❤️","心碎":"💔","雪人":"☃️","情书":"💌","大便":"💩","闹钟":"⏰","眼镜":"👓","雨伞":"☂️","音乐":"🎵","话筒":"🎤","游戏机":"🎮","喇叭":"📢","耳机":"🎧","礼物":"🎁","电话":"📞","电脑":"💻","打印机":"🖨️","手电筒":"🔦","灯泡":"💡","书本":"📖","信封":"✉️","药丸":"💊","口红":"💄","手机":"📱","相机":"📷","电视":"📺","中":"🀄","垃圾桶":"🚮","厕所":"🚾","感叹号":"❗","禁":"🈲","可":"🉑","彩虹":"🌈","旋风":"🌀","雷电":"⚡","雪花":"❄️","星星":"⭐","水滴":"💧","玫瑰":"🌹","加油":"💪","左":"👈","右":"👉","上":"👆","下":"👇","手掌":"🖐️","好的":"👌","好":"👍","差":"👎","胜利":"✌","拳头":"👊","挥手":"👋","鼓掌":"👏","猴子":"🐒","狗":"🐶","狼":"🐺","猫":"🐱","老虎":"🐯","马":"🐎","独角兽":"🦄","斑马":"🦓","鹿":"🦌","牛":"🐮","猪":"🐷","羊":"🐏","长颈鹿":"🦒","大象":"🐘","老鼠":"🐭","蝙蝠":"🦇","刺猬":"🦔","熊猫":"🐼","鸽子":"🕊️","鸭子":"🦆","兔子":"🐇","老鹰":"🦅","青蛙":"🐸","蛇":"🐍","龙":"🐉","鲸鱼":"🐳","海豚":"🐬","足球":"⚽","棒球":"⚾","篮球":"🏀","排球":"🏐","橄榄球":"🏉","网球":"🎾","骰子":"🎲","鸡腿":"🍗","蛋糕":"🎂","啤酒":"🍺","饺子":"🥟","汉堡":"🍔","薯条":"🍟","意大利面":"🍝","干杯":"🥂","筷子":"🥢","糖果":"🍬","奶瓶":"🍼","爆米花":"🍿","邮局":"🏤","医院":"🏥","银行":"🏦","酒店":"🏨","学校":"🏫","城堡":"🏰","火车":"🚂","高铁":"🚄","地铁":"🚇","公交":"🚌","救护车":"🚑","消防车":"🚒","警车":"🚓","出租车":"🚕","汽车":"🚗","货车":"🚛","自行车":"🚲","摩托":"🛵","红绿灯":"🚥","帆船":"⛵","游轮":"🛳️","轮船":"⛴️","飞机":"✈️","直升机":"🚁","缆车":"🚠","警告":"⚠️","禁止":"⛔"};t.prototype.onUpdate=function(t){return t.replace(e,function(t,e){return n[e]?n[e]:t})},t.prototype.onGetContent=function(t){for(var e in n)t=t.replace(new RegExp(n[e],"g"),"["+e+"]");return t},module.exports=t;
|
||||
1
bingchat/miniprogram_npm/mp-html/highlight/config.js
Normal file
1
bingchat/miniprogram_npm/mp-html/highlight/config.js
Normal file
@ -0,0 +1 @@
|
||||
"use strict";module.exports={copyByLongPress:!0,showLanguageName:!0,showLineNumber:!0};
|
||||
1
bingchat/miniprogram_npm/mp-html/highlight/index.js
Normal file
1
bingchat/miniprogram_npm/mp-html/highlight/index.js
Normal file
@ -0,0 +1 @@
|
||||
"use strict";function e(e){this.vm=e}var r=require("./prism.min"),s=require("./config"),t=require("../parser");e.prototype.onParse=function(e,a){if("pre"===e.name){if(a.options.editable)return void(e.attrs.class=(e.attrs.class||"")+" hl-pre");var n;for(n=e.children.length;n--&&"code"!==e.children[n].name;);if(-1===n)return;var l=e.children[n],i=l.attrs.class+" "+e.attrs.class;n=i.indexOf("language-"),-1===n?(n=i.indexOf("lang-"),-1===n?(i="language-text",n=9):n+=5):n+=9;var c;for(c=n;c<i.length&&" "!==i[c];c++);var h=i.substring(n,c);if(l.children.length){var o=this.vm.getText(l.children).replace(/&/g,"&");if(!o)return;if(e.c&&(e.c=void 0),r.languages[h]&&(l.children=new t(this.vm).parse("<pre>"+r.highlight(o,r.languages[h],h).replace(/token /g,"hl-")+"</pre>")[0].children),e.attrs.class="hl-pre",l.attrs.class="hl-code",s.showLanguageName&&e.children.push({name:"div",attrs:{class:"hl-language",style:"user-select:none"},children:[{type:"text",text:h}]}),s.copyByLongPress&&(e.attrs.style+=(e.attrs.style||"")+";user-select:none",e.attrs["data-content"]=o,a.expose()),s.showLineNumber){for(var g=o.split("\n").length,p=[],u=g;u--;)p.push({name:"span",attrs:{class:"span"}});e.children.push({name:"span",attrs:{class:"line-numbers-rows"},children:p})}}}},module.exports=e;
|
||||
83
bingchat/miniprogram_npm/mp-html/highlight/prism.min.js
vendored
Normal file
83
bingchat/miniprogram_npm/mp-html/highlight/prism.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
8
bingchat/miniprogram_npm/mp-html/index.js
Normal file
8
bingchat/miniprogram_npm/mp-html/index.js
Normal file
@ -0,0 +1,8 @@
|
||||
"use strict";function e(t){"@babel/helpers - typeof";return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t,i){return t=n(t),t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function n(t){var n=i(t,"string");return"symbol"===e(n)?n:String(n)}function i(t,n){if("object"!==e(t)||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,n||"default");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}/*!
|
||||
* mp-html v2.4.1
|
||||
* https://github.com/jin-yufeng/mp-html
|
||||
*
|
||||
* Released under the MIT license
|
||||
* Author: Jin Yufeng
|
||||
*/
|
||||
var o=require("./parser"),r=[require("./markdown/index.js"),require("./emoji/index.js"),require("./highlight/index.js"),require("./latex/index.js"),require("./style/index.js")];Component({data:{nodes:[]},properties:{markdown:Boolean,containerStyle:String,content:{type:String,value:"",observer:function(e){this.setContent(e)}},copyLink:{type:Boolean,value:!0},domain:String,errorImg:String,lazyLoad:Boolean,loadingImg:String,pauseVideo:{type:Boolean,value:!0},previewImg:{type:Boolean,value:!0},scrollTable:Boolean,selectable:null,setTitle:{type:Boolean,value:!0},showImgMenu:{type:Boolean,value:!0},tagStyle:Object,useAnchor:null},created:function(){this.plugins=[];for(var e=r.length;e--;)this.plugins.push(new r[e](this))},detached:function(){this._hook("onDetached")},methods:{in:function(e,t,n){e&&t&&n&&(this._in={page:e,selector:t,scrollTop:n})},navigateTo:function(e,n){var i=this;return e=this._ids[decodeURI(e)]||e,new Promise(function(o,r){if(!i.data.useAnchor)return void r(Error("Anchor is disabled"));var a=wx.createSelectorQuery().in(i._in?i._in.page:i).select((i._in?i._in.selector:"._root")+(e?"".concat(">>>","#").concat(e):"")).boundingClientRect();i._in?a.select(i._in.selector).scrollOffset().select(i._in.selector).boundingClientRect():a.selectViewport().scrollOffset(),a.exec(function(e){if(!e[0])return void r(Error("Label not found"));var a=e[1].scrollTop+e[0].top-(e[2]?e[2].top:0)+(n||parseInt(i.data.useAnchor)||0);i._in?i._in.page.setData(t({},i._in.scrollTop,a)):wx.pageScrollTo({scrollTop:a,duration:300}),o()})})},getText:function(e){var t="";return function e(n){for(var i=0;i<n.length;i++){var o=n[i];if("text"===o.type)t+=o.text.replace(/&/g,"&");else if("br"===o.name)t+="\n";else{var r="p"===o.name||"div"===o.name||"tr"===o.name||"li"===o.name||"h"===o.name[0]&&o.name[1]>"0"&&o.name[1]<"7";r&&t&&"\n"!==t[t.length-1]&&(t+="\n"),o.children&&e(o.children),r&&"\n"!==t[t.length-1]?t+="\n":"td"!==o.name&&"th"!==o.name||(t+="\t")}}}(e||this.data.nodes),t},getRect:function(){var e=this;return new Promise(function(t,n){wx.createSelectorQuery().in(e).select("._root").boundingClientRect().exec(function(e){return e[0]?t(e[0]):n(Error("Root label not found"))})})},pauseMedia:function(){for(var e=(this._videos||[]).length;e--;)this._videos[e].pause()},setPlaybackRate:function(e){this.playbackRate=e;for(var t=(this._videos||[]).length;t--;)this._videos[t].playbackRate(e)},setContent:function(e,t){var n=this;this.imgList&&t||(this.imgList=[]),this._videos=[];var i={},r=new o(this).parse(e);if(t)for(var a=this.data.nodes.length,s=r.length;s--;)i["nodes[".concat(a+s,"]")]=r[s];else i.nodes=r;if(this.setData(i,function(){n._hook("onLoad"),n.triggerEvent("load")}),this.data.lazyLoad||this.imgList._unloadimgs<this.imgList.length/2){var l=0,c=function e(t){t&&t.height||(t={}),t.height===l?n.triggerEvent("ready",t):(l=t.height,setTimeout(function(){n.getRect().then(e).catch(e)},350))};this.getRect().then(c).catch(c)}else this.imgList._unloadimgs||this.getRect().then(function(e){n.triggerEvent("ready",e)}).catch(function(){n.triggerEvent("ready",{})})},_hook:function(e){for(var t=r.length;t--;)this.plugins[t][e]&&this.plugins[t][e]()},_add:function(e){e.detail.root=this}}});
|
||||
1
bingchat/miniprogram_npm/mp-html/index.json
Normal file
1
bingchat/miniprogram_npm/mp-html/index.json
Normal file
@ -0,0 +1 @@
|
||||
{"component":true,"usingComponents":{"node":"./node/node"}}
|
||||
1
bingchat/miniprogram_npm/mp-html/index.wxml
Normal file
1
bingchat/miniprogram_npm/mp-html/index.wxml
Normal file
@ -0,0 +1 @@
|
||||
<view class="_root {{selectable?'_select':''}}" style="{{containerStyle}}"><slot wx:if="{{!nodes[0]}}"/><node id="_root" childs="{{nodes}}" opts="{{[lazyLoad,loadingImg,errorImg,showImgMenu,selectable]}}" catchadd="_add"/></view>
|
||||
1
bingchat/miniprogram_npm/mp-html/index.wxss
Normal file
1
bingchat/miniprogram_npm/mp-html/index.wxss
Normal file
@ -0,0 +1 @@
|
||||
._root{padding:1px 0;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}._select{-webkit-user-select:text;user-select:text}
|
||||
1
bingchat/miniprogram_npm/mp-html/latex/index.js
Normal file
1
bingchat/miniprogram_npm/mp-html/latex/index.js
Normal file
@ -0,0 +1 @@
|
||||
"use strict";function t(){}var e=require("./katex.min");t.prototype.onParse=function(t,n){!n.options.editable&&"text"===t.type&&/\$(.+?)\$/.test(t.text)&&(delete t.type,t.name="span",t.attrs={},t.children=t.text.split("$").map(function(t,n){return(n+1)%2==0?{name:"span",attrs:{},children:e.default(t)}:{type:"text",text:t}}),delete t.text)},module.exports=t;
|
||||
1
bingchat/miniprogram_npm/mp-html/latex/katex.min.js
vendored
Normal file
1
bingchat/miniprogram_npm/mp-html/latex/katex.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
bingchat/miniprogram_npm/mp-html/markdown/index.js
Normal file
1
bingchat/miniprogram_npm/mp-html/markdown/index.js
Normal file
@ -0,0 +1 @@
|
||||
"use strict";function t(t){this.vm=t,t._ids={}}var e=require("./marked.min"),a=0;t.prototype.onUpdate=function(t){if(this.vm.data.markdown)return e(t)},t.prototype.onParse=function(t,e){if(e.options.markdown){if(e.options.useAnchor&&t.attrs&&/[\u4e00-\u9fa5]/.test(t.attrs.id)){var n="t"+a++;this.vm._ids[t.attrs.id]=n,t.attrs.id=n}"p"!==t.name&&"table"!==t.name&&"tr"!==t.name&&"th"!==t.name&&"td"!==t.name&&"blockquote"!==t.name&&"pre"!==t.name&&"code"!==t.name||(t.attrs.class="md-".concat(t.name," ").concat(t.attrs.class||""))}},module.exports=t;
|
||||
6
bingchat/miniprogram_npm/mp-html/markdown/marked.min.js
vendored
Normal file
6
bingchat/miniprogram_npm/mp-html/markdown/marked.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
bingchat/miniprogram_npm/mp-html/node/node.js
Normal file
1
bingchat/miniprogram_npm/mp-html/node/node.js
Normal file
@ -0,0 +1 @@
|
||||
"use strict";function t(e){"@babel/helpers - typeof";return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e,i){return e=r(e),e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function r(e){var r=i(e,"string");return"symbol"===t(r)?r:String(r)}function i(e,r){if("object"!==t(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var o=i.call(e,r||"default");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}Component({data:{ctrl:{},isiOS:wx.getSystemInfoSync().system.includes("iOS")},properties:{childs:Array,opts:Array},options:{addGlobalClass:!0},attached:function(){this.triggerEvent("add",this,{bubbles:!0,composed:!0})},methods:{copyCode:function(t){wx.showActionSheet({itemList:["复制代码"],success:function(){return wx.setClipboardData({data:t.currentTarget.dataset.content})}})},noop:function(){},getNode:function(t){try{for(var e=t.split("_"),r=this.data.childs[e[0]],i=1;i<e.length;i++)r=r.children[e[i]];return r}catch(t){return{text:"",attrs:{},children:[]}}},play:function(t){if(this.root.triggerEvent("play"),this.root.data.pauseVideo){for(var e=!1,r=t.target.id,i=this.root._videos.length;i--;)this.root._videos[i].id===r?e=!0:this.root._videos[i].pause();if(!e){var o=wx.createVideoContext(r,this);o.id=r,this.root.playbackRate&&o.playbackRate(this.root.playbackRate),this.root._videos.push(o)}}},imgTap:function(t){var e=this.getNode(t.target.dataset.i);if(e.a)return this.linkTap(e.a);if(!e.attrs.ignore&&(this.root.triggerEvent("imgtap",e.attrs),this.root.data.previewImg)){var r=this.root.imgList[e.i];wx.previewImage({showmenu:this.root.data.showImgMenu,current:r,urls:this.root.imgList})}},imgLoad:function(t){var r,i=t.target.dataset.i,o=this.getNode(i);o.w?(this.data.opts[1]&&!this.data.ctrl[i]||-1===this.data.ctrl[i])&&(r=1):r=t.detail.width,r&&this.setData(e({},"ctrl."+i,r)),this.checkReady()},checkReady:function(){var t=this;this.root.data.lazyLoad||(this.root.imgList._unloadimgs-=1,this.root.imgList._unloadimgs||setTimeout(function(){t.root.getRect().then(function(e){t.root.triggerEvent("ready",e)}).catch(function(){t.root.triggerEvent("ready",{})})},350))},linkTap:function(t){var e=t.currentTarget?this.getNode(t.currentTarget.dataset.i):{},r=e.attrs||t,i=r.href;this.root.triggerEvent("linktap",Object.assign({innerText:this.root.getText(e.children||[])},r)),i&&("#"===i[0]?this.root.navigateTo(i.substring(1)).catch(function(){}):i.split("?")[0].includes("://")?this.root.data.copyLink&&wx.setClipboardData({data:i,success:function(){return wx.showToast({title:"链接已复制"})}}):wx.navigateTo({url:i,fail:function(){wx.switchTab({url:i,fail:function(){}})}}))},mediaError:function(t){var r=t.target.dataset.i,i=this.getNode(r);if("video"===i.name||"audio"===i.name){var o=(this.data.ctrl[r]||0)+1;if(o>i.src.length&&(o=0),o<i.src.length)return this.setData(e({},"ctrl."+r,o))}else"img"===i.name&&(this.data.opts[2]&&this.setData(e({},"ctrl."+r,-1)),this.checkReady());this.root&&this.root.triggerEvent("error",{source:i.name,attrs:i.attrs,errMsg:t.detail.errMsg})}}});
|
||||
1
bingchat/miniprogram_npm/mp-html/node/node.json
Normal file
1
bingchat/miniprogram_npm/mp-html/node/node.json
Normal file
@ -0,0 +1 @@
|
||||
{"component":true,"usingComponents":{"node":"./node"}}
|
||||
1
bingchat/miniprogram_npm/mp-html/node/node.wxml
Normal file
1
bingchat/miniprogram_npm/mp-html/node/node.wxml
Normal file
@ -0,0 +1 @@
|
||||
<wxs module="isInline">var e={abbr:!0,b:!0,big:!0,code:!0,del:!0,em:!0,i:!0,ins:!0,label:!0,q:!0,small:!0,span:!0,strong:!0,sub:!0,sup:!0};module.exports=function(n,i){return e[n]||-1!==(i||"").indexOf("inline")};</wxs><template name="el"><block wx:if="{{n.name==='img'}}"><rich-text wx:if="{{n.t}}" style="display:{{n.t}}" nodes="<img class='_img' style='{{n.attrs.style}}' src='{{n.attrs.src}}'>" data-i="{{i}}" catchtap="imgTap"/><block wx:else><image wx:if="{{(opts[1]&&!ctrl[i])||ctrl[i]<0}}" class="_img" style="{{n.attrs.style}}" src="{{ctrl[i]<0?opts[2]:opts[1]}}" mode="widthFix"/><image id="{{n.attrs.id}}" class="_img {{n.attrs.class}}" style="{{ctrl[i]===-1?'display:none;':''}}width:{{ctrl[i]||1}}px;height:1px;{{n.attrs.style}}" src="{{n.attrs.src}}" mode="{{!n.h?'widthFix':(!n.w?'heightFix':'')}}" lazy-load="{{opts[0]}}" webp="{{n.webp}}" show-menu-by-longpress="{{opts[3]&&!n.attrs.ignore}}" data-i="{{i}}" bindload="imgLoad" binderror="mediaError" catchtap="imgTap" bindlongpress="noop"/></block></block><text wx:elif="{{n.text}}" user-select="{{opts[4]=='force'&&isiOS}}" decode>{{n.text}}</text><text wx:elif="{{n.name==='br'}}">\n</text><view wx:elif="{{n.name==='a'}}" id="{{n.attrs.id}}" class="{{n.attrs.href?'_a ':''}}{{n.attrs.class}}" hover-class="_hover" style="display:inline;{{n.attrs.style}}" data-i="{{i}}" catchtap="linkTap"><node childs="{{n.children}}" opts="{{opts}}" style="display:inherit"/></view><video wx:elif="{{n.name==='video'}}" id="{{n.attrs.id}}" class="{{n.attrs.class}}" style="{{n.attrs.style}}" autoplay="{{n.attrs.autoplay}}" controls="{{n.attrs.controls}}" loop="{{n.attrs.loop}}" muted="{{n.attrs.muted}}" object-fit="{{n.attrs['object-fit']}}" poster="{{n.attrs.poster}}" src="{{n.src[ctrl[i]||0]}}" data-i="{{i}}" bindplay="play" binderror="mediaError"/><audio wx:elif="{{n.name==='audio'}}" id="{{n.attrs.id}}" class="{{n.attrs.class}}" style="{{n.attrs.style}}" author="{{n.attrs.author}}" controls="{{n.attrs.controls}}" loop="{{n.attrs.loop}}" name="{{n.attrs.name}}" poster="{{n.attrs.poster}}" src="{{n.src[ctrl[i]||0]}}" data-i="{{i}}" bindplay="play" binderror="mediaError"/><rich-text wx:elif="{{n.attrs['data-content']}}" nodes="{{[n]}}" data-content="{{n.attrs['data-content']}}" data-lang="{{n.attrs['data-lang']}}" bindlongpress="copyCode"/><rich-text wx:else id="{{n.attrs.id}}" style="{{n.f}}" user-select="{{opts[4]}}" nodes="{{[n]}}"/></template><block wx:for="{{childs}}" wx:for-item="n1" wx:for-index="i1" wx:key="i1"><template wx:if="{{!n1.c&&(!n1.children||n1.name==='a'||!isInline(n1.name,n1.attrs.style))}}" is="el" data="{{n:n1,i:''+i1,opts:opts,ctrl:ctrl}}"/><view wx:else id="{{n1.attrs.id}}" class="_{{n1.name}} {{n1.attrs.class}}" style="{{n1.attrs.style}}"><block wx:for="{{n1.children}}" wx:for-item="n2" wx:for-index="i2" wx:key="i2"><template wx:if="{{!n2.c&&(!n2.children||n2.name==='a'||!isInline(n2.name,n2.attrs.style))}}" is="el" data="{{n:n2,i:i1+'_'+i2,opts:opts,ctrl:ctrl}}"/><view wx:else id="{{n2.attrs.id}}" class="_{{n2.name}} {{n2.attrs.class}}" style="{{n2.attrs.style}}"><block wx:for="{{n2.children}}" wx:for-item="n3" wx:for-index="i3" wx:key="i3"><template wx:if="{{!n3.c&&(!n3.children||n3.name==='a'||!isInline(n3.name,n3.attrs.style))}}" is="el" data="{{n:n3,i:i1+'_'+i2+'_'+i3,opts:opts,ctrl:ctrl}}"/><view wx:else id="{{n3.attrs.id}}" class="_{{n3.name}} {{n3.attrs.class}}" style="{{n3.attrs.style}}"><block wx:for="{{n3.children}}" wx:for-item="n4" wx:for-index="i4" wx:key="i4"><template wx:if="{{!n4.c&&(!n4.children||n4.name==='a'||!isInline(n4.name,n4.attrs.style))}}" is="el" data="{{n:n4,i:i1+'_'+i2+'_'+i3+'_'+i4,opts:opts,ctrl:ctrl}}"/><view wx:else id="{{n4.attrs.id}}" class="_{{n4.name}} {{n4.attrs.class}}" style="{{n4.attrs.style}}"><block wx:for="{{n4.children}}" wx:for-item="n5" wx:for-index="i5" wx:key="i5"><template wx:if="{{!n5.c&&(!n5.children||n5.name==='a'||!isInline(n5.name,n5.attrs.style))}}" is="el" data="{{n:n5,i:i1+'_'+i2+'_'+i3+'_'+i4+'_'+i5,opts:opts,ctrl:ctrl}}"/><node wx:else id="{{n5.attrs.id}}" class="_{{n5.name}} {{n5.attrs.class}}" style="{{n5.attrs.style}}" childs="{{n5.children}}" opts="{{opts}}"/></block></view></block></view></block></view></block></view></block>
|
||||
1
bingchat/miniprogram_npm/mp-html/node/node.wxss
Normal file
1
bingchat/miniprogram_npm/mp-html/node/node.wxss
Normal file
File diff suppressed because one or more lines are too long
1
bingchat/miniprogram_npm/mp-html/parser.js
Normal file
1
bingchat/miniprogram_npm/mp-html/parser.js
Normal file
File diff suppressed because one or more lines are too long
1
bingchat/miniprogram_npm/mp-html/style/index.js
Normal file
1
bingchat/miniprogram_npm/mp-html/style/index.js
Normal file
@ -0,0 +1 @@
|
||||
"use strict";function t(){this.styles=[]}function e(t,e){function r(e){if("#"===e[0]){if(t.attrs.id&&t.attrs.id.trim()===e.substr(1))return 3}else if("."===e[0]){e=e.substr(1);for(var r=(t.attrs.class||"").split(" "),s=0;s<r.length;s++)if(r[s].trim()===e)return 2}else if(t.name===e)return 1;return 0}if(e instanceof Array){for(var s=0,n=0;n<e.length;n++){var i=r(e[n]);if(!i)return 0;i>s&&(s=i)}return s}return r(e)}var r=require("./parser");t.prototype.onParse=function(t,s){var n=this;if("style"===t.name&&t.children.length&&"text"===t.children[0].type)this.styles=this.styles.concat((new r).parse(t.children[0].text));else if(t.name){for(var i=["","","",""],l=0,a=this.styles.length;l<a;l++)!function(){var r,a=n.styles[l],f=e(t,a.key||a.list[a.list.length-1]);if(f){if(!a.key){r=a.list.length-2;for(var c=s.stack.length;r>=0&&c--;)if(">"===a.list[r]){if(r<1||r>a.list.length-2)break;e(s.stack[c],a.list[r-1])?r-=2:r++}else e(s.stack[c],a.list[r])&&r--;f=4}if(a.key||r<0)if(a.pseudo&&t.children){var u;a.style=a.style.replace(/content:([^;]+)/,function(e,r){return u=r.replace(/['"]/g,"").replace(/attr\((.+?)\)/,function(e,r){return t.attrs[r.trim()]||""}).replace(/\\(\w{4})/,function(t,e){return String.fromCharCode(parseInt(e,16))}),""});var o={name:"span",attrs:{style:a.style},children:[{type:"text",text:u}]};"before"===a.pseudo?t.children.unshift(o):t.children.push(o)}else i[f-1]+=a.style+(";"===a.style[a.style.length-1]?"":";")}}();i=i.join(""),i.length>2&&(t.attrs.style=i+(t.attrs.style||""))}},module.exports=t;
|
||||
1
bingchat/miniprogram_npm/mp-html/style/parser.js
Normal file
1
bingchat/miniprogram_npm/mp-html/style/parser.js
Normal file
@ -0,0 +1 @@
|
||||
"use strict";function t(){this.styles=[],this.selectors=[]}function s(t){this.selector="",this.style="",this.handler=t}var i={" ":!0,"\n":!0,"\t":!0,"\r":!0,"\f":!0};t.prototype.parse=function(t){return new s(this).parse(t),this.styles},t.prototype.onSelector=function(t){function s(t){var s,i,e=[];for(s=1,i=0;s<t.length;s++)"."!==t[s]&&"#"!==t[s]||(e.push(t.substring(i,s)),i=s);return e.length?(e.push(t.substring(i,s)),e):t}if(!(t.includes("[")||t.includes("*")||t.includes("@"))){var i={};if(t.includes(":")){var e=t.split(":"),n=e.pop();if("before"!==n&&"after"!==n)return;i.pseudo=n,t=e[0]}if(t.includes(" ")){i.list=[];for(var o=t.split(" "),h=0;h<o.length;h++)if(o[h].length)for(var r=o[h].split(">"),l=0;l<r.length;l++)i.list.push(s(r[l])),l<r.length-1&&i.list.push(">")}else i.key=s(t);this.selectors.push(i)}},t.prototype.onContent=function(t){for(var s=0;s<this.selectors.length;s++)this.selectors[s].style=t;this.styles=this.styles.concat(this.selectors),this.selectors=[]},s.prototype.parse=function(t){this.i=0,this.content=t,this.state=this.blank;for(var s=t.length;this.i<s;this.i++)this.state(t[this.i])},s.prototype.comment=function(){this.i=this.content.indexOf("*/",this.i)+1,this.i||(this.i=this.content.length)},s.prototype.blank=function(t){if(!i[t]){if("/"===t&&"*"===this.content[this.i+1])return void this.comment();this.selector+=t,this.state=this.name}},s.prototype.name=function(t){if("/"===t&&"*"===this.content[this.i+1])return void this.comment();if("{"===t||","===t||";"===t){if(this.handler.onSelector(this.selector.trimEnd()),this.selector="","{"!==t)for(;i[this.content[++this.i]];);"{"===this.content[this.i]?(this.floor=1,this.state=this.val):this.selector+=this.content[this.i]}else i[t]?this.selector+=" ":this.selector+=t},s.prototype.val=function(t){if("/"===t&&"*"===this.content[this.i+1])return void this.comment();if("{"===t)this.floor++;else if("}"===t&&!--this.floor)return this.handler.onContent(this.style),this.style="",void(this.state=this.blank);this.style+=t},module.exports=t;
|
||||
17
bingchat/package-lock.json
generated
Normal file
17
bingchat/package-lock.json
generated
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "bingchat",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"mp-html": "^2.4.1"
|
||||
}
|
||||
},
|
||||
"node_modules/mp-html": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/mp-html/-/mp-html-2.4.1.tgz",
|
||||
"integrity": "sha512-io/SMZwmlqQwWuD3AwpnVslvR/Xz7xhhbAxHQ3n5ooQQQ1v2tF+ikEfyepAdOi4lUePZ70VM3hEV3EEGamkhVA=="
|
||||
}
|
||||
}
|
||||
}
|
||||
5
bingchat/package.json
Normal file
5
bingchat/package.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"mp-html": "^2.4.1"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user