@aivex/ui 1.2.0-dev.29 → 1.2.0-dev.30
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.
- package/dist/comment.cjs +3 -1
- package/dist/comment.cjs.map +1 -1
- package/dist/comment.js +67 -54
- package/dist/comment.js.map +1 -1
- package/dist/components/Comment/CommentInput.d.ts +6 -1
- package/dist/components/ShapeEditor/ShapeEditor.d.ts +1 -1
- package/dist/components/ShapeEditor/_components/Minimap.d.ts +4 -1
- package/dist/components/ShapeEditor/_components/SettingsPanel.d.ts +11 -1
- package/dist/components/ShapeEditor/_model/overlays.d.ts +9 -0
- package/dist/components/ShapeEditor/_model/props.d.ts +7 -0
- package/dist/components/ShapeEditor/_renderers/PixiRenderer.d.ts +1 -1
- package/dist/shape-editor.cjs +1 -1
- package/dist/shape-editor.cjs.map +1 -1
- package/dist/shape-editor.js +1161 -1130
- package/dist/shape-editor.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/comment.cjs
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
"use client";require(`./styles.css`),Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./Button-OQscp8mY.cjs`),t=require(`./IconButton-Cl3T7MUr.cjs`);let n=require(`react/jsx-runtime`),r=require(`react`),i=require(`@tiptap/extension-mention`);i=e.pa(i,1);let a=require(`@tiptap/extension-placeholder`);a=e.pa(a,1);let o=require(`@tiptap/react`),s=require(`@tiptap/starter-kit`);s=e.pa(s,1);let c=require(`tippy.js`);c=e.pa(c,1);var l=(0,r.memo)(function({items:e,command:i,emptyText:a=`No results found.`,ref:o}){let[s,c]=(0,r.useState)(0),l=(0,r.useRef)([]),u=(0,r.useCallback)(t=>{let n=e[t];n&&i(n)},[e,i]),d=(0,r.useCallback)(t=>{c(n=>{let r=e.length;return t===`up`?(n+r-1)%r:(n+1)%r})},[e.length]),f=(0,r.useCallback)(e=>{switch(e.key){case`ArrowUp`:return d(`up`),!0;case`ArrowDown`:return d(`down`),!0;case`Enter`:return u(s),!0;default:return!1}},[d,u,s]);return(0,r.useEffect)(()=>{c(0),l.current=e.map(()=>null)},[e]),(0,r.useEffect)(()=>{l.current[s]?.scrollIntoView({behavior:`smooth`,block:`nearest`})},[s]),(0,r.useImperativeHandle)(o,()=>({onKeyDown:f}),[f]),e.length?(0,n.jsx)(`div`,{className:`aivex:h-full aivex:max-h-[248px] aivex:min-w-[298px] aivex:max-w-[328px] aivex:overflow-y-auto aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:py-2 aivex:shadow-xl`,children:e.map((e,r)=>(0,n.jsxs)(`div`,{ref:e=>{l.current[r]=e},className:`aivex:flex aivex:h-[52px] aivex:cursor-pointer aivex:items-center aivex:gap-2 aivex:px-4 aivex:py-2 ${s===r?`aivex:bg-bg-brand-subtle`:``}`,onClick:()=>u(r),children:[(0,n.jsx)(t.r,{size:`sm`,src:e.avatarUrl,bgColor:e.color,name:e.name}),(0,n.jsxs)(`div`,{className:`aivex:flex aivex:max-w-[260px] aivex:flex-col`,children:[(0,n.jsx)(`div`,{className:`aivex:truncate aivex:text-label-md aivex:text-text-primary`,children:e.name}),e.email?(0,n.jsx)(`div`,{className:`aivex:truncate aivex:text-body-sm-regular aivex:text-text-secondary`,children:e.email}):null]})]},e.id))}):(0,n.jsx)(`div`,{className:`aivex:min-w-[298px] aivex:max-w-[328px] aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:py-2 aivex:shadow-xl`,children:(0,n.jsx)(`div`,{className:`aivex:p-2 aivex:text-body-md-regular aivex:text-text-secondary`,children:a})})}),u=(e,t,n)=>(0,r.useMemo)(()=>{let r=t=>{if(!t)return e;let n=t.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(n)||(e.email??``).toLowerCase().includes(n))},i=e=>t=>{e({id:t.id,label:t.name})};return{items:({query:e})=>r(e),render:()=>{let e=null,r=null;return{onStart:a=>{e=new o.ReactRenderer(l,{props:{...a,emptyText:n,command:i(a.command)},editor:a.editor}),a.clientRect&&(r=(0,c.default)(`body`,{getReferenceClientRect:a.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!0,interactive:!0,trigger:`manual`,placement:`bottom-start`}),t?.(!0))},onUpdate(t){e?.updateProps({...t,emptyText:n,command:i(t.command)}),t.clientRect&&r?.[0]?.setProps({getReferenceClientRect:t.clientRect})},onKeyDown(n){return n.event.key===`Escape`?(r?.[0]&&!r[0].state.isDestroyed&&r[0].hide(),t?.(!1),!0):e?.ref?.onKeyDown(n.event)||!1},onExit(){r?.[0]&&!r[0].state.isDestroyed&&r[0].destroy(),e?.destroy(),r=null,e=null,t?.(!1)}}}}},[e,t,n]);function d({value:e,onChange:t,placeholder:c,onSubmit:l,onEscape:d,userList:p=[],initialContent:m,mentionEmptyText:h,autoFocus:g=!0,handleRef:_}){let v=(0,r.useRef)(null),[y,b]=(0,r.useState)(!1),x=u(p,b,h),S=(0,o.useEditor)({extensions:[s.default,a.default.configure({placeholder:c,emptyEditorClass:`aivex:before:content-[attr(data-placeholder)] aivex:before:text-text-tertiary aivex:before:absolute aivex:before:left-3`}),i.default.configure({HTMLAttributes:{class:`aivex:text-text-brand aivex:px-1`},renderText({node:e}){return`@[${e.attrs.label}](${e.attrs.id})`},deleteTriggerWithBackspace:!0,suggestion:x})],content:m||e,immediatelyRender:!1,editorProps:{attributes:{class:`aivex:px-3 aivex:py-1 aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-secondary aivex:focus:border-border-brand aivex:outline-none aivex:text-body-md-regular aivex:text-text-primary aivex:cursor-text aivex:[&_p]:leading-[22px]`},handleKeyDown:(t,n)=>n.key===`Enter`?y?!1:(n.preventDefault(),e.trim()&&l&&l(),!0):n.key===`Escape`?y?!1:(n.preventDefault(),d?.(),!0):!1},onUpdate:({editor:e})=>{t(f(e.getJSON()))}});return(0,r.useEffect)(()=>{S&&!m&&e!==S.getText()&&S.commands.setContent(e)},[e,S,m]),(0,r.useEffect)(()=>{S&&g&&requestAnimationFrame(()=>{S.commands.focus()})},[S,g]),(0,r.useImperativeHandle)(_,()=>({focus:()=>{S?.commands.focus()}}),[S]),(0,n.jsx)(o.EditorContent,{ref:v,editor:S,className:`aivex:relative aivex:h-full aivex:w-full`,onKeyDown:e=>e.stopPropagation()})}function f(e){if(!e?.content)return``;let t=e=>e.type===`mention`&&e.attrs?`@[${e.attrs.label}](${e.attrs.id})`:e.type===`text`?e.text||``:e.
|
|
1
|
+
"use client";require(`./styles.css`),Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./Button-OQscp8mY.cjs`),t=require(`./IconButton-Cl3T7MUr.cjs`);let n=require(`react/jsx-runtime`),r=require(`react`),i=require(`@tiptap/extension-mention`);i=e.pa(i,1);let a=require(`@tiptap/extension-placeholder`);a=e.pa(a,1);let o=require(`@tiptap/react`),s=require(`@tiptap/starter-kit`);s=e.pa(s,1);let c=require(`tippy.js`);c=e.pa(c,1);var l=(0,r.memo)(function({items:e,command:i,emptyText:a=`No results found.`,ref:o}){let[s,c]=(0,r.useState)(0),l=(0,r.useRef)([]),u=(0,r.useCallback)(t=>{let n=e[t];n&&i(n)},[e,i]),d=(0,r.useCallback)(t=>{c(n=>{let r=e.length;return t===`up`?(n+r-1)%r:(n+1)%r})},[e.length]),f=(0,r.useCallback)(e=>{switch(e.key){case`ArrowUp`:return d(`up`),!0;case`ArrowDown`:return d(`down`),!0;case`Enter`:return u(s),!0;default:return!1}},[d,u,s]);return(0,r.useEffect)(()=>{c(0),l.current=e.map(()=>null)},[e]),(0,r.useEffect)(()=>{l.current[s]?.scrollIntoView({behavior:`smooth`,block:`nearest`})},[s]),(0,r.useImperativeHandle)(o,()=>({onKeyDown:f}),[f]),e.length?(0,n.jsx)(`div`,{className:`aivex:h-full aivex:max-h-[248px] aivex:min-w-[298px] aivex:max-w-[328px] aivex:overflow-y-auto aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:py-2 aivex:shadow-xl`,children:e.map((e,r)=>(0,n.jsxs)(`div`,{ref:e=>{l.current[r]=e},className:`aivex:flex aivex:h-[52px] aivex:cursor-pointer aivex:items-center aivex:gap-2 aivex:px-4 aivex:py-2 ${s===r?`aivex:bg-bg-brand-subtle`:``}`,onClick:()=>u(r),children:[(0,n.jsx)(t.r,{size:`sm`,src:e.avatarUrl,bgColor:e.color,name:e.name}),(0,n.jsxs)(`div`,{className:`aivex:flex aivex:max-w-[260px] aivex:flex-col`,children:[(0,n.jsx)(`div`,{className:`aivex:truncate aivex:text-label-md aivex:text-text-primary`,children:e.name}),e.email?(0,n.jsx)(`div`,{className:`aivex:truncate aivex:text-body-sm-regular aivex:text-text-secondary`,children:e.email}):null]})]},e.id))}):(0,n.jsx)(`div`,{className:`aivex:min-w-[298px] aivex:max-w-[328px] aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:py-2 aivex:shadow-xl`,children:(0,n.jsx)(`div`,{className:`aivex:p-2 aivex:text-body-md-regular aivex:text-text-secondary`,children:a})})}),u=(e,t,n)=>(0,r.useMemo)(()=>{let r=t=>{if(!t)return e;let n=t.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(n)||(e.email??``).toLowerCase().includes(n))},i=e=>t=>{e({id:t.id,label:t.name})};return{items:({query:e})=>r(e),render:()=>{let e=null,r=null;return{onStart:a=>{e=new o.ReactRenderer(l,{props:{...a,emptyText:n,command:i(a.command)},editor:a.editor}),a.clientRect&&(r=(0,c.default)(`body`,{getReferenceClientRect:a.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!0,interactive:!0,trigger:`manual`,placement:`bottom-start`}),t?.(!0))},onUpdate(t){e?.updateProps({...t,emptyText:n,command:i(t.command)}),t.clientRect&&r?.[0]?.setProps({getReferenceClientRect:t.clientRect})},onKeyDown(n){return n.event.key===`Escape`?(r?.[0]&&!r[0].state.isDestroyed&&r[0].hide(),t?.(!1),!0):e?.ref?.onKeyDown(n.event)||!1},onExit(){r?.[0]&&!r[0].state.isDestroyed&&r[0].destroy(),e?.destroy(),r=null,e=null,t?.(!1)}}}}},[e,t,n]);function d({value:e,onChange:t,placeholder:c,onSubmit:l,onEscape:d,userList:p=[],initialContent:m,mentionEmptyText:h,autoFocus:g=!0,handleRef:_}){let v=(0,r.useRef)(null),[y,b]=(0,r.useState)(!1),x=u(p,b,h),S=(0,o.useEditor)({extensions:[s.default,a.default.configure({placeholder:c,emptyEditorClass:`aivex:before:content-[attr(data-placeholder)] aivex:before:text-text-tertiary aivex:before:absolute aivex:before:left-3`}),i.default.configure({HTMLAttributes:{class:`aivex:text-text-brand aivex:px-1`},renderHTML({options:e,node:t}){return[`span`,(0,o.mergeAttributes)(e.HTMLAttributes),`${t.attrs.label}`]},renderText({node:e}){return`@[${e.attrs.label}](${e.attrs.id})`},deleteTriggerWithBackspace:!0,suggestion:x})],content:m||e,immediatelyRender:!1,editorProps:{attributes:{class:`aivex:px-3 aivex:py-1 aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-secondary aivex:focus:border-border-brand aivex:outline-none aivex:text-body-md-regular aivex:text-text-primary aivex:cursor-text aivex:[&_p]:leading-[22px]`},handleKeyDown:(t,n)=>n.key===`Enter`?y||n.shiftKey||n.metaKey||n.ctrlKey||n.altKey?!1:(n.preventDefault(),e.trim()&&l&&l(),!0):n.key===`Escape`?y?!1:(n.preventDefault(),d?.(),!0):!1},onUpdate:({editor:e})=>{t(f(e.getJSON()))}});return(0,r.useEffect)(()=>{S&&!m&&e!==S.getText()&&S.commands.setContent(e)},[e,S,m]),(0,r.useEffect)(()=>{S&&g&&requestAnimationFrame(()=>{S.commands.focus()})},[S,g]),(0,r.useImperativeHandle)(_,()=>({focus:()=>{S?.commands.focus()}}),[S]),(0,n.jsx)(o.EditorContent,{ref:v,editor:S,className:`aivex:relative aivex:h-full aivex:w-full`,onKeyDown:e=>e.stopPropagation()})}function f(e){if(!e?.content)return``;let t=e=>e.type===`mention`&&e.attrs?`@[${e.attrs.label}](${e.attrs.id})`:e.type===`text`?e.text||``:e.type===`hardBreak`?`
|
|
2
|
+
`:e.content?e.content.map(t).join(``):``;return e.content.map(t).join(`
|
|
3
|
+
`)}function p({user:r,value:i,onChange:a,onSubmit:o,onClose:s,title:c=`Comment`,placeholder:l,submitLabel:u=`Send`,showSubmit:f=!0,pending:p=!1,userList:m,mentionEmptyText:h,initialContent:g,className:_}){let v=()=>{!i.trim()||p||o()};return(0,n.jsx)(`div`,{className:`aivex:rounded-2xl aivex:bg-bg-primary aivex:shadow-xl ${_??``}`,children:(0,n.jsxs)(`div`,{className:`aivex:flex aivex:w-[360px] aivex:flex-col`,children:[(0,n.jsxs)(`div`,{className:`aivex:flex aivex:h-12 aivex:items-center aivex:justify-between aivex:border-border-subtle aivex:border-b aivex:px-5 aivex:py-2`,children:[(0,n.jsx)(`span`,{className:`aivex:text-body-lg-medium aivex:text-text-primary`,children:c}),(0,n.jsx)(t.t,{size:`sm`,className:`aivex:text-text-secondary`,onClick:s,children:(0,n.jsx)(e.xt,{size:20})})]}),(0,n.jsxs)(`div`,{className:`aivex:flex aivex:flex-col aivex:px-4 aivex:py-3`,children:[(0,n.jsxs)(`div`,{className:`aivex:flex aivex:gap-1.5`,children:[(0,n.jsx)(`div`,{className:`aivex:h-6 aivex:w-6 aivex:py-1`,children:r?(0,n.jsx)(t.r,{size:`sm`,src:r.avatarUrl,bgColor:r.color,name:r.name}):null}),(0,n.jsx)(`div`,{className:`aivex:min-w-0 aivex:flex-1`,children:(0,n.jsx)(d,{value:i,onChange:a,placeholder:l,onSubmit:v,onEscape:s,userList:m,mentionEmptyText:h,initialContent:g})})]}),f?(0,n.jsx)(`div`,{className:`aivex:grid aivex:transition-[grid-template-rows,opacity] aivex:duration-200 aivex:ease-out ${i.trim()?`aivex:grid-rows-[1fr] aivex:opacity-100`:`aivex:pointer-events-none aivex:grid-rows-[0fr] aivex:opacity-0`}`,children:(0,n.jsx)(`div`,{className:`aivex:flex aivex:justify-end aivex:overflow-hidden aivex:pt-1.5`,children:(0,n.jsx)(e.t,{size:`md`,disabled:!i.trim()||p,onClick:v,tabIndex:i.trim()?void 0:-1,children:u})})}):null]})]})})}function m({users:e,selected:r=!1,resolved:i=!1,onClick:a,maxAvatars:o=3,className:s}){let c=e.slice(0,o);return(0,n.jsxs)(`button`,{type:`button`,onClick:a,className:`aivex:flex aivex:h-fit aivex:cursor-pointer aivex:items-center aivex:rounded-t-full aivex:rounded-br-full aivex:border aivex:p-1 aivex:transition-colors ${r?`aivex:border-border-brand aivex:bg-bg-brand`:`aivex:border-border-subtle aivex:bg-bg-primary aivex:hover:border-border-brand`} ${i?`aivex:opacity-40`:``} ${s??``}`,children:[c.map((e,r)=>(0,n.jsx)(`span`,{className:`aivex:flex`,style:r>0?{marginLeft:`-4px`}:void 0,children:(0,n.jsx)(t.r,{size:`xs`,src:e.avatarUrl,bgColor:e.color,name:e.name})},e.id)),e.length>o?(0,n.jsxs)(`span`,{className:`aivex:px-1 aivex:text-label-sm aivex:text-text-secondary`,children:[`+`,e.length-o]}):null]})}exports.CommentInput=p,exports.CommentPin=m,exports.MentionInput=d;
|
|
2
4
|
//# sourceMappingURL=comment.cjs.map
|
package/dist/comment.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment.cjs","names":[],"sources":["../src/components/Comment/MentionList.tsx","../src/components/Comment/useMentionSuggestion.ts","../src/components/Comment/MentionInput.tsx","../src/components/Comment/CommentInput.tsx","../src/components/Comment/CommentPin.tsx"],"sourcesContent":["\"use client\";\n\nimport { memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from \"react\";\nimport { Avatar } from \"../Avatar\";\nimport type { CommentUser } from \"./types\";\n\nexport interface MentionListHandle {\n onKeyDown: (event: KeyboardEvent) => boolean;\n}\n\ninterface MentionListProps {\n items: CommentUser[];\n command: (item: CommentUser) => void;\n /** 후보 없음 문구(호스트 i18n). 기본 \"No results found.\" */\n emptyText?: string;\n ref?: React.Ref<MentionListHandle>;\n}\n\n/** 멘션(@) 자동완성 목록 — 옵스 에디터 MentionList 이식(도메인 결합 제거). */\nconst MentionList = memo(function MentionList({\n items,\n command,\n emptyText = \"No results found.\",\n ref,\n}: MentionListProps) {\n const [selectedIndex, setSelectedIndex] = useState(0);\n const itemRefs = useRef<(HTMLDivElement | null)[]>([]);\n\n const selectItem = useCallback(\n (index: number) => {\n const item = items[index];\n if (item) command(item);\n },\n [items, command],\n );\n\n const moveSelection = useCallback(\n (direction: \"up\" | \"down\") => {\n setSelectedIndex((prev) => {\n const itemCount = items.length;\n if (direction === \"up\") return (prev + itemCount - 1) % itemCount;\n return (prev + 1) % itemCount;\n });\n },\n [items.length],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent): boolean => {\n switch (event.key) {\n case \"ArrowUp\":\n moveSelection(\"up\");\n return true;\n case \"ArrowDown\":\n moveSelection(\"down\");\n return true;\n case \"Enter\":\n selectItem(selectedIndex);\n return true;\n default:\n return false;\n }\n },\n [moveSelection, selectItem, selectedIndex],\n );\n\n useEffect(() => {\n setSelectedIndex(0);\n itemRefs.current = items.map(() => null);\n }, [items]);\n\n useEffect(() => {\n itemRefs.current[selectedIndex]?.scrollIntoView({ behavior: \"smooth\", block: \"nearest\" });\n }, [selectedIndex]);\n\n useImperativeHandle(ref, () => ({ onKeyDown: handleKeyDown }), [handleKeyDown]);\n\n if (!items.length) {\n return (\n <div className=\"aivex:min-w-[298px] aivex:max-w-[328px] aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:py-2 aivex:shadow-xl\">\n <div className=\"aivex:p-2 aivex:text-body-md-regular aivex:text-text-secondary\">\n {emptyText}\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"aivex:h-full aivex:max-h-[248px] aivex:min-w-[298px] aivex:max-w-[328px] aivex:overflow-y-auto aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:py-2 aivex:shadow-xl\">\n {items.map((item, index) => (\n // 키보드 상호작용은 tiptap 에디터가 MentionListHandle로 위임 처리한다.\n <div\n key={item.id}\n ref={(el) => {\n itemRefs.current[index] = el;\n }}\n className={`aivex:flex aivex:h-[52px] aivex:cursor-pointer aivex:items-center aivex:gap-2 aivex:px-4 aivex:py-2 ${\n selectedIndex === index ? \"aivex:bg-bg-brand-subtle\" : \"\"\n }`}\n onClick={() => selectItem(index)}\n >\n <Avatar size=\"sm\" src={item.avatarUrl} bgColor={item.color} name={item.name} />\n <div className=\"aivex:flex aivex:max-w-[260px] aivex:flex-col\">\n <div className=\"aivex:truncate aivex:text-label-md aivex:text-text-primary\">\n {item.name}\n </div>\n {item.email ? (\n <div className=\"aivex:truncate aivex:text-body-sm-regular aivex:text-text-secondary\">\n {item.email}\n </div>\n ) : null}\n </div>\n </div>\n ))}\n </div>\n );\n});\n\nexport default MentionList;\n","\"use client\";\n\nimport { ReactRenderer } from \"@tiptap/react\";\nimport { useMemo } from \"react\";\nimport tippy, { type Instance as TippyInstance } from \"tippy.js\";\nimport MentionList, { type MentionListHandle } from \"./MentionList\";\nimport type { CommentUser } from \"./types\";\n\n/** tiptap Mention 확장에 꽂는 자동완성 설정 — 옵스 에디터 이식(CommentUser 기반). */\nexport const useMentionSuggestion = (\n userList: CommentUser[],\n onOpenChange?: (isOpen: boolean) => void,\n emptyText?: string,\n) => {\n return useMemo(() => {\n const filterUsers = (query: string) => {\n if (!query) return userList;\n const q = query.toLowerCase();\n return userList.filter(\n (user) =>\n user.name.toLowerCase().includes(q) || (user.email ?? \"\").toLowerCase().includes(q),\n );\n };\n\n const createCommandHandler =\n (originalCommand: (item: { id: string; label: string }) => void) => (item: CommentUser) => {\n originalCommand({ id: item.id, label: item.name });\n };\n\n const createRenderer = () => {\n let component: ReactRenderer<MentionListHandle> | null = null;\n let popup: TippyInstance[] | null = null;\n\n return {\n // biome-ignore lint/suspicious/noExplicitAny: tiptap suggestion props는 확장별 동적 형태라 상위 타입이 없다\n onStart: (props: Record<string, any>) => {\n component = new ReactRenderer(MentionList, {\n props: {\n ...props,\n emptyText,\n command: createCommandHandler(props.command),\n },\n editor: props.editor,\n });\n\n if (!props.clientRect) return;\n\n popup = tippy(\"body\", {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: true,\n interactive: true,\n trigger: \"manual\",\n placement: \"bottom-start\",\n });\n\n onOpenChange?.(true);\n },\n\n // biome-ignore lint/suspicious/noExplicitAny: tiptap suggestion props는 확장별 동적 형태라 상위 타입이 없다\n onUpdate(props: Record<string, any>) {\n component?.updateProps({\n ...props,\n emptyText,\n command: createCommandHandler(props.command),\n });\n\n if (!props.clientRect) return;\n\n popup?.[0]?.setProps({ getReferenceClientRect: props.clientRect });\n },\n\n onKeyDown(props: { event: KeyboardEvent }) {\n if (props.event.key === \"Escape\") {\n if (popup?.[0] && !popup[0].state.isDestroyed) popup[0].hide();\n onOpenChange?.(false);\n return true;\n }\n return component?.ref?.onKeyDown(props.event) || false;\n },\n\n onExit() {\n if (popup?.[0] && !popup[0].state.isDestroyed) popup[0].destroy();\n component?.destroy();\n popup = null;\n component = null;\n onOpenChange?.(false);\n },\n };\n };\n\n return {\n items: ({ query }: { query: string }) => filterUsers(query),\n render: createRenderer,\n };\n }, [userList, onOpenChange, emptyText]);\n};\n","\"use client\";\n\nimport Mention from \"@tiptap/extension-mention\";\nimport Placeholder from \"@tiptap/extension-placeholder\";\nimport { EditorContent, type JSONContent, useEditor } from \"@tiptap/react\";\nimport StarterKit from \"@tiptap/starter-kit\";\nimport { type Ref, useEffect, useImperativeHandle, useRef, useState } from \"react\";\nimport type { CommentUser } from \"./types\";\nimport { useMentionSuggestion } from \"./useMentionSuggestion\";\n\nexport interface MentionInputHandle {\n /** 입력기에 포커스를 준다(예: 전송 버튼 클릭 후 포커스 유지). */\n focus: () => void;\n}\n\nexport interface MentionInputProps {\n value: string;\n onChange: (value: string) => void;\n placeholder?: string;\n /** Enter(멘션 목록 닫힌 상태) 제출. */\n onSubmit?: () => void;\n /** Esc(멘션 목록 닫힌 상태) 취소. */\n onEscape?: () => void;\n /** 멘션(@) 후보. 빈 배열이면 멘션 없이 플레인 입력처럼 동작한다. */\n userList?: CommentUser[];\n initialContent?: JSONContent;\n /** 멘션 후보 없음 문구(호스트 i18n). */\n mentionEmptyText?: string;\n /** 마운트 시 자동 포커스(기본 true). */\n autoFocus?: boolean;\n /** 명령형 핸들(포커스 제어). */\n handleRef?: Ref<MentionInputHandle>;\n}\n\n/**\n * 멘션(@) 지원 코멘트 입력기 — 옵스 에디터 MentionInput 이식.\n * value는 평문 직렬화(`@[이름](id)`)로 주고받는다.\n */\nexport default function MentionInput({\n value,\n onChange,\n placeholder,\n onSubmit,\n onEscape,\n userList = [],\n initialContent,\n mentionEmptyText,\n autoFocus = true,\n handleRef,\n}: MentionInputProps) {\n const editorRef = useRef<HTMLDivElement>(null);\n const [isMentionListOpen, setIsMentionListOpen] = useState(false);\n const suggestion = useMentionSuggestion(userList, setIsMentionListOpen, mentionEmptyText);\n\n const editor = useEditor({\n extensions: [\n StarterKit,\n Placeholder.configure({\n placeholder,\n emptyEditorClass:\n \"aivex:before:content-[attr(data-placeholder)] aivex:before:text-text-tertiary aivex:before:absolute aivex:before:left-3\",\n }),\n Mention.configure({\n HTMLAttributes: { class: \"aivex:text-text-brand aivex:px-1\" },\n renderText({ node }) {\n return `@[${node.attrs.label}](${node.attrs.id})`;\n },\n deleteTriggerWithBackspace: true,\n suggestion,\n }),\n ],\n content: initialContent || value,\n // SSR 환경(next 등)에서 hydration 불일치 방지.\n immediatelyRender: false,\n editorProps: {\n attributes: {\n // 줄높이 22(내부 p에 강제) + py 8 + 보더 2 = 32px — 옆의 Send 버튼(h-8)과 높이 일치.\n class:\n \"aivex:px-3 aivex:py-1 aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-secondary aivex:focus:border-border-brand aivex:outline-none aivex:text-body-md-regular aivex:text-text-primary aivex:cursor-text aivex:[&_p]:leading-[22px]\",\n },\n handleKeyDown: (_view, event) => {\n if (event.key === \"Enter\") {\n if (isMentionListOpen) return false;\n event.preventDefault();\n if (value.trim() && onSubmit) onSubmit();\n return true;\n }\n if (event.key === \"Escape\") {\n if (isMentionListOpen) return false;\n event.preventDefault();\n onEscape?.();\n return true;\n }\n return false;\n },\n },\n onUpdate: ({ editor }) => {\n onChange(extractContentFromJSON(editor.getJSON()));\n },\n });\n\n useEffect(() => {\n if (editor && !initialContent && value !== editor.getText()) {\n editor.commands.setContent(value);\n }\n }, [value, editor, initialContent]);\n\n useEffect(() => {\n if (editor && autoFocus) {\n requestAnimationFrame(() => {\n editor.commands.focus();\n });\n }\n }, [editor, autoFocus]);\n\n useImperativeHandle(\n handleRef,\n () => ({\n focus: () => {\n editor?.commands.focus();\n },\n }),\n [editor],\n );\n\n return (\n <EditorContent\n ref={editorRef}\n editor={editor}\n className=\"aivex:relative aivex:h-full aivex:w-full\"\n onKeyDown={(e) => e.stopPropagation()}\n />\n );\n}\n\n/** tiptap 문서 → 평문(멘션은 `@[이름](id)`) 직렬화. */\nfunction extractContentFromJSON(json: JSONContent): string {\n if (!json?.content) return \"\";\n\n const processNode = (node: JSONContent): string => {\n if (node.type === \"mention\" && node.attrs) {\n return `@[${node.attrs.label}](${node.attrs.id})`;\n }\n if (node.type === \"text\") return node.text || \"\";\n if (node.content) return node.content.map(processNode).join(\"\");\n return \"\";\n };\n return json.content.map(processNode).join(\"\");\n}\n","\"use client\";\n\nimport type { JSONContent } from \"@tiptap/react\";\nimport { Avatar } from \"../Avatar\";\nimport { Button } from \"../Button\";\nimport { CloseIcon } from \"../Icon\";\nimport { IconButton } from \"../IconButton\";\nimport MentionInput from \"./MentionInput\";\nimport type { CommentUser } from \"./types\";\n\nexport interface CommentInputProps {\n /** 작성자(입력행 아바타). */\n user?: CommentUser;\n value: string;\n onChange: (value: string) => void;\n /** 전송(Enter 또는 Send 버튼). 값이 비어 있으면 호출되지 않는다. */\n onSubmit: () => void;\n /** 헤더 닫기 버튼·Esc. */\n onClose?: () => void;\n /** 헤더 타이틀(호스트 i18n). 기본 \"Comment\". */\n title?: string;\n placeholder?: string;\n /** 전송 버튼 라벨(호스트 i18n). 기본 \"Send\". */\n submitLabel?: string;\n /** 전송 중 여부 — 버튼 비활성(스피너 등은 호스트가 submitLabel 자리로). */\n pending?: boolean;\n /** 멘션(@) 후보. 생략하면 멘션 없이 동작. */\n userList?: CommentUser[];\n mentionEmptyText?: string;\n initialContent?: JSONContent;\n className?: string;\n}\n\n/**\n * 새 코멘트 입력 패널 — 옵스 new-editor의 NewCommentPanel 이식(도메인/위치 결합 제거).\n * 코멘트 스레드와 동일한 크롬: 헤더(타이틀+닫기) + 입력행(아바타 · 멘션 입력 · 오른쪽\n * Send 버튼). 화면 배치(핀 오른쪽 등)는 호스트가 감싸는 컨테이너에서 담당한다.\n */\nexport function CommentInput({\n user,\n value,\n onChange,\n onSubmit,\n onClose,\n title = \"Comment\",\n placeholder,\n submitLabel = \"Send\",\n pending = false,\n userList,\n mentionEmptyText,\n initialContent,\n className,\n}: CommentInputProps) {\n const handleSubmit = () => {\n if (!value.trim() || pending) return;\n onSubmit();\n };\n\n return (\n <div className={`aivex:rounded-2xl aivex:bg-bg-primary aivex:shadow-xl ${className ?? \"\"}`}>\n <div className=\"aivex:flex aivex:w-[360px] aivex:flex-col\">\n <div className=\"aivex:flex aivex:h-12 aivex:items-center aivex:justify-between aivex:border-border-subtle aivex:border-b aivex:px-5 aivex:py-2\">\n <span className=\"aivex:text-body-lg-medium aivex:text-text-primary\">{title}</span>\n <IconButton size=\"sm\" className=\"aivex:text-text-secondary\" onClick={onClose}>\n <CloseIcon size={20} />\n </IconButton>\n </div>\n <div className=\"aivex:flex aivex:gap-1.5 aivex:px-4 aivex:py-3\">\n <div className=\"aivex:h-6 aivex:w-6 aivex:py-1\">\n {user ? (\n <Avatar size=\"sm\" src={user.avatarUrl} bgColor={user.color} name={user.name} />\n ) : null}\n </div>\n <div className=\"aivex:flex aivex:w-full aivex:items-end aivex:gap-1.5\">\n <div className=\"aivex:min-w-0 aivex:flex-1\">\n <MentionInput\n value={value}\n onChange={onChange}\n placeholder={placeholder}\n onSubmit={handleSubmit}\n onEscape={onClose}\n userList={userList}\n mentionEmptyText={mentionEmptyText}\n initialContent={initialContent}\n />\n </div>\n <Button\n size=\"md\"\n className=\"aivex:w-[70px] aivex:shrink-0\"\n disabled={!value.trim() || pending}\n onClick={handleSubmit}\n >\n {submitLabel}\n </Button>\n </div>\n </div>\n </div>\n </div>\n );\n}\n","\"use client\";\n\nimport { Avatar } from \"../Avatar\";\nimport type { CommentUser } from \"./types\";\n\nexport interface CommentPinProps {\n /** 스레드 참여자(작성자 우선). 최대 maxAvatars명까지 아바타를 겹쳐 그린다. */\n users: CommentUser[];\n selected?: boolean;\n /** 해결(resolve)된 코멘트 — 반투명 표시. */\n resolved?: boolean;\n onClick?: () => void;\n maxAvatars?: number;\n className?: string;\n}\n\n/**\n * 코멘트 핀(다트) — 옵스 에디터 CommentDart의 말풍선 부분 이식.\n * 좌하단이 뾰족한 말풍선(팁이 코멘트 지점을 가리킴). 위치·스케일 고정은 호스트가\n * ShapeEditor overlayMarkers(anchor \"topLeft\") 등으로 담당한다.\n */\nexport function CommentPin({\n users,\n selected = false,\n resolved = false,\n onClick,\n maxAvatars = 3,\n className,\n}: CommentPinProps) {\n const shown = users.slice(0, maxAvatars);\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className={`aivex:flex aivex:h-fit aivex:cursor-pointer aivex:items-center aivex:rounded-t-full aivex:rounded-br-full aivex:border aivex:p-1 aivex:transition-colors ${\n selected\n ? \"aivex:border-border-brand aivex:bg-bg-brand\"\n : \"aivex:border-border-subtle aivex:bg-bg-primary aivex:hover:border-border-brand\"\n } ${resolved ? \"aivex:opacity-40\" : \"\"} ${className ?? \"\"}`}\n >\n {shown.map((user, i) => (\n <span\n key={user.id}\n className=\"aivex:flex\"\n style={i > 0 ? { marginLeft: \"-4px\" } : undefined}\n >\n <Avatar size=\"xs\" src={user.avatarUrl} bgColor={user.color} name={user.name} />\n </span>\n ))}\n {users.length > maxAvatars ? (\n <span className=\"aivex:px-1 aivex:text-label-sm aivex:text-text-secondary\">\n +{users.length - maxAvatars}\n </span>\n ) : null}\n </button>\n );\n}\n"],"mappings":"kdA0BE,GAAM,EAAA,EAAA,MAAA,SAAgD,CAAA,QAAA,UAAA,YAAA,oBAAA,OAAA,CAEtD,GAAM,CAAA,EAAA,IACH,EAAA,EAAA,UAAkB,EAAA,CACjB,GAAa,EAAM,EAAA,QAAA,EAAA,CAAA,CACf,GAAc,EAAA,EAAK,aAAA,GAAA,KAExB,EAAO,EACT,GAED,GAAM,EAAA,EAAA,EAEF,CAAA,EAAA,EAAkB,CAAA,CAChB,GAAkB,EAAM,EAAA,aAAA,GAAA,CACxB,EAAI,GAAoB,CACxB,IAAA,EAAe,EAAK,cACpB,IAAA,MAAA,EAAA,EAAA,GAAA,GAEG,EAAO,GACf,GAED,EAEI,CAAA,EAAQ,OAAM,CAAA,CACZ,GAAK,EAAA,EAAA,aAAA,GAAA,CACH,OAAA,EAAA,IAAA,CACA,IAAA,UAEA,OADF,EAAK,KAAA,CACH,GACA,IAAA,YAEA,OADF,EAAK,OAAA,CACH,GACA,IAAA,eACF,EACE,EAAO,YAGb,MAAA,KAAgB,CAAY,EAAc,EAG5C,EACE,CAAA,QACA,EAAA,EAAS,eAAgB,GAChB,EAAA,CAEX,EAAA,QAAA,EAAA,QAAgB,KAAA,EACd,CAAA,EAAS,CAAA,IAAyC,EAAA,eAAU,GAAiB,QAAA,IAAA,eAAA,CAAW,SAAC,eACvF,UAEJ,CAAA,EAEA,CAAI,EACF,CAAA,EACO,EAAA,EAAA,qBAAU,OAAA,CAAA,UAAA,EAAA,EAAA,CAAA,EAAA,CAAA,GACb,QASU,EAAA,EAEV,KAAA,MAAA,WAEQ,yMACJ,SAAA,EAAS,KAAQ,EAAA,KAAS,EAAA,EAAA,MAAA,MAAA,SAE5B,EAAA,QAAW,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KAAC,MAAA,WACQ,uCACG,EAAA,EAAA,KAAA,EAAA,CACG,QACb,WACA,cACU,SAAA,EACQ,SAAA,EACF,WAChB,mBACE,iBAEJ,CAAA,CACA,CAAA,EAAU,EAAA,EAAA,KAAA,EAAA,EAAA,CACV,KAAA,KACA,UAAS,yCAER,CAAA,EAAA,MAAA,EAAA,EACM,QACL,WACF,EACF,CAAA,CAAA,IACF,CAAA,CAAA,KCnER,SACE,EAAA,CAAA,QAAA,WAAA,GAAA,WAAC,GAAD,UAAA,aAAA,EAAA,aAAA,KACE,EAAK,EAAA,MAAA,EAAA,EAAA,QACI,EAAA,EAAA,MAAA,SAAA,CACT,KAAA,6BASI,4JAAU,EAAA,8CAAA,iFAAA,GAAA,EAAA,mBAAA,GAAA,GAAA,GAAA,cACH,CAAA,EAAQ,KAAE,EAAA,KAAuB,EAAA,EAAA,KAAA,OAAA,WAExC,mBAAa,EAAA,EAAA,CAAA,WAAA,OAAA,CAAA,IAAA,aAAe,EAAA,EAAA,KAAA,EAAA,EAAA,CAAW,KAAA,KAAqB,IAAA,EAAM,UAAa,QAAA,EAAA,MAC1E,KALK,EAMZ,KAEM,CAAA,OAAN,CAA2E,CAAA,EACvE,OAAM,GACH,EAAA,EAAA,MAAA,OAAA,WAEF"}
|
|
1
|
+
{"version":3,"file":"comment.cjs","names":[],"sources":["../src/components/Comment/MentionList.tsx","../src/components/Comment/useMentionSuggestion.ts","../src/components/Comment/MentionInput.tsx","../src/components/Comment/CommentInput.tsx","../src/components/Comment/CommentPin.tsx"],"sourcesContent":["\"use client\";\n\nimport { memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from \"react\";\nimport { Avatar } from \"../Avatar\";\nimport type { CommentUser } from \"./types\";\n\nexport interface MentionListHandle {\n onKeyDown: (event: KeyboardEvent) => boolean;\n}\n\ninterface MentionListProps {\n items: CommentUser[];\n command: (item: CommentUser) => void;\n /** 후보 없음 문구(호스트 i18n). 기본 \"No results found.\" */\n emptyText?: string;\n ref?: React.Ref<MentionListHandle>;\n}\n\n/** 멘션(@) 자동완성 목록 — 옵스 에디터 MentionList 이식(도메인 결합 제거). */\nconst MentionList = memo(function MentionList({\n items,\n command,\n emptyText = \"No results found.\",\n ref,\n}: MentionListProps) {\n const [selectedIndex, setSelectedIndex] = useState(0);\n const itemRefs = useRef<(HTMLDivElement | null)[]>([]);\n\n const selectItem = useCallback(\n (index: number) => {\n const item = items[index];\n if (item) command(item);\n },\n [items, command],\n );\n\n const moveSelection = useCallback(\n (direction: \"up\" | \"down\") => {\n setSelectedIndex((prev) => {\n const itemCount = items.length;\n if (direction === \"up\") return (prev + itemCount - 1) % itemCount;\n return (prev + 1) % itemCount;\n });\n },\n [items.length],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent): boolean => {\n switch (event.key) {\n case \"ArrowUp\":\n moveSelection(\"up\");\n return true;\n case \"ArrowDown\":\n moveSelection(\"down\");\n return true;\n case \"Enter\":\n selectItem(selectedIndex);\n return true;\n default:\n return false;\n }\n },\n [moveSelection, selectItem, selectedIndex],\n );\n\n useEffect(() => {\n setSelectedIndex(0);\n itemRefs.current = items.map(() => null);\n }, [items]);\n\n useEffect(() => {\n itemRefs.current[selectedIndex]?.scrollIntoView({ behavior: \"smooth\", block: \"nearest\" });\n }, [selectedIndex]);\n\n useImperativeHandle(ref, () => ({ onKeyDown: handleKeyDown }), [handleKeyDown]);\n\n if (!items.length) {\n return (\n <div className=\"aivex:min-w-[298px] aivex:max-w-[328px] aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:py-2 aivex:shadow-xl\">\n <div className=\"aivex:p-2 aivex:text-body-md-regular aivex:text-text-secondary\">\n {emptyText}\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"aivex:h-full aivex:max-h-[248px] aivex:min-w-[298px] aivex:max-w-[328px] aivex:overflow-y-auto aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:py-2 aivex:shadow-xl\">\n {items.map((item, index) => (\n // 키보드 상호작용은 tiptap 에디터가 MentionListHandle로 위임 처리한다.\n <div\n key={item.id}\n ref={(el) => {\n itemRefs.current[index] = el;\n }}\n className={`aivex:flex aivex:h-[52px] aivex:cursor-pointer aivex:items-center aivex:gap-2 aivex:px-4 aivex:py-2 ${\n selectedIndex === index ? \"aivex:bg-bg-brand-subtle\" : \"\"\n }`}\n onClick={() => selectItem(index)}\n >\n <Avatar size=\"sm\" src={item.avatarUrl} bgColor={item.color} name={item.name} />\n <div className=\"aivex:flex aivex:max-w-[260px] aivex:flex-col\">\n <div className=\"aivex:truncate aivex:text-label-md aivex:text-text-primary\">\n {item.name}\n </div>\n {item.email ? (\n <div className=\"aivex:truncate aivex:text-body-sm-regular aivex:text-text-secondary\">\n {item.email}\n </div>\n ) : null}\n </div>\n </div>\n ))}\n </div>\n );\n});\n\nexport default MentionList;\n","\"use client\";\n\nimport { ReactRenderer } from \"@tiptap/react\";\nimport { useMemo } from \"react\";\nimport tippy, { type Instance as TippyInstance } from \"tippy.js\";\nimport MentionList, { type MentionListHandle } from \"./MentionList\";\nimport type { CommentUser } from \"./types\";\n\n/** tiptap Mention 확장에 꽂는 자동완성 설정 — 옵스 에디터 이식(CommentUser 기반). */\nexport const useMentionSuggestion = (\n userList: CommentUser[],\n onOpenChange?: (isOpen: boolean) => void,\n emptyText?: string,\n) => {\n return useMemo(() => {\n const filterUsers = (query: string) => {\n if (!query) return userList;\n const q = query.toLowerCase();\n return userList.filter(\n (user) =>\n user.name.toLowerCase().includes(q) || (user.email ?? \"\").toLowerCase().includes(q),\n );\n };\n\n const createCommandHandler =\n (originalCommand: (item: { id: string; label: string }) => void) => (item: CommentUser) => {\n originalCommand({ id: item.id, label: item.name });\n };\n\n const createRenderer = () => {\n let component: ReactRenderer<MentionListHandle> | null = null;\n let popup: TippyInstance[] | null = null;\n\n return {\n // biome-ignore lint/suspicious/noExplicitAny: tiptap suggestion props는 확장별 동적 형태라 상위 타입이 없다\n onStart: (props: Record<string, any>) => {\n component = new ReactRenderer(MentionList, {\n props: {\n ...props,\n emptyText,\n command: createCommandHandler(props.command),\n },\n editor: props.editor,\n });\n\n if (!props.clientRect) return;\n\n popup = tippy(\"body\", {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: true,\n interactive: true,\n trigger: \"manual\",\n placement: \"bottom-start\",\n });\n\n onOpenChange?.(true);\n },\n\n // biome-ignore lint/suspicious/noExplicitAny: tiptap suggestion props는 확장별 동적 형태라 상위 타입이 없다\n onUpdate(props: Record<string, any>) {\n component?.updateProps({\n ...props,\n emptyText,\n command: createCommandHandler(props.command),\n });\n\n if (!props.clientRect) return;\n\n popup?.[0]?.setProps({ getReferenceClientRect: props.clientRect });\n },\n\n onKeyDown(props: { event: KeyboardEvent }) {\n if (props.event.key === \"Escape\") {\n if (popup?.[0] && !popup[0].state.isDestroyed) popup[0].hide();\n onOpenChange?.(false);\n return true;\n }\n return component?.ref?.onKeyDown(props.event) || false;\n },\n\n onExit() {\n if (popup?.[0] && !popup[0].state.isDestroyed) popup[0].destroy();\n component?.destroy();\n popup = null;\n component = null;\n onOpenChange?.(false);\n },\n };\n };\n\n return {\n items: ({ query }: { query: string }) => filterUsers(query),\n render: createRenderer,\n };\n }, [userList, onOpenChange, emptyText]);\n};\n","\"use client\";\n\nimport Mention from \"@tiptap/extension-mention\";\nimport Placeholder from \"@tiptap/extension-placeholder\";\nimport { EditorContent, type JSONContent, mergeAttributes, useEditor } from \"@tiptap/react\";\nimport StarterKit from \"@tiptap/starter-kit\";\nimport { type Ref, useEffect, useImperativeHandle, useRef, useState } from \"react\";\nimport type { CommentUser } from \"./types\";\nimport { useMentionSuggestion } from \"./useMentionSuggestion\";\n\nexport interface MentionInputHandle {\n /** 입력기에 포커스를 준다(예: 전송 버튼 클릭 후 포커스 유지). */\n focus: () => void;\n}\n\nexport interface MentionInputProps {\n value: string;\n onChange: (value: string) => void;\n placeholder?: string;\n /** Enter(멘션 목록 닫힌 상태) 제출. */\n onSubmit?: () => void;\n /** Esc(멘션 목록 닫힌 상태) 취소. */\n onEscape?: () => void;\n /** 멘션(@) 후보. 빈 배열이면 멘션 없이 플레인 입력처럼 동작한다. */\n userList?: CommentUser[];\n initialContent?: JSONContent;\n /** 멘션 후보 없음 문구(호스트 i18n). */\n mentionEmptyText?: string;\n /** 마운트 시 자동 포커스(기본 true). */\n autoFocus?: boolean;\n /** 명령형 핸들(포커스 제어). */\n handleRef?: Ref<MentionInputHandle>;\n}\n\n/**\n * 멘션(@) 지원 코멘트 입력기 — 옵스 에디터 MentionInput 이식.\n * value는 평문 직렬화(`@[이름](id)`)로 주고받는다.\n */\nexport default function MentionInput({\n value,\n onChange,\n placeholder,\n onSubmit,\n onEscape,\n userList = [],\n initialContent,\n mentionEmptyText,\n autoFocus = true,\n handleRef,\n}: MentionInputProps) {\n const editorRef = useRef<HTMLDivElement>(null);\n const [isMentionListOpen, setIsMentionListOpen] = useState(false);\n const suggestion = useMentionSuggestion(userList, setIsMentionListOpen, mentionEmptyText);\n\n const editor = useEditor({\n extensions: [\n StarterKit,\n Placeholder.configure({\n placeholder,\n emptyEditorClass:\n \"aivex:before:content-[attr(data-placeholder)] aivex:before:text-text-tertiary aivex:before:absolute aivex:before:left-3\",\n }),\n Mention.configure({\n HTMLAttributes: { class: \"aivex:text-text-brand aivex:px-1\" },\n // 멘션이 확정되면 골뱅이는 사라지고 이름만 남는다(시안) — 확정 전\n // 타이핑 중인 \"@검색어\"는 그대로다. 직렬화 형식은 바뀌지 않는다.\n renderHTML({ options, node }) {\n return [\"span\", mergeAttributes(options.HTMLAttributes), `${node.attrs.label}`];\n },\n renderText({ node }) {\n return `@[${node.attrs.label}](${node.attrs.id})`;\n },\n deleteTriggerWithBackspace: true,\n suggestion,\n }),\n ],\n content: initialContent || value,\n // SSR 환경(next 등)에서 hydration 불일치 방지.\n immediatelyRender: false,\n editorProps: {\n attributes: {\n // 줄높이 22(내부 p에 강제) + py 8 + 보더 2 = 32px — 옆의 Send 버튼(h-8)과 높이 일치.\n class:\n \"aivex:px-3 aivex:py-1 aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-secondary aivex:focus:border-border-brand aivex:outline-none aivex:text-body-md-regular aivex:text-text-primary aivex:cursor-text aivex:[&_p]:leading-[22px]\",\n },\n handleKeyDown: (_view, event) => {\n if (event.key === \"Enter\") {\n if (isMentionListOpen) return false;\n // 보조키를 짚은 Enter는 전송이 아니라 개행 — tiptap 기본 동작에 맡긴다.\n if (event.shiftKey || event.metaKey || event.ctrlKey || event.altKey) {\n return false;\n }\n event.preventDefault();\n if (value.trim() && onSubmit) onSubmit();\n return true;\n }\n if (event.key === \"Escape\") {\n if (isMentionListOpen) return false;\n event.preventDefault();\n onEscape?.();\n return true;\n }\n return false;\n },\n },\n onUpdate: ({ editor }) => {\n onChange(extractContentFromJSON(editor.getJSON()));\n },\n });\n\n useEffect(() => {\n if (editor && !initialContent && value !== editor.getText()) {\n editor.commands.setContent(value);\n }\n }, [value, editor, initialContent]);\n\n useEffect(() => {\n if (editor && autoFocus) {\n requestAnimationFrame(() => {\n editor.commands.focus();\n });\n }\n }, [editor, autoFocus]);\n\n useImperativeHandle(\n handleRef,\n () => ({\n focus: () => {\n editor?.commands.focus();\n },\n }),\n [editor],\n );\n\n return (\n <EditorContent\n ref={editorRef}\n editor={editor}\n className=\"aivex:relative aivex:h-full aivex:w-full\"\n onKeyDown={(e) => e.stopPropagation()}\n />\n );\n}\n\n/** tiptap 문서 → 평문(멘션은 `@[이름](id)`, 줄바꿈은 \\n) 직렬화. */\nfunction extractContentFromJSON(json: JSONContent): string {\n if (!json?.content) return \"\";\n\n const processNode = (node: JSONContent): string => {\n if (node.type === \"mention\" && node.attrs) {\n return `@[${node.attrs.label}](${node.attrs.id})`;\n }\n if (node.type === \"text\") return node.text || \"\";\n // Shift+Enter가 넣는 줄바꿈 — 문단 분리(아래 join)와 같은 값으로 편다.\n if (node.type === \"hardBreak\") return \"\\n\";\n if (node.content) return node.content.map(processNode).join(\"\");\n return \"\";\n };\n // 문단마다 한 줄 — 보조키+Enter로 문단이 갈리면 그대로 줄이 나뉜다.\n return json.content.map(processNode).join(\"\\n\");\n}\n","\"use client\";\n\nimport type { JSONContent } from \"@tiptap/react\";\nimport { Avatar } from \"../Avatar\";\nimport { Button } from \"../Button\";\nimport { CloseIcon } from \"../Icon\";\nimport { IconButton } from \"../IconButton\";\nimport MentionInput from \"./MentionInput\";\nimport type { CommentUser } from \"./types\";\n\nexport interface CommentInputProps {\n /** 작성자(입력행 아바타). */\n user?: CommentUser;\n value: string;\n onChange: (value: string) => void;\n /** 전송(Enter 또는 Send 버튼). 값이 비어 있으면 호출되지 않는다. */\n onSubmit: () => void;\n /** 헤더 닫기 버튼·Esc. */\n onClose?: () => void;\n /** 헤더 타이틀(호스트 i18n). 기본 \"Comment\". */\n title?: string;\n placeholder?: string;\n /** 전송 버튼 라벨(호스트 i18n). 기본 \"Send\". */\n submitLabel?: string;\n /**\n * 전송 버튼 사용 — 켜면 내용이 있을 때만 입력 아래 오른쪽에 나타난다(시안).\n * 끄면 어느 상태에서도 없이 Enter로만 보낸다.\n */\n showSubmit?: boolean;\n /** 전송 중 여부 — 버튼 비활성(스피너 등은 호스트가 submitLabel 자리로). */\n pending?: boolean;\n /** 멘션(@) 후보. 생략하면 멘션 없이 동작. */\n userList?: CommentUser[];\n mentionEmptyText?: string;\n initialContent?: JSONContent;\n className?: string;\n}\n\n/**\n * 새 코멘트 입력 패널 — 옵스 new-editor의 NewCommentPanel 이식(도메인/위치 결합 제거).\n * 코멘트 스레드와 동일한 크롬: 헤더(타이틀+닫기) + 입력행(아바타 · 멘션 입력 · 오른쪽\n * Send 버튼). 화면 배치(핀 오른쪽 등)는 호스트가 감싸는 컨테이너에서 담당한다.\n */\nexport function CommentInput({\n user,\n value,\n onChange,\n onSubmit,\n onClose,\n title = \"Comment\",\n placeholder,\n submitLabel = \"Send\",\n showSubmit = true,\n pending = false,\n userList,\n mentionEmptyText,\n initialContent,\n className,\n}: CommentInputProps) {\n const handleSubmit = () => {\n if (!value.trim() || pending) return;\n onSubmit();\n };\n\n return (\n <div className={`aivex:rounded-2xl aivex:bg-bg-primary aivex:shadow-xl ${className ?? \"\"}`}>\n <div className=\"aivex:flex aivex:w-[360px] aivex:flex-col\">\n <div className=\"aivex:flex aivex:h-12 aivex:items-center aivex:justify-between aivex:border-border-subtle aivex:border-b aivex:px-5 aivex:py-2\">\n <span className=\"aivex:text-body-lg-medium aivex:text-text-primary\">{title}</span>\n <IconButton size=\"sm\" className=\"aivex:text-text-secondary\" onClick={onClose}>\n <CloseIcon size={20} />\n </IconButton>\n </div>\n <div className=\"aivex:flex aivex:flex-col aivex:px-4 aivex:py-3\">\n <div className=\"aivex:flex aivex:gap-1.5\">\n <div className=\"aivex:h-6 aivex:w-6 aivex:py-1\">\n {user ? (\n <Avatar size=\"sm\" src={user.avatarUrl} bgColor={user.color} name={user.name} />\n ) : null}\n </div>\n <div className=\"aivex:min-w-0 aivex:flex-1\">\n <MentionInput\n value={value}\n onChange={onChange}\n placeholder={placeholder}\n onSubmit={handleSubmit}\n onEscape={onClose}\n userList={userList}\n mentionEmptyText={mentionEmptyText}\n initialContent={initialContent}\n />\n </div>\n </div>\n {/* 전송 버튼은 빈 입력에서는 없다 — 내용이 생기면 아래로 밀려 나온다(시안).\n grid-rows 0fr↔1fr은 높이를 모르는 내용도 부드럽게 여닫는다. */}\n {showSubmit ? (\n <div\n className={`aivex:grid aivex:transition-[grid-template-rows,opacity] aivex:duration-200 aivex:ease-out ${\n value.trim()\n ? \"aivex:grid-rows-[1fr] aivex:opacity-100\"\n : \"aivex:pointer-events-none aivex:grid-rows-[0fr] aivex:opacity-0\"\n }`}\n >\n {/* 입력과 버튼 사이 6px(시안) — 접히는 안쪽에 둬야 함께 사라진다. */}\n <div className=\"aivex:flex aivex:justify-end aivex:overflow-hidden aivex:pt-1.5\">\n <Button\n size=\"md\"\n disabled={!value.trim() || pending}\n onClick={handleSubmit}\n tabIndex={value.trim() ? undefined : -1}\n >\n {submitLabel}\n </Button>\n </div>\n </div>\n ) : null}\n </div>\n </div>\n </div>\n );\n}\n","\"use client\";\n\nimport { Avatar } from \"../Avatar\";\nimport type { CommentUser } from \"./types\";\n\nexport interface CommentPinProps {\n /** 스레드 참여자(작성자 우선). 최대 maxAvatars명까지 아바타를 겹쳐 그린다. */\n users: CommentUser[];\n selected?: boolean;\n /** 해결(resolve)된 코멘트 — 반투명 표시. */\n resolved?: boolean;\n onClick?: () => void;\n maxAvatars?: number;\n className?: string;\n}\n\n/**\n * 코멘트 핀(다트) — 옵스 에디터 CommentDart의 말풍선 부분 이식.\n * 좌하단이 뾰족한 말풍선(팁이 코멘트 지점을 가리킴). 위치·스케일 고정은 호스트가\n * ShapeEditor overlayMarkers(anchor \"topLeft\") 등으로 담당한다.\n */\nexport function CommentPin({\n users,\n selected = false,\n resolved = false,\n onClick,\n maxAvatars = 3,\n className,\n}: CommentPinProps) {\n const shown = users.slice(0, maxAvatars);\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className={`aivex:flex aivex:h-fit aivex:cursor-pointer aivex:items-center aivex:rounded-t-full aivex:rounded-br-full aivex:border aivex:p-1 aivex:transition-colors ${\n selected\n ? \"aivex:border-border-brand aivex:bg-bg-brand\"\n : \"aivex:border-border-subtle aivex:bg-bg-primary aivex:hover:border-border-brand\"\n } ${resolved ? \"aivex:opacity-40\" : \"\"} ${className ?? \"\"}`}\n >\n {shown.map((user, i) => (\n <span\n key={user.id}\n className=\"aivex:flex\"\n style={i > 0 ? { marginLeft: \"-4px\" } : undefined}\n >\n <Avatar size=\"xs\" src={user.avatarUrl} bgColor={user.color} name={user.name} />\n </span>\n ))}\n {users.length > maxAvatars ? (\n <span className=\"aivex:px-1 aivex:text-label-sm aivex:text-text-secondary\">\n +{users.length - maxAvatars}\n </span>\n ) : null}\n </button>\n );\n}\n"],"mappings":"kdA0BE,GAAM,EAAA,EAAA,MAAA,SAAgD,CAAA,QAAA,UAAA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EACQ,SAAA,EACF,WAChB,mBACE,kBAIP,CAEG,CAAA,CAAA,MAOA,EAAA,EAAC,KAAA,MAAD,WAAK,8FAAU,EAAA,MAAA,CAAA,0CAAA,8EACb,EAAA,EAAA,KAAA,MAAC,WACM,4EACkB,EAAI,EAAA,KAAA,EAAA,EAAA,CAC3B,KAAA,KACA,SAAU,CAAA,EAAM,MAAM,EAAG,YAGlB,SAAA,EAAA,MAAA,CAAA,IAAA,GAAA,GACL,SAAA,EACF,CAAA,CAGN,CAAA,SACF,CAAA,CAAA,KCxFR,SACE,EAAA,CAAA,QAAA,WAAA,GAAA,WAAC,GAAD,UAAA,aAAA,EAAA,aAAA,KACE,EAAK,EAAA,MAAA,EAAA,EAAA,QACI,EAAA,EAAA,MAAA,SAAA,CACT,KAAA,6BASI,4JAAU,EAAA,8CAAA,iFAAA,GAAA,EAAA,mBAAA,GAAA,GAAA,GAAA,cACH,CAAA,EAAQ,KAAE,EAAA,KAAuB,EAAA,EAAA,KAAA,OAAA,WAExC,mBAAa,EAAA,EAAA,CAAA,WAAA,OAAA,CAAA,IAAA,aAAe,EAAA,EAAA,KAAA,EAAA,EAAA,CAAW,KAAA,KAAqB,IAAA,EAAM,UAAa,QAAA,EAAA,MAC1E,KALK,EAMZ,KAEM,CAAA,OAAN,CAA2E,CAAA,EACvE,OAAM,GACH,EAAA,EAAA,MAAA,OAAA,WAEF"}
|
package/dist/comment.js
CHANGED
|
@@ -6,11 +6,11 @@ import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
|
6
6
|
import { memo as o, useCallback as s, useEffect as c, useImperativeHandle as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
7
7
|
import p from "@tiptap/extension-mention";
|
|
8
8
|
import m from "@tiptap/extension-placeholder";
|
|
9
|
-
import { EditorContent as h, ReactRenderer as g,
|
|
10
|
-
import
|
|
11
|
-
import
|
|
9
|
+
import { EditorContent as h, ReactRenderer as g, mergeAttributes as _, useEditor as v } from "@tiptap/react";
|
|
10
|
+
import y from "@tiptap/starter-kit";
|
|
11
|
+
import b from "tippy.js";
|
|
12
12
|
//#region src/components/Comment/MentionList.tsx
|
|
13
|
-
var
|
|
13
|
+
var x = o(function({ items: e, command: t, emptyText: r = "No results found.", ref: o }) {
|
|
14
14
|
let [u, p] = f(0), m = d([]), h = s((n) => {
|
|
15
15
|
let r = e[n];
|
|
16
16
|
r && t(r);
|
|
@@ -69,7 +69,7 @@ var b = o(function({ items: e, command: t, emptyText: r = "No results found.", r
|
|
|
69
69
|
children: r
|
|
70
70
|
})
|
|
71
71
|
});
|
|
72
|
-
}),
|
|
72
|
+
}), S = (e, t, n) => u(() => {
|
|
73
73
|
let r = (t) => {
|
|
74
74
|
if (!t) return e;
|
|
75
75
|
let n = t.toLowerCase();
|
|
@@ -86,14 +86,14 @@ var b = o(function({ items: e, command: t, emptyText: r = "No results found.", r
|
|
|
86
86
|
let e = null, r = null;
|
|
87
87
|
return {
|
|
88
88
|
onStart: (a) => {
|
|
89
|
-
e = new g(
|
|
89
|
+
e = new g(x, {
|
|
90
90
|
props: {
|
|
91
91
|
...a,
|
|
92
92
|
emptyText: n,
|
|
93
93
|
command: i(a.command)
|
|
94
94
|
},
|
|
95
95
|
editor: a.editor
|
|
96
|
-
}), a.clientRect && (r =
|
|
96
|
+
}), a.clientRect && (r = b("body", {
|
|
97
97
|
getReferenceClientRect: a.clientRect,
|
|
98
98
|
appendTo: () => document.body,
|
|
99
99
|
content: e.element,
|
|
@@ -126,65 +126,72 @@ var b = o(function({ items: e, command: t, emptyText: r = "No results found.", r
|
|
|
126
126
|
]);
|
|
127
127
|
//#endregion
|
|
128
128
|
//#region src/components/Comment/MentionInput.tsx
|
|
129
|
-
function
|
|
130
|
-
let
|
|
129
|
+
function C({ value: e, onChange: t, placeholder: n, onSubmit: r, onEscape: a, userList: o = [], initialContent: s, mentionEmptyText: u, autoFocus: g = !0, handleRef: b }) {
|
|
130
|
+
let x = d(null), [C, T] = f(!1), E = S(o, T, u), D = v({
|
|
131
131
|
extensions: [
|
|
132
|
-
|
|
132
|
+
y,
|
|
133
133
|
m.configure({
|
|
134
134
|
placeholder: n,
|
|
135
135
|
emptyEditorClass: "aivex:before:content-[attr(data-placeholder)] aivex:before:text-text-tertiary aivex:before:absolute aivex:before:left-3"
|
|
136
136
|
}),
|
|
137
137
|
p.configure({
|
|
138
138
|
HTMLAttributes: { class: "aivex:text-text-brand aivex:px-1" },
|
|
139
|
+
renderHTML({ options: e, node: t }) {
|
|
140
|
+
return [
|
|
141
|
+
"span",
|
|
142
|
+
_(e.HTMLAttributes),
|
|
143
|
+
`${t.attrs.label}`
|
|
144
|
+
];
|
|
145
|
+
},
|
|
139
146
|
renderText({ node: e }) {
|
|
140
147
|
return `@[${e.attrs.label}](${e.attrs.id})`;
|
|
141
148
|
},
|
|
142
149
|
deleteTriggerWithBackspace: !0,
|
|
143
|
-
suggestion:
|
|
150
|
+
suggestion: E
|
|
144
151
|
})
|
|
145
152
|
],
|
|
146
153
|
content: s || e,
|
|
147
154
|
immediatelyRender: !1,
|
|
148
155
|
editorProps: {
|
|
149
156
|
attributes: { class: "aivex:px-3 aivex:py-1 aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-secondary aivex:focus:border-border-brand aivex:outline-none aivex:text-body-md-regular aivex:text-text-primary aivex:cursor-text aivex:[&_p]:leading-[22px]" },
|
|
150
|
-
handleKeyDown: (t, n) => n.key === "Enter" ?
|
|
157
|
+
handleKeyDown: (t, n) => n.key === "Enter" ? C || n.shiftKey || n.metaKey || n.ctrlKey || n.altKey ? !1 : (n.preventDefault(), e.trim() && r && r(), !0) : n.key === "Escape" ? C ? !1 : (n.preventDefault(), a?.(), !0) : !1
|
|
151
158
|
},
|
|
152
159
|
onUpdate: ({ editor: e }) => {
|
|
153
|
-
t(
|
|
160
|
+
t(w(e.getJSON()));
|
|
154
161
|
}
|
|
155
162
|
});
|
|
156
163
|
return c(() => {
|
|
157
|
-
|
|
164
|
+
D && !s && e !== D.getText() && D.commands.setContent(e);
|
|
158
165
|
}, [
|
|
159
166
|
e,
|
|
160
|
-
|
|
167
|
+
D,
|
|
161
168
|
s
|
|
162
169
|
]), c(() => {
|
|
163
|
-
|
|
164
|
-
|
|
170
|
+
D && g && requestAnimationFrame(() => {
|
|
171
|
+
D.commands.focus();
|
|
165
172
|
});
|
|
166
|
-
}, [
|
|
167
|
-
|
|
168
|
-
} }), [
|
|
169
|
-
ref:
|
|
170
|
-
editor:
|
|
173
|
+
}, [D, g]), l(b, () => ({ focus: () => {
|
|
174
|
+
D?.commands.focus();
|
|
175
|
+
} }), [D]), /* @__PURE__ */ i(h, {
|
|
176
|
+
ref: x,
|
|
177
|
+
editor: D,
|
|
171
178
|
className: "aivex:relative aivex:h-full aivex:w-full",
|
|
172
179
|
onKeyDown: (e) => e.stopPropagation()
|
|
173
180
|
});
|
|
174
181
|
}
|
|
175
|
-
function
|
|
182
|
+
function w(e) {
|
|
176
183
|
if (!e?.content) return "";
|
|
177
|
-
let t = (e) => e.type === "mention" && e.attrs ? `@[${e.attrs.label}](${e.attrs.id})` : e.type === "text" ? e.text || "" : e.content ? e.content.map(t).join("") : "";
|
|
178
|
-
return e.content.map(t).join("");
|
|
184
|
+
let t = (e) => e.type === "mention" && e.attrs ? `@[${e.attrs.label}](${e.attrs.id})` : e.type === "text" ? e.text || "" : e.type === "hardBreak" ? "\n" : e.content ? e.content.map(t).join("") : "";
|
|
185
|
+
return e.content.map(t).join("\n");
|
|
179
186
|
}
|
|
180
187
|
//#endregion
|
|
181
188
|
//#region src/components/Comment/CommentInput.tsx
|
|
182
|
-
function
|
|
183
|
-
let
|
|
184
|
-
!s.trim() ||
|
|
189
|
+
function T({ user: o, value: s, onChange: c, onSubmit: l, onClose: u, title: d = "Comment", placeholder: f, submitLabel: p = "Send", showSubmit: m = !0, pending: h = !1, userList: g, mentionEmptyText: _, initialContent: v, className: y }) {
|
|
190
|
+
let b = () => {
|
|
191
|
+
!s.trim() || h || l();
|
|
185
192
|
};
|
|
186
193
|
return /* @__PURE__ */ i("div", {
|
|
187
|
-
className: `aivex:rounded-2xl aivex:bg-bg-primary aivex:shadow-xl ${
|
|
194
|
+
className: `aivex:rounded-2xl aivex:bg-bg-primary aivex:shadow-xl ${y ?? ""}`,
|
|
188
195
|
children: /* @__PURE__ */ a("div", {
|
|
189
196
|
className: "aivex:flex aivex:w-[360px] aivex:flex-col",
|
|
190
197
|
children: [/* @__PURE__ */ a("div", {
|
|
@@ -199,44 +206,50 @@ function w({ user: o, value: s, onChange: c, onSubmit: l, onClose: u, title: d =
|
|
|
199
206
|
children: /* @__PURE__ */ i(t, { size: 20 })
|
|
200
207
|
})]
|
|
201
208
|
}), /* @__PURE__ */ a("div", {
|
|
202
|
-
className: "aivex:flex aivex:
|
|
203
|
-
children: [/* @__PURE__ */
|
|
204
|
-
className: "aivex:
|
|
205
|
-
children: o ? /* @__PURE__ */ i(n, {
|
|
206
|
-
size: "sm",
|
|
207
|
-
src: o.avatarUrl,
|
|
208
|
-
bgColor: o.color,
|
|
209
|
-
name: o.name
|
|
210
|
-
}) : null
|
|
211
|
-
}), /* @__PURE__ */ a("div", {
|
|
212
|
-
className: "aivex:flex aivex:w-full aivex:items-end aivex:gap-1.5",
|
|
209
|
+
className: "aivex:flex aivex:flex-col aivex:px-4 aivex:py-3",
|
|
210
|
+
children: [/* @__PURE__ */ a("div", {
|
|
211
|
+
className: "aivex:flex aivex:gap-1.5",
|
|
213
212
|
children: [/* @__PURE__ */ i("div", {
|
|
213
|
+
className: "aivex:h-6 aivex:w-6 aivex:py-1",
|
|
214
|
+
children: o ? /* @__PURE__ */ i(n, {
|
|
215
|
+
size: "sm",
|
|
216
|
+
src: o.avatarUrl,
|
|
217
|
+
bgColor: o.color,
|
|
218
|
+
name: o.name
|
|
219
|
+
}) : null
|
|
220
|
+
}), /* @__PURE__ */ i("div", {
|
|
214
221
|
className: "aivex:min-w-0 aivex:flex-1",
|
|
215
|
-
children: /* @__PURE__ */ i(
|
|
222
|
+
children: /* @__PURE__ */ i(C, {
|
|
216
223
|
value: s,
|
|
217
224
|
onChange: c,
|
|
218
225
|
placeholder: f,
|
|
219
|
-
onSubmit:
|
|
226
|
+
onSubmit: b,
|
|
220
227
|
onEscape: u,
|
|
221
|
-
userList:
|
|
222
|
-
mentionEmptyText:
|
|
223
|
-
initialContent:
|
|
228
|
+
userList: g,
|
|
229
|
+
mentionEmptyText: _,
|
|
230
|
+
initialContent: v
|
|
224
231
|
})
|
|
225
|
-
}), /* @__PURE__ */ i(e, {
|
|
226
|
-
size: "md",
|
|
227
|
-
className: "aivex:w-[70px] aivex:shrink-0",
|
|
228
|
-
disabled: !s.trim() || m,
|
|
229
|
-
onClick: y,
|
|
230
|
-
children: p
|
|
231
232
|
})]
|
|
232
|
-
})
|
|
233
|
+
}), m ? /* @__PURE__ */ i("div", {
|
|
234
|
+
className: `aivex:grid aivex:transition-[grid-template-rows,opacity] aivex:duration-200 aivex:ease-out ${s.trim() ? "aivex:grid-rows-[1fr] aivex:opacity-100" : "aivex:pointer-events-none aivex:grid-rows-[0fr] aivex:opacity-0"}`,
|
|
235
|
+
children: /* @__PURE__ */ i("div", {
|
|
236
|
+
className: "aivex:flex aivex:justify-end aivex:overflow-hidden aivex:pt-1.5",
|
|
237
|
+
children: /* @__PURE__ */ i(e, {
|
|
238
|
+
size: "md",
|
|
239
|
+
disabled: !s.trim() || h,
|
|
240
|
+
onClick: b,
|
|
241
|
+
tabIndex: s.trim() ? void 0 : -1,
|
|
242
|
+
children: p
|
|
243
|
+
})
|
|
244
|
+
})
|
|
245
|
+
}) : null]
|
|
233
246
|
})]
|
|
234
247
|
})
|
|
235
248
|
});
|
|
236
249
|
}
|
|
237
250
|
//#endregion
|
|
238
251
|
//#region src/components/Comment/CommentPin.tsx
|
|
239
|
-
function
|
|
252
|
+
function E({ users: e, selected: t = !1, resolved: r = !1, onClick: o, maxAvatars: s = 3, className: c }) {
|
|
240
253
|
let l = e.slice(0, s);
|
|
241
254
|
return /* @__PURE__ */ a("button", {
|
|
242
255
|
type: "button",
|
|
@@ -258,6 +271,6 @@ function T({ users: e, selected: t = !1, resolved: r = !1, onClick: o, maxAvatar
|
|
|
258
271
|
});
|
|
259
272
|
}
|
|
260
273
|
//#endregion
|
|
261
|
-
export {
|
|
274
|
+
export { T as CommentInput, E as CommentPin, C as MentionInput };
|
|
262
275
|
|
|
263
276
|
//# sourceMappingURL=comment.js.map
|
package/dist/comment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment.js","names":[],"sources":["../src/components/Comment/MentionList.tsx","../src/components/Comment/useMentionSuggestion.ts","../src/components/Comment/MentionInput.tsx","../src/components/Comment/CommentInput.tsx","../src/components/Comment/CommentPin.tsx"],"sourcesContent":["\"use client\";\n\nimport { memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from \"react\";\nimport { Avatar } from \"../Avatar\";\nimport type { CommentUser } from \"./types\";\n\nexport interface MentionListHandle {\n onKeyDown: (event: KeyboardEvent) => boolean;\n}\n\ninterface MentionListProps {\n items: CommentUser[];\n command: (item: CommentUser) => void;\n /** 후보 없음 문구(호스트 i18n). 기본 \"No results found.\" */\n emptyText?: string;\n ref?: React.Ref<MentionListHandle>;\n}\n\n/** 멘션(@) 자동완성 목록 — 옵스 에디터 MentionList 이식(도메인 결합 제거). */\nconst MentionList = memo(function MentionList({\n items,\n command,\n emptyText = \"No results found.\",\n ref,\n}: MentionListProps) {\n const [selectedIndex, setSelectedIndex] = useState(0);\n const itemRefs = useRef<(HTMLDivElement | null)[]>([]);\n\n const selectItem = useCallback(\n (index: number) => {\n const item = items[index];\n if (item) command(item);\n },\n [items, command],\n );\n\n const moveSelection = useCallback(\n (direction: \"up\" | \"down\") => {\n setSelectedIndex((prev) => {\n const itemCount = items.length;\n if (direction === \"up\") return (prev + itemCount - 1) % itemCount;\n return (prev + 1) % itemCount;\n });\n },\n [items.length],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent): boolean => {\n switch (event.key) {\n case \"ArrowUp\":\n moveSelection(\"up\");\n return true;\n case \"ArrowDown\":\n moveSelection(\"down\");\n return true;\n case \"Enter\":\n selectItem(selectedIndex);\n return true;\n default:\n return false;\n }\n },\n [moveSelection, selectItem, selectedIndex],\n );\n\n useEffect(() => {\n setSelectedIndex(0);\n itemRefs.current = items.map(() => null);\n }, [items]);\n\n useEffect(() => {\n itemRefs.current[selectedIndex]?.scrollIntoView({ behavior: \"smooth\", block: \"nearest\" });\n }, [selectedIndex]);\n\n useImperativeHandle(ref, () => ({ onKeyDown: handleKeyDown }), [handleKeyDown]);\n\n if (!items.length) {\n return (\n <div className=\"aivex:min-w-[298px] aivex:max-w-[328px] aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:py-2 aivex:shadow-xl\">\n <div className=\"aivex:p-2 aivex:text-body-md-regular aivex:text-text-secondary\">\n {emptyText}\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"aivex:h-full aivex:max-h-[248px] aivex:min-w-[298px] aivex:max-w-[328px] aivex:overflow-y-auto aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:py-2 aivex:shadow-xl\">\n {items.map((item, index) => (\n // 키보드 상호작용은 tiptap 에디터가 MentionListHandle로 위임 처리한다.\n <div\n key={item.id}\n ref={(el) => {\n itemRefs.current[index] = el;\n }}\n className={`aivex:flex aivex:h-[52px] aivex:cursor-pointer aivex:items-center aivex:gap-2 aivex:px-4 aivex:py-2 ${\n selectedIndex === index ? \"aivex:bg-bg-brand-subtle\" : \"\"\n }`}\n onClick={() => selectItem(index)}\n >\n <Avatar size=\"sm\" src={item.avatarUrl} bgColor={item.color} name={item.name} />\n <div className=\"aivex:flex aivex:max-w-[260px] aivex:flex-col\">\n <div className=\"aivex:truncate aivex:text-label-md aivex:text-text-primary\">\n {item.name}\n </div>\n {item.email ? (\n <div className=\"aivex:truncate aivex:text-body-sm-regular aivex:text-text-secondary\">\n {item.email}\n </div>\n ) : null}\n </div>\n </div>\n ))}\n </div>\n );\n});\n\nexport default MentionList;\n","\"use client\";\n\nimport { ReactRenderer } from \"@tiptap/react\";\nimport { useMemo } from \"react\";\nimport tippy, { type Instance as TippyInstance } from \"tippy.js\";\nimport MentionList, { type MentionListHandle } from \"./MentionList\";\nimport type { CommentUser } from \"./types\";\n\n/** tiptap Mention 확장에 꽂는 자동완성 설정 — 옵스 에디터 이식(CommentUser 기반). */\nexport const useMentionSuggestion = (\n userList: CommentUser[],\n onOpenChange?: (isOpen: boolean) => void,\n emptyText?: string,\n) => {\n return useMemo(() => {\n const filterUsers = (query: string) => {\n if (!query) return userList;\n const q = query.toLowerCase();\n return userList.filter(\n (user) =>\n user.name.toLowerCase().includes(q) || (user.email ?? \"\").toLowerCase().includes(q),\n );\n };\n\n const createCommandHandler =\n (originalCommand: (item: { id: string; label: string }) => void) => (item: CommentUser) => {\n originalCommand({ id: item.id, label: item.name });\n };\n\n const createRenderer = () => {\n let component: ReactRenderer<MentionListHandle> | null = null;\n let popup: TippyInstance[] | null = null;\n\n return {\n // biome-ignore lint/suspicious/noExplicitAny: tiptap suggestion props는 확장별 동적 형태라 상위 타입이 없다\n onStart: (props: Record<string, any>) => {\n component = new ReactRenderer(MentionList, {\n props: {\n ...props,\n emptyText,\n command: createCommandHandler(props.command),\n },\n editor: props.editor,\n });\n\n if (!props.clientRect) return;\n\n popup = tippy(\"body\", {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: true,\n interactive: true,\n trigger: \"manual\",\n placement: \"bottom-start\",\n });\n\n onOpenChange?.(true);\n },\n\n // biome-ignore lint/suspicious/noExplicitAny: tiptap suggestion props는 확장별 동적 형태라 상위 타입이 없다\n onUpdate(props: Record<string, any>) {\n component?.updateProps({\n ...props,\n emptyText,\n command: createCommandHandler(props.command),\n });\n\n if (!props.clientRect) return;\n\n popup?.[0]?.setProps({ getReferenceClientRect: props.clientRect });\n },\n\n onKeyDown(props: { event: KeyboardEvent }) {\n if (props.event.key === \"Escape\") {\n if (popup?.[0] && !popup[0].state.isDestroyed) popup[0].hide();\n onOpenChange?.(false);\n return true;\n }\n return component?.ref?.onKeyDown(props.event) || false;\n },\n\n onExit() {\n if (popup?.[0] && !popup[0].state.isDestroyed) popup[0].destroy();\n component?.destroy();\n popup = null;\n component = null;\n onOpenChange?.(false);\n },\n };\n };\n\n return {\n items: ({ query }: { query: string }) => filterUsers(query),\n render: createRenderer,\n };\n }, [userList, onOpenChange, emptyText]);\n};\n","\"use client\";\n\nimport Mention from \"@tiptap/extension-mention\";\nimport Placeholder from \"@tiptap/extension-placeholder\";\nimport { EditorContent, type JSONContent, useEditor } from \"@tiptap/react\";\nimport StarterKit from \"@tiptap/starter-kit\";\nimport { type Ref, useEffect, useImperativeHandle, useRef, useState } from \"react\";\nimport type { CommentUser } from \"./types\";\nimport { useMentionSuggestion } from \"./useMentionSuggestion\";\n\nexport interface MentionInputHandle {\n /** 입력기에 포커스를 준다(예: 전송 버튼 클릭 후 포커스 유지). */\n focus: () => void;\n}\n\nexport interface MentionInputProps {\n value: string;\n onChange: (value: string) => void;\n placeholder?: string;\n /** Enter(멘션 목록 닫힌 상태) 제출. */\n onSubmit?: () => void;\n /** Esc(멘션 목록 닫힌 상태) 취소. */\n onEscape?: () => void;\n /** 멘션(@) 후보. 빈 배열이면 멘션 없이 플레인 입력처럼 동작한다. */\n userList?: CommentUser[];\n initialContent?: JSONContent;\n /** 멘션 후보 없음 문구(호스트 i18n). */\n mentionEmptyText?: string;\n /** 마운트 시 자동 포커스(기본 true). */\n autoFocus?: boolean;\n /** 명령형 핸들(포커스 제어). */\n handleRef?: Ref<MentionInputHandle>;\n}\n\n/**\n * 멘션(@) 지원 코멘트 입력기 — 옵스 에디터 MentionInput 이식.\n * value는 평문 직렬화(`@[이름](id)`)로 주고받는다.\n */\nexport default function MentionInput({\n value,\n onChange,\n placeholder,\n onSubmit,\n onEscape,\n userList = [],\n initialContent,\n mentionEmptyText,\n autoFocus = true,\n handleRef,\n}: MentionInputProps) {\n const editorRef = useRef<HTMLDivElement>(null);\n const [isMentionListOpen, setIsMentionListOpen] = useState(false);\n const suggestion = useMentionSuggestion(userList, setIsMentionListOpen, mentionEmptyText);\n\n const editor = useEditor({\n extensions: [\n StarterKit,\n Placeholder.configure({\n placeholder,\n emptyEditorClass:\n \"aivex:before:content-[attr(data-placeholder)] aivex:before:text-text-tertiary aivex:before:absolute aivex:before:left-3\",\n }),\n Mention.configure({\n HTMLAttributes: { class: \"aivex:text-text-brand aivex:px-1\" },\n renderText({ node }) {\n return `@[${node.attrs.label}](${node.attrs.id})`;\n },\n deleteTriggerWithBackspace: true,\n suggestion,\n }),\n ],\n content: initialContent || value,\n // SSR 환경(next 등)에서 hydration 불일치 방지.\n immediatelyRender: false,\n editorProps: {\n attributes: {\n // 줄높이 22(내부 p에 강제) + py 8 + 보더 2 = 32px — 옆의 Send 버튼(h-8)과 높이 일치.\n class:\n \"aivex:px-3 aivex:py-1 aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-secondary aivex:focus:border-border-brand aivex:outline-none aivex:text-body-md-regular aivex:text-text-primary aivex:cursor-text aivex:[&_p]:leading-[22px]\",\n },\n handleKeyDown: (_view, event) => {\n if (event.key === \"Enter\") {\n if (isMentionListOpen) return false;\n event.preventDefault();\n if (value.trim() && onSubmit) onSubmit();\n return true;\n }\n if (event.key === \"Escape\") {\n if (isMentionListOpen) return false;\n event.preventDefault();\n onEscape?.();\n return true;\n }\n return false;\n },\n },\n onUpdate: ({ editor }) => {\n onChange(extractContentFromJSON(editor.getJSON()));\n },\n });\n\n useEffect(() => {\n if (editor && !initialContent && value !== editor.getText()) {\n editor.commands.setContent(value);\n }\n }, [value, editor, initialContent]);\n\n useEffect(() => {\n if (editor && autoFocus) {\n requestAnimationFrame(() => {\n editor.commands.focus();\n });\n }\n }, [editor, autoFocus]);\n\n useImperativeHandle(\n handleRef,\n () => ({\n focus: () => {\n editor?.commands.focus();\n },\n }),\n [editor],\n );\n\n return (\n <EditorContent\n ref={editorRef}\n editor={editor}\n className=\"aivex:relative aivex:h-full aivex:w-full\"\n onKeyDown={(e) => e.stopPropagation()}\n />\n );\n}\n\n/** tiptap 문서 → 평문(멘션은 `@[이름](id)`) 직렬화. */\nfunction extractContentFromJSON(json: JSONContent): string {\n if (!json?.content) return \"\";\n\n const processNode = (node: JSONContent): string => {\n if (node.type === \"mention\" && node.attrs) {\n return `@[${node.attrs.label}](${node.attrs.id})`;\n }\n if (node.type === \"text\") return node.text || \"\";\n if (node.content) return node.content.map(processNode).join(\"\");\n return \"\";\n };\n return json.content.map(processNode).join(\"\");\n}\n","\"use client\";\n\nimport type { JSONContent } from \"@tiptap/react\";\nimport { Avatar } from \"../Avatar\";\nimport { Button } from \"../Button\";\nimport { CloseIcon } from \"../Icon\";\nimport { IconButton } from \"../IconButton\";\nimport MentionInput from \"./MentionInput\";\nimport type { CommentUser } from \"./types\";\n\nexport interface CommentInputProps {\n /** 작성자(입력행 아바타). */\n user?: CommentUser;\n value: string;\n onChange: (value: string) => void;\n /** 전송(Enter 또는 Send 버튼). 값이 비어 있으면 호출되지 않는다. */\n onSubmit: () => void;\n /** 헤더 닫기 버튼·Esc. */\n onClose?: () => void;\n /** 헤더 타이틀(호스트 i18n). 기본 \"Comment\". */\n title?: string;\n placeholder?: string;\n /** 전송 버튼 라벨(호스트 i18n). 기본 \"Send\". */\n submitLabel?: string;\n /** 전송 중 여부 — 버튼 비활성(스피너 등은 호스트가 submitLabel 자리로). */\n pending?: boolean;\n /** 멘션(@) 후보. 생략하면 멘션 없이 동작. */\n userList?: CommentUser[];\n mentionEmptyText?: string;\n initialContent?: JSONContent;\n className?: string;\n}\n\n/**\n * 새 코멘트 입력 패널 — 옵스 new-editor의 NewCommentPanel 이식(도메인/위치 결합 제거).\n * 코멘트 스레드와 동일한 크롬: 헤더(타이틀+닫기) + 입력행(아바타 · 멘션 입력 · 오른쪽\n * Send 버튼). 화면 배치(핀 오른쪽 등)는 호스트가 감싸는 컨테이너에서 담당한다.\n */\nexport function CommentInput({\n user,\n value,\n onChange,\n onSubmit,\n onClose,\n title = \"Comment\",\n placeholder,\n submitLabel = \"Send\",\n pending = false,\n userList,\n mentionEmptyText,\n initialContent,\n className,\n}: CommentInputProps) {\n const handleSubmit = () => {\n if (!value.trim() || pending) return;\n onSubmit();\n };\n\n return (\n <div className={`aivex:rounded-2xl aivex:bg-bg-primary aivex:shadow-xl ${className ?? \"\"}`}>\n <div className=\"aivex:flex aivex:w-[360px] aivex:flex-col\">\n <div className=\"aivex:flex aivex:h-12 aivex:items-center aivex:justify-between aivex:border-border-subtle aivex:border-b aivex:px-5 aivex:py-2\">\n <span className=\"aivex:text-body-lg-medium aivex:text-text-primary\">{title}</span>\n <IconButton size=\"sm\" className=\"aivex:text-text-secondary\" onClick={onClose}>\n <CloseIcon size={20} />\n </IconButton>\n </div>\n <div className=\"aivex:flex aivex:gap-1.5 aivex:px-4 aivex:py-3\">\n <div className=\"aivex:h-6 aivex:w-6 aivex:py-1\">\n {user ? (\n <Avatar size=\"sm\" src={user.avatarUrl} bgColor={user.color} name={user.name} />\n ) : null}\n </div>\n <div className=\"aivex:flex aivex:w-full aivex:items-end aivex:gap-1.5\">\n <div className=\"aivex:min-w-0 aivex:flex-1\">\n <MentionInput\n value={value}\n onChange={onChange}\n placeholder={placeholder}\n onSubmit={handleSubmit}\n onEscape={onClose}\n userList={userList}\n mentionEmptyText={mentionEmptyText}\n initialContent={initialContent}\n />\n </div>\n <Button\n size=\"md\"\n className=\"aivex:w-[70px] aivex:shrink-0\"\n disabled={!value.trim() || pending}\n onClick={handleSubmit}\n >\n {submitLabel}\n </Button>\n </div>\n </div>\n </div>\n </div>\n );\n}\n","\"use client\";\n\nimport { Avatar } from \"../Avatar\";\nimport type { CommentUser } from \"./types\";\n\nexport interface CommentPinProps {\n /** 스레드 참여자(작성자 우선). 최대 maxAvatars명까지 아바타를 겹쳐 그린다. */\n users: CommentUser[];\n selected?: boolean;\n /** 해결(resolve)된 코멘트 — 반투명 표시. */\n resolved?: boolean;\n onClick?: () => void;\n maxAvatars?: number;\n className?: string;\n}\n\n/**\n * 코멘트 핀(다트) — 옵스 에디터 CommentDart의 말풍선 부분 이식.\n * 좌하단이 뾰족한 말풍선(팁이 코멘트 지점을 가리킴). 위치·스케일 고정은 호스트가\n * ShapeEditor overlayMarkers(anchor \"topLeft\") 등으로 담당한다.\n */\nexport function CommentPin({\n users,\n selected = false,\n resolved = false,\n onClick,\n maxAvatars = 3,\n className,\n}: CommentPinProps) {\n const shown = users.slice(0, maxAvatars);\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className={`aivex:flex aivex:h-fit aivex:cursor-pointer aivex:items-center aivex:rounded-t-full aivex:rounded-br-full aivex:border aivex:p-1 aivex:transition-colors ${\n selected\n ? \"aivex:border-border-brand aivex:bg-bg-brand\"\n : \"aivex:border-border-subtle aivex:bg-bg-primary aivex:hover:border-border-brand\"\n } ${resolved ? \"aivex:opacity-40\" : \"\"} ${className ?? \"\"}`}\n >\n {shown.map((user, i) => (\n <span\n key={user.id}\n className=\"aivex:flex\"\n style={i > 0 ? { marginLeft: \"-4px\" } : undefined}\n >\n <Avatar size=\"xs\" src={user.avatarUrl} bgColor={user.color} name={user.name} />\n </span>\n ))}\n {users.length > maxAvatars ? (\n <span className=\"aivex:px-1 aivex:text-label-sm aivex:text-text-secondary\">\n +{users.length - maxAvatars}\n </span>\n ) : null}\n </button>\n );\n}\n"],"mappings":";;;;;;;;;;;;IA0BE,IAAiB,EAAA,SAAqC,EAAA,UAAA,YAAA,eAAA,qBAAA,UAAA;CAEtD,IAAM,CAAA,GAAa,KACE,EAAA,EAAA,EACjB,IAAa,EAAM,EAAA,CAAA,EACf,IAAc,GAAK,MAAA;MAExB,IAAO,EACT;AAED,EAAA,KAAM,EAAA,EAAgB;IAElB,CAAA,GAAA,EAAkB,CAAA,EAChB,IAAkB,GAAM,MAAA;AACxB,KAAI,MAAoB;GACxB,IAAA,IAAe,EAAK;UACp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CAAA,EAAU,kBAAA,GAAA;KAA4B,MAAA;gBAC1D;KACW,SACT;eACL,kBAAD,GAAA,EAAA,MAAA,IAAA,CAAA;KAAK,CAAA,CAAA;OACH,kBAAA,OAAC;eAAI;eAED,kBAAA,OAAC;gBAAY;eAAU,IAAK,kBAAA,GAAA;MAAW,MAAA;MAAqB,KAAA,EAAM;MAAa,SAC7E,EAAA;MACA,MACN,EAAA;MAAK,CAAA,GAAA;QACH,kBAAA,OAAC;gBAAI;gBACH,kBAAC,OAAA;iBACQ;gBACG,kBAAA,GAAA;OACG;OACb;OACA;OACU,UAAA;OACQ,UAAA;OACF;OAChB;OACE;OAEJ,CAAA;MACA,CAAA,EAAU,kBAAA,GAAA;MACV,MAAA;MACA,WAAS;gBAER,CAAA,EAAA,MAAA,IAAA;MACM,SACL;gBACF;MACF,CAAA,CAAA;;IACF,CAAA,CAAA;;;;;;ACnER,SACE,EAAA,EAAA,UAAC,cAAD,IAAA,cAAA,IAAA,YAAA,gBAAA,GAAA,gBAAA;KACE,IAAK,EAAA,MAAA,GAAA,EAAA;QACI,kBAAA,UAAA;EACT,MAAA;;aASI,4JAAU,IAAA,gDAAA,iFAAA,GAAA,IAAA,qBAAA,GAAA,GAAA,KAAA;YACH,CAAA,EAAQ,KAAE,GAAA,MAAuB,kBAAA,QAAA;cAExC;UAAa,IAAA,IAAA,EAAA,YAAA,QAAA,GAAA,KAAA;aAAe,kBAAA,GAAA;IAAW,MAAA;IAAqB,KAAA,EAAM;IAAa,SAAA,EAAA;IAC1E,MALK,EAMZ;IAEM,CAAA;UAAN,CAA2E,EAAA,EACvE,SAAM,IACH,kBAAA,QAAA;cAEF"}
|
|
1
|
+
{"version":3,"file":"comment.js","names":[],"sources":["../src/components/Comment/MentionList.tsx","../src/components/Comment/useMentionSuggestion.ts","../src/components/Comment/MentionInput.tsx","../src/components/Comment/CommentInput.tsx","../src/components/Comment/CommentPin.tsx"],"sourcesContent":["\"use client\";\n\nimport { memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from \"react\";\nimport { Avatar } from \"../Avatar\";\nimport type { CommentUser } from \"./types\";\n\nexport interface MentionListHandle {\n onKeyDown: (event: KeyboardEvent) => boolean;\n}\n\ninterface MentionListProps {\n items: CommentUser[];\n command: (item: CommentUser) => void;\n /** 후보 없음 문구(호스트 i18n). 기본 \"No results found.\" */\n emptyText?: string;\n ref?: React.Ref<MentionListHandle>;\n}\n\n/** 멘션(@) 자동완성 목록 — 옵스 에디터 MentionList 이식(도메인 결합 제거). */\nconst MentionList = memo(function MentionList({\n items,\n command,\n emptyText = \"No results found.\",\n ref,\n}: MentionListProps) {\n const [selectedIndex, setSelectedIndex] = useState(0);\n const itemRefs = useRef<(HTMLDivElement | null)[]>([]);\n\n const selectItem = useCallback(\n (index: number) => {\n const item = items[index];\n if (item) command(item);\n },\n [items, command],\n );\n\n const moveSelection = useCallback(\n (direction: \"up\" | \"down\") => {\n setSelectedIndex((prev) => {\n const itemCount = items.length;\n if (direction === \"up\") return (prev + itemCount - 1) % itemCount;\n return (prev + 1) % itemCount;\n });\n },\n [items.length],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent): boolean => {\n switch (event.key) {\n case \"ArrowUp\":\n moveSelection(\"up\");\n return true;\n case \"ArrowDown\":\n moveSelection(\"down\");\n return true;\n case \"Enter\":\n selectItem(selectedIndex);\n return true;\n default:\n return false;\n }\n },\n [moveSelection, selectItem, selectedIndex],\n );\n\n useEffect(() => {\n setSelectedIndex(0);\n itemRefs.current = items.map(() => null);\n }, [items]);\n\n useEffect(() => {\n itemRefs.current[selectedIndex]?.scrollIntoView({ behavior: \"smooth\", block: \"nearest\" });\n }, [selectedIndex]);\n\n useImperativeHandle(ref, () => ({ onKeyDown: handleKeyDown }), [handleKeyDown]);\n\n if (!items.length) {\n return (\n <div className=\"aivex:min-w-[298px] aivex:max-w-[328px] aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:py-2 aivex:shadow-xl\">\n <div className=\"aivex:p-2 aivex:text-body-md-regular aivex:text-text-secondary\">\n {emptyText}\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"aivex:h-full aivex:max-h-[248px] aivex:min-w-[298px] aivex:max-w-[328px] aivex:overflow-y-auto aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:py-2 aivex:shadow-xl\">\n {items.map((item, index) => (\n // 키보드 상호작용은 tiptap 에디터가 MentionListHandle로 위임 처리한다.\n <div\n key={item.id}\n ref={(el) => {\n itemRefs.current[index] = el;\n }}\n className={`aivex:flex aivex:h-[52px] aivex:cursor-pointer aivex:items-center aivex:gap-2 aivex:px-4 aivex:py-2 ${\n selectedIndex === index ? \"aivex:bg-bg-brand-subtle\" : \"\"\n }`}\n onClick={() => selectItem(index)}\n >\n <Avatar size=\"sm\" src={item.avatarUrl} bgColor={item.color} name={item.name} />\n <div className=\"aivex:flex aivex:max-w-[260px] aivex:flex-col\">\n <div className=\"aivex:truncate aivex:text-label-md aivex:text-text-primary\">\n {item.name}\n </div>\n {item.email ? (\n <div className=\"aivex:truncate aivex:text-body-sm-regular aivex:text-text-secondary\">\n {item.email}\n </div>\n ) : null}\n </div>\n </div>\n ))}\n </div>\n );\n});\n\nexport default MentionList;\n","\"use client\";\n\nimport { ReactRenderer } from \"@tiptap/react\";\nimport { useMemo } from \"react\";\nimport tippy, { type Instance as TippyInstance } from \"tippy.js\";\nimport MentionList, { type MentionListHandle } from \"./MentionList\";\nimport type { CommentUser } from \"./types\";\n\n/** tiptap Mention 확장에 꽂는 자동완성 설정 — 옵스 에디터 이식(CommentUser 기반). */\nexport const useMentionSuggestion = (\n userList: CommentUser[],\n onOpenChange?: (isOpen: boolean) => void,\n emptyText?: string,\n) => {\n return useMemo(() => {\n const filterUsers = (query: string) => {\n if (!query) return userList;\n const q = query.toLowerCase();\n return userList.filter(\n (user) =>\n user.name.toLowerCase().includes(q) || (user.email ?? \"\").toLowerCase().includes(q),\n );\n };\n\n const createCommandHandler =\n (originalCommand: (item: { id: string; label: string }) => void) => (item: CommentUser) => {\n originalCommand({ id: item.id, label: item.name });\n };\n\n const createRenderer = () => {\n let component: ReactRenderer<MentionListHandle> | null = null;\n let popup: TippyInstance[] | null = null;\n\n return {\n // biome-ignore lint/suspicious/noExplicitAny: tiptap suggestion props는 확장별 동적 형태라 상위 타입이 없다\n onStart: (props: Record<string, any>) => {\n component = new ReactRenderer(MentionList, {\n props: {\n ...props,\n emptyText,\n command: createCommandHandler(props.command),\n },\n editor: props.editor,\n });\n\n if (!props.clientRect) return;\n\n popup = tippy(\"body\", {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: true,\n interactive: true,\n trigger: \"manual\",\n placement: \"bottom-start\",\n });\n\n onOpenChange?.(true);\n },\n\n // biome-ignore lint/suspicious/noExplicitAny: tiptap suggestion props는 확장별 동적 형태라 상위 타입이 없다\n onUpdate(props: Record<string, any>) {\n component?.updateProps({\n ...props,\n emptyText,\n command: createCommandHandler(props.command),\n });\n\n if (!props.clientRect) return;\n\n popup?.[0]?.setProps({ getReferenceClientRect: props.clientRect });\n },\n\n onKeyDown(props: { event: KeyboardEvent }) {\n if (props.event.key === \"Escape\") {\n if (popup?.[0] && !popup[0].state.isDestroyed) popup[0].hide();\n onOpenChange?.(false);\n return true;\n }\n return component?.ref?.onKeyDown(props.event) || false;\n },\n\n onExit() {\n if (popup?.[0] && !popup[0].state.isDestroyed) popup[0].destroy();\n component?.destroy();\n popup = null;\n component = null;\n onOpenChange?.(false);\n },\n };\n };\n\n return {\n items: ({ query }: { query: string }) => filterUsers(query),\n render: createRenderer,\n };\n }, [userList, onOpenChange, emptyText]);\n};\n","\"use client\";\n\nimport Mention from \"@tiptap/extension-mention\";\nimport Placeholder from \"@tiptap/extension-placeholder\";\nimport { EditorContent, type JSONContent, mergeAttributes, useEditor } from \"@tiptap/react\";\nimport StarterKit from \"@tiptap/starter-kit\";\nimport { type Ref, useEffect, useImperativeHandle, useRef, useState } from \"react\";\nimport type { CommentUser } from \"./types\";\nimport { useMentionSuggestion } from \"./useMentionSuggestion\";\n\nexport interface MentionInputHandle {\n /** 입력기에 포커스를 준다(예: 전송 버튼 클릭 후 포커스 유지). */\n focus: () => void;\n}\n\nexport interface MentionInputProps {\n value: string;\n onChange: (value: string) => void;\n placeholder?: string;\n /** Enter(멘션 목록 닫힌 상태) 제출. */\n onSubmit?: () => void;\n /** Esc(멘션 목록 닫힌 상태) 취소. */\n onEscape?: () => void;\n /** 멘션(@) 후보. 빈 배열이면 멘션 없이 플레인 입력처럼 동작한다. */\n userList?: CommentUser[];\n initialContent?: JSONContent;\n /** 멘션 후보 없음 문구(호스트 i18n). */\n mentionEmptyText?: string;\n /** 마운트 시 자동 포커스(기본 true). */\n autoFocus?: boolean;\n /** 명령형 핸들(포커스 제어). */\n handleRef?: Ref<MentionInputHandle>;\n}\n\n/**\n * 멘션(@) 지원 코멘트 입력기 — 옵스 에디터 MentionInput 이식.\n * value는 평문 직렬화(`@[이름](id)`)로 주고받는다.\n */\nexport default function MentionInput({\n value,\n onChange,\n placeholder,\n onSubmit,\n onEscape,\n userList = [],\n initialContent,\n mentionEmptyText,\n autoFocus = true,\n handleRef,\n}: MentionInputProps) {\n const editorRef = useRef<HTMLDivElement>(null);\n const [isMentionListOpen, setIsMentionListOpen] = useState(false);\n const suggestion = useMentionSuggestion(userList, setIsMentionListOpen, mentionEmptyText);\n\n const editor = useEditor({\n extensions: [\n StarterKit,\n Placeholder.configure({\n placeholder,\n emptyEditorClass:\n \"aivex:before:content-[attr(data-placeholder)] aivex:before:text-text-tertiary aivex:before:absolute aivex:before:left-3\",\n }),\n Mention.configure({\n HTMLAttributes: { class: \"aivex:text-text-brand aivex:px-1\" },\n // 멘션이 확정되면 골뱅이는 사라지고 이름만 남는다(시안) — 확정 전\n // 타이핑 중인 \"@검색어\"는 그대로다. 직렬화 형식은 바뀌지 않는다.\n renderHTML({ options, node }) {\n return [\"span\", mergeAttributes(options.HTMLAttributes), `${node.attrs.label}`];\n },\n renderText({ node }) {\n return `@[${node.attrs.label}](${node.attrs.id})`;\n },\n deleteTriggerWithBackspace: true,\n suggestion,\n }),\n ],\n content: initialContent || value,\n // SSR 환경(next 등)에서 hydration 불일치 방지.\n immediatelyRender: false,\n editorProps: {\n attributes: {\n // 줄높이 22(내부 p에 강제) + py 8 + 보더 2 = 32px — 옆의 Send 버튼(h-8)과 높이 일치.\n class:\n \"aivex:px-3 aivex:py-1 aivex:rounded-lg aivex:border aivex:border-border-subtle aivex:bg-bg-secondary aivex:focus:border-border-brand aivex:outline-none aivex:text-body-md-regular aivex:text-text-primary aivex:cursor-text aivex:[&_p]:leading-[22px]\",\n },\n handleKeyDown: (_view, event) => {\n if (event.key === \"Enter\") {\n if (isMentionListOpen) return false;\n // 보조키를 짚은 Enter는 전송이 아니라 개행 — tiptap 기본 동작에 맡긴다.\n if (event.shiftKey || event.metaKey || event.ctrlKey || event.altKey) {\n return false;\n }\n event.preventDefault();\n if (value.trim() && onSubmit) onSubmit();\n return true;\n }\n if (event.key === \"Escape\") {\n if (isMentionListOpen) return false;\n event.preventDefault();\n onEscape?.();\n return true;\n }\n return false;\n },\n },\n onUpdate: ({ editor }) => {\n onChange(extractContentFromJSON(editor.getJSON()));\n },\n });\n\n useEffect(() => {\n if (editor && !initialContent && value !== editor.getText()) {\n editor.commands.setContent(value);\n }\n }, [value, editor, initialContent]);\n\n useEffect(() => {\n if (editor && autoFocus) {\n requestAnimationFrame(() => {\n editor.commands.focus();\n });\n }\n }, [editor, autoFocus]);\n\n useImperativeHandle(\n handleRef,\n () => ({\n focus: () => {\n editor?.commands.focus();\n },\n }),\n [editor],\n );\n\n return (\n <EditorContent\n ref={editorRef}\n editor={editor}\n className=\"aivex:relative aivex:h-full aivex:w-full\"\n onKeyDown={(e) => e.stopPropagation()}\n />\n );\n}\n\n/** tiptap 문서 → 평문(멘션은 `@[이름](id)`, 줄바꿈은 \\n) 직렬화. */\nfunction extractContentFromJSON(json: JSONContent): string {\n if (!json?.content) return \"\";\n\n const processNode = (node: JSONContent): string => {\n if (node.type === \"mention\" && node.attrs) {\n return `@[${node.attrs.label}](${node.attrs.id})`;\n }\n if (node.type === \"text\") return node.text || \"\";\n // Shift+Enter가 넣는 줄바꿈 — 문단 분리(아래 join)와 같은 값으로 편다.\n if (node.type === \"hardBreak\") return \"\\n\";\n if (node.content) return node.content.map(processNode).join(\"\");\n return \"\";\n };\n // 문단마다 한 줄 — 보조키+Enter로 문단이 갈리면 그대로 줄이 나뉜다.\n return json.content.map(processNode).join(\"\\n\");\n}\n","\"use client\";\n\nimport type { JSONContent } from \"@tiptap/react\";\nimport { Avatar } from \"../Avatar\";\nimport { Button } from \"../Button\";\nimport { CloseIcon } from \"../Icon\";\nimport { IconButton } from \"../IconButton\";\nimport MentionInput from \"./MentionInput\";\nimport type { CommentUser } from \"./types\";\n\nexport interface CommentInputProps {\n /** 작성자(입력행 아바타). */\n user?: CommentUser;\n value: string;\n onChange: (value: string) => void;\n /** 전송(Enter 또는 Send 버튼). 값이 비어 있으면 호출되지 않는다. */\n onSubmit: () => void;\n /** 헤더 닫기 버튼·Esc. */\n onClose?: () => void;\n /** 헤더 타이틀(호스트 i18n). 기본 \"Comment\". */\n title?: string;\n placeholder?: string;\n /** 전송 버튼 라벨(호스트 i18n). 기본 \"Send\". */\n submitLabel?: string;\n /**\n * 전송 버튼 사용 — 켜면 내용이 있을 때만 입력 아래 오른쪽에 나타난다(시안).\n * 끄면 어느 상태에서도 없이 Enter로만 보낸다.\n */\n showSubmit?: boolean;\n /** 전송 중 여부 — 버튼 비활성(스피너 등은 호스트가 submitLabel 자리로). */\n pending?: boolean;\n /** 멘션(@) 후보. 생략하면 멘션 없이 동작. */\n userList?: CommentUser[];\n mentionEmptyText?: string;\n initialContent?: JSONContent;\n className?: string;\n}\n\n/**\n * 새 코멘트 입력 패널 — 옵스 new-editor의 NewCommentPanel 이식(도메인/위치 결합 제거).\n * 코멘트 스레드와 동일한 크롬: 헤더(타이틀+닫기) + 입력행(아바타 · 멘션 입력 · 오른쪽\n * Send 버튼). 화면 배치(핀 오른쪽 등)는 호스트가 감싸는 컨테이너에서 담당한다.\n */\nexport function CommentInput({\n user,\n value,\n onChange,\n onSubmit,\n onClose,\n title = \"Comment\",\n placeholder,\n submitLabel = \"Send\",\n showSubmit = true,\n pending = false,\n userList,\n mentionEmptyText,\n initialContent,\n className,\n}: CommentInputProps) {\n const handleSubmit = () => {\n if (!value.trim() || pending) return;\n onSubmit();\n };\n\n return (\n <div className={`aivex:rounded-2xl aivex:bg-bg-primary aivex:shadow-xl ${className ?? \"\"}`}>\n <div className=\"aivex:flex aivex:w-[360px] aivex:flex-col\">\n <div className=\"aivex:flex aivex:h-12 aivex:items-center aivex:justify-between aivex:border-border-subtle aivex:border-b aivex:px-5 aivex:py-2\">\n <span className=\"aivex:text-body-lg-medium aivex:text-text-primary\">{title}</span>\n <IconButton size=\"sm\" className=\"aivex:text-text-secondary\" onClick={onClose}>\n <CloseIcon size={20} />\n </IconButton>\n </div>\n <div className=\"aivex:flex aivex:flex-col aivex:px-4 aivex:py-3\">\n <div className=\"aivex:flex aivex:gap-1.5\">\n <div className=\"aivex:h-6 aivex:w-6 aivex:py-1\">\n {user ? (\n <Avatar size=\"sm\" src={user.avatarUrl} bgColor={user.color} name={user.name} />\n ) : null}\n </div>\n <div className=\"aivex:min-w-0 aivex:flex-1\">\n <MentionInput\n value={value}\n onChange={onChange}\n placeholder={placeholder}\n onSubmit={handleSubmit}\n onEscape={onClose}\n userList={userList}\n mentionEmptyText={mentionEmptyText}\n initialContent={initialContent}\n />\n </div>\n </div>\n {/* 전송 버튼은 빈 입력에서는 없다 — 내용이 생기면 아래로 밀려 나온다(시안).\n grid-rows 0fr↔1fr은 높이를 모르는 내용도 부드럽게 여닫는다. */}\n {showSubmit ? (\n <div\n className={`aivex:grid aivex:transition-[grid-template-rows,opacity] aivex:duration-200 aivex:ease-out ${\n value.trim()\n ? \"aivex:grid-rows-[1fr] aivex:opacity-100\"\n : \"aivex:pointer-events-none aivex:grid-rows-[0fr] aivex:opacity-0\"\n }`}\n >\n {/* 입력과 버튼 사이 6px(시안) — 접히는 안쪽에 둬야 함께 사라진다. */}\n <div className=\"aivex:flex aivex:justify-end aivex:overflow-hidden aivex:pt-1.5\">\n <Button\n size=\"md\"\n disabled={!value.trim() || pending}\n onClick={handleSubmit}\n tabIndex={value.trim() ? undefined : -1}\n >\n {submitLabel}\n </Button>\n </div>\n </div>\n ) : null}\n </div>\n </div>\n </div>\n );\n}\n","\"use client\";\n\nimport { Avatar } from \"../Avatar\";\nimport type { CommentUser } from \"./types\";\n\nexport interface CommentPinProps {\n /** 스레드 참여자(작성자 우선). 최대 maxAvatars명까지 아바타를 겹쳐 그린다. */\n users: CommentUser[];\n selected?: boolean;\n /** 해결(resolve)된 코멘트 — 반투명 표시. */\n resolved?: boolean;\n onClick?: () => void;\n maxAvatars?: number;\n className?: string;\n}\n\n/**\n * 코멘트 핀(다트) — 옵스 에디터 CommentDart의 말풍선 부분 이식.\n * 좌하단이 뾰족한 말풍선(팁이 코멘트 지점을 가리킴). 위치·스케일 고정은 호스트가\n * ShapeEditor overlayMarkers(anchor \"topLeft\") 등으로 담당한다.\n */\nexport function CommentPin({\n users,\n selected = false,\n resolved = false,\n onClick,\n maxAvatars = 3,\n className,\n}: CommentPinProps) {\n const shown = users.slice(0, maxAvatars);\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className={`aivex:flex aivex:h-fit aivex:cursor-pointer aivex:items-center aivex:rounded-t-full aivex:rounded-br-full aivex:border aivex:p-1 aivex:transition-colors ${\n selected\n ? \"aivex:border-border-brand aivex:bg-bg-brand\"\n : \"aivex:border-border-subtle aivex:bg-bg-primary aivex:hover:border-border-brand\"\n } ${resolved ? \"aivex:opacity-40\" : \"\"} ${className ?? \"\"}`}\n >\n {shown.map((user, i) => (\n <span\n key={user.id}\n className=\"aivex:flex\"\n style={i > 0 ? { marginLeft: \"-4px\" } : undefined}\n >\n <Avatar size=\"xs\" src={user.avatarUrl} bgColor={user.color} name={user.name} />\n </span>\n ))}\n {users.length > maxAvatars ? (\n <span className=\"aivex:px-1 aivex:text-label-sm aivex:text-text-secondary\">\n +{users.length - maxAvatars}\n </span>\n ) : null}\n </button>\n );\n}\n"],"mappings":";;;;;;;;;;;;IA0BE,IAAiB,EAAA,SAAqC,EAAA,UAAA,YAAA,eAAA,qBAAA,UAAA;CAEtD,IAAM,CAAA,GAAa,KACE,EAAA,EAAA,EACjB,IAAa,EAAM,EAAA,CAAA,EACf,IAAc,GAAK,MAAA;MAExB,IAAO,EACT;AAED,EAAA,KAAM,EAAA,EAAgB;IAElB,CAAA,GAAA,EAAkB,CAAA,EAChB,IAAkB,GAAM,MAAA;AACxB,KAAI,MAAoB;GACxB,IAAA,IAAe,EAAK;UACpB,MAAA,QAAA,IAAA,IAAA,KAAA,KAEG,IAAO,KACf;IAED;IAEI,CAAA,EAAQ,OAAM,CAAA,EACZ,IAAK,GAAA,MAAA;AACH,UAAA,EAAA,KAAA;GACA,KAAA,UAEA,QADF,EAAK,KAAA,EACH;GACA,KAAA,YAEA,QADF,EAAK,OAAA,EACH;GACA,KAAA,gBACF,EACE,EAAO;WAGb,QAAA;;IAAgB;EAAY;EAAc;EAG5C;EACE,CAAA;QACA,QAAS;AAGX,IAFW,EAAA,EAEX,EAAA,UAAgB,EAAA,UAAA,KAAA;IACd,CAAA,EAAS,CAAA,UAAmD;IAAiB,QAAA,IAAA,eAAA;GAAW,UAAC;UACvF;GAEJ,CAAA;IAEA,CAAI,EACF,CAAA,IACiB,UAAA,EAAA,WAAA,GAAA,GAAA,CAAA,EAAA,CAAA,IACb,SASU,kBAAA,OAAM;aAIR;EACJ,UAAA,EAAS,KAAQ,GAAA,MAAS,kBAAA,OAAA;;AAE5B,MAAA,QAAW,KAAA;;cAKX,uGAAA,MAAA,IAAA,6BAAA;kBAAa,EAAA,EAAA;aAAU,CAAK,kBAAA,GAAA;IAAW,MAAA;IAAqB,KAAA,E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,IAAG;;OAGlB,UAAA,EAAA,MAAA,GAAA,KAAA,IAAA;OACL,UAAA;OACF,CAAA;MAGN,CAAA;;IACF,CAAA,CAAA;;;;;;ACxFR,SACE,EAAA,EAAA,UAAC,cAAD,IAAA,cAAA,IAAA,YAAA,gBAAA,GAAA,gBAAA;KACE,IAAK,EAAA,MAAA,GAAA,EAAA;QACI,kBAAA,UAAA;EACT,MAAA;;aASI,4JAAU,IAAA,gDAAA,iFAAA,GAAA,IAAA,qBAAA,GAAA,GAAA,KAAA;YACH,CAAA,EAAQ,KAAE,GAAA,MAAuB,kBAAA,QAAA;cAExC;UAAa,IAAA,IAAA,EAAA,YAAA,QAAA,GAAA,KAAA;aAAe,kBAAA,GAAA;IAAW,MAAA;IAAqB,KAAA,EAAM;IAAa,SAAA,EAAA;IAC1E,MALK,EAMZ;IAEM,CAAA;UAAN,CAA2E,EAAA,EACvE,SAAM,IACH,kBAAA,QAAA;cAEF"}
|
|
@@ -14,6 +14,11 @@ export interface CommentInputProps {
|
|
|
14
14
|
placeholder?: string;
|
|
15
15
|
/** 전송 버튼 라벨(호스트 i18n). 기본 "Send". */
|
|
16
16
|
submitLabel?: string;
|
|
17
|
+
/**
|
|
18
|
+
* 전송 버튼 사용 — 켜면 내용이 있을 때만 입력 아래 오른쪽에 나타난다(시안).
|
|
19
|
+
* 끄면 어느 상태에서도 없이 Enter로만 보낸다.
|
|
20
|
+
*/
|
|
21
|
+
showSubmit?: boolean;
|
|
17
22
|
/** 전송 중 여부 — 버튼 비활성(스피너 등은 호스트가 submitLabel 자리로). */
|
|
18
23
|
pending?: boolean;
|
|
19
24
|
/** 멘션(@) 후보. 생략하면 멘션 없이 동작. */
|
|
@@ -27,4 +32,4 @@ export interface CommentInputProps {
|
|
|
27
32
|
* 코멘트 스레드와 동일한 크롬: 헤더(타이틀+닫기) + 입력행(아바타 · 멘션 입력 · 오른쪽
|
|
28
33
|
* Send 버튼). 화면 배치(핀 오른쪽 등)는 호스트가 감싸는 컨테이너에서 담당한다.
|
|
29
34
|
*/
|
|
30
|
-
export declare function CommentInput({ user, value, onChange, onSubmit, onClose, title, placeholder, submitLabel, pending, userList, mentionEmptyText, initialContent, className, }: CommentInputProps): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare function CommentInput({ user, value, onChange, onSubmit, onClose, title, placeholder, submitLabel, showSubmit, pending, userList, mentionEmptyText, initialContent, className, }: CommentInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,6 +4,6 @@ import type { ShapeEditorProps } from "./_model/props";
|
|
|
4
4
|
* 그리기·히트테스트·뷰포트는 `EditorRenderer`(Konva/Pixi)에 위임한다. `backend`로 교체.
|
|
5
5
|
* 갭(회전/꼭짓점추가 등)은 여기서 한 번 구현하면 양쪽 렌더러에 적용된다.
|
|
6
6
|
*/
|
|
7
|
-
export default function ShapeEditor<TMeta, TMarkerMeta = unknown>({ document: editorDocument, clipboardScope, renderImageState, dimmed, selectedIds: controlledSelectedIds, activeTool, draftStyle, draftMeta, readOnly, disableMarquee, locked, onLockedInteraction, onDrawAttemptWithoutDraft, onIdleEscape, overrideShapeInteraction, defaultViewSettings, viewSettings, onViewSettingsChange, showMinimap, minimapPosition, showViewSettings, getContextMenuItems, strings, canMergeSelection, brushSize, zoomBound, zoomAnimationDuration, decorationShapes, regionMask, guideMask, maskPalette, overlayMarkers, renderOverlayMarker, onOverlayMarkerClick, renderImageOverlay, getSelectionLabel, hideSelectionLabelDot, formatSelectionInfo, externalTools, assistant, keymap, handleRef, backend, onActiveToolChange, onSelectionChange, onEditingChange, onShapesCreated, onShapesUpdated, onShapesDeleted, onDrawSessionChange, onDraftShapeChange, onViewportChange, onShapesTransformPreview, }: ShapeEditorProps<TMeta, TMarkerMeta> & {
|
|
7
|
+
export default function ShapeEditor<TMeta, TMarkerMeta = unknown>({ document: editorDocument, clipboardScope, renderImageState, dimmed, selectedIds: controlledSelectedIds, activeTool, draftStyle, draftMeta, readOnly, disableMarquee, locked, onLockedInteraction, onDrawAttemptWithoutDraft, onIdleEscape, overrideShapeInteraction, defaultViewSettings, viewSettings, onViewSettingsChange, showMinimap, minimapPosition, showViewSettings, getContextMenuItems, strings, viewSettingItems, canMergeSelection, brushSize, zoomBound, zoomAnimationDuration, decorationShapes, regionMask, guideMask, maskPalette, overlayMarkers, renderOverlayMarker, onOverlayMarkerClick, renderImageOverlay, getSelectionLabel, hideSelectionLabelDot, formatSelectionInfo, externalTools, assistant, keymap, handleRef, backend, onActiveToolChange, onSelectionChange, onEditingChange, onShapesCreated, onShapesUpdated, onShapesDeleted, onDrawSessionChange, onDraftShapeChange, onViewportChange, onShapesTransformPreview, }: ShapeEditorProps<TMeta, TMarkerMeta> & {
|
|
8
8
|
backend?: "konva" | "pixi";
|
|
9
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,7 +5,8 @@ import type { MinimapPosition } from "../_model/props";
|
|
|
5
5
|
import { type EditorStrings } from "../_model/strings";
|
|
6
6
|
import type { ViewSettings } from "../_model/viewSettings";
|
|
7
7
|
import type { MinimapNavigation } from "../_state/useMinimapNavigation";
|
|
8
|
-
|
|
8
|
+
import type { ViewSettingItemKey } from "./SettingsPanel";
|
|
9
|
+
export declare const Minimap: import("react").MemoExoticComponent<<TMeta>({ image, imageUrl, imageVisible, loading, maskDataUrl, region, roiMaskId, shapes, view, viewDefaults, onChangeView, nav, registerShape, rectRef, zoomLabelRef, onZoom100, open, onToggleOpen, position, showSettings, settingsOpen, onToggleSettings, onCloseSettings, labels, settingsLabels, settingsItems, }: {
|
|
9
10
|
image: {
|
|
10
11
|
w: number;
|
|
11
12
|
h: number;
|
|
@@ -42,4 +43,6 @@ export declare const Minimap: import("react").MemoExoticComponent<<TMeta>({ imag
|
|
|
42
43
|
labels?: EditorStrings["minimap"];
|
|
43
44
|
/** 설정 팝오버 문자열. 기본 한국어. */
|
|
44
45
|
settingsLabels?: EditorStrings["viewSettings"];
|
|
46
|
+
/** 설정 팝오버 항목 구성 — SettingsPanel.items 그대로 전달. */
|
|
47
|
+
settingsItems?: ViewSettingItemKey[];
|
|
45
48
|
}) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { type EditorStrings } from "../_model/strings";
|
|
2
2
|
import { type ViewSettings } from "../_model/viewSettings";
|
|
3
3
|
export { DEFAULT_VIEW_SETTINGS, VIEW_SETTING_RANGES, type ViewSettings, } from "../_model/viewSettings";
|
|
4
|
+
/** 보기 설정 항목 키 — 슬라이더 5종 + 토글 6종. */
|
|
5
|
+
export type ViewSettingItemKey = "brightness" | "contrast" | "strokeSize" | "simplifyStrength" | "zoomSensitivity" | "pixelation" | "cursorGuide" | "guideMask" | "regionMask" | "keepZoomOnImageChange" | "wheelZoom";
|
|
6
|
+
/** 기본 항목 구성 — 전 항목, 기존 표시 순서. 호스트가 items로 재구성한다. */
|
|
7
|
+
export declare const DEFAULT_VIEW_SETTING_ITEMS: ViewSettingItemKey[];
|
|
4
8
|
/**
|
|
5
9
|
* 미니맵 기어 버튼에서 열리는 보기 설정 팝오버(도메인 무관).
|
|
6
10
|
* 바깥 클릭/Esc로 닫힘. 값은 호출부가 소유하고 onChange로 부분 갱신.
|
|
7
11
|
* 컨트롤은 @aivex/ui(Button/Slider/Switch/Divider)로 렌더한다.
|
|
8
12
|
*/
|
|
9
|
-
export declare function SettingsPanel({ value, defaults, onChange, onClose, labels, openDown, alignEnd, }: {
|
|
13
|
+
export declare function SettingsPanel({ value, defaults, onChange, onClose, labels, items, openDown, alignEnd, }: {
|
|
10
14
|
value: ViewSettings;
|
|
11
15
|
/** "초기화"가 되돌릴 기준값 — 호스트 기본값이 반영된 시드. */
|
|
12
16
|
defaults: ViewSettings;
|
|
@@ -14,6 +18,12 @@ export declare function SettingsPanel({ value, defaults, onChange, onClose, labe
|
|
|
14
18
|
onClose: () => void;
|
|
15
19
|
/** UI 문자열. 기본 한국어. */
|
|
16
20
|
labels?: EditorStrings["viewSettings"];
|
|
21
|
+
/**
|
|
22
|
+
* 표시할 항목과 순서 — 제품마다 노출 범위가 다르다(예: 아이브데이터는
|
|
23
|
+
* 단순화 강도·픽셀화·가이드 마스크 없음, 6547:201301). 슬라이더와 토글은
|
|
24
|
+
* 각자 블록 안에서 이 배열의 순서를 따른다.
|
|
25
|
+
*/
|
|
26
|
+
items?: ViewSettingItemKey[];
|
|
17
27
|
/** 미니맵이 위쪽 모서리에 붙으면 팝오버는 아래로 연다(기본은 위로). */
|
|
18
28
|
openDown?: boolean;
|
|
19
29
|
/** 미니맵이 오른쪽 모서리에 붙으면 우측 정렬로 열어 화면 밖으로 나가지 않게 한다. */
|
|
@@ -85,6 +85,15 @@ export type OutlineSegment = [Point, Point];
|
|
|
85
85
|
* 인접 구멍 경계에 이음선이 생기지 않는다).
|
|
86
86
|
*/
|
|
87
87
|
export declare function drawRegionDim(ctx: CanvasRenderingContext2D, region: Pick<RegionOverlayData, "rects" | "zones" | "dimHoles" | "dim">, width: number, height: number): void;
|
|
88
|
+
/**
|
|
89
|
+
* 완료 딤 스타일 — static/black + opacity/dim 토큰을 호스트 엘리먼트의 계산값으로
|
|
90
|
+
* 런타임에 해석한다. 캔버스는 CSS 변수를 직접 참조할 수 없어 여기서 읽어 넘긴다.
|
|
91
|
+
* 폴백은 토큰 미로드 환경(단위 테스트 등)용으로 현재 토큰 값과 같다.
|
|
92
|
+
*/
|
|
93
|
+
export declare function resolveCompletedDimStyle(host: HTMLElement): {
|
|
94
|
+
color: string;
|
|
95
|
+
opacity: number;
|
|
96
|
+
};
|
|
88
97
|
/** 기본값이 채워진 윤곽 스트로크 — 렌더러가 그대로 그린다. */
|
|
89
98
|
export type ResolvedRegionOutlineStyle = Required<RegionOutlineStyle>;
|
|
90
99
|
/**
|