This commit is contained in:
杜恒 2021-04-23 16:41:48 +08:00
parent ee09362c4f
commit 61db123164
16 changed files with 183 additions and 16 deletions

File diff suppressed because one or more lines are too long

View File

@ -1920,6 +1920,53 @@
transform-origin: left; transform-origin: left;
} }
} }
.joe_collapse {
&__item {
margin-bottom: 10px;
color: var(--routine);
border: 1px solid var(--classC);
&-head {
display: flex;
align-items: center;
background: var(--classD);
padding: 10px 12px;
padding-right: 8px;
cursor: pointer;
overflow: hidden;
user-select: none;
&--label {
padding-right: 8px;
}
&--icon {
flex-shrink: 0;
margin-left: auto;
fill: var(--minor);
transition: transform 0.3s ease;
}
}
&-wrapper {
max-height: 0;
overflow: hidden;
transition: max-height .3s ease;
&--content {
padding: 12px;
*:last-child {
margin-bottom: 0 !important;
}
}
}
&:last-child {
margin-bottom: 0;
}
&.active {
.joe_collapse__item-head--icon {
transform: rotate(-180deg);
}
}
}
}
.joe_detail { .joe_detail {
background: var(--background); background: var(--background);

View File

@ -341,6 +341,62 @@ document.addEventListener('DOMContentLoaded', () => {
} }
} }
window.customElements.define('joe-timeline', JoeTimeline); window.customElements.define('joe-timeline', JoeTimeline);
class JoeCollapse extends HTMLElement {
constructor() {
super();
const _temp = getChildren(this, '_temp');
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
let content = '';
_innerHTML.replace(/{collapse-item([^}]*)}([\s\S]*?){\/collapse-item}/g, function ($0, $1, $2) {
content += `
<div class="joe_collapse__item" ${$1}>
<div class="joe_collapse__item-head">
<div class="joe_collapse__item-head--label"></div>
<svg class="joe_collapse__item-head--icon" xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24"><path d="M7.406 7.828L12 12.422l4.594-4.594L18 9.234l-6 6-6-6z"/></svg>
</div>
<div class="joe_collapse__item-wrapper">
<div class="joe_collapse__item-wrapper--content">${$2.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>
</div>
</div>
`;
});
let htmlStr = `<div class="joe_collapse">${content}</div>`;
if (getChildren(this, '_content')) {
getChildren(this, '_content').innerHTML = htmlStr;
} else {
const span = document.createElement('span');
span.className = '_content';
span.style.display = 'block';
span.innerHTML = htmlStr;
this.appendChild(span);
}
this.querySelectorAll('.joe_collapse__item-head--label').forEach(item => {
const label = item.getAttribute('label') || '折叠标题';
item.innerHTML = label;
});
this.querySelectorAll('.joe_collapse__item').forEach(item => {
const head = getChildren(item, 'joe_collapse__item-head');
const wrapper = getChildren(item, 'joe_collapse__item-wrapper');
const content = getChildren(wrapper, 'joe_collapse__item-wrapper--content');
const open = item.getAttribute('open');
if (open !== null) {
item.classList.add('active');
wrapper.style.maxHeight = content.offsetHeight + 'px';
}
head.addEventListener('click', () => {
if (item.classList.contains('active')) {
item.classList.remove('active');
wrapper.style.maxHeight = 0;
} else {
item.classList.add('active');
wrapper.style.maxHeight = content.offsetHeight + 'px';
}
});
});
}
}
window.customElements.define('joe-collapse', JoeCollapse);
class JoeDplayer extends HTMLElement { class JoeDplayer extends HTMLElement {
constructor() { constructor() {
super(); super();

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=202104231345') ?>"> <link rel="stylesheet" href="<?php Helper::options()->themeUrl('typecho/write/css/joe.write.min.css?v=202104231640') ?>">
<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=202104231345') ?>"></script> <script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.parse.min.js?v=202104231640') ?>"></script>
<script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.write.chunk.js?v=202104231345') ?>"></script> <script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.write.chunk.js?v=202104231640') ?>"></script>
<script src="<?php Helper::options()->themeUrl('assets/js/joe.short.min.js?v=202104231345') ?>"></script> <script src="<?php Helper::options()->themeUrl('assets/js/joe.short.min.js?v=202104231640') ?>"></script>
<?php <?php
} }
} }

View File

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

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

