@me1a/ui 2.6.0 → 2.6.2
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.
|
@@ -21,8 +21,16 @@ interface MarkdownEditorProps {
|
|
|
21
21
|
* whether the editor is disabled
|
|
22
22
|
*/
|
|
23
23
|
disabled?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* callback when key is pressed
|
|
26
|
+
*/
|
|
27
|
+
onKeyDown?: (event: KeyboardEvent) => void;
|
|
28
|
+
/**
|
|
29
|
+
* whether to focus the editor on mount
|
|
30
|
+
*/
|
|
31
|
+
autoFocus?: boolean;
|
|
24
32
|
}
|
|
25
33
|
|
|
26
|
-
declare function MarkdownEditor({ value, onChange, className, placeholder, disabled }: MarkdownEditorProps): react_jsx_runtime.JSX.Element | null;
|
|
34
|
+
declare function MarkdownEditor({ value, onChange, className, placeholder, disabled, onKeyDown, autoFocus }: MarkdownEditorProps): react_jsx_runtime.JSX.Element | null;
|
|
27
35
|
|
|
28
36
|
export { MarkdownEditor, type MarkdownEditorProps };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useEditor as
|
|
1
|
+
import{useEditor as x,EditorContent as b}from"@tiptap/react";import k from"@tiptap/extension-placeholder";import{useEffect as s}from"react";import{clsx as c}from"clsx";import{twMerge as u}from"tailwind-merge";function t(...r){return u(c(r))}import g from"@tiptap/starter-kit";import{Markdown as w}from"tiptap-markdown";var i=[g.configure({heading:{levels:[1,2,3]}}),w];import{jsx as h}from"react/jsx-runtime";function z({value:r,onChange:d,className:a,placeholder:f,disabled:e,onKeyDown:m,autoFocus:p}){let o=x({extensions:[...i,k.configure({placeholder:f??"Write something..."})],content:r,editable:!e,autofocus:p,onUpdate:({editor:n})=>{d?.(n.storage.markdown.getMarkdown())},editorProps:{attributes:{class:t("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",a)},handleKeyDown:(n,l)=>(m?.(l),!1)}});return s(()=>{o&&r!==void 0&&r!==o.storage.markdown.getMarkdown()&&o.commands.setContent(r)},[r,o]),s(()=>{o?.setEditable(!e)},[o,e]),o?h(b,{editor:o}):null}export{z as MarkdownEditor};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +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,
|
|
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 onKeyDown,\n autoFocus\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 autofocus: autoFocus,\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 handleKeyDown: (view, event) => {\n onKeyDown?.(event)\n return false\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 useEffect(() => {\n editor?.setEditable(!disabled)\n }, [editor, disabled])\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,EFgDS,cAAAE,MAAA,oBAnDF,SAASC,EAAe,CAC7B,MAAAC,EACA,SAAAC,EACA,UAAAC,EACA,YAAAC,EACA,SAAAC,EACA,UAAAC,EACA,UAAAC,CACF,EAAwB,CACtB,IAAMC,EAASC,EAAU,CACvB,WAAY,CACV,GAAGC,EACHC,EAAY,UAAU,CACpB,YAAaP,GAAe,oBAC9B,CAAC,CACH,EACA,QAASH,EACT,SAAU,CAACI,EACX,UAAWE,EACX,SAAU,CAAC,CAAE,OAAQK,CAAE,IAAM,CAC3BV,IAAYU,EAAE,QAAgB,SAAS,YAAY,CAAC,CACtD,EACA,YAAa,CACX,WAAY,CACV,MAAOC,EACL,+UACAV,CACF,CACF,EACA,cAAe,CAACW,EAAMC,KACpBT,IAAYS,CAAK,EACV,GAEX,CACF,CAAC,EAaD,OAVAC,EAAU,IAAM,CACVR,GAAUP,IAAU,QAAaA,IAAWO,EAAO,QAAgB,SAAS,YAAY,GAC1FA,EAAO,SAAS,WAAWP,CAAK,CAEpC,EAAG,CAACA,EAAOO,CAAM,CAAC,EAElBQ,EAAU,IAAM,CACdR,GAAQ,YAAY,CAACH,CAAQ,CAC/B,EAAG,CAACG,EAAQH,CAAQ,CAAC,EAEhBG,EAIET,EAACkB,EAAA,CAAc,OAAQT,EAAQ,EAH7B,IAIX","names":["useEditor","EditorContent","Placeholder","useEffect","clsx","twMerge","cn","inputs","StarterKit","Markdown","extensions","jsx","MarkdownEditor","value","onChange","className","placeholder","disabled","onKeyDown","autoFocus","editor","useEditor","extensions","Placeholder","e","cn","view","event","useEffect","EditorContent"]}
|