This commit is contained in:
杜恒 2021-04-23 09:34:22 +08:00
parent 5b490ca519
commit f217f02207
14 changed files with 401 additions and 380 deletions

File diff suppressed because one or more lines are too long

View File

@ -1795,7 +1795,7 @@
border: 1px solid #19be6b; border: 1px solid #19be6b;
} }
&-content { &-content {
padding: 1px 1px 10px 24px; padding-left: 24px;
position: relative; position: relative;
top: -3px; top: -3px;
*:last-child { *:last-child {
@ -1803,6 +1803,7 @@
} }
} }
&:last-child { &:last-child {
padding-bottom: 0;
.joe_timeline__item-tail { .joe_timeline__item-tail {
display: none; display: none;
} }
@ -1868,9 +1869,6 @@
height: 500px; height: 500px;
} }
.joe_detail { .joe_detail {
background: var(--background); background: var(--background);
border-radius: var(--radius-wrap); border-radius: var(--radius-wrap);
@ -2284,7 +2282,6 @@
} }
} }
} }
&-video { &-video {
margin-bottom: 18px; margin-bottom: 18px;
.play, .play,
@ -2364,8 +2361,6 @@
} }
} }
} }
/* 以下未测试 */
&-protected { &-protected {
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -2402,10 +2397,6 @@
} }
} }
} }
&-copy {
cursor: pointer;
user-select: none;
}
} }
&__agree { &__agree {
display: flex; display: flex;

View File

@ -1,117 +1,117 @@
/* 获取直属子元素 */ /* 获取直属子元素 */
function getChildren(el, className) { function getChildren(el, className) {
for (let item of el.children) if (item.className === className) return item; for (let item of el.children) if (item.className === className) return item;
return null; return null;
} }
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 {
constructor() { constructor() {
super(); super();
this.innerHTML = ` this.innerHTML = `
<span class="joe_mtitle"> <span class="joe_mtitle">
<span class="joe_mtitle__text"> <span class="joe_mtitle__text">
${this.getAttribute('title') || '默认标题'} ${this.getAttribute('title') || '默认标题'}
</span> </span>
</span> </span>
`; `;
} }
} }
window.customElements.define('joe-mtitle', JoeMtitle); window.customElements.define('joe-mtitle', JoeMtitle);
class JoeMp3 extends HTMLElement { class JoeMp3 extends HTMLElement {
constructor() { constructor() {
super(); super();
this.options = { this.options = {
name: this.getAttribute('name'), name: this.getAttribute('name'),
url: this.getAttribute('url'), url: this.getAttribute('url'),
theme: this.getAttribute('theme') || '#1989fa', theme: this.getAttribute('theme') || '#1989fa',
cover: this.getAttribute('cover'), cover: this.getAttribute('cover'),
autoplay: this.getAttribute('autoplay') ? true : false autoplay: this.getAttribute('autoplay') ? true : false
}; };
this.render(); this.render();
} }
render() { render() {
if (!this.options.url) return (this.innerHTML = '音频地址未填写!'); if (!this.options.url) return (this.innerHTML = '音频地址未填写!');
this.innerHTML = '<span style="display: block" class="_content"></span>'; this.innerHTML = '<span style="display: block" class="_content"></span>';
new APlayer({ new APlayer({
container: getChildren(this, '_content'), container: getChildren(this, '_content'),
theme: this.options.theme, theme: this.options.theme,
autoplay: this.options.autoplay, autoplay: this.options.autoplay,
audio: [ audio: [
{ {
url: this.options.url, url: this.options.url,
name: this.options.name, name: this.options.name,
cover: this.options.cover cover: this.options.cover
} }
] ]
}); });
} }
} }
window.customElements.define('joe-mp3', JoeMp3); 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'),
color: this.getAttribute('color') || '#1989fa', color: this.getAttribute('color') || '#1989fa',
autoplay: this.getAttribute('autoplay') ? true : false autoplay: this.getAttribute('autoplay') ? true : false
}; };
this.render(); this.render();
} }
render() { render() {
if (!this.options.id) return (this.innerHTML = '网易云歌曲ID未填写'); if (!this.options.id) return (this.innerHTML = '网易云歌曲ID未填写');
this.innerHTML = '<span style="display: block" class="_content"></span>'; this.innerHTML = '<span style="display: block" class="_content"></span>';
fetch('https://api.i-meto.com/meting/api?server=netease&type=song&id=' + this.options.id).then(async response => { fetch('https://api.i-meto.com/meting/api?server=netease&type=song&id=' + this.options.id).then(async response => {
const audio = await response.json(); const audio = await response.json();
new APlayer({ new APlayer({
container: getChildren(this, '_content'), container: getChildren(this, '_content'),
lrcType: 3, lrcType: 3,
theme: this.options.color, theme: this.options.color,
autoplay: this.options.autoplay, autoplay: this.options.autoplay,
audio audio
}); });
}); });
} }
} }
window.customElements.define('joe-music', JoeMusic); window.customElements.define('joe-music', JoeMusic);
class JoeMlist extends HTMLElement { class JoeMlist extends HTMLElement {
constructor() { constructor() {
super(); super();
this.options = { this.options = {
id: this.getAttribute('id'), id: this.getAttribute('id'),
color: this.getAttribute('color') || '#1989fa', color: this.getAttribute('color') || '#1989fa',
autoplay: this.getAttribute('autoplay') ? true : false autoplay: this.getAttribute('autoplay') ? true : false
}; };
this.render(); this.render();
} }
render() { render() {
if (!this.options.id) return (this.innerHTML = '网易云歌单ID未填写'); if (!this.options.id) return (this.innerHTML = '网易云歌单ID未填写');
this.innerHTML = '<span style="display: block" class="_content"></span>'; this.innerHTML = '<span style="display: block" class="_content"></span>';
fetch('https://api.i-meto.com/meting/api?server=netease&type=playlist&id=' + this.options.id).then(async response => { fetch('https://api.i-meto.com/meting/api?server=netease&type=playlist&id=' + this.options.id).then(async response => {
const audio = await response.json(); const audio = await response.json();
new APlayer({ new APlayer({
container: getChildren(this, '_content'), container: getChildren(this, '_content'),
lrcType: 3, lrcType: 3,
theme: this.options.color, theme: this.options.color,
autoplay: this.options.autoplay, autoplay: this.options.autoplay,
audio audio
}); });
}); });
} }
} }
window.customElements.define('joe-mlist', JoeMlist); window.customElements.define('joe-mlist', JoeMlist);
class JoeAbtn extends HTMLElement { class JoeAbtn extends HTMLElement {
constructor() { constructor() {
super(); super();
this.options = { this.options = {
icon: this.getAttribute('icon') || '', icon: this.getAttribute('icon') || '',
color: this.getAttribute('color') || '#ff6800', color: this.getAttribute('color') || '#ff6800',
href: this.getAttribute('href') || '#', href: this.getAttribute('href') || '#',
radius: this.getAttribute('radius') || '17.5px', radius: this.getAttribute('radius') || '17.5px',
content: this.getAttribute('content') || '多彩按钮' content: this.getAttribute('content') || '多彩按钮'
}; };
this.innerHTML = ` this.innerHTML = `
<a class="joe_abtn" style="background: ${this.options.color}; border-radius: ${this.options.radius}" href="${this.options.href}" target="_blank" rel="noopener noreferrer nofollow"> <a class="joe_abtn" style="background: ${this.options.color}; border-radius: ${this.options.radius}" href="${this.options.href}" target="_blank" rel="noopener noreferrer nofollow">
<span class="joe_abtn__icon"> <span class="joe_abtn__icon">
<i class="${this.options.icon} fa"></i> <i class="${this.options.icon} fa"></i>
@ -121,19 +121,19 @@ document.addEventListener('DOMContentLoaded', () => {
</span> </span>
</a> </a>
`; `;
} }
} }
window.customElements.define('joe-abtn', JoeAbtn); window.customElements.define('joe-abtn', JoeAbtn);
class JoeAnote extends HTMLElement { class JoeAnote extends HTMLElement {
constructor() { constructor() {
super(); super();
this.options = { this.options = {
icon: this.getAttribute('icon') || 'fa-download', icon: this.getAttribute('icon') || 'fa-download',
href: this.getAttribute('href') || '#', href: this.getAttribute('href') || '#',
type: /^secondary$|^success$|^warning$|^error$|^info$/.test(this.getAttribute('type')) ? this.getAttribute('type') : 'secondary', type: /^secondary$|^success$|^warning$|^error$|^info$/.test(this.getAttribute('type')) ? this.getAttribute('type') : 'secondary',
content: this.getAttribute('content') || '标签按钮' content: this.getAttribute('content') || '标签按钮'
}; };
this.innerHTML = ` this.innerHTML = `
<a class="joe_anote ${this.options.type}" href="${this.options.href}" target="_blank" rel="noopener noreferrer nofollow"> <a class="joe_anote ${this.options.type}" href="${this.options.href}" target="_blank" rel="noopener noreferrer nofollow">
<span class="joe_anote__icon"> <span class="joe_anote__icon">
<i class="fa ${this.options.icon}"></i> <i class="fa ${this.options.icon}"></i>
@ -143,89 +143,89 @@ document.addEventListener('DOMContentLoaded', () => {
</span> </span>
</a> </a>
`; `;
} }
} }
window.customElements.define('joe-anote', JoeAnote); window.customElements.define('joe-anote', JoeAnote);
class JoeDotted extends HTMLElement { class JoeDotted extends HTMLElement {
constructor() { constructor() {
super(); super();
this.startColor = this.getAttribute('startColor') || '#ff6c6c'; this.startColor = this.getAttribute('startColor') || '#ff6c6c';
this.endColor = this.getAttribute('endColor') || '#1989fa'; this.endColor = this.getAttribute('endColor') || '#1989fa';
this.innerHTML = ` this.innerHTML = `
<span class="joe_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> <span class="joe_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>
`; `;
} }
} }
window.customElements.define('joe-dotted', JoeDotted); window.customElements.define('joe-dotted', JoeDotted);
class JoeHide extends HTMLElement { class JoeHide extends HTMLElement {
constructor() { constructor() {
super(); super();
this.render(); this.render();
} }
render() { render() {
this.innerHTML = '<span class="joe_hide">此处内容作者设置了 <i class="joe_hide__button">回复</i> 可见</span>'; this.innerHTML = '<span class="joe_hide">此处内容作者设置了 <i class="joe_hide__button">回复</i> 可见</span>';
this.$button = this.querySelector('.joe_hide__button'); this.$button = this.querySelector('.joe_hide__button');
const $comment = document.querySelector('.joe_comment'); const $comment = document.querySelector('.joe_comment');
const $header = document.querySelector('.joe_header'); const $header = document.querySelector('.joe_header');
if (!$comment || !$header) return; if (!$comment || !$header) return;
this.$button.addEventListener('click', () => { this.$button.addEventListener('click', () => {
const top = $comment.offsetTop - $header.offsetHeight - 15; const top = $comment.offsetTop - $header.offsetHeight - 15;
window.scrollTo({ top, behavior: 'smooth' }); window.scrollTo({ top, behavior: 'smooth' });
}); });
} }
} }
window.customElements.define('joe-hide', JoeHide); window.customElements.define('joe-hide', JoeHide);
class JoeCardDefault extends HTMLElement { class JoeCardDefault extends HTMLElement {
constructor() { constructor() {
super(); super();
const _temp = getChildren(this, '_temp'); const _temp = getChildren(this, '_temp');
this.options = { this.options = {
width: this.getAttribute('width') || '100%', width: this.getAttribute('width') || '100%',
label: this.getAttribute('label') || '卡片标题', label: this.getAttribute('label') || '卡片标题',
content: _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '卡片内容' content: _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '卡片内容'
}; };
const htmlStr = ` const htmlStr = `
<div class="joe_card__default" style="width: ${this.options.width}"> <div class="joe_card__default" style="width: ${this.options.width}">
<div class="joe_card__default-title">${this.options.label}</div> <div class="joe_card__default-title">${this.options.label}</div>
<div class="joe_card__default-content">${this.options.content}</div> <div class="joe_card__default-content">${this.options.content}</div>
</div> </div>
`; `;
if (getChildren(this, '_content')) { if (getChildren(this, '_content')) {
getChildren(this, '_content').innerHTML = htmlStr; getChildren(this, '_content').innerHTML = htmlStr;
} else { } else {
const span = document.createElement('span'); const span = document.createElement('span');
span.style.display = 'block'; span.style.display = 'block';
span.className = '_content'; span.className = '_content';
span.innerHTML = htmlStr; span.innerHTML = htmlStr;
this.appendChild(span); this.appendChild(span);
} }
} }
} }
window.customElements.define('joe-card-default', JoeCardDefault); window.customElements.define('joe-card-default', JoeCardDefault);
class JoeMessage extends HTMLElement { class JoeMessage extends HTMLElement {
constructor() { constructor() {
super(); super();
this.options = { this.options = {
type: /^success$|^info$|^warning$|^error$/.test(this.getAttribute('type')) ? this.getAttribute('type') : 'info', type: /^success$|^info$|^warning$|^error$/.test(this.getAttribute('type')) ? this.getAttribute('type') : 'info',
content: this.getAttribute('content') || '消息内容' content: this.getAttribute('content') || '消息内容'
}; };
this.innerHTML = ` this.innerHTML = `
<span class="joe_message ${this.options.type}"> <span class="joe_message ${this.options.type}">
<span class="joe_message__icon"></span> <span class="joe_message__icon"></span>
<span class="joe_message__content">${this.options.content}</span> <span class="joe_message__content">${this.options.content}</span>
</span> </span>
`; `;
} }
} }
window.customElements.define('joe-message', JoeMessage); window.customElements.define('joe-message', JoeMessage);
class JoeProgress extends HTMLElement { class JoeProgress extends HTMLElement {
constructor() { constructor() {
super(); super();
this.options = { this.options = {
percentage: /^\d{1,3}%$/.test(this.getAttribute('percentage')) ? this.getAttribute('percentage') : '50%', percentage: /^\d{1,3}%$/.test(this.getAttribute('percentage')) ? this.getAttribute('percentage') : '50%',
color: this.getAttribute('color') || '#ff6c6c' color: this.getAttribute('color') || '#ff6c6c'
}; };
this.innerHTML = ` this.innerHTML = `
<span class="joe_progress"> <span class="joe_progress">
<div class="joe_progress__strip"> <div class="joe_progress__strip">
<div class="joe_progress__strip-percent" style="width: ${this.options.percentage}; background: ${this.options.color};"></div> <div class="joe_progress__strip-percent" style="width: ${this.options.percentage}; background: ${this.options.color};"></div>
@ -233,184 +233,174 @@ document.addEventListener('DOMContentLoaded', () => {
<div class="joe_progress__percentage">${this.options.percentage}</div> <div class="joe_progress__percentage">${this.options.percentage}</div>
</span> </span>
`; `;
} }
} }
window.customElements.define('joe-progress', JoeProgress); window.customElements.define('joe-progress', JoeProgress);
class JoeCallout extends HTMLElement { class JoeCallout extends HTMLElement {
constructor() { constructor() {
super(); super();
const _temp = getChildren(this, '_temp'); const _temp = getChildren(this, '_temp');
this.options = { this.options = {
color: this.getAttribute('color') || '#f0ad4e', color: this.getAttribute('color') || '#f0ad4e',
content: _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '标注内容' content: _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '标注内容'
}; };
const htmlStr = ` const htmlStr = `
<div class="joe_callout" style="border-left-color: ${this.options.color};"> <div class="joe_callout" style="border-left-color: ${this.options.color};">
${this.options.content} ${this.options.content}
</div> </div>
`; `;
if (getChildren(this, '_content')) { if (getChildren(this, '_content')) {
getChildren(this, '_content').innerHTML = htmlStr; getChildren(this, '_content').innerHTML = htmlStr;
} else { } else {
const span = document.createElement('span'); const span = document.createElement('span');
span.style.display = 'block'; span.style.display = 'block';
span.className = '_content'; span.className = '_content';
span.innerHTML = htmlStr; span.innerHTML = htmlStr;
this.appendChild(span); this.appendChild(span);
} }
} }
} }
window.customElements.define('joe-callout', JoeCallout); window.customElements.define('joe-callout', JoeCallout);
class JoeCardList extends HTMLElement { class JoeCardList extends HTMLElement {
constructor() { constructor() {
super(); super();
const _temp = getChildren(this, '_temp'); const _temp = getChildren(this, '_temp');
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, ''); let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
let content = ''; let content = '';
_innerHTML.replace(/{card-list-item}([\s\S]*?){\/card-list-item}/g, function ($0, $1) { _innerHTML.replace(/{card-list-item}([\s\S]*?){\/card-list-item}/g, function ($0, $1) {
content += `<div class="joe_card__list-item">${$1.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>`; content += `<div class="joe_card__list-item">${$1.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>`;
}); });
let htmlStr = `<div class="joe_card__list">${content}</div>`; let htmlStr = `<div class="joe_card__list">${content}</div>`;
if (getChildren(this, '_content')) { if (getChildren(this, '_content')) {
getChildren(this, '_content').innerHTML = htmlStr; getChildren(this, '_content').innerHTML = htmlStr;
} else { } else {
const span = document.createElement('span'); const span = document.createElement('span');
span.className = '_content'; span.className = '_content';
span.style.display = 'block'; span.style.display = 'block';
span.innerHTML = htmlStr; span.innerHTML = htmlStr;
this.appendChild(span); this.appendChild(span);
} }
} }
} }
window.customElements.define('joe-card-list', JoeCardList); window.customElements.define('joe-card-list', JoeCardList);
class JoeTimeline extends HTMLElement { class JoeTimeline extends HTMLElement {
constructor() { constructor() {
super(); super();
const _temp = getChildren(this, '_temp'); const _temp = getChildren(this, '_temp');
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, ''); let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
let content = ''; let content = '';
_innerHTML.replace(/{timeline-item([^}]*)}([\s\S]*?){\/timeline-item}/g, function ($0, $1, $2) { _innerHTML.replace(/{timeline-item([^}]*)}([\s\S]*?){\/timeline-item}/g, function ($0, $1, $2) {
content += ` content += `
<div class="joe_timeline__item"> <div class="joe_timeline__item">
<div class="joe_timeline__item-tail"></div> <div class="joe_timeline__item-tail"></div>
<div class="joe_timeline__item-circle" ${$1}></div> <div class="joe_timeline__item-circle" ${$1}></div>
<div class="joe_timeline__item-content">${$2.trim().replace(/^(<br>)|(<br>)$/g, '')}</div> <div class="joe_timeline__item-content">${$2.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>
</div> </div>
`; `;
}); });
let htmlStr = `<div class="joe_timeline">${content}</div>`; let htmlStr = `<div class="joe_timeline">${content}</div>`;
if (getChildren(this, '_content')) { if (getChildren(this, '_content')) {
getChildren(this, '_content').innerHTML = htmlStr; getChildren(this, '_content').innerHTML = htmlStr;
} else { } else {
const span = document.createElement('span'); const span = document.createElement('span');
span.className = '_content'; span.className = '_content';
span.style.display = 'block'; span.style.display = 'block';
span.innerHTML = htmlStr; span.innerHTML = htmlStr;
this.appendChild(span); this.appendChild(span);
} }
this.querySelectorAll('.joe_timeline__item-circle').forEach((item, index) => { this.querySelectorAll('.joe_timeline__item-circle').forEach((item, index) => {
const color = item.getAttribute('color') || '#19be6b'; const color = item.getAttribute('color') || '#19be6b';
item.style.borderColor = color; item.style.borderColor = color;
}); });
} }
} }
window.customElements.define('joe-timeline', JoeTimeline); window.customElements.define('joe-timeline', JoeTimeline);
class JoeDplayer extends HTMLElement { class JoeDplayer extends HTMLElement {
constructor() { constructor() {
super(); super();
this.options = { this.options = {
src: this.getAttribute('src'), src: this.getAttribute('src'),
player: this.getAttribute('player') player: this.getAttribute('player')
}; };
this.render(); this.render();
} }
render() { render() {
if (this.options.src) this.innerHTML = `<iframe allowfullscreen="true" class="joe_vplayer" src="${this.options.player + this.options.src}"></iframe>`; if (this.options.src) this.innerHTML = `<iframe allowfullscreen="true" class="joe_vplayer" src="${this.options.player + this.options.src}"></iframe>`;
else this.innerHTML = '播放地址未填写!'; else this.innerHTML = '播放地址未填写!';
} }
} }
window.customElements.define('joe-dplayer', JoeDplayer); window.customElements.define('joe-dplayer', JoeDplayer);
class JoeBilibili extends HTMLElement { class JoeBilibili extends HTMLElement {
constructor() { constructor() {
super(); super();
this.bvid = this.getAttribute('bvid'); this.bvid = this.getAttribute('bvid');
this.render(); this.render();
} }
render() { render() {
if (this.bvid) this.innerHTML = `<iframe allowfullscreen="true" class="joe_vplayer" src="//player.bilibili.com/player.html?bvid=${this.bvid}"></iframe>`; if (this.bvid) this.innerHTML = `<iframe allowfullscreen="true" class="joe_vplayer" src="//player.bilibili.com/player.html?bvid=${this.bvid}"></iframe>`;
else this.innerHTML = 'Bvid未填写'; else this.innerHTML = 'Bvid未填写';
} }
} }
window.customElements.define('joe-bilibili', JoeBilibili); window.customElements.define('joe-bilibili', JoeBilibili);
class JoeTabs extends HTMLElement { class JoeTabs extends HTMLElement {
constructor() { constructor() {
super(); super();
const _temp = getChildren(this, '_temp'); const _temp = getChildren(this, '_temp');
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, ''); let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
let navs = ''; let navs = '';
let contents = ''; let contents = '';
_innerHTML.replace(/{tabs-pane([^}]*)}([\s\S]*?){\/tabs-pane}/g, function ($0, $1, $2) { _innerHTML.replace(/{tabs-pane([^}]*)}([\s\S]*?){\/tabs-pane}/g, function ($0, $1, $2) {
navs += `<div class="joe_tabs__head-item" ${$1}></div>`; navs += `<div class="joe_tabs__head-item" ${$1}></div>`;
contents += `<div style="display: none" class="joe_tabs__body-item" ${$1}>${$2.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>`; contents += `<div style="display: none" class="joe_tabs__body-item" ${$1}>${$2.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>`;
}); });
let htmlStr = ` let htmlStr = `
<div class="joe_tabs"> <div class="joe_tabs">
<div class="joe_tabs__head">${navs}</div> <div class="joe_tabs__head">${navs}</div>
<div class="joe_tabs__body">${contents}</div> <div class="joe_tabs__body">${contents}</div>
</div> </div>
`; `;
if (getChildren(this, '_content')) { if (getChildren(this, '_content')) {
getChildren(this, '_content').innerHTML = htmlStr; getChildren(this, '_content').innerHTML = htmlStr;
} else { } else {
const span = document.createElement('span'); const span = document.createElement('span');
span.className = '_content'; span.className = '_content';
span.style.display = 'block'; span.style.display = 'block';
span.innerHTML = htmlStr; span.innerHTML = htmlStr;
this.appendChild(span); this.appendChild(span);
} }
this.querySelectorAll('.joe_tabs__head-item').forEach((item, index) => { this.querySelectorAll('.joe_tabs__head-item').forEach((item, index) => {
const label = item.getAttribute('label'); const label = item.getAttribute('label');
item.innerHTML = label; item.innerHTML = label;
item.addEventListener('click', () => { item.addEventListener('click', () => {
this.querySelectorAll('.joe_tabs__head-item').forEach(_item => _item.classList.remove('active')); this.querySelectorAll('.joe_tabs__head-item').forEach(_item => _item.classList.remove('active'));
this.querySelectorAll('.joe_tabs__body-item').forEach(_item => (_item.style.display = 'none')); this.querySelectorAll('.joe_tabs__body-item').forEach(_item => (_item.style.display = 'none'));
if (this.querySelector(`.joe_tabs__body-item[label="${label}"]`)) { if (this.querySelector(`.joe_tabs__body-item[label="${label}"]`)) {
this.querySelector(`.joe_tabs__body-item[label="${label}"]`).style.display = 'block'; this.querySelector(`.joe_tabs__body-item[label="${label}"]`).style.display = 'block';
} }
item.classList.add('active'); item.classList.add('active');
}); });
if (index === 0) item.click(); if (index === 0) item.click();
}); });
} }
} }
window.customElements.define('joe-tabs', JoeTabs); window.customElements.define('joe-tabs', JoeTabs);
class JoeCopy extends HTMLElement {
constructor() {
super();
this.options = {
showText: this.getAttribute('showText') || '点击复制',
copyText: this.getAttribute('copyText') || '默认文本'
};
this.innerHTML = `<span class="joe_copy" style="cursor: pointer; user-select: none;">${this.options.showText}</span>`;
const button = getChildren(this, 'joe_copy');
if (typeof ClipboardJS !== 'undefined' && typeof Qmsg !== 'undefined') {
new ClipboardJS(button, { text: () => this.options.copyText }).on('success', () => Qmsg.success('复制成功!'));
} else {
button.addEventListener('click', () => alert('该功能请前往前台查看!'));
}
}
}
window.customElements.define('joe-copy', JoeCopy);
$('.joe_detail__article p:empty').remove(); $('.joe_detail__article p:empty').remove();
/*
------------------------以下未测试------------------------------------------
*/
/* 点击复制 */
class JoeCopy extends HTMLElement {
constructor() {
super();
this.options = {
text: this.getAttribulte('text') || '默认文本',
content: this.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '点击复制'
};
this.render();
}
get template() {
return `<span class="joe_detail__article-copy">${this.options.content}</span>`;
}
render() {
this.innerHTML = this.template;
this.event();
}
event() {
this.$copy = this.querySelector('.joe_detail__article-copy');
new ClipboardJS(this.$copy, { text: () => this.options.text }).on('success', () => Qmsg.success('复制成功!'));
}
}
window.customElements.define('joe-copy', JoeCopy);
}); });

