add setting for view mode
This commit is contained in:
parent
4b68d4a22f
commit
43f00a7a36
|
@ -27,16 +27,7 @@ class SettingsService {
|
|||
$this->l10n = $l10n;
|
||||
$this->root = $root;
|
||||
$this->attrs = [
|
||||
'fileSuffix' => [
|
||||
'default' => '.txt',
|
||||
'validate' => function ($value) {
|
||||
if (in_array($value, [ '.txt', '.md' ])) {
|
||||
return $value;
|
||||
} else {
|
||||
return '.txt';
|
||||
}
|
||||
},
|
||||
],
|
||||
'fileSuffix' => $this->getListAttrs('.txt', '.md'),
|
||||
'notesPath' => [
|
||||
'default' => function (string $uid) {
|
||||
return $this->getDefaultNotesPath($uid);
|
||||
|
@ -55,6 +46,21 @@ class SettingsService {
|
|||
return implode(DIRECTORY_SEPARATOR, $path);
|
||||
},
|
||||
],
|
||||
'noteMode' => $this->getListAttrs('edit', 'preview'),
|
||||
];
|
||||
}
|
||||
|
||||
private function getListAttrs(...$values) : array {
|
||||
$first = $values[0];
|
||||
return [
|
||||
'default' => $first,
|
||||
'validate' => function ($value) use ($values, $first) {
|
||||
if (in_array($value, $values)) {
|
||||
return $value;
|
||||
} else {
|
||||
return $first;
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,16 @@
|
|||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="settings-block">
|
||||
<p class="settings-hint">
|
||||
<label for="noteMode">{{ t('notes', 'Display mode for notes') }}</label>
|
||||
</p>
|
||||
<select id="noteMode" v-model="settings.noteMode" @change="onChangeSettings">
|
||||
<option v-for="mode in noteModes" :key="mode.value" :value="mode.value">
|
||||
{{ mode.label }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</AppNavigationSettings>
|
||||
</template>
|
||||
|
||||
|
@ -45,6 +55,10 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
extensions: ['.txt', '.md'],
|
||||
noteModes: [
|
||||
{ value: 'edit', label: t('notes', 'Open in edit mode') },
|
||||
{ value: 'preview', label: t('notes', 'Open in preview mode') },
|
||||
],
|
||||
saving: false,
|
||||
}
|
||||
},
|
||||
|
|
|
@ -212,7 +212,7 @@ export default {
|
|||
|
||||
this.onUpdateTitle(this.title)
|
||||
this.loading = true
|
||||
this.preview = false
|
||||
this.preview = store.state.app.settings.noteMode === 'preview'
|
||||
fetchNote(parseInt(this.noteId))
|
||||
.then((note) => {
|
||||
if (note.error) {
|
||||
|
|
Loading…
Reference in New Issue