mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-10 23:39:03 +00:00
allow modification of parent file globals via __eval
This commit is contained in:
parent
507731cefa
commit
da70a3ed4f
@ -16,6 +16,7 @@ a complete rework of the enhancer, with new features and a port to the browser a
|
|||||||
- a rainbow indentation lines style.
|
- a rainbow indentation lines style.
|
||||||
- border & background style options for the code line numbers extension.
|
- border & background style options for the code line numbers extension.
|
||||||
- an icon sets option to encode images to data urls to prevent quality reduction.
|
- an icon sets option to encode images to data urls to prevent quality reduction.
|
||||||
|
- customisation of integrated titlebar window buttons
|
||||||
|
|
||||||
#### improved
|
#### improved
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 32e51cfe45c90f9757ef3427cf60bb54aa95427a
|
Subproject commit 31835e966e93b686c24b5b6c76ea72a87ae987e1
|
@ -17,12 +17,17 @@ window.__enhancerElectronApi = {
|
|||||||
addChangeListener: api.storage.addChangeListener,
|
addChangeListener: api.storage.addChangeListener,
|
||||||
removeChangeListener: api.storage.removeChangeListener,
|
removeChangeListener: api.storage.removeChangeListener,
|
||||||
},
|
},
|
||||||
sendMessage: (id, data = undefined) => {
|
browser: require('electron').remote.getCurrentWindow(),
|
||||||
|
sendMessage: (channel, data = undefined) => {
|
||||||
const { ipcRenderer } = require('electron');
|
const { ipcRenderer } = require('electron');
|
||||||
ipcRenderer.send(`notion-enhancer:${id}`, data);
|
ipcRenderer.send(`notion-enhancer:${channel}`, data);
|
||||||
},
|
},
|
||||||
onMessage: (id, callback) => {
|
sendMessageToHost: (channel, data = undefined) => {
|
||||||
const { ipcRenderer } = require('electron');
|
const { ipcRenderer } = require('electron');
|
||||||
ipcRenderer.on(`notion-enhancer:${id}`, callback);
|
ipcRenderer.sendToHost(`notion-enhancer:${channel}`, data);
|
||||||
|
},
|
||||||
|
onMessage: (channel, callback) => {
|
||||||
|
const { ipcRenderer } = require('electron');
|
||||||
|
ipcRenderer.on(`notion-enhancer:${channel}`, callback);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = async function (target, __exports) {
|
module.exports = async function (target, __exports, __eval) {
|
||||||
if (target === 'renderer/preload') {
|
if (target === 'renderer/preload') {
|
||||||
require('notion-enhancer/electronApi.cjs');
|
require('notion-enhancer/electronApi.cjs');
|
||||||
document.addEventListener('readystatechange', (event) => {
|
document.addEventListener('readystatechange', (event) => {
|
||||||
@ -29,7 +29,7 @@ module.exports = async function (target, __exports) {
|
|||||||
for (const { source, target: scriptTarget } of (mod.js ? mod.js.electron : []) || []) {
|
for (const { source, target: scriptTarget } of (mod.js ? mod.js.electron : []) || []) {
|
||||||
if (`${target}.js` !== scriptTarget) continue;
|
if (`${target}.js` !== scriptTarget) continue;
|
||||||
const script = require(`notion-enhancer/repo/${mod._dir}/${source}`);
|
const script = require(`notion-enhancer/repo/${mod._dir}/${source}`);
|
||||||
script(api, await registry.db(mod.id), __exports);
|
script(api, await registry.db(mod.id), __exports, __eval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 7707136dfecd1d2b69bcb1db6d56dca35ea2b329
|
Subproject commit 4bba5136828cb36ff8d6a8b38779b9e5537fae9a
|
@ -17,7 +17,7 @@ const sendMessage = (id, data) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let enhancerMenu;
|
let enhancerMenu;
|
||||||
module.exports.focusMenu = () => {
|
module.exports.focusMenu = async () => {
|
||||||
if (enhancerMenu) return enhancerMenu.show();
|
if (enhancerMenu) return enhancerMenu.show();
|
||||||
|
|
||||||
const { fs } = require('notion-enhancer/api/index.cjs'),
|
const { fs } = require('notion-enhancer/api/index.cjs'),
|
||||||
@ -26,11 +26,13 @@ module.exports.focusMenu = () => {
|
|||||||
file: 'enhancer-menu-window-state.json',
|
file: 'enhancer-menu-window-state.json',
|
||||||
defaultWidth: 1250,
|
defaultWidth: 1250,
|
||||||
defaultHeight: 850,
|
defaultHeight: 850,
|
||||||
});
|
}),
|
||||||
|
{ registry } = require('notion-enhancer/api/index.cjs'),
|
||||||
|
integratedTitlebar = await registry.enabled('a5658d03-21c6-4088-bade-fa4780459133');
|
||||||
|
|
||||||
enhancerMenu = new BrowserWindow({
|
enhancerMenu = new BrowserWindow({
|
||||||
show: true,
|
show: true,
|
||||||
// frame: !store().frameless,
|
frame: !integratedTitlebar,
|
||||||
titleBarStyle: 'hiddenInset',
|
titleBarStyle: 'hiddenInset',
|
||||||
x: windowState.x,
|
x: windowState.x,
|
||||||
y: windowState.y,
|
y: windowState.y,
|
||||||
|
@ -75,7 +75,7 @@ export default async function (
|
|||||||
}
|
}
|
||||||
await fsp.appendFile(
|
await fsp.appendFile(
|
||||||
file,
|
file,
|
||||||
`\n\n//notion-enhancer\nrequire('notion-enhancer')('${target}', exports)`
|
`\n\n//notion-enhancer\nrequire('notion-enhancer')('${target}', exports, (js) => eval(js))`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user