This commit is contained in:
杜恒 2021-04-22 15:36:33 +08:00
parent 88030a0b16
commit 593e236a02
16 changed files with 446 additions and 277 deletions

File diff suppressed because one or more lines are too long

View File

@ -2261,6 +2261,61 @@
margin-bottom: 0 !important; margin-bottom: 0 !important;
} }
} }
&-tabs {
display: block;
width: 100%;
overflow: hidden;
background: var(--background);
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
border: 1px solid var(--classC);
border-radius: 4px;
.heads {
width: 100%;
overflow-x: auto;
overflow-y: hidden;
display: flex;
background: var(--classD);
.item {
position: relative;
padding: 0 15px;
line-height: 40px;
height: 40px;
color: var(--minor);
cursor: pointer;
transition: color 0.5s;
white-space: nowrap;
font-size: 14px;
&::after {
content: '';
position: absolute;
background: var(--theme);
bottom: 0;
left: 15px;
right: 15px;
height: 2px;
opacity: 0;
border-radius: 2px;
transform: scaleX(0.5);
transition: opacity 0.25s, transform 0.25s;
}
&.active {
color: var(--theme);
&::after {
opacity: 1;
transform: scaleX(1);
}
}
}
}
.bodys {
.item {
padding: 15px;
*:last-child {
margin-bottom: 0 !important;
}
}
}
}
/* 以下未测试 */ /* 以下未测试 */
&-protected { &-protected {

View File

@ -1,5 +1,4 @@
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
$('.joe_detail__article p:empty').remove(); $('.joe_detail__article p:empty').remove();
class JoeMtitle extends HTMLElement { class JoeMtitle extends HTMLElement {
@ -10,7 +9,8 @@ document.addEventListener('DOMContentLoaded', () => {
<span class="text"> <span class="text">
${this.getAttribute('title') || '默认标题'} ${this.getAttribute('title') || '默认标题'}
</span> </span>
</span>`; </span>
`;
} }
} }
window.customElements.define('joe-mtitle', JoeMtitle); window.customElements.define('joe-mtitle', JoeMtitle);
@ -205,10 +205,11 @@ document.addEventListener('DOMContentLoaded', () => {
if (this.querySelector('._content')) { if (this.querySelector('._content')) {
this.querySelector('._content').innerHTML = htmlStr; this.querySelector('._content').innerHTML = htmlStr;
} else { } else {
const div = document.createElement('div'); const span = document.createElement('span');
div.className = '_content'; span.style.display = 'block';
div.innerHTML = htmlStr; span.className = '_content';
this.appendChild(div); span.innerHTML = htmlStr;
this.appendChild(span);
} }
} }
} }
@ -263,17 +264,59 @@ document.addEventListener('DOMContentLoaded', () => {
if (this.querySelector('._content')) { if (this.querySelector('._content')) {
this.querySelector('._content').innerHTML = htmlStr; this.querySelector('._content').innerHTML = htmlStr;
} else { } else {
const div = document.createElement('div'); const span = document.createElement('span');
div.className = '_content'; span.style.display = 'block';
div.innerHTML = htmlStr; span.className = '_content';
this.appendChild(div); span.innerHTML = htmlStr;
this.appendChild(span);
} }
} }
} }
window.customElements.define('joe-callout', JoeCallout); window.customElements.define('joe-callout', JoeCallout);
class JoeTabs extends HTMLElement {
constructor() {
super();
const _temp = this.querySelector('._temp');
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
let navs = '';
let contents = '';
_innerHTML.replace(/{tabs-pane([^}]*)}([\s\S]*?){\/tabs-pane}/g, function ($0, $1, $2) {
navs += `<div class="item" ${$1}></div>`;
contents += `<div style="display: none" class="item" ${$1}>${$2.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>`;
});
let htmlStr = `
<span class="joe_detail__article-tabs">
<div class="heads">${navs}</div>
<div class="bodys">${contents}</div>
</span>
`;
if (this.querySelector('._content')) {
this.querySelector('._content').innerHTML = htmlStr;
} else {
const span = document.createElement('span');
span.className = '_content';
span.style.display = 'block';
span.innerHTML = htmlStr;
this.appendChild(span);
}
this.querySelectorAll('.heads .item').forEach((item, index) => {
const label = item.getAttribute('label');
item.innerHTML = label;
item.addEventListener('click', () => {
this.querySelectorAll('.heads .item').forEach(_item => _item.classList.remove('active'));
this.querySelectorAll('.bodys .item').forEach(_item => (_item.style.display = 'none'));
if (this.querySelector(`.bodys .item[label="${label}"]`)) {
this.querySelector(`.bodys .item[label="${label}"]`).style.display = 'block';
}
item.classList.add('active');
});
if (index === 0) item.click();
});
}
}
window.customElements.define('joe-tabs', JoeTabs);
$('.joe_detail__article p:empty').remove();
/* /*
------------------------以下未测试------------------------------------------ ------------------------以下未测试------------------------------------------
*/ */
@ -282,7 +325,7 @@ document.addEventListener('DOMContentLoaded', () => {
constructor() { constructor() {
super(); super();
this.options = { this.options = {
text: this.getAttribute('text') || '默认文本', text: this.getAttribulte('text') || '默认文本',
content: this.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '点击复制' content: this.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '点击复制'
}; };
this.render(); this.render();

File diff suppressed because one or more lines are too long

View File

@ -50,7 +50,7 @@ class Editor
<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/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=2021042210') ?>"> <link rel="stylesheet" href="<?php Helper::options()->themeUrl('typecho/write/css/joe.write.min.css?v=2021042215') ?>">
<script> <script>
window.JoeConfig = { window.JoeConfig = {
uploadAPI: '<?php Helper::security()->index('/action/upload'); ?>', uploadAPI: '<?php Helper::security()->index('/action/upload'); ?>',
@ -65,9 +65,9 @@ class Editor
</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/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=2021042210') ?>"></script> <script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.parse.min.js?v=2021042215') ?>"></script>
<script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.write.chunk.js?v=2021042210') ?>"></script> <script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.write.chunk.js?v=2021042215') ?>"></script>
<script src="<?php Helper::options()->themeUrl('assets/js/joe.short.min.js?v=2021042210') ?>"></script> <script src="<?php Helper::options()->themeUrl('assets/js/joe.short.min.js?v=2021042215') ?>"></script>
<?php <?php
} }
} }

