mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 11:47:54 +01:00
25 lines
697 B
TypeScript
25 lines
697 B
TypeScript
import CharacterCount from "@tiptap/extension-character-count";
|
|
import Placeholder from "@tiptap/extension-placeholder";
|
|
import { EditorOptions, useEditor } from "@tiptap/react";
|
|
import StarterKit from "@tiptap/starter-kit";
|
|
|
|
export const useTiptap = (options: Partial<EditorOptions> = {}, deps?: any) => {
|
|
let defaultOptions: Partial<EditorOptions> = {
|
|
extensions: [
|
|
StarterKit,
|
|
CharacterCount,
|
|
Placeholder.configure({
|
|
placeholder: "Start writing your note...",
|
|
}),
|
|
],
|
|
};
|
|
|
|
const editor = useEditor({ ...defaultOptions, ...options }, deps);
|
|
|
|
/**
|
|
* Add editor to global for use in React Native.
|
|
*/
|
|
global.editor = editor;
|
|
return editor;
|
|
};
|