This commit is contained in:
杜恒 2021-04-19 15:18:29 +08:00
parent 3bcf16d512
commit 6f625826ad
15 changed files with 328 additions and 249 deletions

File diff suppressed because one or more lines are too long

View File

@ -1867,10 +1867,195 @@
}
}
}
&-checkbox {
-webkit-appearance: none;
position: relative;
border-radius: 2px;
width: 15px;
height: 15px;
border: 2px solid var(--theme);
vertical-align: -2px;
&:disabled {
cursor: not-allowed;
}
&:checked {
border: none;
background: var(--theme);
&::after {
content: '';
width: 3px;
height: 7px;
position: absolute;
top: 2px;
left: 5px;
border: 2px solid #fff;
border-top: 0;
border-left: 0;
transform: rotate(45deg);
}
}
}
&-player {
width: 100%;
height: 500px;
}
&-card_default {
display: block;
margin: 0 auto;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
border-radius: var(--radius-inner);
border: 1px solid var(--classC);
background: var(--background);
> .title {
display: block;
padding: 8px 12px;
border-bottom: 1px solid var(--classC);
color: var(--main);
user-select: none;
}
> .content {
display: block;
padding: 12px;
color: var(--routine);
*:last-child {
margin-bottom: 0 !important;
}
}
}
&-mtitle {
display: flex;
justify-content: center;
> .text {
position: relative;
color: var(--minor);
padding: 0 12px;
transition: padding 0.35s;
&:hover {
padding: 0;
}
&::before,
&::after {
content: '';
position: absolute;
top: 50%;
width: 20px;
height: 1px;
background: var(--theme);
}
&::before {
left: -35px;
}
&::after {
right: -35px;
}
}
}
&-hide {
display: block;
background: repeating-linear-gradient(145deg, var(--classD), var(--classD) 15px, var(--background) 0, var(--background) 25px);
padding: 15px 0;
text-align: center;
position: relative;
user-select: none;
line-height: normal;
> i {
position: relative;
font-style: normal;
cursor: pointer;
color: var(--theme);
}
}
&-abtn {
display: inline-block;
color: #fff;
height: 35px;
line-height: 35px;
padding: 0 15px;
transform-origin: 100% 0;
transform: translateZ(0);
&:hover {
animation-name: wobble-bottom;
animation-duration: 1s;
animation-timing-function: ease-in-out;
animation-iteration-count: 1;
}
> .icon {
display: inline-block;
vertical-align: top;
text-align: center;
.fa {
color: #fff;
}
[class^='fa-'] {
margin-right: 8px;
}
}
> .content {
color: #fff;
display: inline-block;
vertical-align: top;
max-width: 200px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
&-anote {
position: relative;
display: inline-block;
color: #fff;
height: 35px;
line-height: 35px;
transform: translateZ(0);
transition: transform 0.35s;
&:hover {
transform: translateY(-3px);
}
> .icon {
display: inline-block;
vertical-align: top;
width: 35px;
height: 35px;
text-align: center;
background: rgba(0, 0, 0, 0.2);
.fa {
color: #fff;
}
}
> .content {
color: #fff;
display: inline-block;
vertical-align: top;
padding: 0 12px;
max-width: 200px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
&.secondary {
background: #34495e;
}
&.success {
background: #27ae60;
}
&.warning {
background: #f39c12;
}
&.error {
background: #e74c3c;
}
&.info {
background: #3498db;
}
}
&-dotted {
display: block;
width: 100%;
height: 2px;
background-size: 80px;
}
/* 以下未测试 */
&-protected {
display: flex;
justify-content: center;
@ -1907,65 +2092,6 @@
}
}
}
&-checkbox {
-webkit-appearance: none;
position: relative;
border-radius: 2px;
width: 15px;
height: 15px;
border: 2px solid var(--theme);
vertical-align: -2px;
&:disabled {
cursor: not-allowed;
}
&:checked {
border: none;
background: var(--theme);
&::after {
content: '';
width: 3px;
height: 7px;
position: absolute;
top: 2px;
left: 5px;
border: 2px solid #fff;
border-top: 0;
border-left: 0;
transform: rotate(45deg);
}
}
}
&-card {
margin: 0 auto;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
border-radius: var(--radius-inner);
border: 1px solid var(--classC);
background: var(--background);
.title {
padding: 8px 10px;
border-bottom: 1px solid var(--classC);
color: var(--main);
user-select: none;
}
.content {
padding: 10px;
color: var(--routine);
}
}
&-hide {
background: repeating-linear-gradient(145deg, var(--classD), var(--classD) 15px, var(--background) 0, var(--background) 25px);
padding: 15px 0;
text-align: center;
position: relative;
user-select: none;
line-height: normal;
i {
position: relative;
font-style: normal;
cursor: pointer;
color: var(--theme);
}
}
&-message {
position: relative;
border-left-width: 4px;
@ -2043,117 +2169,6 @@
}
}
}
&-mtitle {
display: flex;
justify-content: center;
.text {
position: relative;
color: var(--minor);
padding: 0 12px;
transition: padding 0.35s;
&:hover {
padding: 0;
}
&::before,
&::after {
content: '';
position: absolute;
top: 50%;
width: 20px;
height: 1px;
background: var(--theme);
}
&::before {
left: -35px;
}
&::after {
right: -35px;
}
}
}
&-anote {
position: relative;
display: inline-block;
color: #fff;
height: 35px;
line-height: 35px;
transform: translateZ(0);
transition: transform 0.35s;
&:hover {
transform: translateY(-3px);
}
.icon {
display: inline-block;
vertical-align: top;
width: 35px;
height: 35px;
text-align: center;
background: rgba(0, 0, 0, 0.2);
.fa {
color: #fff;
}
}
.content {
color: #fff;
display: inline-block;
vertical-align: top;
padding: 0 12px;
max-width: 200px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
&.secondary {
background: #34495e;
}
&.success {
background: #27ae60;
}
&.warning {
background: #f39c12;
}
&.error {
background: #e74c3c;
}
&.info {
background: #3498db;
}
}
&-abtn {
display: inline-block;
color: #fff;
height: 35px;
line-height: 35px;
padding: 0 15px;
transform-origin: 100% 0;
transform: translateZ(0);
&:hover {
animation-name: wobble-bottom;
animation-duration: 1s;
animation-timing-function: ease-in-out;
animation-iteration-count: 1;
}
.icon {
display: inline-block;
vertical-align: top;
text-align: center;
.fa {
color: #fff;
}
[class^='fa-'] {
margin-right: 8px;
}
}
.content {
color: #fff;
display: inline-block;
vertical-align: top;
max-width: 200px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
&-copy {
cursor: pointer;
user-select: none;
@ -2237,11 +2252,6 @@
}
}
}
&-dotted {
width: 100%;
height: 2px;
background-size: 80px;
}
}
&__agree {
display: flex;

View File

@ -3,11 +3,11 @@ document.addEventListener('DOMContentLoaded', () => {
constructor() {
super();
this.innerHTML = `
<div class="joe_detail__article-mtitle">
<span class="joe_detail__article-mtitle">
<span class="text">
${this.getAttribute('title') || '默认标题'}
</span>
</div>`;
</span>`;
}
}
window.customElements.define('joe-mtitle', JoeMtitle);
@ -114,7 +114,7 @@ document.addEventListener('DOMContentLoaded', () => {
this.startColor = this.getAttribute('startColor') || '#ff6c6c';
this.endColor = this.getAttribute('endColor') || '#1989fa';
this.innerHTML = `
<div class="joe_detail__article-dotted" style="background-image: repeating-linear-gradient(-45deg, ${this.startColor} 0, ${this.startColor} 20%, transparent 0, transparent 25%, ${this.endColor} 0, ${this.endColor} 45%, transparent 0, transparent 50%)"></div>
<span class="joe_detail__article-dotted" style="background-image: repeating-linear-gradient(-45deg, ${this.startColor} 0, ${this.startColor} 20%, transparent 0, transparent 25%, ${this.endColor} 0, ${this.endColor} 45%, transparent 0, transparent 50%)"></span>
`;
}
}
@ -125,7 +125,7 @@ document.addEventListener('DOMContentLoaded', () => {
this.render();
}
render() {
this.innerHTML = '<div class="joe_detail__article-hide">此处内容作者设置了 <i>回复</i> 可见</div>';
this.innerHTML = '<span class="joe_detail__article-hide">此处内容作者设置了 <i>回复</i> 可见</span>';
this.$button = this.querySelector('i');
const $comment = document.querySelector('.joe_comment');
const $header = document.querySelector('.joe_header');
@ -137,11 +137,39 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
window.customElements.define('joe-hide', JoeHide);
class JoeCardDefault extends HTMLElement {
constructor() {
super();
const _temp = this.querySelector('._temp');
this.options = {
width: this.getAttribute('width') || '100%',
label: this.getAttribute('label') || '卡片标题',
content: _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '卡片内容'
};
const htmlStr = `
<span class="joe_detail__article-card_default" style="width: ${this.options.width}">
<span class="title">${this.options.label}</span>
<span class="content">${this.options.content}</span>
</span>
`;
if (this.querySelector('._content')) {
this.querySelector('._content').innerHTML = htmlStr;
} else {
const div = document.createElement('div');
div.className = '_content';
div.innerHTML = htmlStr;
this.appendChild(div);
}
}
}
window.customElements.define('joe-card-default', JoeCardDefault);
const article = document.querySelector('.joe_detail__article');
if (article) article.innerHTML = article.innerHTML.replace(/<p><\/p>/g, '');
/*
------------------------以下未测试------------------------------------------
*/
/* 点击复制 */
class JoeCopy extends HTMLElement {
constructor() {
@ -188,28 +216,4 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
window.customElements.define('joe-message', JoeMessage);
/* 默认卡片 */
class JoeCard extends HTMLElement {
constructor() {
super();
this.options = {
width: this.getAttribute('width') || '100%',
label: this.getAttribute('label') || '默认标题',
content: this.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '默认内容'
};
this.render();
}
get template() {
return `
<div class="joe_detail__article-card" style="width: ${this.options.width}">
<div class="title">${this.options.label}</div>
<div class="content">${this.options.content}</div>
</div>
`;
}
render() {
this.innerHTML = this.template;
}
}
window.customElements.define('joe-card', JoeCard);
});

File diff suppressed because one or more lines are too long

View File

@ -55,10 +55,11 @@ class Editor
themeURL: '<?php Helper::options()->themeUrl(); ?>'
}
</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('assets/js/joe.short.min.js?v=20210419') ?>"></script>
<script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.parse.min.js?v=20210419') ?>"></script>
<script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.write.chunk.js?v=20210419') ?>"></script>
<script src="<?php Helper::options()->themeUrl('assets/js/joe.short.min.js?v=20210419') ?>"></script>
<?php
}
}

View File

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

View File

@ -43,16 +43,13 @@ function _parseContent($post, $login)
$content = preg_replace('/{hide[^}]*}(.*?){\/hide}/', '<joe-hide></joe-hide>', $content);
}
}
/* 过滤默认卡片 */
if (strpos($content, '{card-default') !== false) {
$content = preg_replace('/{card-default(.*)}/SU', '<joe-card $1>', $content);
$content = preg_replace('/{\/card-default}/SU', '</joe-card>', $content);
$content = preg_replace('/{card-default([^}]*)}(.*?){\/card-default}/', '<section style="margin-bottom: 15px"><joe-card-default $1><span class="_temp" style="display: none">$2</span></joe-card-default></section>', $content);
}
/* 过滤复制粘贴功能 */
if (strpos($content, '{copy') !== false) {
$content = preg_replace('/{copy(.*)}/SU', '<joe-copy $1>', $content);

View File

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

File diff suppressed because one or more lines are too long

View File

@ -653,11 +653,33 @@ body.fullscreen {
}
}
}
.joe_detail__article-card_default {
display: block;
margin: 0 auto;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
border-radius: 4px;
border: 1px solid #ebeef5;
background: #fff;
> .title {
display: block;
padding: 8px 10px;
border-bottom: 1px solid #ebeef5;
color: #303133;
user-select: none;
}
> .content {
display: block;
padding: 10px;
color: #606266;
*:last-child {
margin-bottom: 0 !important;
}
}
}
.joe_detail__article-mtitle {
display: flex;
justify-content: center;
.text {
> .text {
position: relative;
color: #909399;
padding: 0 12px;
@ -679,20 +701,33 @@ body.fullscreen {
}
}
}
.joe_detail__article-player {
width: 100%;
height: 180px;
border: none;
}
.joe_detail__article-hide {
display: block;
background: repeating-linear-gradient(145deg, #f2f6fc, #f2f6fc 15px, #fff 0, #fff 25px);
padding: 15px 0;
text-align: center;
position: relative;
user-select: none;
line-height: normal;
> i {
position: relative;
font-style: normal;
cursor: pointer;
color: #409eff;
}
}
.joe_detail__article-abtn {
display: inline-block;
color: #fff;
height: 35px;
line-height: 35px;
padding: 0 15px;
.icon {
> .icon {
display: inline-block;
vertical-align: top;
text-align: center;
@ -703,7 +738,7 @@ body.fullscreen {
margin-right: 8px;
}
}
.content {
> .content {
color: #fff;
display: inline-block;
vertical-align: top;
@ -716,14 +751,13 @@ body.fullscreen {
color: #fff;
}
}
.joe_detail__article-anote {
position: relative;
display: inline-block;
color: #fff;
height: 35px;
line-height: 35px;
.icon {
> .icon {
display: inline-block;
vertical-align: top;
width: 35px;
@ -734,7 +768,7 @@ body.fullscreen {
color: #fff;
}
}
.content {
> .content {
display: inline-block;
vertical-align: top;
padding: 0 12px;
@ -763,27 +797,15 @@ body.fullscreen {
color: #fff;
}
}
.joe_detail__article-dotted {
display: block;
width: 100%;
height: 2px;
background-size: 80px;
}
.joe_detail__article-hide {
background: repeating-linear-gradient(145deg, #f2f6fc, #f2f6fc 15px, #fff 0, #fff 25px);
padding: 15px 0;
text-align: center;
position: relative;
user-select: none;
line-height: normal;
i {
position: relative;
font-style: normal;
cursor: pointer;
color: #409eff;
}
}
@media (max-width: 768px) {
.cm-modal__wrapper {

View File

@ -477,7 +477,7 @@ export default class JoeAction {
cm.focus();
}
handleHide(cm) {
const str = `${this._getLineCh(cm) ? '\n' : ''}{hide}\n需要隐藏的内容\n{/hide}\n`;
const str = `${this._getLineCh(cm) ? '\n\n' : '\n'}{hide}\n需要隐藏的内容\n{/hide}\n\n`;
this._replaceSelection(cm, str);
cm.focus();
}
@ -587,4 +587,27 @@ export default class JoeAction {
}
});
}
handleCardDefault(cm) {
this._openModal({
title: '默认卡片',
innerHtml: `
<div class="fitem">
<label>卡片标题</label>
<input autocomplete="off" name="label" placeholder="请输入卡片标题"/>
</div>
<div class="fitem">
<label>卡片宽度</label>
<input autocomplete="off" name="width" placeholder="请输入卡片宽度例如100%"/>
</div>
`,
confirm: () => {
const label = $(".cm-modal input[name='label']").val();
const width = $(".cm-modal input[name='width']").val();
const str = `\n{card-default label="${label}" width="${width}"}\n卡片内容\n{/card-default}\n\n`;
if (this._getLineCh(cm)) this._replaceSelection(cm, '\n' + str);
else this._replaceSelection(cm, str);
cm.focus();
}
});
}
}

View File

@ -25,7 +25,12 @@ export default function createPreviewHtml(str) {
str = str.replace(/{anote([^}]*)\/}/g, '<joe-anote $1></joe-anote>');
str = str.replace(/{dotted([^}]*)\/}/g, '<joe-dotted $1></joe-dotted>');
str = str.replace(/{hide[^}]*}(.*?){\/hide}/g, '<joe-hide></joe-hide>');
str = str.replace(/{card-default([^}]*)}(.*?){\/card-default}/g, '<section style="margin-bottom: 15px"><joe-card-default $1><span class="_temp" style="display: none">$2</span></joe-card-default></section>');
$('.cm-preview-content').html(str);
const div = document.createElement('div');
div.innerHTML = str;
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));
}

View File

@ -160,6 +160,11 @@ export default [
title: '回复可见',
innerHTML: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M342.016 640.512a483.328 483.328 0 0 1-126.976-63.488l-104.96 102.4a51.2 51.2 0 0 1-71.168-74.24l102.4-96.256a419.328 419.328 0 0 1-84.48-133.12 51.2 51.2 0 1 1 95.744-34.816 278.016 278.016 0 0 0 15.872 32.256 378.88 378.88 0 0 0 55.808 77.312A381.952 381.952 0 0 0 512 563.2a382.464 382.464 0 0 0 286.208-112.64 378.88 378.88 0 0 0 58.368-77.312 278.016 278.016 0 0 0 13.824-32.256 51.2 51.2 0 1 1 95.744 34.816 419.328 419.328 0 0 1-84.48 133.12l102.4 96.256a51.2 51.2 0 0 1-71.168 73.216L807.936 576a460.8 460.8 0 0 1-125.952 62.976l58.368 102.4a51.2 51.2 0 0 1-88.576 51.2l-74.752-130.048A521.728 521.728 0 0 1 512 665.6q-32.256 0-62.976-3.072l-76.8 129.536a51.2 51.2 0 0 1-88.576-51.2z"/></svg>'
},
{
type: 'card-default',
title: '默认卡片',
innerHTML: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M928 160H96a32 32 0 0 0-32 32v672a32 32 0 0 0 32 32h832a32 32 0 0 0 32-32V192a32 32 0 0 0-32-32zm-32 672H128V224h768v608zM230.592 448.096H544a32 32 0 1 0 0-64H230.592a32 32 0 0 0 0 64zm0 192H544a32 32 0 1 0 0-64H230.592a32 32 0 1 0 0 64zM768 704a32 32 0 0 0 32-32V350.016a32 32 0 1 0-64 0V672a32 32 0 0 0 32 32z"/></svg>'
},
/* --------------------------- 短代码结束 --------------------------- */
{
type: 'clean',

File diff suppressed because one or more lines are too long

View File

@ -292,6 +292,9 @@ class Joe extends JoeAction {
case 'hide':
super.handleHide(this.cm);
break;
case 'card-default':
super.handleCardDefault(this.cm);
break;
}
});
$('.cm-tools').append(el);