@me1a/ui 2.5.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface MarkdownEditorProps {
|
|
4
|
+
/**
|
|
5
|
+
* current value of the editor
|
|
6
|
+
*/
|
|
7
|
+
value?: string;
|
|
8
|
+
/**
|
|
9
|
+
* callback when value changes
|
|
10
|
+
*/
|
|
11
|
+
onChange?: (value: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* additional class name
|
|
14
|
+
*/
|
|
15
|
+
className?: string;
|
|
16
|
+
/**
|
|
17
|
+
* placeholder text
|
|
18
|
+
*/
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
/**
|
|
21
|
+
* whether the editor is disabled
|
|
22
|
+
*/
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare function MarkdownEditor({ value, onChange, className, placeholder, disabled }: MarkdownEditorProps): react_jsx_runtime.JSX.Element | null;
|
|
27
|
+
|
|
28
|
+
export { MarkdownEditor, type MarkdownEditorProps };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useEditor as c,EditorContent as u}from"@tiptap/react";import g from"@tiptap/extension-placeholder";import{useEffect as x}from"react";import{clsx as a}from"clsx";import{twMerge as f}from"tailwind-merge";function e(...o){return f(a(o))}import p from"@tiptap/starter-kit";import{Markdown as l}from"tiptap-markdown";var t=[p.configure({heading:{levels:[1,2,3]}}),l];import{jsx as b}from"react/jsx-runtime";function W({value:o,onChange:n,className:i,placeholder:s,disabled:d}){let r=c({extensions:[...t,g.configure({placeholder:s??"Write something..."})],content:o,editable:!d,onUpdate:({editor:m})=>{n?.(m.storage.markdown.getMarkdown())},editorProps:{attributes:{class:e("prose prose-sm dark:prose-invert max-w-none w-full min-h-[60px] rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",i)}}});return x(()=>{r&&o!==void 0&&o!==r.storage.markdown.getMarkdown()&&r.commands.setContent(o)},[o,r]),r?b(u,{editor:r}):null}export{W as MarkdownEditor};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/molecules/markdown-editor/markdown-editor.tsx","../../src/utils/cn.ts","../../src/components/molecules/markdown-editor/extensions.ts"],"sourcesContent":["import { useEditor, EditorContent } from \"@tiptap/react\"\nimport Placeholder from \"@tiptap/extension-placeholder\"\nimport { useEffect } from \"react\"\nimport { cn } from \"@/utils\"\nimport { MarkdownEditorProps } from \"./markdown-editor.types\"\nimport { extensions } from \"./extensions\"\n\nexport function MarkdownEditor({\n value,\n onChange,\n className,\n placeholder,\n disabled\n}: MarkdownEditorProps) {\n const editor = useEditor({\n extensions: [\n ...extensions,\n Placeholder.configure({\n placeholder: placeholder ?? \"Write something...\"\n })\n ],\n content: value,\n editable: !disabled,\n onUpdate: ({ editor: e }) => {\n onChange?.((e.storage as any).markdown.getMarkdown())\n },\n editorProps: {\n attributes: {\n class: cn(\n \"prose prose-sm dark:prose-invert max-w-none w-full min-h-[60px] rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50\",\n className\n )\n }\n }\n })\n\n // Sync value changes from outside\n useEffect(() => {\n if (editor && value !== undefined && value !== (editor.storage as any).markdown.getMarkdown()) {\n editor.commands.setContent(value)\n }\n }, [value, editor])\n\n if (!editor) {\n return null\n }\n\n return <EditorContent editor={editor} />\n}\n","import { type ClassValue, clsx } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n","import StarterKit from \"@tiptap/starter-kit\"\nimport { Markdown } from \"tiptap-markdown\"\n\nexport const extensions = [\n StarterKit.configure({\n heading: {\n levels: [1, 2, 3]\n }\n }),\n Markdown\n]\n"],"mappings":"AAAA,OAAS,aAAAA,EAAW,iBAAAC,MAAqB,gBACzC,OAAOC,MAAiB,gCACxB,OAAS,aAAAC,MAAiB,QCF1B,OAA0B,QAAAC,MAAY,OACtC,OAAS,WAAAC,MAAe,iBAEjB,SAASC,KAAMC,EAAsB,CAC1C,OAAOF,EAAQD,EAAKG,CAAM,CAAC,CAC7B,CCLA,OAAOC,MAAgB,sBACvB,OAAS,YAAAC,MAAgB,kBAElB,IAAMC,EAAa,CACxBF,EAAW,UAAU,CACnB,QAAS,CACP,OAAQ,CAAC,EAAG,EAAG,CAAC,CAClB,CACF,CAAC,EACDC,CACF,EFqCS,cAAAE,MAAA,oBAxCF,SAASC,EAAe,CAC7B,MAAAC,EACA,SAAAC,EACA,UAAAC,EACA,YAAAC,EACA,SAAAC,CACF,EAAwB,CACtB,IAAMC,EAASC,EAAU,CACvB,WAAY,CACV,GAAGC,EACHC,EAAY,UAAU,CACpB,YAAaL,GAAe,oBAC9B,CAAC,CACH,EACA,QAASH,EACT,SAAU,CAACI,EACX,SAAU,CAAC,CAAE,OAAQK,CAAE,IAAM,CAC3BR,IAAYQ,EAAE,QAAgB,SAAS,YAAY,CAAC,CACtD,EACA,YAAa,CACX,WAAY,CACV,MAAOC,EACL,+UACAR,CACF,CACF,CACF,CACF,CAAC,EASD,OANAS,EAAU,IAAM,CACVN,GAAUL,IAAU,QAAaA,IAAWK,EAAO,QAAgB,SAAS,YAAY,GAC1FA,EAAO,SAAS,WAAWL,CAAK,CAEpC,EAAG,CAACA,EAAOK,CAAM,CAAC,EAEbA,EAIEP,EAACc,EAAA,CAAc,OAAQP,EAAQ,EAH7B,IAIX","names":["useEditor","EditorContent","Placeholder","useEffect","clsx","twMerge","cn","inputs","StarterKit","Markdown","extensions","jsx","MarkdownEditor","value","onChange","className","placeholder","disabled","editor","useEditor","extensions","Placeholder","e","cn","useEffect","EditorContent"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@me1a/ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -165,6 +165,10 @@
|
|
|
165
165
|
"types": "./dist/navigation-menu/index.d.mts",
|
|
166
166
|
"import": "./dist/navigation-menu/index.mjs"
|
|
167
167
|
},
|
|
168
|
+
"./markdown-editor": {
|
|
169
|
+
"types": "./dist/markdown-editor/index.d.mts",
|
|
170
|
+
"import": "./dist/markdown-editor/index.mjs"
|
|
171
|
+
},
|
|
168
172
|
"./card": {
|
|
169
173
|
"types": "./dist/card/index.d.mts",
|
|
170
174
|
"import": "./dist/card/index.mjs"
|
|
@@ -314,13 +318,18 @@
|
|
|
314
318
|
"@radix-ui/react-tabs": "^1.1.12",
|
|
315
319
|
"@radix-ui/react-toast": "^1.2.13",
|
|
316
320
|
"@radix-ui/react-tooltip": "^1.2.6",
|
|
321
|
+
"@tailwindcss/typography": "^0.5.19",
|
|
317
322
|
"@tanstack/react-table": "^8.21.3",
|
|
323
|
+
"@tiptap/extension-placeholder": "^3.19.0",
|
|
324
|
+
"@tiptap/react": "^3.19.0",
|
|
325
|
+
"@tiptap/starter-kit": "^3.19.0",
|
|
318
326
|
"class-variance-authority": "^0.7.1",
|
|
319
327
|
"clsx": "^2.1.1",
|
|
320
328
|
"cmdk": "^1.1.1",
|
|
321
329
|
"lucide-react": "^0.511.0",
|
|
322
330
|
"react-dropzone": "^14.3.8",
|
|
323
331
|
"react-resizable-panels": "^3.0.2",
|
|
332
|
+
"tiptap-markdown": "^0.9.0",
|
|
324
333
|
"vaul": "^1.1.2",
|
|
325
334
|
"vite": "^6.3.5"
|
|
326
335
|
},
|