Commits

Roger Haase committed 2581df6

auto-scroll edit textarea for ReST items

  • Participants
  • Parent commits 67ae770

Comments (0)

Files changed (1)

File MoinMoin/converter/rst_in.py

 from MoinMoin import log
 logging = log.getLogger(__name__)
 
+from flask import request
 from flask import g as flaskg
 
 from MoinMoin import config
         self.header_size = 1
         self.status = ['document']
         self.footnotes = dict()
+        self.last_lineno = 0
+        self.current_lineno = 0
 
     def dispatch_visit(self, node):
         """
         """
         node_name = node.__class__.__name__
         method = getattr(self, 'visit_' + node_name, self.unknown_visit)
+        self.current_lineno = node.line
         return method(node)
 
     def dispatch_departure(self, node):
         pass
 
     def open_moin_page_node(self, mointree_element):
+        if request.user_agent and flaskg.user.edit_on_doubleclick:
+            # add data-lineno attribute for auto-scrolling edit textarea (user_agent is None when running tests)
+            if self.last_lineno < self.current_lineno:
+                mointree_element.attrib[html.data_lineno] = self.current_lineno
+                self.last_lineno = self.current_lineno
         self.current_node.append(mointree_element)
         self.current_node = mointree_element
         self.path.append(mointree_element)