diff --git a/app/mindmap/buffer.py b/app/mindmap/buffer.py index b20a0ed..7bc747c 100644 --- a/app/mindmap/buffer.py +++ b/app/mindmap/buffer.py @@ -31,11 +31,13 @@ class AppBuffer(BrowserBuffer): self.url = "file://" + (os.path.join(os.path.dirname(__file__), "index.html")) self.buffer_widget.setUrl(QUrl(self.url)) - def add_sub_node(self): - self.buffer_widget.eval_js("add_node();") + for method_name in ["zoom_in", "zoom_out", "zoom_reset", "add_sub_node", "remove_node"]: + self.build_js_method(method_name) - def remove_node(self): - self.buffer_widget.eval_js("remove_node();") + def build_js_method(self, method_name): + def _do (): + self.buffer_widget.eval_js("{}();".format(method_name)) + setattr(self, method_name, _do) def update_node_topic(self): self.send_input_message("Update topic: ", "update_node_topic") diff --git a/app/mindmap/index.html b/app/mindmap/index.html index 2fdb8ab..ee5894f 100644 --- a/app/mindmap/index.html +++ b/app/mindmap/index.html @@ -33,12 +33,14 @@ theme:'greensea', editable:true } + _jm = jsMind.show(options); + _jm.select_node("root"); } open_empty(); - function add_node(){ + function add_sub_node(){ var selected_node = _jm.get_selected_node(); // as parent of new node if(!selected_node) { _jm.move_node(selected_id,'_first_'); @@ -60,6 +62,7 @@ function remove_node(){ var selected_id = get_selected_nodeid(); if(selected_id) { + _jm.select_node(_jm.get_selected_node().parent); _jm.remove_node(selected_id); } } @@ -70,6 +73,18 @@ _jm.update_node(selected_id, topic); } } + + function zoom_in() { + _jm.view.zoomIn(); + }; + + function zoom_out() { + _jm.view.zoomOut(); + }; + + function zoom_reset() { + _jm.view.setZoom(1); + } diff --git a/eaf.el b/eaf.el index 6aa050f..c7b39ff 100644 --- a/eaf.el +++ b/eaf.el @@ -423,6 +423,10 @@ Try not to modify this alist directly. Use `eaf-setq' to modify instead." ("DEL" . "remove_node") ("M-o" . "remove_node") ("M-m" . "update_node_topic") + ("M-r" . "refresh_page") + ("C--" . "zoom_out") + ("C-=" . "zoom_in") + ("C-0" . "zoom_reset") ) "The keybinding of EAF Mindmap." :type 'cons) @@ -1283,7 +1287,7 @@ This function works best if paired with a fuzzy search package." (if history-file-exists (mapcar (lambda (h) (when (string-match history-pattern h) - (format "[%s] ⇰ %s" (match-string 1 h) (match-string 2 h)))) + (format "[%s] ⇰ %s" (match-string 1 h) (match-string 2 h)))) (with-temp-buffer (insert-file-contents browser-history-file-path) (split-string (buffer-string) "\n" t))) nil)))