@me1a/ui 2.6.3 → 2.6.5
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.
|
@@ -29,8 +29,12 @@ interface MarkdownEditorProps {
|
|
|
29
29
|
* whether to focus the editor on mount
|
|
30
30
|
*/
|
|
31
31
|
autoFocus?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* whether to immediately render the editor
|
|
34
|
+
*/
|
|
35
|
+
immediatelyRender?: boolean;
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
declare function MarkdownEditor({ value, onChange, className, placeholder, disabled, onKeyDown, autoFocus }: MarkdownEditorProps): react_jsx_runtime.JSX.Element | null;
|
|
38
|
+
declare function MarkdownEditor({ value, onChange, className, placeholder, disabled, onKeyDown, autoFocus, immediatelyRender }: MarkdownEditorProps): react_jsx_runtime.JSX.Element | null;
|
|
35
39
|
|
|
36
40
|
export { MarkdownEditor, type MarkdownEditorProps };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useEditor as
|
|
1
|
+
import{useEditor as g,EditorContent as w}from"@tiptap/react";import b from"@tiptap/extension-placeholder";import k from"@tiptap/starter-kit";import{Markdown as x}from"tiptap-markdown";import{useEffect as d}from"react";import{clsx as u}from"clsx";import{twMerge as c}from"tailwind-merge";function n(...o){return c(u(o))}import{jsx as y}from"react/jsx-runtime";function q({value:o,onChange:a,className:f,placeholder:m,disabled:t,onKeyDown:i,autoFocus:p,immediatelyRender:l}){let r=g({extensions:[k,x,b.configure({placeholder:m??"Write something..."})],content:o,editable:!t,autofocus:p,immediatelyRender:l||!1,onUpdate:({editor:s})=>{a?.(s.storage.markdown.getMarkdown())},editorProps:{attributes:{class: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",f)},handleKeyDown:(s,e)=>e.key==="Enter"&&!e.shiftKey?(i?.(e),!0):(i?.(e),!1)}});return d(()=>{r&&o!==void 0&&o!==r.storage.markdown.getMarkdown()&&r.commands.setContent(o)},[o,r]),d(()=>{r?.setEditable(!t)},[r,t]),r?y(w,{editor:r}):null}export{q 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"],"sourcesContent":["import { useEditor, EditorContent } from \"@tiptap/react\"\nimport Placeholder from \"@tiptap/extension-placeholder\"\nimport StarterKit from \"@tiptap/starter-kit\"\nimport { Markdown } from \"tiptap-markdown\"\nimport { useEffect } from \"react\"\nimport { cn } from \"@/utils\"\nimport { MarkdownEditorProps } from \"./markdown-editor.types\"\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 StarterKit,\n Markdown,\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"],"mappings":"AAAA,OAAS,aAAAA,EAAW,iBAAAC,MAAqB,gBACzC,OAAOC,MAAiB,gCACxB,OAAOC,MAAgB,sBACvB,OAAS,YAAAC,MAAgB,kBACzB,OAAS,aAAAC,MAAiB,QCJ1B,OAA0B,QAAAC,MAAY,OACtC,OAAS,WAAAC,MAAe,iBAEjB,SAASC,KAAMC,EAAsB,CAC1C,OAAOF,EAAQD,EAAKG,CAAM,CAAC,CAC7B,
|
|
1
|
+
{"version":3,"sources":["../../src/components/molecules/markdown-editor/markdown-editor.tsx","../../src/utils/cn.ts"],"sourcesContent":["import { useEditor, EditorContent } from \"@tiptap/react\"\nimport Placeholder from \"@tiptap/extension-placeholder\"\nimport StarterKit from \"@tiptap/starter-kit\"\nimport { Markdown } from \"tiptap-markdown\"\nimport { useEffect } from \"react\"\nimport { cn } from \"@/utils\"\nimport { MarkdownEditorProps } from \"./markdown-editor.types\"\n\nexport function MarkdownEditor({\n value,\n onChange,\n className,\n placeholder,\n disabled,\n onKeyDown,\n autoFocus,\n immediatelyRender\n}: MarkdownEditorProps) {\n const editor = useEditor({\n extensions: [\n StarterKit,\n Markdown,\n Placeholder.configure({\n placeholder: placeholder ?? \"Write something...\"\n })\n ],\n content: value,\n editable: !disabled,\n autofocus: autoFocus,\n immediatelyRender: immediatelyRender || false,\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 if (event.key === \"Enter\" && !event.shiftKey) {\n onKeyDown?.(event)\n return true\n }\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"],"mappings":"AAAA,OAAS,aAAAA,EAAW,iBAAAC,MAAqB,gBACzC,OAAOC,MAAiB,gCACxB,OAAOC,MAAgB,sBACvB,OAAS,YAAAC,MAAgB,kBACzB,OAAS,aAAAC,MAAiB,QCJ1B,OAA0B,QAAAC,MAAY,OACtC,OAAS,WAAAC,MAAe,iBAEjB,SAASC,KAAMC,EAAsB,CAC1C,OAAOF,EAAQD,EAAKG,CAAM,CAAC,CAC7B,CD6DS,cAAAC,MAAA,oBA1DF,SAASC,EAAe,CAC7B,MAAAC,EACA,SAAAC,EACA,UAAAC,EACA,YAAAC,EACA,SAAAC,EACA,UAAAC,EACA,UAAAC,EACA,kBAAAC,CACF,EAAwB,CACtB,IAAMC,EAASC,EAAU,CACvB,WAAY,CACVC,EACAC,EACAC,EAAY,UAAU,CACpB,YAAaT,GAAe,oBAC9B,CAAC,CACH,EACA,QAASH,EACT,SAAU,CAACI,EACX,UAAWE,EACX,kBAAmBC,GAAqB,GACxC,SAAU,CAAC,CAAE,OAAQM,CAAE,IAAM,CAC3BZ,IAAYY,EAAE,QAAgB,SAAS,YAAY,CAAC,CACtD,EACA,YAAa,CACX,WAAY,CACV,MAAOC,EACL,+UACAZ,CACF,CACF,EACA,cAAe,CAACa,EAAMC,IAChBA,EAAM,MAAQ,SAAW,CAACA,EAAM,UAClCX,IAAYW,CAAK,EACV,KAETX,IAAYW,CAAK,EACV,GAEX,CACF,CAAC,EAaD,OAVAC,EAAU,IAAM,CACVT,GAAUR,IAAU,QAAaA,IAAWQ,EAAO,QAAgB,SAAS,YAAY,GAC1FA,EAAO,SAAS,WAAWR,CAAK,CAEpC,EAAG,CAACA,EAAOQ,CAAM,CAAC,EAElBS,EAAU,IAAM,CACdT,GAAQ,YAAY,CAACJ,CAAQ,CAC/B,EAAG,CAACI,EAAQJ,CAAQ,CAAC,EAEhBI,EAIEV,EAACoB,EAAA,CAAc,OAAQV,EAAQ,EAH7B,IAIX","names":["useEditor","EditorContent","Placeholder","StarterKit","Markdown","useEffect","clsx","twMerge","cn","inputs","jsx","MarkdownEditor","value","onChange","className","placeholder","disabled","onKeyDown","autoFocus","immediatelyRender","editor","useEditor","StarterKit","Markdown","Placeholder","e","cn","view","event","useEffect","EditorContent"]}
|