This commit is contained in:
haoouba 2021-04-21 22:48:18 +08:00
parent ba0938b5d3
commit 6af7d8f87c
17 changed files with 944 additions and 816 deletions

View File

@ -38,19 +38,59 @@ document.addEventListener('DOMContentLoaded', () => {
} }
} }
window.customElements.define('joe-bilibili', JoeBilibili); window.customElements.define('joe-bilibili', JoeBilibili);
class JoeMp3 extends HTMLElement {
constructor() {
super();
this.options = {
name: this.getAttribute('name'),
url: this.getAttribute('url'),
theme: this.getAttribute('theme') || '#1989fa',
cover: this.getAttribute('cover'),
autoplay: this.getAttribute('autoplay') ? true : false
};
this.render();
}
render() {
if (!this.options.url) return (this.innerHTML = '音频地址未填写!');
this.innerHTML = '<div></div>';
new APlayer({
container: this.querySelector('div'),
theme: this.options.theme,
autoplay: this.options.autoplay,
audio: [
{
url: this.options.url,
name: this.options.name,
cover: this.options.cover
}
]
});
}
}
window.customElements.define('joe-mp3', JoeMp3);
class JoeMusic extends HTMLElement { class JoeMusic extends HTMLElement {
constructor() { constructor() {
super(); super();
this.options = { this.options = {
id: this.getAttribute('id'), id: this.getAttribute('id'),
width: this.getAttribute('width') || '100%', color: this.getAttribute('color') || '#1989fa',
autoplay: this.getAttribute('autoplay') ? 1 : 0 autoplay: this.getAttribute('autoplay') ? true : false
}; };
this.render(); this.render();
} }
render() { render() {
if (this.options.id) this.innerHTML = `<iframe style="display: block; margin: 0 auto; border: 0;" width="${this.options.width}" height="86px" src="//music.163.com/outchain/player?type=2&id=${this.options.id}&auto=${this.options.autoplay}&height=66"></iframe>`; if (!this.options.id) return (this.innerHTML = '网易云歌曲ID未填写');
else this.innerHTML = '网易云歌曲ID未填写'; this.innerHTML = '<div></div>';
fetch('https://api.i-meto.com/meting/api?server=netease&type=song&id=' + this.options.id).then(async response => {
const audio = await response.json();
new APlayer({
container: this.querySelector('div'),
lrcType: 3,
theme: this.options.color,
autoplay: this.options.autoplay,
audio
});
});
} }
} }
window.customElements.define('joe-music', JoeMusic); window.customElements.define('joe-music', JoeMusic);
@ -59,17 +99,24 @@ document.addEventListener('DOMContentLoaded', () => {
super(); super();
this.options = { this.options = {
id: this.getAttribute('id'), id: this.getAttribute('id'),
width: this.getAttribute('width') || '100%', color: this.getAttribute('color') || '#1989fa',
autoplay: this.getAttribute('autoplay') ? 1 : 0 autoplay: this.getAttribute('autoplay') ? true : false
}; };
this.render(); this.render();
} }
get template() {
return `<iframe style="display: block; margin: 0 auto; border: 0;" width="${this.options.width}" height="450px" src="//music.163.com/outchain/player?type=0&id=${this.options.id}&auto=${this.options.autoplay}&height=430"></iframe>`;
}
render() { render() {
if (this.options.id) this.innerHTML = this.template; if (!this.options.id) return (this.innerHTML = '网易云歌单ID未填写');
else this.innerHTML = '网易云歌单ID未填写'; this.innerHTML = '<div></div>';
fetch('https://api.i-meto.com/meting/api?server=netease&type=playlist&id=' + this.options.id).then(async response => {
const audio = await response.json();
new APlayer({
container: this.querySelector('div'),
lrcType: 3,
theme: this.options.color,
autoplay: this.options.autoplay,
audio
});
});
} }
} }
window.customElements.define('joe-mlist', JoeMlist); window.customElements.define('joe-mlist', JoeMlist);
@ -222,8 +269,7 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-callout', JoeCallout); window.customElements.define('joe-callout', JoeCallout);
const article = document.querySelector('.joe_detail__article'); $('.joe_detail__article p:empty').remove();
if (article) article.innerHTML = article.innerHTML.replace(/<p><\/p>/g, '');
/* /*
------------------------以下未测试------------------------------------------ ------------------------以下未测试------------------------------------------

File diff suppressed because one or more lines are too long

View File

@ -47,9 +47,10 @@ class Editor
public static function Edit() public static function Edit()
{ {
?> ?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-tomorrow.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-tomorrow.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="<?php Helper::options()->themeUrl('typecho/write/css/joe.write.min.css?v=2021042116') ?>"> <link rel="stylesheet" href="<?php Helper::options()->themeUrl('typecho/write/css/joe.write.min.css?v=2021042122') ?>">
<script> <script>
window.JoeConfig = { window.JoeConfig = {
uploadAPI: '<?php Helper::security()->index('/action/upload'); ?>', uploadAPI: '<?php Helper::security()->index('/action/upload'); ?>',
@ -61,10 +62,11 @@ class Editor
themeURL: '<?php Helper::options()->themeUrl(); ?>' themeURL: '<?php Helper::options()->themeUrl(); ?>'
} }
</script> </script>
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.2.4/plugin/prism/prism.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.2.4/plugin/prism/prism.min.js"></script>
<script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.parse.min.js?v=2021042116') ?>"></script> <script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.parse.min.js?v=2021042122') ?>"></script>
<script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.write.chunk.js?v=2021042116') ?>"></script> <script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.write.chunk.js?v=2021042122') ?>"></script>
<script src="<?php Helper::options()->themeUrl('assets/js/joe.short.min.js?v=2021042116') ?>"></script> <script src="<?php Helper::options()->themeUrl('assets/js/joe.short.min.js?v=2021042122') ?>"></script>
<?php <?php
} }
} }

View File

@ -2,7 +2,7 @@
/* 获取主题当前版本号 */ /* 获取主题当前版本号 */
function _getVersion() function _getVersion()
{ {
return "6.5.2"; return "6.5.3";
}; };
/* 判断是否是手机 */ /* 判断是否是手机 */

