From 4a3caf30bb7371f8ad83214f1b310c6924dfbb0e Mon Sep 17 00:00:00 2001 From: Mathieu PATUREL Date: Wed, 4 Jan 2017 19:49:49 +1100 Subject: [PATCH] auto create preview when modified (and enabled) --- MarkdownLivePreview.py | 8 ++++++++ sample.md | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/MarkdownLivePreview.py b/MarkdownLivePreview.py index 8ce1074..15ab19d 100644 --- a/MarkdownLivePreview.py +++ b/MarkdownLivePreview.py @@ -11,6 +11,14 @@ from .functions import * class MarkdownLivePreviewListener(sublime_plugin.EventListener): + def on_modified(self, view): + window = view.window() + vsettings = view.settings() + if vsettings.get(PREVIEW_ENABLED): + id = vsettings.get(PREVIEW_ID) + if id is None or get_view_from_id(window, id) is None: + preview = create_preview(view) + def on_activated(self, view): # if view is md_view and has no preview # -> create preview diff --git a/sample.md b/sample.md index 3251cc7..91b2cf3 100644 --- a/sample.md +++ b/sample.md @@ -1,7 +1,7 @@ -# DuckDuckGo - The Search engine you'll fall in love with +# DuckDuckGo - The Search engine you'll fall in love with ![image](http://afterishtar.pl/images/100x100.gif) - + this is a test hello world... \ No newline at end of file