更新
This commit is contained in:
parent
2405648151
commit
5b986cea0e
@ -18,7 +18,6 @@ require_once('factory.php');
|
||||
/* 页面加载计时 */
|
||||
_startCountTime();
|
||||
|
||||
|
||||
/* 主题初始化 */
|
||||
function themeInit($self)
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ class Editor
|
||||
public static function edit()
|
||||
{
|
||||
echo "<link rel='stylesheet' href='" . Helper::options()->themeUrl . '/typecho/editor/joe.editor.css' . "'>";
|
||||
echo "<script src='" . Helper::options()->themeUrl . '/typecho/editor/joe.extend.js' . "'></script>";
|
||||
echo "<script src='" . Helper::options()->themeUrl . '/typecho/editor/joe.editor.js' . "'></script>";
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
function _parseShortCode($content)
|
||||
{
|
||||
/* 过滤网易云音乐歌单 */
|
||||
if (preg_match('/\[music-list\s{0,}id="\d{0,}"\s{0,}\/]/', $content)) {
|
||||
if (preg_match('/\[music-list\s{0,}id="\d{0,}"\s{0,}\/\]/', $content)) {
|
||||
$content = preg_replace(
|
||||
'/\[music-list\s{0,}id="(\d{0,})"\s{0,}\/]/',
|
||||
'<iframe width="330" height="450" src="//music.163.com/outchain/player?type=0&id=$1&auto=0&height=430"></iframe>',
|
||||
@ -11,9 +11,9 @@ function _parseShortCode($content)
|
||||
);
|
||||
}
|
||||
/* 过滤网易云音乐单首歌 */
|
||||
if (preg_match('/\[music\s{0,}id="\d{0,}"\s{0,}\/]/', $content)) {
|
||||
if (preg_match('/\[music\s{0,}id="\d{0,}"\s{0,}\/\]/', $content)) {
|
||||
$content = preg_replace(
|
||||
'/\[music\s{0,}id="(\d{0,})"\s{0,}\/]/',
|
||||
'/\[music\s{0,}id="(\d{0,})"\s{0,}\/\]/',
|
||||
'<iframe width="330" height="86" src="//music.163.com/outchain/player?type=2&id=$1&auto=0&height=66"></iframe>',
|
||||
$content
|
||||
);
|
||||
|
@ -16,6 +16,8 @@
|
||||
<?php $this->need('public/include.php'); ?>
|
||||
<!-- 首页所使用到的CSS以及JS -->
|
||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.index.css'); ?>">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@5.4.5/css/swiper.min.css" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/swiper@5.4.5/js/swiper.min.js"></script>
|
||||
<script src="<?php $this->options->themeUrl('assets/js/joe.index.js'); ?>"></script>
|
||||
</head>
|
||||
|
||||
|
@ -55,7 +55,6 @@
|
||||
<link rel="stylesheet" href="https://apip.weatherdt.com/standard/static/css/weather-standard.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-tomorrow.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/swiper@5.4.5/css/swiper.min.css" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.7.2/animate.min.css" />
|
||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.normalize.css'); ?>">
|
||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.global.css'); ?>">
|
||||
@ -65,10 +64,9 @@
|
||||
<script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/lazyload/joe.lazyload.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/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/swiper@5.4.5/js/swiper.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/wowjs@1.1.3/dist/wow.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||
<script src="<?php $this->options->themeUrl('assets/js/joe.global.js'); ?>"></script>
|
||||
<!-- 下面是异步加载的JS -->
|
||||
<!-- 是异步加载的JS -->
|
||||
<script async src="https://apip.weatherdt.com/standard/static/js/weather-standard.js?v=2.0"></script>
|
||||
<script async src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/smooth/joe.smooth.js"></script>
|
@ -1 +1 @@
|
||||
table.typecho-list-table textarea[name='fields[thumb]'],table.typecho-list-table textarea[name='fields[abstract]']{width:100%;height:80px}#wmd-button-row{height:auto}
|
||||
table.typecho-list-table textarea[name='fields[thumb]'],table.typecho-list-table textarea[name='fields[abstract]']{width:100%;height:80px}#wmd-button-row{height:auto}#wmd-button-row .wmd-button .icon{width:20px;height:20px;vertical-align:middle;fill:#9b9b9b}
|
||||
|
@ -1,18 +1,64 @@
|
||||
$(function () {
|
||||
$('#wmd-editarea textarea').attr('placeholder', '请输入文章内容...(支持图片粘贴上传)')
|
||||
$('#wmd-button-bar .wmd-edittab').remove()
|
||||
$('#wmd-button-row .wmd-spacer').remove()
|
||||
$('#wmd-editarea textarea').attr('placeholder', '请输入文章内容...(支持图片粘贴上传)');
|
||||
$('#wmd-button-bar .wmd-edittab').remove();
|
||||
$('#wmd-button-row .wmd-spacer').remove();
|
||||
|
||||
/* 增加自定义功能 */
|
||||
const items = [
|
||||
{
|
||||
title: '回复可见',
|
||||
id: 'wmd-hide-button'
|
||||
}
|
||||
]
|
||||
/* 增加自定义功能 */
|
||||
const items = [
|
||||
{
|
||||
title: '回复可见',
|
||||
id: 'wmd-hide-button',
|
||||
svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" ><path d="M554.666667 438.101333V277.333333h-85.333334v160.768L330.112 357.717333l-42.666667 73.898667L426.666667 512l-139.221334 80.384 42.666667 73.898667L469.333333 585.898667V746.666667h85.333334v-160.768l139.221333 80.384 42.666667-73.898667L597.333333 512l139.221334-80.384-42.666667-73.898667L554.666667 438.101333z" p-id="15752" fill="#9b9b9b"></path></svg>'
|
||||
},
|
||||
{
|
||||
title: '网易云歌单',
|
||||
id: 'wmd-mlist-button',
|
||||
svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M806.3 435.8L553.8 320c-17.4-8-38.2-0.9-46.5 15.8l-123.2 248c-8.2-7.9-17.7-14.9-28.8-20-52.3-24-114.8-2.7-139.8 47.5-25 50.2-2.8 110.3 49.4 134.3 52.3 24 114.8 2.7 139.8-47.5l120.5-242.4c8.3-16.7 29.1-23.8 46.5-15.8L698 497.7c17.4 8 24.7 28 16.4 44.7l-78.1 157.1c-8.2-7.9-17.7-14.9-28.8-20-52.3-24-114.8-2.7-139.8 47.5-25 50.2-2.8 110.3 49.4 134.3 52.3 24 114.8 2.7 139.8-47.5l165.7-333.2c8.4-16.8 1.1-36.8-16.3-44.8zM269.7 358c-28.8 17.1-37.8 53.5-19.9 81.2 17.8 27.7 55.7 36.3 84.5 19.1 28.8-17.1 37.8-53.5 19.9-81.2L268 243.4c-5.9-9.2-3-21.3 6.6-27l17.4-10.3c9.6-5.7 12.6-17.9 6.7-27.1L288 162.3c-6-9.2-18.6-12.1-28.2-6.4l-52.2 31c-9.6 5.7-12.6 17.8-6.6 27l88 136.9c-6.6 1.3-13.2 3.6-19.3 7.2z" p-id="32541" fill="#9b9b9b"></path></svg>'
|
||||
},
|
||||
{
|
||||
title: '网易云音乐',
|
||||
id: 'wmd-music-button',
|
||||
svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M263.714782 756.045051a111.4112 141.312 83.299 1 0 280.693286-32.978849 111.4112 141.312 83.299 1 0-280.693286 32.978849Z" p-id="25774" fill="#9b9b9b"></path><path d="M497.664 228.9664h23.7568c13.1072 0 23.7568 10.6496 23.7568 23.7568V737.28H497.664V228.9664z" p-id="25775" fill="#9b9b9b"></path><path d="M593.92 294.2976c-32.768-14.7456-55.7056-47.7184-55.7056-86.4256 0-28.672 13.1072-54.4768 33.3824-71.68-42.3936 9.4208-73.9328 47.104-73.9328 92.16 0 52.224 41.7792 94.4128 94.0032 94.4128h2.2528v-28.4672z" p-id="25776" fill="#9b9b9b"></path><path d="M681.984 422.912c0-76.3904-61.8496-138.24-138.24-138.24-16.1792 0-31.744 2.8672-46.08 7.7824v38.912c9.8304-2.4576 20.0704-3.6864 30.72-3.6864 71.2704 0 129.024 57.7536 129.024 129.024 0 24.1664-6.7584 46.8992-18.2272 66.1504C665.6 497.664 681.984 462.2336 681.984 422.912z" p-id="25777" fill="#9b9b9b"></path></svg>'
|
||||
},
|
||||
{
|
||||
title: 'BiliBili视频',
|
||||
id: 'wmd-bili-button',
|
||||
svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M776.192 239.552h-135.392l61.344-61.344c10.592-10.592 10.592-25.376 0-35.968s-25.376-10.592-35.968 0l-103.648 103.68h-101.536l-103.68-103.648c-8.448-10.592-21.152-12.704-33.856-6.336-2.112 0-2.112 2.112-4.224 4.224-10.592 10.592-10.592 25.376 0 35.968l63.456 63.456H247.296c-74.048 0-135.392 61.344-135.392 135.392V711.36c0 71.936 61.344 133.28 135.392 133.28h21.152c0 25.376 21.152 44.416 44.416 44.416s44.416-21.152 44.416-44.416h313.12c2.112 25.376 23.264 44.416 48.672 42.304a45.504 45.504 0 0 0 42.304-42.304h16.928c74.048 0 135.392-61.344 135.392-135.392V372.864c-2.112-74.048-63.456-133.28-137.504-133.28z m-4.256 522.56H255.712c-27.488 0-48.672-23.264-50.784-50.784l-2.112-342.72a51.52 51.52 0 0 1 50.784-50.784h516.224c27.488 0 48.672 23.264 50.784 50.784l2.112 342.72c-2.112 29.6-23.264 50.784-50.784 50.784zM422.88 434.176l12.704 63.456-169.248 31.744-12.704-63.456 169.248-31.744z m162.88 63.488l12.704-63.456 169.248 31.744-12.704 63.456-169.248-31.744z m33.856 133.28c0 2.112 0 6.336-2.112 8.448-10.592 23.264-33.856 38.08-61.344 40.192a59.456 59.456 0 0 1-44.416-21.152c-12.704 12.704-27.488 21.152-44.416 21.152a77.344 77.344 0 0 1-61.344-40.192c0-2.112-2.112-4.224-2.112-8.448 0-8.448 6.336-14.816 14.816-16.928h2.112c6.336 0 10.592 2.112 12.704 8.448 0 0 16.928 23.264 31.744 23.264 29.632 0 29.632-25.376 46.528-44.416 19.04 21.152 19.04 44.416 46.528 44.416 19.04 0 31.744-23.264 31.744-23.264 2.112-4.224 8.448-8.448 12.704-8.448 8.448-2.112 14.816 4.224 16.928 12.704v4.224h0.032z" p-id="40668" fill="#9b9b9b"></path></svg>'
|
||||
},
|
||||
{
|
||||
title: 'DPlayer视频',
|
||||
id: 'wmd-dplayer-button',
|
||||
svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M858.88 244.48h-182.016l61.184-61.184a25.6 25.6 0 0 0-36.096-36.096l-97.536 97.28h-182.528l-97.28-97.28a25.6 25.6 0 0 0-36.352 0 25.6 25.6 0 0 0 0 36.096l61.184 61.184h-181.76a25.6 25.6 0 0 0-25.6 25.6v490.752a25.6 25.6 0 0 0 25.6 25.6h691.2a25.6 25.6 0 0 0 25.6-25.6V270.08a25.6 25.6 0 0 0-25.6-25.6z m-25.6 490.752h-640V295.68h640zM743.68 832.256h-460.8a25.6 25.6 0 0 0 0 51.2h460.8a25.6 25.6 0 1 0 0-51.2z" p-id="46595" fill="#9b9b9b"></path><path d="M439.808 623.104a25.6 25.6 0 0 0 12.8 3.584 25.6 25.6 0 0 0 12.8-3.584l171.008-98.56a25.6 25.6 0 0 0 0-44.544l-171.008-98.56a25.6 25.6 0 0 0-38.4 22.016v197.632a25.6 25.6 0 0 0 12.8 22.016z m38.4-175.104l94.208 54.272-94.208 54.272z" p-id="46596" fill="#9b9b9b"></path></svg>'
|
||||
}
|
||||
];
|
||||
|
||||
items.forEach(_ => {
|
||||
let item = `<li class="wmd-button" id="${_.id}" title="${_.title}">啊</li>`
|
||||
$('#wmd-button-row').append(item)
|
||||
})
|
||||
})
|
||||
/* 用于设置插入到文章的短代码内容 */
|
||||
function getInsertTextById(id) {
|
||||
let str = '';
|
||||
switch (id) {
|
||||
case 'wmd-hide-button':
|
||||
str = `\n\n[hide]${$('#text').selectionRange() ? $('#text').selectionRange() : '回复可见'}[/hide]\n\n`;
|
||||
break;
|
||||
case 'wmd-mlist-button':
|
||||
str = `\n\n[music-list id="网易云歌单ID" /]\n\n`;
|
||||
break;
|
||||
case 'wmd-music-button':
|
||||
str = `\n\n[music id="网易云音乐ID" /]\n\n`;
|
||||
break;
|
||||
case 'wmd-bili-button':
|
||||
str = `\n\n[bilibili bvid="哔哩哔哩的Bvid" /]\n\n`;
|
||||
break;
|
||||
case 'wmd-dplayer-button':
|
||||
str = `\n\n[dplayer src="M3U8或MP4地址" /]\n\n`;
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/* 此处无需修改 */
|
||||
items.forEach(_ => {
|
||||
let item = $(`<li class="wmd-button" id="${_.id}" title="${_.title}">${_.svg}</li>`);
|
||||
item.on('mousedown touchstart', () => $('#text').insertContent(getInsertTextById(_.id)));
|
||||
$('#wmd-button-row').append(item);
|
||||
});
|
||||
});
|
||||
|
@ -8,6 +8,11 @@ table.typecho-list-table {
|
||||
#wmd-button-row {
|
||||
height: auto;
|
||||
.wmd-button {
|
||||
|
||||
.icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
vertical-align: middle;
|
||||
fill: #9b9b9b;
|
||||
}
|
||||
}
|
||||
}
|
60
typecho/editor/joe.extend.js
Normal file
60
typecho/editor/joe.extend.js
Normal file
@ -0,0 +1,60 @@
|
||||
(function ($) {
|
||||
$.fn.extend({
|
||||
insertContent: function (myValue, t) {
|
||||
var $t = $(this)[0];
|
||||
if (document.selection) {
|
||||
this.focus();
|
||||
var sel = document.selection.createRange();
|
||||
sel.text = myValue;
|
||||
this.focus();
|
||||
sel.moveStart('character', -l);
|
||||
var wee = sel.text.length;
|
||||
if (arguments.length == 2) {
|
||||
var l = $t.value.length;
|
||||
sel.moveEnd('character', wee + t);
|
||||
t <= 0 ? sel.moveStart('character', wee - 2 * t - myValue.length) : sel.moveStart('character', wee - t - myValue.length);
|
||||
sel.select();
|
||||
}
|
||||
} else if ($t.selectionStart || $t.selectionStart == '0') {
|
||||
var startPos = $t.selectionStart;
|
||||
var endPos = $t.selectionEnd;
|
||||
var scrollTop = $t.scrollTop;
|
||||
$t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length);
|
||||
this.focus();
|
||||
$t.selectionStart = startPos + myValue.length;
|
||||
$t.selectionEnd = startPos + myValue.length;
|
||||
$t.scrollTop = scrollTop;
|
||||
if (arguments.length == 2) {
|
||||
$t.setSelectionRange(startPos - t, $t.selectionEnd + t);
|
||||
this.focus();
|
||||
}
|
||||
} else {
|
||||
this.value += myValue;
|
||||
this.focus();
|
||||
}
|
||||
},
|
||||
selectionRange: function (start, end) {
|
||||
var str = '';
|
||||
var thisSrc = this[0];
|
||||
if (start === undefined) {
|
||||
if (/input|textarea/i.test(thisSrc.tagName) && /firefox/i.test(navigator.userAgent)) str = thisSrc.value.substring(thisSrc.selectionStart, thisSrc.selectionEnd);
|
||||
else if (document.selection) str = document.selection.createRange().text;
|
||||
else str = document.getSelection().toString();
|
||||
} else {
|
||||
if (!/input|textarea/.test(thisSrc.tagName.toLowerCase())) return false;
|
||||
end === undefined && (end = start);
|
||||
if (thisSrc.setSelectionRange) {
|
||||
thisSrc.setSelectionRange(start, end);
|
||||
this.focus();
|
||||
} else {
|
||||
var range = thisSrc.createTextRange();
|
||||
range.move('character', start);
|
||||
range.moveEnd('character', end - start);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
if (start === undefined) return str;
|
||||
else return this;
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
Loading…
Reference in New Issue
Block a user