View File

@ -15,6 +15,9 @@ function _parseContent($post, $login)
$content = preg_replace('/{music-list([^}]*)\/}/SU', '<joe-mlist $1></joe-mlist>', $content); $content = preg_replace('/{music-list([^}]*)\/}/SU', '<joe-mlist $1></joe-mlist>', $content);
$content = preg_replace('/{music([^}]*)\/}/SU', '<joe-music $1></joe-music>', $content); $content = preg_replace('/{music([^}]*)\/}/SU', '<joe-music $1></joe-music>', $content);
} }
if (strpos($content, '{mp3') !== false) {
$content = preg_replace('/{mp3([^}]*)\/}/SU', '<joe-mp3 $1></joe-mp3>', $content);
}
if (strpos($content, '{bilibili') !== false) { if (strpos($content, '{bilibili') !== false) {
$content = preg_replace('/{bilibili([^}]*)\/}/SU', '<joe-bilibili $1></joe-bilibili>', $content); $content = preg_replace('/{bilibili([^}]*)\/}/SU', '<joe-bilibili $1></joe-bilibili>', $content);
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "typecho-joe-next", "name": "typecho-joe-next",
"version": "6.5.2", "version": "6.5.3",
"description": "A Theme Of Typecho", "description": "A Theme Of Typecho",
"main": "index.php", "main": "index.php",
"keywords": [ "keywords": [

View File

@ -31,8 +31,6 @@
</div> </div>
</div> </div>
<div class="joe_aplayer"></div>
<script> <script>
console.log("%c页面加载耗时<?php _endCountTime(); ?> | Theme By Joe", "color:#fff; background: linear-gradient(270deg, #986fee, #8695e6, #68b7dd, #18d7d3); padding: 8px 15px; border-radius: 0 15px 0 15px"); console.log("%c页面加载耗时<?php _endCountTime(); ?> | Theme By Joe", "color:#fff; background: linear-gradient(270deg, #986fee, #8695e6, #68b7dd, #18d7d3); padding: 8px 15px; border-radius: 0 15px 0 15px");
<?php $this->options->JCustomScript() ?> <?php $this->options->JCustomScript() ?>

View File

@ -18,15 +18,17 @@
<?php endif; ?> <?php endif; ?>
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.mode.min.css'); ?>"> <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.mode.min.css'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.normalize.min.css'); ?>"> <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.normalize.min.css'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.global.min.css?v=2021042116'); ?>"> <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.global.min.css?v=2021042122'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.responsive.min.css'); ?>"> <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.responsive.min.css'); ?>">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.0.0/plugin/qmsg/qmsg.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.0.0/plugin/qmsg/qmsg.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.7.2/animate.min.css" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.7.2/animate.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.0.0/plugin/scroll/joe.scroll.js"></script> <script src="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.0.0/plugin/scroll/joe.scroll.js"></script>
<script src="https://cdn.jsdelivr.net/npm/lazysizes@5.3.0/lazysizes.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/lazysizes@5.3.0/lazysizes.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.0.0/plugin/sketchpad/joe.sketchpad.js"></script> <script src="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.0.0/plugin/sketchpad/joe.sketchpad.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.0.0/assets/js/joe.extend.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.0.0/assets/js/joe.extend.min.js"></script>
@ -38,6 +40,6 @@
<?php if ($this->options->JCursorEffects && $this->options->JCursorEffects !== 'off') : ?> <?php if ($this->options->JCursorEffects && $this->options->JCursorEffects !== 'off') : ?>
<script src="<?php $this->options->themeUrl('assets/cursor/' . $this->options->JCursorEffects); ?>" async></script> <script src="<?php $this->options->themeUrl('assets/cursor/' . $this->options->JCursorEffects); ?>" async></script>
<?php endif; ?> <?php endif; ?>
<script src="<?php $this->options->themeUrl('assets/js/joe.global.min.js?v=2021042116'); ?>"></script> <script src="<?php $this->options->themeUrl('assets/js/joe.global.min.js?v=2021042122'); ?>"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.short.min.js?v=2021042116'); ?>"></script> <script src="<?php $this->options->themeUrl('assets/js/joe.short.min.js?v=2021042122'); ?>"></script>
<?php $this->options->JCustomHeadEnd() ?> <?php $this->options->JCustomHeadEnd() ?>

File diff suppressed because one or more lines are too long

View File

@ -206,6 +206,60 @@ body.fullscreen {
border-radius: 3px; border-radius: 3px;
background: #c0c4cc; background: #c0c4cc;
} }
}
.cm-autosave {
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 999;
&::before,
&::after {
content: '';
position: absolute;
top: 0;
width: 0;
height: 3px;
transition: width 0.5s;
}
&::before {
border-radius: 0 1.5px 1.5px 0;
left: 50%;
background: linear-gradient(to right, #4cd964, #5ac8fa, #007aff);
}
&::after {
border-radius: 1.5px 0 0 1.5px;
right: 50%;
background: linear-gradient(to left, #4cd964, #5ac8fa, #007aff);
}
&.active {
&::before,
&::after {
width: 50%;
}
}
}
}
.cm-progress-left,
.cm-progress-right {
position: absolute;
top: 0;
width: 0;
height: 3px;
background-color: #ff5627;
transition: width 0.5s;
z-index: 1;
}
.cm-progress-left {
right: 50%;
border-radius: 1.5px 0 0 1.5px;
}
.cm-progress-right {
left: 50%;
border-radius: 0 1.5px 1.5px 0;
}
}
.cm-preview-content { .cm-preview-content {
padding: 20px; padding: 20px;
font-size: 14px; font-size: 14px;
@ -414,59 +468,6 @@ body.fullscreen {
text-decoration: none; text-decoration: none;
} }
} }
}
.cm-autosave {
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 999;
&::before,
&::after {
content: '';
position: absolute;
top: 0;
width: 0;
height: 3px;
transition: width 0.5s;
}
&::before {
border-radius: 0 1.5px 1.5px 0;
left: 50%;
background: linear-gradient(to right, #4cd964, #5ac8fa, #007aff);
}
&::after {
border-radius: 1.5px 0 0 1.5px;
right: 50%;
background: linear-gradient(to left, #4cd964, #5ac8fa, #007aff);
}
&.active {
&::before,
&::after {
width: 50%;
}
}
}
}
.cm-progress-left,
.cm-progress-right {
position: absolute;
top: 0;
width: 0;
height: 3px;
background-color: #ff5627;
transition: width 0.5s;
z-index: 1;
}
.cm-progress-left {
right: 50%;
border-radius: 1.5px 0 0 1.5px;
}
.cm-progress-right {
left: 50%;
border-radius: 0 1.5px 1.5px 0;
}
}
.cm-modal { .cm-modal {
display: flex; display: flex;

View File

@ -350,15 +350,15 @@ export default class JoeAction {
} }
handleNetease(cm, type) { handleNetease(cm, type) {
this._openModal({ this._openModal({
title: type ? '网易云歌单' : '网云单首', title: type ? '网易云歌单' : '网云单首',
innerHtml: ` innerHtml: `
<div class="fitem"> <div class="fitem">
<label>歌${type ? '单' : '曲'} ID</label> <label>歌${type ? '单' : '曲'} ID</label>
<input autocomplete="off" name="id" placeholder="请输入歌${type ? '单' : '曲'}ID"/> <input autocomplete="off" name="id" placeholder="请输入歌${type ? '单' : '曲'}ID"/>
</div> </div>
<div class="fitem"> <div class="fitem">
<label>显示宽度</label> <label>主题色彩</label>
<input autocomplete="off" value="100%" name="width" placeholder="请输入宽度(百分比/像素)"/> <input style="width: 44px;padding: 0 2px;flex: none" autocomplete="off" value="#1989fa" name="color" type="color"/>
</div> </div>
<div class="fitem"> <div class="fitem">
<label>自动播放</label> <label>自动播放</label>
@ -370,9 +370,9 @@ export default class JoeAction {
`, `,
confirm: () => { confirm: () => {
const id = $(".cm-modal input[name='id']").val(); const id = $(".cm-modal input[name='id']").val();
const width = $(".cm-modal input[name='width']").val() || '100%'; const color = $(".cm-modal input[name='color']").val();
const autoplay = $(".cm-modal select[name='autoplay']").val(); const autoplay = $(".cm-modal select[name='autoplay']").val();
const str = `\n{${type ? 'music-list' : 'music'} id="${id}" width="${width}" ${autoplay === '1' ? 'autoplay="autoplay"' : ''}/}\n\n`; const str = `\n{${type ? 'music-list' : 'music'} id="${id}" color="${color}" ${autoplay === '1' ? 'autoplay="autoplay"' : ''}/}\n\n`;
if (this._getLineCh(cm)) this._replaceSelection(cm, '\n' + str); if (this._getLineCh(cm)) this._replaceSelection(cm, '\n' + str);
else this._replaceSelection(cm, str); else this._replaceSelection(cm, str);
cm.focus(); cm.focus();
@ -679,4 +679,45 @@ export default class JoeAction {
} }
}); });
} }
handleMp3(cm) {
this._openModal({
title: '插入音乐',
innerHtml: `
<div class="fitem">
<label>音频名称</label>
<input autocomplete="off" name="name" placeholder="请输入音频名称"/>
</div>
<div class="fitem">
<label>音频地址</label>
<input autocomplete="off" name="url" placeholder="请输入音频地址"/>
</div>
<div class="fitem">
<label>音频封面</label>
<input autocomplete="off" name="cover" placeholder="请输入图片地址"/>
</div>
<div class="fitem">
<label>主题色彩</label>
<input style="width: 44px;padding: 0 2px;flex: none" autocomplete="off" value="#f0ad4e" name="theme" type="color"/>
</div>
<div class="fitem">
<label>自动播放</label>
<select name="autoplay">
<option value="1" selected></option>
<option value="0"></option>
</select>
</div>
`,
confirm: () => {
const name = $(".cm-modal input[name='name']").val();
const url = $(".cm-modal input[name='url']").val();
const cover = $(".cm-modal input[name='cover']").val();
const theme = $(".cm-modal input[name='theme']").val();
const autoplay = $(".cm-modal select[name='autoplay']").val();
const str = `\n{mp3 name="${name}" url="${url}" cover="${cover}" theme="${theme}" ${autoplay === '1' ? 'autoplay="autoplay"' : ''}/}\n\n`;
if (this._getLineCh(cm)) this._replaceSelection(cm, '\n' + str);
else this._replaceSelection(cm, str);
cm.focus();
}
});
}
} }

View File

@ -1,9 +1,10 @@
const parser = new HyperDown(); const parser = new HyperDown();
const player = window.JoeConfig.playerAPI; const player = window.JoeConfig.playerAPI;
const div = document.createElement('div');
export default function createPreviewHtml(str) { export default function createPreviewHtml(str) {
str = str.replace(/ /g, '&emsp;'); str = str.replace(/ /g, '&emsp;');
/* 生成HTML元素 */
str = parser.makeHtml(str); str = parser.makeHtml(str);
str = str.replace(/{x}/g, '<input type="checkbox" class="joe_detail__article-checkbox" checked disabled></input>'); str = str.replace(/{x}/g, '<input type="checkbox" class="joe_detail__article-checkbox" checked disabled></input>');
@ -21,6 +22,7 @@ export default function createPreviewHtml(str) {
str = str.replace(/{bilibili([^}]*)\/}/g, '<joe-bilibili $1></joe-bilibili>'); str = str.replace(/{bilibili([^}]*)\/}/g, '<joe-bilibili $1></joe-bilibili>');
str = str.replace(/{music-list([^}]*)\/}/g, '<joe-mlist $1></joe-mlist>'); str = str.replace(/{music-list([^}]*)\/}/g, '<joe-mlist $1></joe-mlist>');
str = str.replace(/{music([^}]*)\/}/g, '<joe-music $1></joe-music>'); str = str.replace(/{music([^}]*)\/}/g, '<joe-music $1></joe-music>');
str = str.replace(/{mp3([^}]*)\/}/g, '<joe-mp3 $1></joe-mp3>');
str = str.replace(/{abtn([^}]*)\/}/g, '<joe-abtn $1></joe-abtn>'); str = str.replace(/{abtn([^}]*)\/}/g, '<joe-abtn $1></joe-abtn>');
str = str.replace(/{anote([^}]*)\/}/g, '<joe-anote $1></joe-anote>'); str = str.replace(/{anote([^}]*)\/}/g, '<joe-anote $1></joe-anote>');
str = str.replace(/{dotted([^}]*)\/}/g, '<joe-dotted $1></joe-dotted>'); str = str.replace(/{dotted([^}]*)\/}/g, '<joe-dotted $1></joe-dotted>');
@ -30,10 +32,7 @@ export default function createPreviewHtml(str) {
str = str.replace(/{card-default([^}]*)}([\s\S]*?){\/card-default}/g, '<section style="margin-bottom: 15px"><joe-card-default $1><span class="_temp" style="display: none">$2</span></joe-card-default></section>'); str = str.replace(/{card-default([^}]*)}([\s\S]*?){\/card-default}/g, '<section style="margin-bottom: 15px"><joe-card-default $1><span class="_temp" style="display: none">$2</span></joe-card-default></section>');
str = str.replace(/{callout([^}]*)}([\s\S]*?){\/callout}/g, '<section style="margin-bottom: 15px"><joe-callout $1><span class="_temp" style="display: none">$2</span></joe-callout></section>'); str = str.replace(/{callout([^}]*)}([\s\S]*?){\/callout}/g, '<section style="margin-bottom: 15px"><joe-callout $1><span class="_temp" style="display: none">$2</span></joe-callout></section>');
const div = document.createElement('div'); $('.cm-preview-content').html(str);
div.innerHTML = str; $('.cm-preview-content p:empty').remove();
div.innerHTML = div.innerHTML.replace(/<p><\/p>/g, '');
const _ = div.innerHTML;
$('.cm-preview-content').html(_);
$('.cm-preview-content pre code').each((i, el) => Prism.highlightElement(el)); $('.cm-preview-content pre code').each((i, el) => Prism.highlightElement(el));
} }