View File

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

View File

@ -58,6 +58,9 @@ function _parseContent($post, $login)
if (strpos($content, '{callout') !== false) { if (strpos($content, '{callout') !== false) {
$content = preg_replace('/{callout([^}]*)}([\s\S]*?){\/callout}/', '<section style="margin-bottom: 15px"><joe-callout $1><span class="_temp" style="display: none">$2</span></joe-callout></section>', $content); $content = preg_replace('/{callout([^}]*)}([\s\S]*?){\/callout}/', '<section style="margin-bottom: 15px"><joe-callout $1><span class="_temp" style="display: none">$2</span></joe-callout></section>', $content);
} }
if (strpos($content, '{tabs') !== false) {
$content = preg_replace('/{tabs}([\s\S]*?){\/tabs}/', '<section style="margin-bottom: 15px"><joe-tabs><span class="_temp" style="display: none">$1</span></joe-tabs></section>', $content);
}

View File

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

View File

@ -18,7 +18,7 @@
<?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=2021042208'); ?>"> <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.global.min.css?v=2021042215'); ?>">
<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" />
@ -40,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=2021042208'); ?>"></script> <script src="<?php $this->options->themeUrl('assets/js/joe.global.min.js?v=2021042215'); ?>"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.short.min.js?v=2021042208'); ?>"></script> <script src="<?php $this->options->themeUrl('assets/js/joe.short.min.js?v=2021042215'); ?>"></script>
<?php $this->options->JCustomHeadEnd() ?> <?php $this->options->JCustomHeadEnd() ?>

File diff suppressed because one or more lines are too long

View File

