| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- #ifndef MARKDOWNEDITORCONFIG_H
- #define MARKDOWNEDITORCONFIG_H
- #include "iconfig.h"
- #include "webresource.h"
- #include <QSharedPointer>
- #include <QVector>
- namespace vnotex
- {
- class TextEditorConfig;
- class MarkdownEditorConfig : public IConfig
- {
- public:
- enum SectionNumberMode
- {
- None,
- Read,
- Edit
- };
- enum SectionNumberStyle
- {
- // 1.1.
- DigDotDigDot,
- // 1.1
- DigDotDig
- };
- MarkdownEditorConfig(ConfigMgr *p_mgr,
- IConfig *p_topConfig,
- const QSharedPointer<TextEditorConfig> &p_textEditorConfig);
- void init(const QJsonObject &p_app, const QJsonObject &p_user) Q_DECL_OVERRIDE;
- QJsonObject toJson() const Q_DECL_OVERRIDE;
- int revision() const Q_DECL_OVERRIDE;
- TextEditorConfig &getTextEditorConfig();
- const TextEditorConfig &getTextEditorConfig() const;
- const WebResource &getViewerResource() const;
- const WebResource &getExportResource() const;
- bool getWebPlantUml() const;
- void setWebPlantUml(bool p_enabled);
- const QString &getPlantUmlJar() const;
- void setPlantUmlJar(const QString &p_jar);
- const QString &getPlantUmlCommand() const;
- bool getWebGraphviz() const;
- void setWebGraphviz(bool p_enabled);
- const QString &getGraphvizExe() const;
- void setGraphvizExe(const QString &p_exe);
- bool getPrependDotInRelativeLink() const;
- bool getConfirmBeforeClearObsoleteImages() const;
- void setConfirmBeforeClearObsoleteImages(bool p_confirm);
- bool getInsertFileNameAsTitle() const;
- void setInsertFileNameAsTitle(bool p_enabled);
- SectionNumberMode getSectionNumberMode() const;
- void setSectionNumberMode(SectionNumberMode p_mode);
- int getSectionNumberBaseLevel() const;
- void setSectionNumberBaseLevel(int p_level);
- SectionNumberStyle getSectionNumberStyle() const;
- void setSectionNumberStyle(SectionNumberStyle p_style);
- bool getConstrainImageWidthEnabled() const;
- void setConstrainImageWidthEnabled(bool p_enabled);
- bool getConstrainInPlacePreviewWidthEnabled() const;
- void setConstrainInPlacePreviewWidthEnabled(bool p_enabled);
- qreal getZoomFactorInReadMode() const;
- void setZoomFactorInReadMode(qreal p_factor);
- bool getFetchImagesInParseAndPaste() const;
- void setFetchImagesInParseAndPaste(bool p_enabled);
- bool getProtectFromXss() const;
- bool getHtmlTagEnabled() const;
- void setHtmlTagEnabled(bool p_enabled);
- bool getAutoBreakEnabled() const;
- void setAutoBreakEnabled(bool p_enabled);
- bool getLinkifyEnabled() const;
- void setLinkifyEnabled(bool p_enabled);
- bool getIndentFirstLineEnabled() const;
- void setIndentFirstLineEnabled(bool p_enabled);
- bool getSmartTableEnabled() const;
- void setSmartTableEnabled(bool p_enabled);
- int getSmartTableInterval() const;
- bool isSpellCheckEnabled() const;
- void setSpellCheckEnabled(bool p_enabled);
- private:
- QString sectionNumberModeToString(SectionNumberMode p_mode) const;
- SectionNumberMode stringToSectionNumberMode(const QString &p_str) const;
- QString sectionNumberStyleToString(SectionNumberStyle p_style) const;
- SectionNumberStyle stringToSectionNumberStyle(const QString &p_str) const;
- void loadViewerResource(const QJsonObject &p_app, const QJsonObject &p_user);
- QJsonObject saveViewerResource() const;
- void loadExportResource(const QJsonObject &p_app, const QJsonObject &p_user);
- QJsonObject saveExportResource() const;
- QSharedPointer<TextEditorConfig> m_textEditorConfig;
- WebResource m_viewerResource;
- WebResource m_exportResource;
- // Whether use javascript or external program to render PlantUML.
- bool m_webPlantUml = true;
- // File path of the JAR to render PlantUmL.
- QString m_plantUmlJar;
- // Command to render PlantUml. If set, will ignore m_plantUmlJar.
- // %1: the format to render in.
- QString m_plantUmlCommand;
- bool m_webGraphviz = true;
- // Graphviz executable file.
- QString m_graphvizExe;
- // Whether prepend a dot in front of the relative link, like images.
- bool m_prependDotInRelativeLink = false;
- // Whether ask for user confirmation before clearing obsolete images.
- bool m_confirmBeforeClearObsoleteImages = true;
- // Whether insert the name of the new file as title.
- bool m_insertFileNameAsTitle = true;
- // Whether enable section numbering.
- SectionNumberMode m_sectionNumberMode = SectionNumberMode::Read;
- // 1 based.
- int m_sectionNumberBaseLevel = 2;
- // Section number style.
- SectionNumberStyle m_sectionNumberStyle = SectionNumberStyle::DigDotDigDot;
- // Whether enable image width constraint.
- bool m_constrainImageWidthEnabled = true;
- // Whether enable in-place preview width constraint.
- bool m_constrainInPlacePreviewWidthEnabled = false;
- qreal m_zoomFactorInReadMode = 1.0;
- // Whether fetch images to local in Parse To Markdown And Paste.
- bool m_fetchImagesInParseAndPaste = true;
- // Whether protect from Cross-Site Scripting.
- bool m_protectFromXss = false;
- // Whether allow HTML tag in Markdown source.
- bool m_htmlTagEnabled = true;
- // Whether auto break a line with `\n`.
- bool m_autoBreakEnabled = false;
- // Whether convert URL-like text to links.
- bool m_linkifyEnabled = true;
- // Whether indent the first line of a paragraph.
- bool m_indentFirstLineEnabled = false;
- bool m_smartTableEnabled = true;
- // Interval time to do smart table format.
- int m_smartTableInterval = 2000;
- // Override the config in TextEditorConfig.
- bool m_spellCheckEnabled = true;
- };
- }
- #endif // MARKDOWNEDITORCONFIG_H
|