mirror of
				https://github.com/notion-enhancer/notion-enhancer.git
				synced 2025-10-30 13:48:08 +11:00 
			
		
		
		
	#160 patch opening by notion://url on linux + tab bugfixes
This commit is contained in:
		
							parent
							
								
									21b8c3ca15
								
							
						
					
					
						commit
						e826b9ff73
					
				| @ -13,13 +13,14 @@ a flexibility update. | ||||
|   higher up on the list = higher priority of application = loaded last in order to override others. | ||||
|   (excluding the core, which though pinned to the top of the list is always loaded first so theming | ||||
|   variables can be modified.) | ||||
| - new: in-page columns disabled/wrapped and wider pages when the window is narrower than 600px | ||||
|   for improved responsiveness. | ||||
| - new: in-page columns are disabled/wrapped and pages are wider when | ||||
|   the window is narrower than 600px for improved responsiveness. | ||||
| - new: relaunch button in tray menu. | ||||
| - new: a core mod option to make transitions snappy/0s. | ||||
| - new: a core mod option for a default page id/url (all new windows will load it instead of the | ||||
|   normal "most recent" page). | ||||
| - new: css variables for increasing line spacing/paragraph margins. | ||||
| - new: patch the notion:// url scheme/protocol to work on linux. | ||||
| - improved: menu will now respect integrated titlebar setting. | ||||
| - improved: use keyup listeners instead of a globalShortcut for the enhancements menu toggle. | ||||
| - bugfix: removed messenger emoji set as the provider no longer supports it. | ||||
|  | ||||
							
								
								
									
										12
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								README.md
									
									
									
									
									
								
							| @ -114,8 +114,16 @@ team to take to heart for future improvements." | ||||
| 
 | ||||
| ## features | ||||
| 
 | ||||
| once applied, modules can be configured via the graphical menu, which is opened from | ||||
| the tray/menubar icon or with `OPTION/ALT+E`. | ||||
| most of the enhancer's functionality is split into configurable enhancement modules, | ||||
| but some basic improvements are built in by default: | ||||
| 
 | ||||
| - the notion:// url scheme/protocol is patched to work on linux. | ||||
| - in-page columns are disabled/wrapped and pages are wider when | ||||
|   the window is narrower than 600px for improved responsiveness. | ||||
| - a tray/menubar icon: links relevant to the enhancer + buttons to manage notion windows. | ||||
| 
 | ||||
| once applied, modules can be configured via the graphical menu, | ||||
| which is opened from the tray/menubar ic,on or with `OPTION/ALT+E`. | ||||
| 
 | ||||
|  | ||||
| 
 | ||||
