Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Add statistics option to the editor bar (option to enable)

Smaug67393835db27c71d
diff --git a/frontend/app/components/MarkdownEditor/EditorPreferences.vue b/frontend/app/components/MarkdownEditor/EditorPreferences.vue
index 04ebf80b..9a388f9e 100644
--- a/frontend/app/components/MarkdownEditor/EditorPreferences.vue
+++ b/frontend/app/components/MarkdownEditor/EditorPreferences.vue
@@ -7,11 +7,15 @@
<AppSelect v-model="store.get('editorFontFamily').value" :items="EDITOR_FONTS" placeholder="Select theme" />
<label for="category">Font size</label>
<input v-model="store.get('editorFontSize').value" type="number" min="1" max="100" placeholder="Select font size" />
- <div style="display: flex; align-items: center; gap: 10px; margin-top: 15px">
+ <div class="row">
<label for="category">Spell check</label>
<AppToggle v-model="store.get('editorSpellCheck').value" />
</div>
<tag>Note: Enabling spell check can take effect after restarting the editor (reload the page)</tag>
+ <div class="row">
+ <label for="category">Display editor statistics</label>
+ <AppToggle v-model="store.get('editorDisplayStats').value" />
+ </div>
</form>
</div>
</template>
@@ -44,4 +48,11 @@ textarea {
font-size: 14px;
resize: none;
}
+
+.row {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ margin-top: 15px;
+}
</style>
diff --git a/frontend/app/components/MarkdownEditor/Toolbar.vue b/frontend/app/components/MarkdownEditor/Toolbar.vue
index f8f698ab..0980a82f 100644
--- a/frontend/app/components/MarkdownEditor/Toolbar.vue
+++ b/frontend/app/components/MarkdownEditor/Toolbar.vue
@@ -7,7 +7,10 @@
<VoiceRecognition @transcription="handleTranscription" />
<AppSelect v-if="!minimal" v-model="localValue.parent_id" :items="categories" placeholder="Select category" size="300px" class="entry" />
- <div class="help">
+ <div class="right">
+ <tag v-if="preferences.get('editorDisplayStats').value" class="stats no-tablet">
+ {{ stats.words }} words β€’ {{ stats.characters }} chars β€’ {{ stats.lines }} lines
+ </tag>
<button @click="openSettings">
<Icon name="settings" display="lg" fill="var(--font-color-light)" />
</button>
@@ -28,6 +31,22 @@ const props = defineProps<{
modelValue: Partial<Node>;
minimal?: boolean;
}>();
+
+const preferences = usePreferences();
+
+const stats = computed(() => {
+ const content = props.modelValue.content || '';
+ const words = content
+ .trim()
+ .split(/\s+/)
+ .filter(word => word.length > 0);
+ return {
+ characters: content.length,
+ words: words.length,
+ lines: content.split('\n').length,
+ };
+});
+
const handleTranscription = (text: string) => {
emit('execute-action', 'insertText', text);
};
@@ -169,9 +188,10 @@ input {
background-color: var(--bg-color);
}
-.help {
+.right {
margin-left: auto;
-
+ display: flex;
+ align-items: center;
&:hover:deep(svg) {
fill: var(--font-color-dark);
}
@@ -181,4 +201,8 @@ input {
padding: 4px 8px;
}
}
+
+.stats {
+ color: var(--font-color-light);
+}
</style>
diff --git a/frontend/app/composables/Preferences.ts b/frontend/app/composables/Preferences.ts
index 25793bad..25daef54 100644
--- a/frontend/app/composables/Preferences.ts
+++ b/frontend/app/composables/Preferences.ts
@@ -43,6 +43,7 @@ export const DEFAULT_PREFERENCES = {
editorFontFamily: 'JetBrains Mono' as string,
editorFontSize: 14 as number,
editorSpellCheck: true as boolean,
+ editorDisplayStats: false as boolean,
developerMode: false as boolean,
};
diff --git a/frontend/app/pages/dashboard/settings/_views/preferences.vue b/frontend/app/pages/dashboard/settings/_views/preferences.vue
index fe5db3b3..fe026f9e 100644
--- a/frontend/app/pages/dashboard/settings/_views/preferences.vue
+++ b/frontend/app/pages/dashboard/settings/_views/preferences.vue
@@ -227,6 +227,13 @@ const options = ref<{ label: string; options: Option[] }[]>([
key: 'editorSpellCheck',
value: Boolean(preferencesStore.get('editorSpellCheck')),
},
+ {
+ label: 'Display statistics bar',
+ description: 'Show a small statistics bar at the top of the editor with word count, characters, and lines.',
+ type: 'toggle',
+ key: 'editorDisplayStats',
+ value: Boolean(preferencesStore.get('editorDisplayStats')),
+ },
],
},
{