mirror of
https://github.com/outline/outline.git
synced 2026-11-22 22:02:35 +03:00
* feat: Live document stats in the corner of the editor Moves word and character counts out of the Insights dialog into an optional bar in the bottom corner of the document that updates as you type, adding paragraph count and reading time. Enabled with a new "Show editing stats" preference, or toggled with Cmd+Shift+G. The counts switch to the selection while text is selected, and fade out while idle. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: Stats bar should not intercept clicks in the editor Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Add toggle to document menu and command menu * fix: Empty documents should not report a one minute read Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
31 lines
865 B
TypeScript
31 lines
865 B
TypeScript
import { getTextStats } from "./useTextStats";
|
|
|
|
describe("getTextStats", () => {
|
|
it("counts words, characters and paragraphs", () => {
|
|
const stats = getTextStats("Hello world\nSecond paragraph here");
|
|
|
|
expect(stats.words).toBe(5);
|
|
expect(stats.characters).toBe(33);
|
|
expect(stats.paragraphs).toBe(2);
|
|
});
|
|
|
|
it("ignores empty lines when counting paragraphs", () => {
|
|
const stats = getTextStats("One\n\n \nTwo\n");
|
|
|
|
expect(stats.paragraphs).toBe(2);
|
|
});
|
|
|
|
it("returns zeroed stats for empty text", () => {
|
|
const stats = getTextStats("");
|
|
|
|
expect(stats.words).toBe(0);
|
|
expect(stats.characters).toBe(0);
|
|
expect(stats.paragraphs).toBe(0);
|
|
expect(stats.readingTime).toBe(0);
|
|
});
|
|
|
|
it("rounds reading time up to a minute for short text", () => {
|
|
expect(getTextStats("Hello world").readingTime).toBe(1);
|
|
});
|
|
});
|