def on_view_note(self, app, args): if len(args) < 1: self.error("Must specify note url") return app.focus_windows() nodeurl = args[1] if keepnote.notebook.is_node_url(nodeurl): host, nodeid = keepnote.notebook.parse_node_url(nodeurl) self.view_nodeid(app, nodeid) else: # do text search window = self.app.get_current_window() if window is None: return notebook = window.get_notebook() if notebook is None: return results = list(notebook.search_node_titles(nodeurl)) if len(results) == 1: self.view_nodeid(app, results[0][0]) else: viewer = window.get_viewer() viewer.start_search_result() for nodeid, title in results: node = notebook.get_node_by_id(nodeid) if node: viewer.add_search_result(node)
def view_nodeid(self, app, nodeid): for window in app.get_windows(): notebook = window.get_notebook() if not notebook: continue node = notebook.get_node_by_id(nodeid) if node: window.get_viewer().goto_node(node) break
def on_new_note(self, app, args): if len(args) < 1: self.error("Must specify note url") return app.focus_windows() nodeurl = args[1] window, notebook = self.get_window_notebook() nodeid = self.get_nodeid(nodeurl) if notebook and nodeid: node = notebook.get_node_by_id(nodeid) if node: window.get_viewer().new_node( keepnote.notebook.CONTENT_TYPE_PAGE, "child", node)