File diff suppressed because one or more lines are too long

View File

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

View File

@ -65,16 +65,15 @@ function _parseContent($post, $login)
$content = preg_replace('/{card-list}([\s\S]*?){\/card-list}/', '<section style="margin-bottom: 15px"><joe-card-list><span class="_temp" style="display: none">$1</span></joe-card-list></section>', $content); $content = preg_replace('/{card-list}([\s\S]*?){\/card-list}/', '<section style="margin-bottom: 15px"><joe-card-list><span class="_temp" style="display: none">$1</span></joe-card-list></section>', $content);
} }
if (strpos($content, '{timeline') !== false) { if (strpos($content, '{timeline') !== false) {
$content = preg_replace('/{timeline}([\s\S]*?){\/timeline}/', '<section><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, '{copy') !== false) { if (strpos($content, '{copy') !== false) {
$content = preg_replace('/{copy(.*)}/SU', '<joe-copy $1>', $content); $content = preg_replace('/{copy([^}]*)\/}/SU', '<joe-copy $1></joe-copy>', $content);
$content = preg_replace('/{\/copy}/SU', '</joe-copy>', $content);
} }
echo $content; echo $content;
} }

View File

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

File diff suppressed because one or more lines are too long

View File

@ -962,7 +962,7 @@ body.fullscreen {
border: 1px solid #19be6b; border: 1px solid #19be6b;
} }
&-content { &-content {
padding: 1px 1px 10px 24px; padding-left: 24px;
position: relative; position: relative;
top: -3px; top: -3px;
*:last-child { *:last-child {

View File

@ -735,4 +735,27 @@ export default class JoeAction {
this._replaceSelection(cm, str); this._replaceSelection(cm, str);
cm.focus(); cm.focus();
} }
handleCopy(cm) {
this._openModal({
title: '插入音乐',
innerHtml: `
<div class="fitem">
<label>显示文案</label>
<input autocomplete="off" name="showText" placeholder="请输入显示文案"/>
</div>
<div class="fitem" style="align-items: flex-start">
<label>复制内容</label>
<textarea autocomplete="off" name="copyText" placeholder="请输入需要复制的内容"></textarea>
</div>
`,
confirm: () => {
const showText = $(".cm-modal input[name='showText']").val();
const copyText = $(".cm-modal textarea[name='copyText']").val();
const str = `\n{copy showText="${showText}" copyText="${copyText}"/}\n\n`;
if (this._getLineCh(cm)) this._replaceSelection(cm, '\n' + str);
else this._replaceSelection(cm, str);
cm.focus()
}
});
}
} }

View File

@ -26,6 +26,7 @@ export default function createPreviewHtml(str) {
str = str.replace(/{mp3([^}]*)\/}/g, '<joe-mp3 $1></joe-mp3>'); 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(/{copy([^}]*)\/}/g, '<joe-copy $1></joe-copy>');
str = str.replace(/{dotted([^}]*)\/}/g, '<joe-dotted $1></joe-dotted>'); str = str.replace(/{dotted([^}]*)\/}/g, '<joe-dotted $1></joe-dotted>');
str = str.replace(/{message([^}]*)\/}/g, '<joe-message $1></joe-message>'); str = str.replace(/{message([^}]*)\/}/g, '<joe-message $1></joe-message>');
str = str.replace(/{progress([^}]*)\/}/g, '<joe-progress $1></joe-progress>'); str = str.replace(/{progress([^}]*)\/}/g, '<joe-progress $1></joe-progress>');
@ -34,7 +35,7 @@ export default function createPreviewHtml(str) {
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>'); 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><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>');
$('.cm-preview-content').html(str); $('.cm-preview-content').html(str);
$('.cm-preview-content p:empty').remove(); $('.cm-preview-content p:empty').remove();

