@@ -87,6 +87,13 @@ const DocContextMenu = ({
8787 ? usersMap . get ( currentDoc . userId )
8888 : undefined
8989
90+ const contentCounters = useMemo ( ( ) => {
91+ return {
92+ wordCount : currentDoc ?. head ?. content . match ( / \S + / g) ?. length || 0 ,
93+ characterCount : currentDoc ?. head ?. content . replace ( / \s + / g, '' ) . length || 0 ,
94+ }
95+ } , [ currentDoc ?. head ?. content ] )
96+
9097 if ( currentDoc == null ) {
9198 return (
9299 < MetadataContainer
@@ -213,26 +220,22 @@ const DocContextMenu = ({
213220 } }
214221 />
215222 ) }
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- ] }
223+ < MetadataContainerRow
224+ row = { {
225+ label : translate ( lngKeys . WordCount ) ,
226+ type : 'content' ,
227+ icon : mdiFormatLetterCase ,
228+ content : contentCounters . wordCount ,
229+ } }
230+ />
231+ < MetadataContainerRow
232+ row = { {
233+ label : translate ( lngKeys . CharacterCount ) ,
234+ type : 'content' ,
235+ icon : mdiText ,
236+ content : contentCounters . characterCount ,
237+ } }
238+ />
236239 < BackLinksList team = { team } docs = { backLinks } />
237240 < MetadataContainerBreak />
238241 < DocContextMenuActions
0 commit comments