mobile: implement toc

This commit is contained in:
Ammar Ahmed
2024-01-04 11:38:40 +05:00
committed by Abdullah Atta
parent c33c365b62
commit 71d94853ba
19 changed files with 521 additions and 40 deletions

View File

@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Editor } from "@notesnook/editor";
import { Editor, scrollIntoViewById } from "@notesnook/editor";
import {
ThemeDefinition,
useThemeColors,
@@ -107,9 +107,17 @@ export type EditorController = {
updateTab: () => void;
loading: boolean;
setLoading: (value: boolean) => void;
getTableOfContents: () => any[];
scrollIntoView: (id: string) => void;
};
export function useEditorController(update: () => void): EditorController {
export function useEditorController({
update,
getTableOfContents
}: {
update: () => void;
getTableOfContents: () => any[];
}): EditorController {
const tab = useTabContext();
const [loading, setLoading] = useState(true);
const setTheme = useThemeEngineStore((store) => store.setTheme);
@@ -341,6 +349,8 @@ export function useEditorController(update: () => void): EditorController {
};
return {
getTableOfContents: getTableOfContents,
scrollIntoView: (id: string) => scrollIntoViewById(id),
contentChange,
selectionChange,
titleChange,