This repository has been archived by the owner on Feb 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
建议加入日历面板功能。 #19
Labels
help wanted
Extra attention is needed
Comments
现在思源已经支持代码片段了,这种功能建议用代码片段实现,这样换主题也能用 // 把日历图标 放到 搜索图标前面
var barSearch = document.getElementById("barDailyNote");
barSearch.insertAdjacentHTML(
"afterend",
'<div id="calendar"class="toolbar__item b3-tooltips b3-tooltips__se" aria-label="日历" ></div>'
);
let calendarIcon = document.getElementById("calendar");
// 日历面板,这里是插入挂件
barSearch.insertAdjacentHTML(
"afterend",
` <div
data-node-index="1"
data-type="NodeWidget"
class="iframe"
data-subtype="widget"
>
<div class="iframe-content">
<iframe id="calendarPanel" style="visibility:hidden;position: fixed; z-index: 1000; top: 225px; left: 200px; width: 300px; height: 350px; background-color: var(--b3-theme-background);box-shadow: rgba(15, 15, 15, 0.05) 0px 0px 0px 1px, rgba(15, 15, 15, 0.1) 0px 3px 6px, rgba(15, 15, 15, 0.2) 0px 9px 24px;border:none; border-radius: 5px; transform: translate(-50%, -50%); overflow: auto;" src="/appearance/themes/Savor/calendar" data-src="/appearance/themes/Savor/calendar" data-subtype="widget" ></iframe>
</div>
</div>`
);
let calendarPanel = document.getElementById("calendarPanel");
calendarIcon.innerHTML = `<svg t="1662957805816" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2374" width="200" height="200"><path d="M797.257 402.286h-570.514v113.371h570.514v-113.371zM910.629 76.8h-58.514v-76.8h-113.371v76.8h-453.486v-76.8h-113.371v76.8h-58.514c-62.171 0-113.371 51.2-113.371 113.371v724.114c0 62.171 51.2 109.714 113.371 109.714h797.257c62.171 0 113.371-47.543 113.371-109.714v-724.114c0-62.171-51.2-113.371-113.371-113.371zM910.629 914.286h-797.257v-625.371h797.257v625.371zM625.371 629.029h-398.629v113.371h398.629v-113.371z"></path></svg>`;
calendarIcon.addEventListener(
"click",
function (e) {
e.stopPropagation();
if (calendarPanel.style.visibility === "hidden") {
calendarPanel.style.visibility = "visible";
} else {
calendarPanel.style.visibility = "hidden";
}
},
false
);
calendarPanel.addEventListener('click',function(e){e.stopPropagation()},false)
// 隐藏历史面板
function hideCalendarPanel() {
if (calendarPanel.style.visibility === "visible") {
calendarPanel.style.visibility = "hidden";
}
}
// 点击其他区域时,隐藏日历面板
window.addEventListener("click", hideCalendarPanel, false); |
感谢大神解答,亲测有用 |
目前日历只支持2023.01.17的日期格式,希望能够增加对2023-01-17格式的支持 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
建议加入日历面板功能。可参考Savor主题
The text was updated successfully, but these errors were encountered: