diff --git a/package.json b/package.json index 7f895bb..83befd3 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,10 @@ "gray-matter": "^4.0.3", "itty-router": "^5.0.17", "lodash.throttle": "^4.1.1", + "markdown-it": "^14.1.0", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-markdown-editor-lite": "^1.3.4", "react-router-dom": "^7.0.2", "tldraw": "^3.6.0", "vercel": "^39.1.1" diff --git a/src/css/style.css b/src/css/style.css index 9902992..f87f64e 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -324,4 +324,13 @@ p:has(+ ol) { box-shadow: 0 0px 16px rgba(0, 0, 0, 0.15); overflow: hidden; background-color: white; +} + +.rc-md-editor { + border: none !important; + font-family: inherit; +} + +.rc-md-editor .editor-container { + border-radius: 4px; } \ No newline at end of file diff --git a/src/shapes/MarkdownShapeUtil.tsx b/src/shapes/MarkdownShapeUtil.tsx index 9e71fbf..aa27c19 100644 --- a/src/shapes/MarkdownShapeUtil.tsx +++ b/src/shapes/MarkdownShapeUtil.tsx @@ -1,11 +1,18 @@ /** TODO: build this */ import { BaseBoxShapeUtil, TLBaseBoxShape, TLBaseShape } from "tldraw" +import MdEditor from "react-markdown-editor-lite" +import MarkdownIt from "markdown-it" +import "react-markdown-editor-lite/lib/index.css" + +// Initialize markdown parser +const mdParser = new MarkdownIt() export type IMarkdownShape = TLBaseShape< "MarkdownTool", { content: string + html: string } > @@ -20,13 +27,58 @@ export class MarkdownShape extends BaseBoxShapeUtil< getDefaultProps(): IMarkdownShape["props"] & { w: number; h: number } { return { - content: "", - w: 100, - h: 100, + content: "# New Note", + html: "