Wax Counters
Hello @victormutai . We need to rewrite the counters functionality. The old implementation is in here. https://gitlab.coko.foundation/wax/wax-prosemirror/-/blob/master/wax-prosemirror-services/src/BottomInfoService/CounterInfoService/components/EditorInfoTool.js?ref_type=heads
I don't know what is going on and why it is so complicated. Also it really affects the performance of the editor as all of these loops make it too heavy. Let's delete everything except the styling ,the component and the translations basically. It should be way much easier. The code that you will need is the following.
get the text of the current doc const docText= state.doc.textBetween(0,state.doc.content.size,undefined,' ',);
So .length
should give you total characters. Similar a starting point of words is docText.split(' ').filter(word => word !== '').length
. If you have to use other characters to split please do.
Lastly to iterate through all the nodes in the document use the following
state.doc.descendants((node) => {
console.log(node);
});
Inside node you will find a property of type i beleive so you can then get the types you need. That's basically all. With those 3, implementation should be minimal. It's a react component , just return it in a useMemo and update the args array of when you need it to rerender.