diff --git a/CHANGELOG.md b/CHANGELOG.md index fdd284c..75c31f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. - border & background style options for the code line numbers extension. - an icon sets option to encode images to data urls to prevent quality reduction. +- customisation of integrated titlebar window buttons #### improved diff --git a/insert/api b/insert/api index 32e51cf..31835e9 160000 --- a/insert/api +++ b/insert/api @@ -1 +1 @@ -Subproject commit 32e51cfe45c90f9757ef3427cf60bb54aa95427a +Subproject commit 31835e966e93b686c24b5b6c76ea72a87ae987e1 diff --git a/insert/electronApi.cjs b/insert/electronApi.cjs index 5e74b2f..396a1d8 100644 --- a/insert/electronApi.cjs +++ b/insert/electronApi.cjs @@ -17,12 +17,17 @@ window.__enhancerElectronApi = { addChangeListener: api.storage.addChangeListener, removeChangeListener: api.storage.removeChangeListener, }, - sendMessage: (id, data = undefined) => { + browser: require('electron').remote.getCurrentWindow(), + sendMessage: (channel, data = undefined) => { 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'); - 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); }, }; diff --git a/insert/init.cjs b/insert/init.cjs index 55ee86e..6a47441 100644 --- a/insert/init.cjs +++ b/insert/init.cjs @@ -6,7 +6,7 @@ 'use strict'; -module.exports = async function (target, __exports) { +module.exports = async function (target, __exports, __eval) { if (target === 'renderer/preload') { require('notion-enhancer/electronApi.cjs'); 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 : []) || []) { if (`${target}.js` !== scriptTarget) continue; 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); } } }; diff --git a/insert/repo b/insert/repo index 7707136..4bba513 160000 --- a/insert/repo +++ b/insert/repo @@ -1 +1 @@ -Subproject commit 7707136dfecd1d2b69bcb1db6d56dca35ea2b329 +Subproject commit 4bba5136828cb36ff8d6a8b38779b9e5537fae9a diff --git a/insert/worker.cjs b/insert/worker.cjs index 1f0f0bb..336cae9 100644 --- a/insert/worker.cjs +++ b/insert/worker.cjs @@ -17,7 +17,7 @@ const sendMessage = (id, data) => { }; let enhancerMenu; -module.exports.focusMenu = () => { +module.exports.focusMenu = async () => { if (enhancerMenu) return enhancerMenu.show(); const { fs } = require('notion-enhancer/api/index.cjs'), @@ -26,11 +26,13 @@ module.exports.focusMenu = () => { file: 'enhancer-menu-window-state.json', defaultWidth: 1250, defaultHeight: 850, - }); + }), + { registry } = require('notion-enhancer/api/index.cjs'), + integratedTitlebar = await registry.enabled('a5658d03-21c6-4088-bade-fa4780459133'); enhancerMenu = new BrowserWindow({ show: true, - // frame: !store().frameless, + frame: !integratedTitlebar, titleBarStyle: 'hiddenInset', x: windowState.x, y: windowState.y, diff --git a/pkg/apply.mjs b/pkg/apply.mjs index 05100b3..8002b15 100644 --- a/pkg/apply.mjs +++ b/pkg/apply.mjs @@ -75,7 +75,7 @@ export default async function ( } await fsp.appendFile( file, - `\n\n//notion-enhancer\nrequire('notion-enhancer')('${target}', exports)` + `\n\n//notion-enhancer\nrequire('notion-enhancer')('${target}', exports, (js) => eval(js))` ); } }