|  | ||||
| @ -18,7 +18,7 @@ module.exports = (store, __exports) => { | ||||
| 
 | ||||
|   document.defaultView.addEventListener('keyup', (event) => { | ||||
|     // additional hotkeys
 | ||||
|     if (event.code === 'F5') location.reload(); | ||||
|     if (event.key === 'F5') location.reload(); | ||||
|     // open menu on hotkey toggle
 | ||||
|     const hotkey = toKeyEvent(store().menu_toggle); | ||||
|     let triggered = true; | ||||
| @ -49,7 +49,6 @@ module.exports = (store, __exports) => { | ||||
|       triggered = true; | ||||
|       for (let prop in close_tab_keybinding) | ||||
|         if (close_tab_keybinding[prop] !== event[prop]) triggered = false; | ||||
|       console.log(triggered, event); | ||||
|       if (triggered) electron.ipcRenderer.sendToHost('enhancer:close-tab'); | ||||
|     } | ||||
|   }); | ||||
|  | ||||
| @ -118,7 +118,7 @@ window['__start'] = async () => { | ||||
| 
 | ||||
|   const $popup = document.querySelector('#popup'); | ||||
|   document.addEventListener('keyup', (event) => { | ||||
|     if (event.code === 'F5') location.reload(); | ||||
|     if (event.key === 'F5') location.reload(); | ||||
|     // further-configuration popup
 | ||||
|     if ( | ||||
|       $popup.classList.contains('visible') && | ||||
| @ -126,12 +126,13 @@ window['__start'] = async () => { | ||||
|     ) | ||||
|       $popup.classList.remove('visible'); | ||||
|     // close window on hotkey toggle
 | ||||
|     console.log(); | ||||
|     const hotkey = toKeyEvent(coreStore().menu_toggle); | ||||
|     let triggered = true; | ||||
|     for (let prop in hotkey) | ||||
|       if (hotkey[prop] !== event[prop]) triggered = false; | ||||
|     if (triggered) electron.remote.getCurrentWindow().close(); | ||||
|     if (triggered || ((event.ctrlKey || event.metaKey) && event.key === 'w')) | ||||
|       electron.remote.getCurrentWindow().close(); | ||||
|     console.log(event.ctrlKey, event.key); | ||||
|     //  focus search
 | ||||
|     const meta = | ||||
|       !(event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey; | ||||
| @ -108,14 +108,20 @@ module.exports = (store, __exports) => { | ||||
|           document | ||||
|             .querySelectorAll('.dragged-over') | ||||
|             .forEach((el) => el.classList.remove('dragged-over')); | ||||
|           document | ||||
|             .querySelectorAll('.slideIn') | ||||
|             .forEach((el) => el.classList.remove('slideIn')); | ||||
|           const from = getTab(this.views.tabs[+this.$dragging]), | ||||
|             to = getTab(event.target); | ||||
|           if (!from[1].classList.contains('new') && from[0] !== to[0]) | ||||
|             to[1].parentElement.insertBefore(from[1], to[1]); | ||||
|           from[1].classList.remove('slideIn'); | ||||
|           this.$dragging = null; | ||||
|           document | ||||
|             .querySelector('#tabs') | ||||
|             .appendChild(document.querySelector('.tab.new')); | ||||
|         }); | ||||
|         document.addEventListener('keyup', (event) => { | ||||
|           if (!electron.remote.getCurrentWindow().isFocused()) return; | ||||
|           // switch between tabs via key modifier
 | ||||
|           const select_tab_modifier = toKeyEvent( | ||||
|             store('e1692c29-475e-437b-b7ff-3eee872e1a42').select_modifier | ||||
| @ -139,8 +145,8 @@ module.exports = (store, __exports) => { | ||||
|           triggered = true; | ||||
|           for (let prop in close_tab_keybinding) | ||||
|             if (close_tab_keybinding[prop] !== event[prop]) triggered = false; | ||||
|           console.log(triggered, event); | ||||
|           if (triggered) this.closeTab(this.views.current.id); | ||||
|           if (triggered && document.querySelector('.tab.current .close')) | ||||
|             document.querySelector('.tab.current .close').click(); | ||||
|         }); | ||||
|       } | ||||
| 
 | ||||
| @ -219,7 +225,7 @@ module.exports = (store, __exports) => { | ||||
|                 ? idToNotionURL(store().default_page) | ||||
|                 : this.views.current.$el().src | ||||
|             ); | ||||
|             this.views.html[id].getWebContents().openDevTools(); | ||||
|             // this.views.html[id].getWebContents().openDevTools();
 | ||||
|           } | ||||
|         }); | ||||
|       } | ||||
| @ -297,8 +303,8 @@ module.exports = (store, __exports) => { | ||||
|             this.newTab(); | ||||
|             break; | ||||
|           case 'enhancer:close-tab': | ||||
|             if (event.target.id == this.views.current.id) | ||||
|               this.closeTab(+event.target.id); | ||||
|             if (document.querySelector('.tab.current .close')) | ||||
|               document.querySelector('.tab.current .close').click(); | ||||
|             break; | ||||
|         } | ||||
|       } | ||||
|  | ||||
							
								
								
									
										0
									
								
								mods/core/systemMenu.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								mods/core/systemMenu.js
									
									
									
									
									
										Normal file
									
								
							| @ -33,7 +33,7 @@ module.exports = (store, __exports) => { | ||||
|     // menu
 | ||||
| 
 | ||||
|     electron.ipcMain.on('enhancer:open-menu', (event, arg) => { | ||||
|       openExtensionMenu(); | ||||
|       openEnhancerMenu(); | ||||
|     }); | ||||
|     electron.ipcMain.on('enhancer:set-menu-theme', (event, arg) => { | ||||
|       if (!enhancer_menu) return; | ||||
| @ -81,13 +81,13 @@ module.exports = (store, __exports) => { | ||||
|       }; | ||||
|     } | ||||
| 
 | ||||
|     function openExtensionMenu() { | ||||
|     function openEnhancerMenu() { | ||||
|       if (enhancer_menu) return enhancer_menu.show(); | ||||
|       const window_state = require(`${helpers.__notion.replace( | ||||
|         /\\/g, | ||||
|         '/' | ||||
|       )}/app/node_modules/electron-window-state/index.js`)({
 | ||||
|         file: 'menu-windowstate.json', | ||||
|         file: 'enhancerMenu.windowState.json', | ||||
|         path: helpers.__data, | ||||
|         defaultWidth: 275, | ||||
|         defaultHeight: 600, | ||||
| @ -106,7 +106,7 @@ module.exports = (store, __exports) => { | ||||
|         width: window_state.width, | ||||
|         height: window_state.height, | ||||
|         webPreferences: { | ||||
|           preload: path.resolve(`${__dirname}/menu.js`), | ||||
|           preload: path.resolve(`${__dirname}/enhancerMenu.js`), | ||||
|           nodeIntegration: true, | ||||
|           session: electron.session.fromPartition('persist:notion'), | ||||
|         }, | ||||
| @ -116,6 +116,7 @@ module.exports = (store, __exports) => { | ||||
|         window_state.saveState(enhancer_menu); | ||||
|         enhancer_menu = null; | ||||
|       }); | ||||
|       // enhancer_menu.webContents.openDevTools();
 | ||||
|     } | ||||
| 
 | ||||
|     // tray
 | ||||
| @ -165,7 +166,7 @@ module.exports = (store, __exports) => { | ||||
|         type: 'normal', | ||||
|         label: 'Enhancements', | ||||
|         accelerator: store().menu_toggle, | ||||
|         click: openExtensionMenu, | ||||
|         click: openEnhancerMenu, | ||||
|       }, | ||||
|       { | ||||
|         type: 'normal', | ||||
|  | ||||
							
								
								
									
										38
									
								
								pkg/apply.js
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								pkg/apply.js
									
									
									
									
									
								
							| @ -90,18 +90,40 @@ module.exports = async function ({ overwrite_version, friendly_errors } = {}) { | ||||
|         filter: (stats) => stats.isFile() && stats.path.endsWith('.js'), | ||||
|       } | ||||
|     )) { | ||||
|       insertion_target = path.resolve( | ||||
|       const insertion_file = path.resolve( | ||||
|         `${helpers.__notion}/app/${insertion_target}` | ||||
|       ); | ||||
|       fs.appendFile( | ||||
|         insertion_target, | ||||
|         `\n\n//notion-enhancer\nrequire('${helpers.realpath( | ||||
|           __dirname | ||||
|         )}/loader.js')(__filename, exports);` | ||||
|       ); | ||||
|       if (insertion_target === 'main/main.js') { | ||||
|         // https://github.com/dragonwocky/notion-enhancer/issues/160
 | ||||
|         // patch the notion:// url scheme/protocol to work on linux
 | ||||
|         fs.readFile(insertion_file, 'utf8', (err, data) => { | ||||
|           if (err) throw err; | ||||
|           fs.writeFile( | ||||
|             insertion_file, | ||||
|             `${data.replace( | ||||
|               /process.platform === "win32"/g, | ||||
|               'process.platform === "win32" || process.platform === "linux"' | ||||
|             )}\n\n//notion-enhancer\nrequire('${helpers.realpath(
 | ||||
|               __dirname | ||||
|             )}/loader.js')(__filename, exports);`,
 | ||||
|             'utf8', | ||||
|             (err) => { | ||||
|               if (err) throw err; | ||||
|             } | ||||
|           ); | ||||
|         }); | ||||
|       } else { | ||||
|         fs.appendFile( | ||||
|           insertion_file, | ||||
|           `\n\n//notion-enhancer\nrequire('${helpers.realpath( | ||||
|             __dirname | ||||
|           )}/loader.js')(__filename, exports);` | ||||
|         ); | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
|     // not resolved, nothing depends on it so it's just a "let it do its thing"
 | ||||
|     // not resolved, nothing else in application depends on it
 | ||||
|     // so it's just a "let it do its thing"
 | ||||
|     console.info(' ...recording enhancement version.'); | ||||
|     fs.outputFile( | ||||
|       path.resolve(`${helpers.__notion}/app/ENHANCER_VERSION.txt`), | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user