feat: Improved table of contents (#1223)
* feat: New table of contents * fix: Hide TOC in edit mode * feat: Highlight follows scroll position * scroll tracking * UI * fix: Unrelated css fix with long doc titles * Improve responsiveness * feat: Add keyboard shortcut access to TOC * fix: Headings should reflect content correctly when viewing old document revision * flow * fix: Persist TOC choice between sessions
This commit is contained in:
@@ -4,6 +4,7 @@ import pkg from 'rich-markdown-editor/package.json';
|
||||
import addDays from 'date-fns/add_days';
|
||||
import invariant from 'invariant';
|
||||
import { client } from 'utils/ApiClient';
|
||||
import getHeadingsForText from 'shared/utils/getHeadingsForText';
|
||||
import parseTitle from 'shared/utils/parseTitle';
|
||||
import unescape from 'shared/utils/unescape';
|
||||
import BaseModel from 'models/BaseModel';
|
||||
@@ -53,6 +54,11 @@ export default class Document extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
@computed
|
||||
get headings() {
|
||||
return getHeadingsForText(this.text);
|
||||
}
|
||||
|
||||
@computed
|
||||
get isOnlyTitle(): boolean {
|
||||
const { title } = parseTitle(this.text);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// @flow
|
||||
import { computed } from 'mobx';
|
||||
import getHeadingsForText from 'shared/utils/getHeadingsForText';
|
||||
import BaseModel from './BaseModel';
|
||||
import User from './User';
|
||||
|
||||
@@ -9,6 +11,11 @@ class Revision extends BaseModel {
|
||||
text: string;
|
||||
createdAt: string;
|
||||
createdBy: User;
|
||||
|
||||
@computed
|
||||
get headings() {
|
||||
return getHeadingsForText(this.text);
|
||||
}
|
||||
}
|
||||
|
||||
export default Revision;
|
||||
|
||||
Reference in New Issue
Block a user