Skip to content

Commit

Permalink
#1307: option to disable Markdown support
Browse files Browse the repository at this point in the history
  • Loading branch information
antelle committed Oct 17, 2019
1 parent 858a9bf commit c62193d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/scripts/comp/format/kdbx-to-html.js
Expand Up @@ -5,6 +5,7 @@ import { DateFormat } from 'util/formatting/date-format';
import { MdToHtml } from 'util/formatting/md-to-html';
import { StringFormat } from 'util/formatting/string-format';
import { Locale } from 'util/locale';
import { AppSettingsModel } from 'models/app-settings-model';

const Templates = {
db: require('templates/export/db.hbs'),
Expand Down Expand Up @@ -43,7 +44,7 @@ function walkEntry(db, entry, parents) {
let value = entryField(entry, field.name);
if (value) {
let html = false;
if (field.markdown) {
if (field.markdown && AppSettingsModel.useMarkdown) {
const converted = MdToHtml.convert(value);
if (converted !== value) {
value = converted;
Expand Down
1 change: 1 addition & 0 deletions app/scripts/locales/base.json
Expand Up @@ -399,6 +399,7 @@
"setGenShowSubgroups": "Show entries from all subgroups",
"setGenTableView": "Entries list table view",
"setGenColorfulIcons": "Colorful custom icons in the list",
"setGenUseMarkdown": "Markdown in Notes",
"setGenDirectAutotype": "If only one matching entry is found, select that one automatically for Autotype",
"setGenFunction": "Function",
"setGenAutoSyncOnClose": "Automatically save and sync on close",
Expand Down
1 change: 1 addition & 0 deletions app/scripts/models/app-settings-model.js
Expand Up @@ -44,6 +44,7 @@ AppSettingsModel.defineModelProperties(
minimizeOnClose: false,
tableView: false,
colorfulIcons: false,
useMarkdown: true,
directAutotype: true,
titlebarStyle: 'default',
lockOnMinimize: true,
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/views/fields/field-view-text.js
Expand Up @@ -9,6 +9,7 @@ import { Tip } from 'util/ui/tip';
import { FieldView } from 'views/fields/field-view';
import { GeneratorView } from 'views/generator-view';
import { escape } from 'util/fn';
import { AppSettingsModel } from 'models/app-settings-model';

class FieldViewText extends FieldView {
hasOptions = true;
Expand All @@ -19,7 +20,7 @@ class FieldViewText extends FieldView {
}

renderValue(value) {
if (this.model.markdown) {
if (this.model.markdown && AppSettingsModel.useMarkdown) {
if (value && value.isProtected) {
value = value.getText();
}
Expand Down
8 changes: 8 additions & 0 deletions app/scripts/views/settings/settings-general-view.js
Expand Up @@ -40,6 +40,7 @@ class SettingsGeneralView extends View {
'change .settings__general-lock-on-os-lock': 'changeLockOnOsLock',
'change .settings__general-table-view': 'changeTableView',
'change .settings__general-colorful-icons': 'changeColorfulIcons',
'change .settings__general-use-markdown': 'changeUseMarkdown',
'change .settings__general-direct-autotype': 'changeDirectAutotype',
'change .settings__general-titlebar-style': 'changeTitlebarStyle',
'click .settings__general-update-btn': 'checkUpdate',
Expand Down Expand Up @@ -104,6 +105,7 @@ class SettingsGeneralView extends View {
updateManual,
releaseNotesLink: Links.ReleaseNotes,
colorfulIcons: AppSettingsModel.colorfulIcons,
useMarkdown: AppSettingsModel.useMarkdown,
directAutotype: AppSettingsModel.directAutotype,
supportsTitleBarStyles: Launcher && Features.supportsTitleBarStyles(),
titlebarStyle: AppSettingsModel.titlebarStyle,
Expand Down Expand Up @@ -297,6 +299,12 @@ class SettingsGeneralView extends View {
Events.emit('refresh');
}

changeUseMarkdown(e) {
const useMarkdown = e.target.checked || false;
AppSettingsModel.useMarkdown = useMarkdown;
Events.emit('refresh');
}

changeDirectAutotype(e) {
const directAutotype = e.target.checked || false;
AppSettingsModel.directAutotype = directAutotype;
Expand Down
4 changes: 4 additions & 0 deletions app/templates/settings/settings-general.hbs
Expand Up @@ -88,6 +88,10 @@
<input type="checkbox" class="settings__input input-base settings__general-colorful-icons" id="settings__general-colorful-icons" {{#if colorfulIcons}}checked{{/if}} />
<label for="settings__general-colorful-icons">{{res 'setGenColorfulIcons'}}</label>
</div>
<div>
<input type="checkbox" class="settings__input input-base settings__general-use-markdown" id="settings__general-use-markdown" {{#if useMarkdown}}checked{{/if}} />
<label for="settings__general-use-markdown">{{res 'setGenUseMarkdown'}}</label>
</div>

<h2>{{res 'setGenFunction'}}</h2>
{{#if canAutoSaveOnClose}}
Expand Down
1 change: 1 addition & 0 deletions release-notes.md
Expand Up @@ -7,6 +7,7 @@ Release notes
`+` #565: global shortcut to open KeeWeb
`+` #862: downloading attachments on mobile
`+` #480: option to launch the app minimized
`+` #1307: option to disable Markdown support
`-` fix #1273: untranslated menu items
`-` fix #1311: better monospace fonts

Expand Down

0 comments on commit c62193d

Please sign in to comment.