diff --git a/src/resources/export_template.html b/src/resources/export_template.html
index b21da8fd..b4858078 100644
--- a/src/resources/export_template.html
+++ b/src/resources/export_template.html
@@ -1,4 +1,4 @@
-
+
diff --git a/src/resources/markdown_template.html b/src/resources/markdown_template.html
index 8e70c11d..2467a218 100644
--- a/src/resources/markdown_template.html
+++ b/src/resources/markdown_template.html
@@ -1,4 +1,4 @@
-
+
diff --git a/src/resources/simple_template.html b/src/resources/simple_template.html
index 4e2e73b8..5badbb32 100644
--- a/src/resources/simple_template.html
+++ b/src/resources/simple_template.html
@@ -1,4 +1,4 @@
-
+
diff --git a/src/resources/themes/v_moonlight/v_moonlight.css b/src/resources/themes/v_moonlight/v_moonlight.css
index 87423bb1..e4ebafdb 100644
--- a/src/resources/themes/v_moonlight/v_moonlight.css
+++ b/src/resources/themes/v_moonlight/v_moonlight.css
@@ -164,13 +164,14 @@ table tr th :last-child, table tr td :last-child {
}
div.mermaid-diagram {
- width: fit-content;
- overflow: hidden;
+ margin: 16px 0px 16px 0px;
+ overflow-y: hidden;
background: #B0BEC5;
color: #6C6C6C;
}
div.flowchart-diagram {
+ margin: 16px 0px 16px 0px;
width: fit-content;
overflow: hidden;
background: #B0BEC5;
@@ -178,6 +179,7 @@ div.flowchart-diagram {
}
div.plantuml-diagram {
+ margin: 16px 0px 16px 0px;
width: fit-content;
overflow: hidden;
background: #B0BEC5;
diff --git a/src/resources/themes/v_native/v_native.css b/src/resources/themes/v_native/v_native.css
index 2ed805a0..da870c8b 100644
--- a/src/resources/themes/v_native/v_native.css
+++ b/src/resources/themes/v_native/v_native.css
@@ -169,16 +169,18 @@ table tr th :last-child, table tr td :last-child {
}
div.mermaid-diagram {
- width: fit-content;
- overflow: hidden;
+ margin: 16px 0px 16px 0px;
+ overflow-y: hidden;
}
div.flowchart-diagram {
+ margin: 16px 0px 16px 0px;
width: fit-content;
overflow: hidden;
}
div.plantuml-diagram {
+ margin: 16px 0px 16px 0px;
width: fit-content;
overflow: hidden;
}
diff --git a/src/resources/themes/v_pure/v_pure.css b/src/resources/themes/v_pure/v_pure.css
index 99aea318..91b23f3e 100644
--- a/src/resources/themes/v_pure/v_pure.css
+++ b/src/resources/themes/v_pure/v_pure.css
@@ -170,16 +170,18 @@ table tr th :last-child, table tr td :last-child {
}
div.mermaid-diagram {
- width: fit-content;
- overflow: hidden;
+ margin: 16px 0px 16px 0px;
+ overflow-y: hidden;
}
div.flowchart-diagram {
+ margin: 16px 0px 16px 0px;
width: fit-content;
overflow: hidden;
}
div.plantuml-diagram {
+ margin: 16px 0px 16px 0px;
width: fit-content;
overflow: hidden;
}
diff --git a/src/vlinenumberarea.cpp b/src/vlinenumberarea.cpp
index 50fde2df..a7c3c25b 100644
--- a/src/vlinenumberarea.cpp
+++ b/src/vlinenumberarea.cpp
@@ -33,8 +33,7 @@ int VLineNumberArea::calculateWidth() const
++digits;
}
- int width = m_digitWidth * (digits + 1);
- const_cast(this)->m_width = width;
+ const_cast(this)->m_width = m_digitWidth * digits + 3;
return m_width;
}
diff --git a/src/vmdtab.cpp b/src/vmdtab.cpp
index 7c506610..e7c1abcd 100644
--- a/src/vmdtab.cpp
+++ b/src/vmdtab.cpp
@@ -68,14 +68,18 @@ VMdTab::VMdTab(VFile *p_file, VEditArea *p_editArea,
void VMdTab::setupUI()
{
- m_stacks = new QStackedLayout(this);
+ m_splitter = new QSplitter(this);
+ m_splitter->setOrientation(Qt::Horizontal);
setupMarkdownViewer();
// Setup editor when we really need it.
m_editor = NULL;
- setLayout(m_stacks);
+ QVBoxLayout *layout = new QVBoxLayout();
+ layout->addWidget(m_splitter);
+ layout->setContentsMargins(0, 0, 0, 0);
+ setLayout(layout);
}
void VMdTab::showFileReadMode()
@@ -87,7 +91,8 @@ void VMdTab::showFileReadMode()
updateWebView();
- m_stacks->setCurrentWidget(m_webViewer);
+ setCurrentMode(Mode::Read);
+
clearSearchedWordHighlight();
updateStatus();
@@ -216,7 +221,8 @@ void VMdTab::showFileEditMode()
VMdEditor *mdEdit = getEditor();
- m_stacks->setCurrentWidget(mdEdit);
+ setCurrentMode(Mode::Edit);
+
mdEdit->beginEdit();
// If editor is not init, we need to wait for it to init headers.
@@ -444,7 +450,7 @@ void VMdTab::setupMarkdownViewer()
m_webViewer->setHtml(VUtils::generateHtmlTemplate(m_mdConType),
m_file->getBaseUrl());
- m_stacks->addWidget(m_webViewer);
+ m_splitter->addWidget(m_webViewer);
}
void VMdTab::setupMarkdownEditor()
@@ -503,7 +509,7 @@ void VMdTab::setupMarkdownEditor()
enableHeadingSequence(m_enableHeadingSequence);
m_editor->reloadFile();
- m_stacks->addWidget(m_editor);
+ m_splitter->insertWidget(0, m_editor);
}
void VMdTab::updateOutlineFromHtml(const QString &p_tocHtml)
@@ -781,7 +787,11 @@ MarkdownConverterType VMdTab::getMarkdownConverterType() const
void VMdTab::focusChild()
{
- m_stacks->currentWidget()->setFocus();
+ if (m_mode == Mode::Read) {
+ m_webViewer->setFocus();
+ } else {
+ m_editor->setFocus();
+ }
}
void VMdTab::requestUpdateVimStatus()
@@ -1303,3 +1313,30 @@ VWordCountInfo VMdTab::fetchWordCountInfo(bool p_editMode) const
return VWordCountInfo();
}
+
+void VMdTab::setCurrentMode(Mode p_mode)
+{
+ switch (p_mode) {
+ case Mode::Read:
+ m_webViewer->show();
+ if (m_editor) {
+ m_editor->hide();
+ }
+
+ break;
+
+ case Mode::EditPreview:
+ case Mode::Edit:
+ Q_ASSERT(m_editor);
+ m_editor->show();
+ m_webViewer->hide();
+ break;
+
+ default:
+ break;
+ }
+
+ m_mode = p_mode;
+
+ focusChild();
+}
diff --git a/src/vmdtab.h b/src/vmdtab.h
index fce7b16d..55a948e3 100644
--- a/src/vmdtab.h
+++ b/src/vmdtab.h
@@ -9,12 +9,12 @@
#include "vconfigmanager.h"
class VWebView;
-class QStackedLayout;
class VDocument;
class VMdEditor;
class VInsertSelector;
class QTimer;
class QWebEngineDownloadItem;
+class QSplitter;
class VMdTab : public VEditTab
{
@@ -145,6 +145,8 @@ private slots:
private:
enum TabReady { None = 0, ReadMode = 0x1, EditMode = 0x2 };
+ enum Mode { Read = 0, Edit, EditPreview };
+
// Setup UI.
void setupUI();
@@ -213,6 +215,8 @@ private:
// Update web view by current content.
void updateWebView();
+ void setCurrentMode(Mode p_mode);
+
VMdEditor *m_editor;
VWebView *m_webViewer;
VDocument *m_document;
@@ -221,7 +225,7 @@ private:
// Whether heading sequence is enabled.
bool m_enableHeadingSequence;
- QStackedLayout *m_stacks;
+ QSplitter *m_splitter;
// Timer to write backup file when content has been changed.
QTimer *m_backupTimer;
@@ -232,6 +236,8 @@ private:
VHeaderPointer m_headerFromEditMode;
VVim::SearchItem m_lastSearchItem;
+
+ Mode m_mode;
};
inline VMdEditor *VMdTab::getEditor()