@ -940,6 +940,60 @@ body.fullscreen {
margin-bottom: 0 !important; margin-bottom: 0 !important;
} }
} }
.joe_detail__article-tabs {
display: block;
width: 100%;
overflow: hidden;
background: #fff;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
border: 1px solid #ebeef5;
border-radius: 4px;
.heads {
width: 100%;
overflow-x: auto;
overflow-y: hidden;
display: flex;
background: #f2f6fc;
.item {
position: relative;
padding: 0 15px;
line-height: 40px;
height: 40px;
color: #909399;
cursor: pointer;
transition: color 0.5s;
white-space: nowrap;
&::after {
content: '';
position: absolute;
background: #409eff;
bottom: 0;
left: 15px;
right: 15px;
height: 2px;
opacity: 0;
border-radius: 2px;
transform: scaleX(0.5);
transition: opacity 0.25s, transform 0.25s;
}
&.active {
color: #409eff;
&::after {
opacity: 1;
transform: scaleX(1);
}
}
}
}
.bodys {
.item {
padding: 15px;
*:last-child {
margin-bottom: 0 !important;
}
}
}
}
@media (max-width: 768px) { @media (max-width: 768px) {
.cm-modal__wrapper { .cm-modal__wrapper {

View File

@ -720,4 +720,9 @@ export default class JoeAction {
} }
}); });
} }
handleTabs(cm) {
const str = `${this._getLineCh(cm) ? '\n\n' : '\n'}{tabs}\n{tabs-pane label="标签一"}\n 标签一内容\n{/tabs-pane}\n{tabs-pane label="标签二"}\n 标签二内容\n{/tabs-pane}\n{/tabs}\n\n`;
this._replaceSelection(cm, str);
cm.focus();
}
} }

View File

@ -32,6 +32,7 @@ export default function createPreviewHtml(str) {
str = str.replace(/{hide[^}]*}([\s\S]*?){\/hide}/g, '<joe-hide></joe-hide>'); str = str.replace(/{hide[^}]*}([\s\S]*?){\/hide}/g, '<joe-hide></joe-hide>');
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>');
str = str.replace(/{tabs}([\s\S]*?){\/tabs}/g, '<section style="margin-bottom: 15px"><joe-tabs><span class="_temp" style="display: none">$1</span></joe-tabs></section>');
$('.cm-preview-content').html(str); $('.cm-preview-content').html(str);
$('.cm-preview-content p:empty').remove(); $('.cm-preview-content p:empty').remove();

View File

@ -185,6 +185,11 @@ export default [
title: '外部音乐', 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>' 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: 'tabs',
title: '标签页',
innerHTML: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M904 788c4.31 0 7.853 2.735 8 6.12v63.548c0 3.412-3.455 6.216-7.732 6.33L904 864H120c-4.31 0-7.853-2.735-8-6.12v-63.548c0-3.412 3.455-6.216 7.732-6.33L120 788h784zm0-192c4.31 0 7.853 2.735 8 6.12v63.548c0 3.412-3.455 6.216-7.732 6.33L904 672H120c-4.31 0-7.853-2.735-8-6.12v-63.548c0-3.412 3.455-6.216 7.732-6.33L120 596h784zm-8-436c8.837 0 16 7.163 16 16v288c0 8.837-7.163 16-16 16H608c-8.837 0-16-7.163-16-16V176c0-8.837 7.163-16 16-16h288zm-384 0c8.695 0 15.828 7.03 16 15.686V464c0 8.695-7.03 15.828-15.686 16H128c-8.695 0-15.828-7.03-16-15.686V176c0-8.695 7.03-15.828 15.686-16H512zm-56 72H184v176h272V232z"/></svg>'
},
/* --------------------------- 短代码结束 --------------------------- */ /* --------------------------- 短代码结束 --------------------------- */
{ {
type: 'clean', type: 'clean',

File diff suppressed because one or more lines are too long

View File

@ -312,6 +312,9 @@ class Joe extends JoeAction {
case 'mp3': case 'mp3':
super.handleMp3(this.cm); super.handleMp3(this.cm);
break; break;
case 'tabs':
super.handleTabs(this.cm);
break;
case 'preview': case 'preview':
el.toggleClass('active'); el.toggleClass('active');
if (el.hasClass('active')) window.JoeConfig.canPreview = true; if (el.hasClass('active')) window.JoeConfig.canPreview = true;