@ -1086,6 +1086,53 @@ body.fullscreen {
transform-origin: left; transform-origin: left;
} }
} }
.joe_collapse {
&__item {
margin-bottom: 10px;
color: #606266;
&-head {
display: flex;
align-items: center;
background: #f2f6fc;
padding: 10px 12px;
padding-right: 8px;
cursor: pointer;
overflow: hidden;
border: 1px solid #ebeef5;
user-select: none;
&--label {
padding-right: 8px;
}
&--icon {
flex-shrink: 0;
margin-left: auto;
fill: #909399;
transition: transform 0.3s ease;
}
}
&-wrapper {
max-height: 0;
overflow: hidden;
transition: max-height .3s ease;
&--content {
border: 1px solid #ebeef5;
border-top: 0;
padding: 12px;
*:last-child {
margin-bottom: 0 !important;
}
}
}
&:last-child {
margin-bottom: 0;
}
&.active {
.joe_collapse__item-head--icon {
transform: rotate(-180deg);
}
}
}
}
@media (max-width: 768px) { @media (max-width: 768px) {
.cm-modal__wrapper { .cm-modal__wrapper {

View File

@ -768,4 +768,9 @@ export default class JoeAction {
this._replaceSelection(cm, str); this._replaceSelection(cm, str);
cm.focus(); cm.focus();
} }
handleCollapse(cm) {
const str = `${this._getLineCh(cm) ? '\n\n' : '\n'}{collapse}\n{collapse-item label="折叠标题一" open}\n 折叠内容一\n{/collapse-item}\n{collapse-item label="折叠标题二"}\n 折叠内容二\n{/collapse-item}\n{/collapse}\n\n`;
this._replaceSelection(cm, str);
cm.focus();
}
} }

View File

@ -38,6 +38,7 @@ export default function createPreviewHtml(str) {
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>'); 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>');
str = str.replace(/{card-list}([\s\S]*?){\/card-list}/g, '<section style="margin-bottom: 15px"><joe-card-list><span class="_temp" style="display: none">$1</span></joe-card-list></section>'); str = str.replace(/{card-list}([\s\S]*?){\/card-list}/g, '<section style="margin-bottom: 15px"><joe-card-list><span class="_temp" style="display: none">$1</span></joe-card-list></section>');
str = str.replace(/{timeline}([\s\S]*?){\/timeline}/g, '<section style="margin-bottom: 15px"><joe-timeline><span class="_temp" style="display: none">$1</span></joe-timeline></section>'); str = str.replace(/{timeline}([\s\S]*?){\/timeline}/g, '<section style="margin-bottom: 15px"><joe-timeline><span class="_temp" style="display: none">$1</span></joe-timeline></section>');
str = str.replace(/{collapse}([\s\S]*?){\/collapse}/g, '<section style="margin-bottom: 15px"><joe-collapse><span class="_temp" style="display: none">$1</span></joe-collapse></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

@ -215,6 +215,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="M848 432a80.064 80.064 0 0 0-73.216 48H217.216A80.096 80.096 0 0 0 144 432a80.096 80.096 0 0 0-80 80c0 44.128 35.904 80 80 80a80 80 0 0 0 73.216-48h557.536a80 80 0 0 0 73.216 48c44.128 0 80-35.872 80-80A80.032 80.032 0 0 0 848 432z"/></svg>' innerHTML: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M848 432a80.064 80.064 0 0 0-73.216 48H217.216A80.096 80.096 0 0 0 144 432a80.096 80.096 0 0 0-80 80c0 44.128 35.904 80 80 80a80 80 0 0 0 73.216-48h557.536a80 80 0 0 0 73.216 48c44.128 0 80-35.872 80-80A80.032 80.032 0 0 0 848 432z"/></svg>'
}, },
{
type: 'collapse',
title: '折叠面板',
innerHTML: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="18" height="18"><path d="M944 128H80c-8.8 0-16 7.2-16 16v736c0 8.8 7.2 16 16 16h864c8.8 0 16-7.2 16-16V144c0-8.8-7.2-16-16-16zm-48 64v216H128V192h768zM128 832V472h768v360H128z"/><path d="M706 340.8c6.4 7.6 18 7.6 24.4 0l58.8-69.2c8.8-10.4 1.6-26.4-12-26.4H659.6c-13.6 0-21.2 16-12 26.4l58.4 69.2z"/></svg>'
},
/* --------------------------- 短代码结束 --------------------------- */ /* --------------------------- 短代码结束 --------------------------- */
{ {
type: 'clean', type: 'clean',

File diff suppressed because one or more lines are too long

View File

@ -330,6 +330,9 @@ class Joe extends JoeAction {
case 'lamp': case 'lamp':
super.handleLamp(this.cm); super.handleLamp(this.cm);
break; break;
case 'collapse':
super.handleCollapse(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;