Example #1
0
def toggleMarkdown(self):
    utility.start_safe_block(const.MARKDOWN_PREFS)
    self.saveNow()
    selected = self.web.selectedHtml()
    current_field = self.currentField
    html_field = self.note.fields[self.currentField]
    # if not isinstance(html_field, unicode):
    #     html_field = unicode(html_field)
    # if not isinstance(selected, unicode):
    #     selected = unicode(selected)
    if not html_field:
        html_field = u""
    if not selected:
        selected = u""
    markdowner = Markdowner(self, self.parentWindow, self.note,
                            html_field, current_field, selected)
    markdowner.apply_markdown()
    self.saveNow()
    self.web.setFocus()
    self.web.eval("focusField(%d);" % self.currentField)
    utility.end_safe_block(const.MARKDOWN_PREFS)
Example #2
0
def toggleMarkdown(self):
    utility.start_safe_block(const.MARKDOWN_PREFS)
    self.saveNow()
    selected = self.web.selectedHtml()
    current_field = self.currentField
    html_field = self.note.fields[self.currentField]
    # if not isinstance(html_field, unicode):
    #     html_field = unicode(html_field)
    # if not isinstance(selected, unicode):
    #     selected = unicode(selected)
    if not html_field:
        html_field = u""
    if not selected:
        selected = u""
    markdowner = Markdowner(self, self.parentWindow, self.note, html_field,
                            current_field, selected)
    markdowner.apply_markdown()
    self.saveNow()
    self.web.setFocus()
    self.web.eval("focusField(%d);" % self.currentField)
    utility.end_safe_block(const.MARKDOWN_PREFS)
Example #3
0
def on_focus_gained(self, note, field):

    tags = note.tags

    if not preferences.PREFS.get(const.MARKDOWN_OVERRIDE_EDITING):
        if const.MARKDOWN_PREFS.get("disable_buttons"):
            # disable all buttons except for the Markdown toggle
            self.disableButtons()
            markdown_button = self._buttons.get(const.MARKDOWN)
            if markdown_button:
                # markdown_button.setChecked(True)
                markdown_button.setEnabled(True)

    if const.MARKDOWN_PREFS.get("safe_block"):
        return
    else:
        utility.start_safe_block(const.MARKDOWN_PREFS)
        try:
            time.sleep(0.001)
            self.saveNow()
        except AttributeError as e:
            print e  # TODO: log error
        html_field = note.fields[field]
        # if not isinstance(html_field, unicode):
        #     html_field = unicode(html_field)
        if not html_field:
            html_field = u""
        markdowner = Markdowner(self, self.parentWindow, note,
                                html_field, field, u"")
        markdowner.on_focus_gained()
        self.web.setFocus()
        self.web.eval("focusField(%d);" % self.currentField)
        note.tags = tags
        try:
            time.sleep(0.001)
            self.updateTags()
        except AttributeError as e:
            print e  # TODO: log error
        utility.end_safe_block(const.MARKDOWN_PREFS)
Example #4
0
def on_focus_gained(self, note, field):

    tags = note.tags

    if not preferences.PREFS.get(const.MARKDOWN_OVERRIDE_EDITING):
        if const.MARKDOWN_PREFS.get("disable_buttons"):
            # disable all buttons except for the Markdown toggle
            self.disableButtons()
            markdown_button = self._buttons.get(const.MARKDOWN)
            if markdown_button:
                # markdown_button.setChecked(True)
                markdown_button.setEnabled(True)

    if const.MARKDOWN_PREFS.get("safe_block"):
        return
    else:
        utility.start_safe_block(const.MARKDOWN_PREFS)
        try:
            time.sleep(0.001)
            self.saveNow()
        except AttributeError as e:
            print e  # TODO: log error
        html_field = note.fields[field]
        # if not isinstance(html_field, unicode):
        #     html_field = unicode(html_field)
        if not html_field:
            html_field = u""
        markdowner = Markdowner(self, self.parentWindow, note, html_field,
                                field, u"")
        markdowner.on_focus_gained()
        self.web.setFocus()
        self.web.eval("focusField(%d);" % self.currentField)
        note.tags = tags
        try:
            time.sleep(0.001)
            self.updateTags()
        except AttributeError as e:
            print e  # TODO: log error
        utility.end_safe_block(const.MARKDOWN_PREFS)