View File

@ -180,6 +180,11 @@ export default [
title: '标注', title: '标注',
innerHTML: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="18" height="18"><path d="M842.13 910h-72.36c-19.88 0-36-16.12-36-36s16.12-36 36-36h72.36c19.88 0 36 16.12 36 36s-16.11 36-36 36zm-177.69 0h-72.23c-19.88 0-36-16.12-36-36s16.12-36 36-36h72.23c19.88 0 36 16.12 36 36s-16.12 36-36 36zm-177.57 0h-72.23c-19.88 0-36-16.12-36-36s16.12-36 36-36h72.23c19.88 0 36 16.12 36 36s-16.11 36-36 36zm-177.56 0h-72.23c-19.88 0-36-16.12-36-36s16.12-36 36-36h72.23c19.88 0 36 16.12 36 36s-16.12 36-36 36zM150 878.02c-19.88 0-36-16.1-36-35.98V769.8c0-19.88 16.12-36 36-36s36 16.12 36 36V842c0 19.88-16.12 36.02-36 36.02zm724-55.2c-19.88 0-36-16.12-36-36v-72.23c0-19.88 16.12-36 36-36s36 16.12 36 36v72.23c0 19.88-16.12 36-36 36zM150 700.47c-19.88 0-36-16.12-36-36v-72.23c0-19.88 16.12-36 36-36s36 16.12 36 36v72.23c0 19.88-16.12 36-36 36zm724-55.22c-19.88 0-36-16.12-36-36v-72.23c0-19.88 16.12-36 36-36s36 16.12 36 36v72.23c0 19.89-16.12 36-36 36zM150 522.91c-19.88 0-36-16.12-36-36v-72.23c0-19.88 16.12-36 36-36s36 16.12 36 36v72.23c0 19.88-16.12 36-36 36zm724-55.22c-19.88 0-36-16.12-36-36v-72.23c0-19.88 16.12-36 36-36s36 16.12 36 36v72.23c0 19.88-16.12 36-36 36zM150 345.34c-19.88 0-36-16.12-36-36v-72.23c0-19.88 16.12-36 36-36s36 16.12 36 36v72.23c0 19.89-16.12 36-36 36zm724-55.21c-19.88 0-36-16.12-36-36V182c0-19.88 16.12-36.05 36-36.05s36 16.07 36 35.95v72.23c0 19.88-16.12 36-36 36zM786.85 186h-72.23c-19.88 0-36-16.12-36-36s16.12-36 36-36h72.23c19.88 0 36 16.12 36 36s-16.12 36-36 36zm-177.56 0h-72.23c-19.88 0-36-16.12-36-36s16.12-36 36-36h72.23c19.88 0 36 16.12 36 36s-16.12 36-36 36zm-177.56 0H359.5c-19.88 0-36-16.12-36-36s16.12-36 36-36h72.23c19.88 0 36 16.12 36 36s-16.12 36-36 36zm-177.57 0H182c-19.88 0-36.03-16.12-36.03-36s16.08-36 35.97-36h72.23c19.88 0 36 16.12 36 36s-16.13 36-36.01 36z"/><path d="M213 120v784c0 4.42-3.58 8-8 8h-84c-4.42 0-8-3.58-8-8V120c0-4.42 3.58-8 8-8h84c4.42 0 8 3.58 8 8z"/></svg>' innerHTML: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="18" height="18"><path d="M842.13 910h-72.36c-19.88 0-36-16.12-36-36s16.12-36 36-36h72.36c19.88 0 36 16.12 36 36s-16.11 36-36 36zm-177.69 0h-72.23c-19.88 0-36-16.12-36-36s16.12-36 36-36h72.23c19.88 0 36 16.12 36 36s-16.12 36-36 36zm-177.57 0h-72.23c-19.88 0-36-16.12-36-36s16.12-36 36-36h72.23c19.88 0 36 16.12 36 36s-16.11 36-36 36zm-177.56 0h-72.23c-19.88 0-36-16.12-36-36s16.12-36 36-36h72.23c19.88 0 36 16.12 36 36s-16.12 36-36 36zM150 878.02c-19.88 0-36-16.1-36-35.98V769.8c0-19.88 16.12-36 36-36s36 16.12 36 36V842c0 19.88-16.12 36.02-36 36.02zm724-55.2c-19.88 0-36-16.12-36-36v-72.23c0-19.88 16.12-36 36-36s36 16.12 36 36v72.23c0 19.88-16.12 36-36 36zM150 700.47c-19.88 0-36-16.12-36-36v-72.23c0-19.88 16.12-36 36-36s36 16.12 36 36v72.23c0 19.88-16.12 36-36 36zm724-55.22c-19.88 0-36-16.12-36-36v-72.23c0-19.88 16.12-36 36-36s36 16.12 36 36v72.23c0 19.89-16.12 36-36 36zM150 522.91c-19.88 0-36-16.12-36-36v-72.23c0-19.88 16.12-36 36-36s36 16.12 36 36v72.23c0 19.88-16.12 36-36 36zm724-55.22c-19.88 0-36-16.12-36-36v-72.23c0-19.88 16.12-36 36-36s36 16.12 36 36v72.23c0 19.88-16.12 36-36 36zM150 345.34c-19.88 0-36-16.12-36-36v-72.23c0-19.88 16.12-36 36-36s36 16.12 36 36v72.23c0 19.89-16.12 36-36 36zm724-55.21c-19.88 0-36-16.12-36-36V182c0-19.88 16.12-36.05 36-36.05s36 16.07 36 35.95v72.23c0 19.88-16.12 36-36 36zM786.85 186h-72.23c-19.88 0-36-16.12-36-36s16.12-36 36-36h72.23c19.88 0 36 16.12 36 36s-16.12 36-36 36zm-177.56 0h-72.23c-19.88 0-36-16.12-36-36s16.12-36 36-36h72.23c19.88 0 36 16.12 36 36s-16.12 36-36 36zm-177.56 0H359.5c-19.88 0-36-16.12-36-36s16.12-36 36-36h72.23c19.88 0 36 16.12 36 36s-16.12 36-36 36zm-177.57 0H182c-19.88 0-36.03-16.12-36.03-36s16.08-36 35.97-36h72.23c19.88 0 36 16.12 36 36s-16.13 36-36.01 36z"/><path d="M213 120v784c0 4.42-3.58 8-8 8h-84c-4.42 0-8-3.58-8-8V120c0-4.42 3.58-8 8-8h84c4.42 0 8 3.58 8 8z"/></svg>'
}, },
{
type: 'mp3',
title: '外部音乐',
innerHTML: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M736 249.6c-12.8-6.4-32-6.4-44.8 6.4-12.8 12.8-6.4 32 6.4 44.8C761.6 352 800 428.8 800 512c0 76.8-32 153.6-89.6 204.8-12.8 12.8-12.8 32 0 44.8 12.8 12.8 32 12.8 44.8 0C825.6 697.6 864 608 864 512c-6.4-102.4-51.2-198.4-128-262.4z"/><path d="M640 345.6c-12.8-6.4-32-6.4-44.8 6.4-12.8 12.8-6.4 32 6.4 44.8 38.4 25.6 57.6 70.4 57.6 115.2s-19.2 83.2-44.8 108.8c-12.8 12.8-12.8 32 0 44.8 12.8 12.8 32 12.8 44.8 0 44.8-38.4 64-96 64-153.6-6.4-64-38.4-128-83.2-166.4zM499.2 211.2L288 345.6H185.6c-12.8 0-19.2 6.4-19.2 19.2v313.6c0 12.8 12.8 25.6 19.2 25.6H288l211.2 115.2H512c12.8 0 19.2-6.4 19.2-19.2V230.4c0-6.4 0-6.4-6.4-12.8 0-6.4-19.2-12.8-25.6-6.4z"/></svg>'
},
/* --------------------------- 短代码结束 --------------------------- */ /* --------------------------- 短代码结束 --------------------------- */
{ {
type: 'clean', type: 'clean',

File diff suppressed because one or more lines are too long

View File

@ -43,6 +43,7 @@ class Joe extends JoeAction {
</div> </div>
`); `);
createPreviewHtml($('#text').val()); createPreviewHtml($('#text').val());
let _temp = null;
const cm = new EditorView({ const cm = new EditorView({
state: EditorState.create({ state: EditorState.create({
doc: $('#text').val(), doc: $('#text').val(),
@ -51,8 +52,11 @@ class Joe extends JoeAction {
keymap.of([defaultTabBinding, ...defaultKeymap, ...historyKeymap, ...closeBracketsKeymap]), keymap.of([defaultTabBinding, ...defaultKeymap, ...historyKeymap, ...closeBracketsKeymap]),
EditorView.updateListener.of(update => { EditorView.updateListener.of(update => {
if (!update.docChanged) return; if (!update.docChanged) return;
if (_temp !== update.state.doc.toString()) {
_temp = update.state.doc.toString();
if (window.requestAnimationFrame) window.requestAnimationFrame(() => createPreviewHtml(update.state.doc.toString())); if (window.requestAnimationFrame) window.requestAnimationFrame(() => createPreviewHtml(update.state.doc.toString()));
else createPreviewHtml(update.state.doc.toString()); else createPreviewHtml(update.state.doc.toString());
}
}), }),
EditorView.domEventHandlers({ EditorView.domEventHandlers({
paste: e => { paste: e => {
@ -305,6 +309,9 @@ class Joe extends JoeAction {
case 'callout': case 'callout':
super.handleCallout(this.cm); super.handleCallout(this.cm);
break; break;
case 'mp3':
super.handleMp3(this.cm);
break;
} }
}); });
$('.cm-tools').append(el); $('.cm-tools').append(el);

View File

@ -9,7 +9,7 @@
"@codemirror/history": "^0.18.1", "@codemirror/history": "^0.18.1",
"@codemirror/matchbrackets": "^0.18.0", "@codemirror/matchbrackets": "^0.18.0",
"@codemirror/state": "^0.18.6", "@codemirror/state": "^0.18.6",
"@codemirror/view": "^0.18.7", "@codemirror/view": "^0.18.8",
"@rollup/plugin-node-resolve": "^11.2.1", "@rollup/plugin-node-resolve": "^11.2.1",
"rollup-plugin-uglify": "^6.0.4" "rollup-plugin-uglify": "^6.0.4"
} }