Skip to content

Commit

Permalink
feat: characters and words count in info bar
Browse files Browse the repository at this point in the history
  • Loading branch information
gbicou committed Apr 6, 2023
1 parent b0f319f commit 13e4c57
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@tiptap/core": "^2.0.2",
"@tiptap/extension-character-count": "^2.0.2",
"@tiptap/extension-placeholder": "^2.0.2",
"@tiptap/extension-underline": "^2.0.2",
"@tiptap/pm": "^2.0.2",
Expand Down
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/extensions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Extensions } from "@tiptap/core";
import StarterKit from "@tiptap/starter-kit";
import { Underline } from "@tiptap/extension-underline";
import { CharacterCount } from "@tiptap/extension-character-count";

export const extensions: Extensions = [StarterKit, Underline];
export const extensions: Extensions = [StarterKit, Underline, CharacterCount];
18 changes: 18 additions & 0 deletions src/tiptap-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@
</div>

<editor-content class="tiptap-editor__content" :editor="editor" />

<div class="tiptap-editor__info">
{{ editor.storage.characterCount.characters() }} chars, {{ editor.storage.characterCount.words() }} words
</div>
</div>
</template>

Expand Down Expand Up @@ -239,6 +243,20 @@
border-color: var(--border-normal);
}
&__info {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
min-height: 30px;
padding: 0 8px;
background-color: var(--background-subdued);
color: var(--foreground-subdued);
border-top: 2px solid var(--border-normal);
font-family: var(--family-monospace);
font-size: 12px;
}
&__toolbar {
--v-button-background-color: transparent;
--v-button-color: var(--foreground-normal);
Expand Down

0 comments on commit 13e4c57

Please sign in to comment.