mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-19 19:19:03 +00:00
add onLoad, onSwitch, and onResize functions to panel extensions
This commit is contained in:
parent
6b6626c966
commit
feaa55681f
@ -68,6 +68,8 @@ module.exports = {
|
|||||||
if (panelMods.length < 1) return;
|
if (panelMods.length < 1) return;
|
||||||
const attempt_interval = setInterval(enhance, 500);
|
const attempt_interval = setInterval(enhance, 500);
|
||||||
function enhance() {
|
function enhance() {
|
||||||
|
let curPanelJs;
|
||||||
|
|
||||||
const frame = document.querySelector('.notion-frame');
|
const frame = document.querySelector('.notion-frame');
|
||||||
if (!frame) return;
|
if (!frame) return;
|
||||||
clearInterval(attempt_interval);
|
clearInterval(attempt_interval);
|
||||||
@ -147,13 +149,17 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadContent(mod) {
|
function loadContent(mod) {
|
||||||
|
if (curPanelJs && curPanelJs.onSwitch) curPanelJs.onSwitch();
|
||||||
|
|
||||||
store().last_open = mod.id;
|
store().last_open = mod.id;
|
||||||
panel.querySelector('.enhancer-panel--title').innerText = mod.panel.name || mod.name;
|
panel.querySelector('.enhancer-panel--title').innerText = mod.panel.name || mod.name;
|
||||||
panel.querySelector('.enhancer-panel--icon').innerHTML = mod.panelIcon;
|
panel.querySelector('.enhancer-panel--icon').innerHTML = mod.panelIcon;
|
||||||
document.getElementById('enhancer-panel--content').innerHTML = mod.panelHtml;
|
document.getElementById('enhancer-panel--content').innerHTML = mod.panelHtml;
|
||||||
|
|
||||||
if (mod.panelJs)
|
if (mod.panelJs) {
|
||||||
require(mod.panelJs)(store(mod.id))();
|
curPanelJs = require(mod.panelJs)(store(mod.id));
|
||||||
|
if (curPanelJs && curPanelJs.onLoad) curPanelJs.onLoad();
|
||||||
|
}
|
||||||
|
|
||||||
if (mod.panelFullHeight) {
|
if (mod.panelFullHeight) {
|
||||||
panel.dataset.fullHeight = mod.panelFullHeight;
|
panel.dataset.fullHeight = mod.panelFullHeight;
|
||||||
@ -296,6 +302,10 @@ module.exports = {
|
|||||||
frame.style.paddingRight = 0;
|
frame.style.paddingRight = 0;
|
||||||
panel.style.right = width + 'px';
|
panel.style.right = width + 'px';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (curPanelJs && curPanelJs.onResize) {
|
||||||
|
curPanelJs.onResize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableResize() {
|
function enableResize() {
|
||||||
|
Loading…
Reference in New Issue
Block a user