mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
🎨 Added word count to beta editor
closes https://github.com/TryGhost/Team/issues/3242 - the beta editor now provides `<WordCountPlugin>` for tracking word count so we can add the UI for it back
This commit is contained in:
parent
49f936b098
commit
3ee857a0de
@ -42,6 +42,7 @@
|
||||
@onChange={{@onBodyChange}}
|
||||
@registerAPI={{this.registerEditorAPI}}
|
||||
@cursorDidExitAtTop={{this.focusTitle}}
|
||||
@updateWordCount={{@updateWordCount}}
|
||||
/>
|
||||
|
||||
{{!-- <KoenigEditor
|
||||
|
@ -123,6 +123,11 @@ const KoenigEditor = (props) => {
|
||||
return <_KoenigEditor {...props} />;
|
||||
};
|
||||
|
||||
const WordCountPlugin = (props) => {
|
||||
const {WordCountPlugin: _WordCountPlugin} = editorResource.read();
|
||||
return <_WordCountPlugin {...props} />;
|
||||
};
|
||||
|
||||
export default class KoenigLexicalEditor extends Component {
|
||||
@service ajax;
|
||||
@service feature;
|
||||
@ -502,6 +507,7 @@ export default class KoenigLexicalEditor extends Component {
|
||||
onChange={this.args.onChange}
|
||||
registerAPI={this.args.registerAPI}
|
||||
/>
|
||||
<WordCountPlugin onChange={this.args.updateWordCount} />
|
||||
</KoenigComposer>
|
||||
</Suspense>
|
||||
</ErrorHandler>
|
||||
|
@ -127,7 +127,7 @@ export default class LexicalEditorController extends Controller {
|
||||
fromAnalytics = false;
|
||||
|
||||
// koenig related properties
|
||||
wordcount = null;
|
||||
wordCount = 0;
|
||||
|
||||
/* private properties ----------------------------------------------------*/
|
||||
|
||||
@ -305,8 +305,8 @@ export default class LexicalEditorController extends Controller {
|
||||
}
|
||||
|
||||
@action
|
||||
updateWordCount(counts) {
|
||||
this.set('wordCount', counts);
|
||||
updateWordCount(count) {
|
||||
this.set('wordCount', count);
|
||||
}
|
||||
|
||||
@action
|
||||
|
@ -75,7 +75,7 @@
|
||||
@scrollContainerSelector=".gh-koenig-editor"
|
||||
@scrollOffsetBottomSelector=".gh-mobile-nav-bar"
|
||||
@onEditorCreated={{this.setKoenigEditor}}
|
||||
@onWordCountChange={{this.updateWordCount}}
|
||||
@updateWordCount={{this.updateWordCount}}
|
||||
@featureImage={{this.post.featureImage}}
|
||||
@featureImageAlt={{this.post.featureImageAlt}}
|
||||
@featureImageCaption={{this.post.featureImageCaption}}
|
||||
@ -98,9 +98,9 @@
|
||||
{{/if}}
|
||||
|
||||
<div class="gh-editor-wordcount-container">
|
||||
{{!-- <div class="gh-editor-wordcount">
|
||||
{{gh-pluralize this.wordCount.wordCount "word"}}
|
||||
</div> --}}
|
||||
<div class="gh-editor-wordcount">
|
||||
{{gh-pluralize this.wordCount "word"}}
|
||||
</div>
|
||||
{{!-- <a href="https://github.com/TryGhost/Koenig/tree/main/packages/koenig-lexical" target="_blank" rel="noopener noreferrer" class="gh-lexical-indicator">Lexical</a> --}}
|
||||
<a href="https://ghost.org/help/using-the-editor/" class="flex" target="_blank" rel="noopener noreferrer">{{svg-jar "help"}}</a>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user