Skip to content

Commit 4f082cd

Browse files
sushantdhimanRokt33r
authored andcommitted
feat(DocContextMenu): show word/character count
1 parent f14274a commit 4f082cd

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/cloud/components/DocPage/NewDocContextMenu.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {
33
mdiAccountMultiple,
44
mdiClockOutline,
55
mdiContentSaveOutline,
6+
mdiText,
7+
mdiFormatLetterCase,
68
} from '@mdi/js'
79
import React, { useMemo, useState } from 'react'
810
import Button from '../../../design/components/atoms/Button'
@@ -211,6 +213,26 @@ const DocContextMenu = ({
211213
}}
212214
/>
213215
)}
216+
{currentDoc.head && [
217+
<MetadataContainerRow
218+
key='word-count'
219+
row={{
220+
label: translate(lngKeys.WordCount),
221+
type: 'content',
222+
icon: mdiFormatLetterCase,
223+
content: currentDoc.head.content.match(/\S+/g)?.length || 0,
224+
}}
225+
/>,
226+
<MetadataContainerRow
227+
key='character-count'
228+
row={{
229+
label: translate(lngKeys.CharacterCount),
230+
type: 'content',
231+
icon: mdiText,
232+
content: currentDoc.head.content.replace(/\s+/g, '').length || 0,
233+
}}
234+
/>,
235+
]}
214236
<BackLinksList team={team} docs={backLinks} />
215237
<MetadataContainerBreak />
216238
<DocContextMenuActions

src/cloud/lib/i18n/enUS.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ const enTranslation: TranslationSource = {
360360
[lngKeys.CreatedBy]: 'Created By',
361361
[lngKeys.UpdatedBy]: 'Updated By',
362362
[lngKeys.Contributors]: 'Contributors',
363+
[lngKeys.WordCount]: 'Word Count',
364+
[lngKeys.CharacterCount]: 'Character Count',
363365
[lngKeys.History]: 'History',
364366
[lngKeys.Share]: 'Share',
365367
[lngKeys.PublicSharing]: 'Public Sharing',

src/cloud/lib/i18n/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ export enum lngKeys {
384384
CreatedBy = 'Created.By',
385385
UpdatedBy = 'Updated.By',
386386
Contributors = 'Contributors',
387+
WordCount = 'Word.Count',
388+
CharacterCount = 'Character.Count',
387389
History = 'History',
388390
Share = 'Share',
389391
PublicSharing = 'Public.Sharing',

0 commit comments

Comments
 (0)