mirror of
https://github.com/outline/outline.git
synced 2026-11-21 05:24:03 +03:00
* Reducing loading on first open, closes #10263 * perf: Prosemirror deps loaded with Document model * More initial component reduction * more * refactor
27 lines
709 B
TypeScript
27 lines
709 B
TypeScript
import { EyeIcon } from "outline-icons";
|
|
import { useMemo } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { useTextStats } from "~/hooks/useTextStats";
|
|
import type Document from "~/models/Document";
|
|
import { ProsemirrorHelper } from "~/models/helpers/ProsemirrorHelper";
|
|
|
|
const ReadingTime = ({ document }: { document: Document }) => {
|
|
const { t } = useTranslation();
|
|
const markdown = useMemo(
|
|
() => ProsemirrorHelper.toMarkdown(document),
|
|
[document]
|
|
);
|
|
const stats = useTextStats(markdown);
|
|
|
|
return (
|
|
<>
|
|
<EyeIcon size={18} />
|
|
{t(`{{ minutes }}m read`, {
|
|
minutes: stats.total.readingTime,
|
|
})}
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default ReadingTime;
|