View File

@ -200,6 +200,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="M365.714 329.143c0-47.543-29.257-87.772-73.143-102.4V36.57C292.571 14.63 277.943 0 256 0s-36.571 14.629-36.571 36.571v190.172c-43.886 14.628-73.143 54.857-73.143 102.4 0 47.543 29.257 87.771 73.143 102.4V588.8c-43.886 14.629-73.143 54.857-73.143 102.4 0 47.543 29.257 87.771 73.143 102.4v193.829c0 21.942 14.628 36.571 36.571 36.571s36.571-14.629 36.571-36.571V797.257c43.886-14.628 73.143-54.857 73.143-102.4 0-47.543-29.257-87.771-73.143-102.4V435.2c43.886-18.286 73.143-58.514 73.143-106.057zM256 731.429c-21.943 0-36.571-14.629-36.571-36.572s14.628-36.571 36.571-36.571 36.571 14.628 36.571 36.571S277.943 731.43 256 731.43zm0-365.715c-21.943 0-36.571-14.628-36.571-36.571S234.057 292.57 256 292.57s36.571 14.629 36.571 36.572-14.628 36.571-36.571 36.571zM768 731.43H475.429c-18.286 0-36.572 14.628-36.572 36.571s14.629 36.571 36.572 36.571H768c18.286 0 36.571-14.628 36.571-36.571S789.943 731.429 768 731.429zm73.143-512H475.429c-18.286 0-36.572 14.628-36.572 36.571s14.629 36.571 36.572 36.571h365.714c18.286 0 36.571-14.628 36.571-36.571s-14.628-36.571-36.571-36.571zM768 438.857c18.286 0 36.571-14.628 36.571-36.571S789.943 365.714 768 365.714H475.429c-18.286 0-36.572 14.629-36.572 36.572s14.629 36.571 36.572 36.571H768zm73.143 146.286H475.429c-18.286 0-36.572 14.628-36.572 36.571s14.629 36.572 36.572 36.572h365.714c18.286 0 36.571-14.629 36.571-36.572s-14.628-36.571-36.571-36.571z"/></svg>' innerHTML: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M365.714 329.143c0-47.543-29.257-87.772-73.143-102.4V36.57C292.571 14.63 277.943 0 256 0s-36.571 14.629-36.571 36.571v190.172c-43.886 14.628-73.143 54.857-73.143 102.4 0 47.543 29.257 87.771 73.143 102.4V588.8c-43.886 14.629-73.143 54.857-73.143 102.4 0 47.543 29.257 87.771 73.143 102.4v193.829c0 21.942 14.628 36.571 36.571 36.571s36.571-14.629 36.571-36.571V797.257c43.886-14.628 73.143-54.857 73.143-102.4 0-47.543-29.257-87.771-73.143-102.4V435.2c43.886-18.286 73.143-58.514 73.143-106.057zM256 731.429c-21.943 0-36.571-14.629-36.571-36.572s14.628-36.571 36.571-36.571 36.571 14.628 36.571 36.571S277.943 731.43 256 731.43zm0-365.715c-21.943 0-36.571-14.628-36.571-36.571S234.057 292.57 256 292.57s36.571 14.629 36.571 36.572-14.628 36.571-36.571 36.571zM768 731.43H475.429c-18.286 0-36.572 14.628-36.572 36.571s14.629 36.571 36.572 36.571H768c18.286 0 36.571-14.628 36.571-36.571S789.943 731.429 768 731.429zm73.143-512H475.429c-18.286 0-36.572 14.628-36.572 36.571s14.629 36.571 36.572 36.571h365.714c18.286 0 36.571-14.628 36.571-36.571s-14.628-36.571-36.571-36.571zM768 438.857c18.286 0 36.571-14.628 36.571-36.571S789.943 365.714 768 365.714H475.429c-18.286 0-36.572 14.629-36.572 36.572s14.629 36.571 36.572 36.571H768zm73.143 146.286H475.429c-18.286 0-36.572 14.628-36.572 36.571s14.629 36.572 36.572 36.572h365.714c18.286 0 36.571-14.629 36.571-36.572s-14.628-36.571-36.571-36.571z"/></svg>'
}, },
{
type: 'copy',
title: '复制文本',
innerHTML: '<svg t="1619140348056" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3613" width="20" height="20"><path d="M731.682 676.057V183.323c0-30.233-24.512-54.746-54.748-54.746H184.216c-30.233 0-54.747 24.513-54.747 54.746v492.734c0 30.208 24.514 54.747 54.747 54.747h492.718c30.235 0 54.748-24.539 54.748-54.747z m-109.493 0H238.963c-30.234 0-54.747-24.538-54.747-54.745V238.07c0-30.233 24.513-54.747 54.747-54.747h383.226c30.234 0 54.745 24.513 54.745 54.747v383.243c0 30.206-24.512 54.744-54.745 54.744z m218.986-383.24h-54.746v54.747c30.232 0 54.746 24.513 54.746 54.76V785.55c0 30.207-24.514 54.746-54.746 54.746H403.202c-30.234 0-54.747-24.539-54.747-54.746h-54.747v54.746c0 30.208 24.513 54.748 54.747 54.748h492.72c30.234 0 54.747-24.54 54.747-54.748V347.564c0-30.235-24.514-54.747-54.747-54.747z" p-id="3614"></path></svg>'
},
/* --------------------------- 短代码结束 --------------------------- */ /* --------------------------- 短代码结束 --------------------------- */
{ {
type: 'clean', type: 'clean',

File diff suppressed because one or more lines are too long

View File

@ -321,6 +321,9 @@ class Joe extends JoeAction {
case 'timeline': case 'timeline':
super.handleTimeline(this.cm); super.handleTimeline(this.cm);
break; break;
case 'copy':
super.handleCopy(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;