Add zoom feature and select node default.

master
Andy Stewart 6 years ago
parent b92fc0dabc
commit 86ca1dfd90
  1. 10
      app/mindmap/buffer.py
  2. 17
      app/mindmap/index.html
  3. 6
      eaf.el

@ -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")

@ -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);
}
</script>
</body>
</html>

@ -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)))

Loading…
Cancel
Save