From 41234631f87c702fd3c400574bdd355fd23f5b12 Mon Sep 17 00:00:00 2001 From: nineya <361654768@qq.com> Date: Wed, 20 Dec 2023 19:23:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(editorOptions):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8E=A7=E4=BB=B6=E5=BD=B1=E5=93=8D?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E7=BB=93=E6=9E=9C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/js/editor-options.min.js | 22 ++++++++++++++- src/js/editor-options.js | 48 ++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 19 deletions(-) diff --git a/source/js/editor-options.min.js b/source/js/editor-options.min.js index f5d5c16..3e3384e 100644 --- a/source/js/editor-options.min.js +++ b/source/js/editor-options.min.js @@ -1 +1,21 @@ -!function(){const a=[{value:"$副标题",html:"mew-subtitle | 副标题"},{value:'',html:"mew-music | 网易云单曲"},{value:'',html:"mew-music | 网易云歌单"},{value:'',html:"mew-music | 自定义单曲"},{value:'',html:"mew-bilibili | bilibili视频"},{value:'\n\n$第一页内容\n\n\n$第二页内容\n\n',html:"mew-tabs | 标签页"},{value:'$文件资源描述说明',html:"mew-cloud | 网盘链接"},{value:'',html:"mew-progress | 进度条"},{value:'\n$面板内容\n',html:"mew-panel | 面板"},{value:'$消息内容',html:"mew-message | 消息"},{value:"",html:"mew-hr | 信封分割线"},{value:'\n $时间标题\n $时间子项1具体内容\n $时间子项2具体内容\n',html:"mew-timeline | 时间线"},{value:'打开博客 ',html:"mew-btn | 按钮"},{value:'$引言内容',html:"mew-quote | 引言"},{value:'$网页摘要说明',html:"mew-link | 外部链接"},{value:'',html:"mew-link | 博客文章/页面链接"},{value:'',html:"mew-video | 视频播放器"},{value:'\n $图1描述\n $图2描述\n',html:"mew-photos | 画廊"},{value:"\n$被隔离的内容\n",html:"mew-raw | 样式隔离"},{value:"\n$评论后可见的内容\n",html:"mew-hide | 评论后可见"}];window.handleEditorOptions=e=>(new Set(a.map(e=>e.html).map(e=>e.substring(0,e.indexOf(" ")))).forEach(e=>{customElements.get(e)||customElements.define(e,class extends HTMLElement{constructor(){super(),this.hasAttribute("draw")||(this.innerText=this.outerHTML,this.style="display: block;background: #eee;padding: 9px;border-radius: 5px;color: #999;font-family: monospace;",this.setAttribute("draw",!0))}})}),{hint:{emoji:function(){let i={};return["hehe","haha","tushe","a","ku","nu","kaixin","han","lei","heixian","bishi","bugaoxing","zhenbang","qian","yiwen","yingxiang","tu","yi","weiqu","huaxin","hu","xiaoyan","len","taikaixin","huaji","mianqiang","kuanhan","guai","shuijiao","jingku","shengqi","jingya","pen","turanxingfen","wabi","tanshou","wuzuixiao","hejiu","xili","landeli","zhayao","chigua","xiaoguai","nidongde","heiheihei","huanhu","xiaoniao","suanshuang","jinzhang","anzhongguancha","xiaohonglian","yamiedie","weiweiyixiao","what","tuosai","pu","kunchenggou","kejianzhongguancha","caigou","laohu","aowu","aoteman","heitougaoxing","heitoudengyan","wangyuanjing","butin","ganfan","damuzhi","shengli","haha2","ok","honglingjin","aixin","xinsui","meigui","liwu","yanhua","caihong","taiyang","xingxingyueliang","dangao","chabei","xiangjiao","bianbian","yaowan","qianbi","lazhu","shafa","yinyue","dengpao","shouzhi"].forEach(e=>{i[e]=`/themes/dream/source/img/emoji/${e}.png`}),i}(),extend:[{key:"a.filter(e=>-1$副标题",html:"mew-subtitle | 副标题"},{value:'',html:"mew-music | 网易云单曲"},{value:'',html:"mew-music | 网易云歌单"},{value:'',html:"mew-music | 自定义单曲"},{value:'',html:"mew-bilibili | bilibili视频"},{value:'\n\n$第一页内容\n\n\n$第二页内容\n\n',html:"mew-tabs | 标签页"},{value:'$文件资源描述说明',html:"mew-cloud | 网盘链接"},{value:'',html:"mew-progress | 进度条"},{value:'\n$面板内容\n',html:"mew-panel | 面板"},{value:'$消息内容',html:"mew-message | 消息"},{value:"",html:"mew-hr | 信封分割线"},{value:'\n $时间标题\n $时间子项1具体内容\n $时间子项2具体内容\n',html:"mew-timeline | 时间线"},{value:'打开博客 ',html:"mew-btn | 按钮"},{value:'$引言内容',html:"mew-quote | 引言"},{value:'$网页摘要说明',html:"mew-link | 外部链接"},{value:'',html:"mew-link | 博客文章/页面链接"},{value:'',html:"mew-video | 视频播放器"},{value:'\n $图1描述\n $图2描述\n',html:"mew-photos | 画廊"},{value:"\n$被隔离的内容\n",html:"mew-raw | 样式隔离"},{value:"\n$评论后可见的内容\n",html:"mew-hide | 评论后可见"}];window.handleEditorOptions=e=>{return i=Array.from(new Set(n.map(e=>e.html).map(e=>e.substring(0,e.indexOf(" "))))).map(e=>e+` { + position: relative; + display: block; + width: 100%; + height: 48px; + overflow: hidden; +} + +${e}:before { + content: '${e} 自定义元素'; + position: absolute; + display: block; + background: #eee; + border-radius: 8px; + height: 48px; + padding: 10px; + width: 100%; + text-align: center; + font-family: monospace; + color: #999; +}`).join("\n"),(a=document.createElement("style")).appendChild(document.createTextNode(i)),document.getElementById("vditor").before(a),{hint:{emoji:function(){let i={};return["hehe","haha","tushe","a","ku","nu","kaixin","han","lei","heixian","bishi","bugaoxing","zhenbang","qian","yiwen","yingxiang","tu","yi","weiqu","huaxin","hu","xiaoyan","len","taikaixin","huaji","mianqiang","kuanhan","guai","shuijiao","jingku","shengqi","jingya","pen","turanxingfen","wabi","tanshou","wuzuixiao","hejiu","xili","landeli","zhayao","chigua","xiaoguai","nidongde","heiheihei","huanhu","xiaoniao","suanshuang","jinzhang","anzhongguancha","xiaohonglian","yamiedie","weiweiyixiao","what","tuosai","pu","kunchenggou","kejianzhongguancha","caigou","laohu","aowu","aoteman","heitougaoxing","heitoudengyan","wangyuanjing","butin","ganfan","damuzhi","shengli","haha2","ok","honglingjin","aixin","xinsui","meigui","liwu","yanhua","caihong","taiyang","xingxingyueliang","dangao","chabei","xiangjiao","bianbian","yaowan","qianbi","lazhu","shafa","yinyue","dengpao","shouzhi"].forEach(e=>{i[e]=`/themes/dream/source/img/emoji/${e}.png`}),i}(),extend:[{key:"n.filter(e=>-1 item.html) - .map(html => html.substring(0, html.indexOf(' ')))) - customs.forEach(item => { - if (customElements.get(item)) { - return - } - customElements.define(item, - class extends HTMLElement { - constructor() { - super() - if (this.hasAttribute('draw')) return - this.innerText = this.outerHTML - this.style = 'display: block;background: #eee;padding: 9px;border-radius: 5px;color: #999;font-family: monospace;' - this.setAttribute('draw', true) - } - }) - }) + let cssText = Array.from( + new Set(customElement + .map(item => item.html) + .map(html => html.substring(0, html.indexOf(' '))) + ) + ).map(item => `${item} { + position: relative; + display: block; + width: 100%; + height: 48px; + overflow: hidden; +} + +${item}:before { + content: '${item} 自定义元素'; + position: absolute; + display: block; + background: #eee; + border-radius: 8px; + height: 48px; + padding: 10px; + width: 100%; + text-align: center; + font-family: monospace; + color: #999; +}`) + .join('\n') + const style = document.createElement('style') + style.appendChild(document.createTextNode(cssText)) + document.getElementById('vditor').before(style) } function handleEmojiImg() {