@univerjs/preset-docs-thread-comment 0.7.0 → 0.8.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- .univer-absolute{position:absolute}.univer-relative{position:relative}.univer-left-0{left:0}.univer-right-0{right:0}.univer-top-0{top:0}.univer-m-0{margin:0}.univer-mb-1{margin-bottom:4px}.univer-mb-3{margin-bottom:12px}.univer-mb-4{margin-bottom:16px}.univer-ml-1{margin-left:4px}.univer-mr-1\.5{margin-right:6px}.univer-mr-2{margin-right:8px}.univer-mt-2{margin-top:8px}.univer-mt-3{margin-top:12px}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-inline-flex{display:inline-flex}.univer-grid{display:grid}.univer-h-1\.5{height:6px}.univer-h-3\.5{height:14px}.univer-h-6{height:24px}.univer-max-h-80{max-height:320px}.univer-min-h-full{min-height:100%}.univer-w-6{width:24px}.univer-w-\[278px\]{width:278px}.univer-w-\[3px\]{width:3px}.univer-w-full{width:100%}.univer-flex-1{flex:1 1 0%}.univer-flex-shrink-0{flex-shrink:0}.univer-flex-grow-0{flex-grow:0}.univer-cursor-pointer{cursor:pointer}.univer-list-none{list-style-type:none}.univer-flex-row{flex-direction:row}.univer-flex-col{flex-direction:column}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-3{gap:12px}.univer-overflow-hidden{overflow:hidden}.univer-overflow-y-auto{overflow-y:auto}.univer-overflow-x-hidden{overflow-x:hidden}.univer-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-break-words{word-wrap:break-word}.univer-rounded-\[3px\]{border-radius:3px}.univer-rounded-full{border-radius:9999px}.univer-rounded-lg{border-radius:8px}.univer-rounded-md{border-radius:6px}.univer-rounded-sm{border-radius:2px}.univer-rounded-t-md{border-top-left-radius:6px;border-top-right-radius:6px}.univer-bg-gray-50{background-color:var(--univer-gray-50)}.univer-bg-gray-900{background-color:var(--univer-gray-900)}.univer-bg-white{background-color:var(--univer-white)}.univer-bg-yellow-400{background-color:var(--univer-yellow-400)}.univer-bg-yellow-500{background-color:var(--univer-yellow-500)}.univer-bg-cover{background-size:cover}.univer-bg-center{background-position:center}.univer-bg-no-repeat{background-repeat:no-repeat}.univer-p-1\.5{padding:6px}.univer-p-4{padding:16px}.univer-pb-3{padding-bottom:12px}.univer-pl-\[30px\]{padding-left:30px}.univer-text-base{font-size:16px;line-height:24px}.univer-text-sm{font-size:14px;line-height:20px}.univer-text-xs{font-size:12px;line-height:16px}.univer-text-xs\/normal{font-size:12px;line-height:1.5}.univer-font-medium{font-weight:500}.univer-leading-5{line-height:20px}.univer-text-gray-600{color:var(--univer-gray-600)}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-text-green-500{color:var(--univer-green-500)}.univer-text-primary-600{color:var(--univer-primary-600)}.univer-shadow{--tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, .1), 0 1px 2px -1px rgba(0, 0, 0, .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 3px #0000001a,0 1px 2px -1px #0000001a;box-shadow:var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--tw-shadow)}.hover\:univer-bg-gray-200:hover{background-color:var(--univer-gray-200)}.hover\:univer-bg-gray-50:hover{background-color:var(--univer-gray-50)}.dark\:univer-bg-gray-900:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-900)}.dark\:univer-text-gray-200:where(.univer-dark,.univer-dark *){color:var(--univer-gray-200)}.dark\:univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)}.dark\:hover\:univer-bg-gray-800:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-800)}.\[\&_a\]\:univer-block a{display:block}.\[\&_a\]\:univer-cursor-pointer a{cursor:pointer}.\[\&_a\]\:univer-rounded a{border-radius:4px}.\[\&_a\]\:univer-px-2 a{padding-left:8px;padding-right:8px}.\[\&_a\]\:univer-py-1\.5 a{padding-top:6px;padding-bottom:6px}.\[\&_a\]\:univer-transition-colors a{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}
1
+ .univer-absolute{position:absolute}.univer-relative{position:relative}.univer-left-0{left:0}.univer-right-0{right:0}.univer-top-0{top:0}.univer-m-0{margin:0}.univer-mb-1{margin-bottom:4px}.univer-mb-3{margin-bottom:12px}.univer-mb-4{margin-bottom:16px}.univer-ml-1{margin-left:4px}.univer-mr-1\.5{margin-right:6px}.univer-mr-2{margin-right:8px}.univer-mt-2{margin-top:8px}.univer-mt-3{margin-top:12px}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-inline-flex{display:inline-flex}.univer-grid{display:grid}.univer-h-1\.5{height:6px}.univer-h-3\.5{height:14px}.univer-h-6{height:24px}.univer-max-h-80{max-height:320px}.univer-min-h-full{min-height:100%}.univer-w-6{width:24px}.univer-w-\[278px\]{width:278px}.univer-w-\[3px\]{width:3px}.univer-w-full{width:100%}.univer-flex-1{flex:1 1 0%}.univer-flex-shrink-0{flex-shrink:0}.univer-flex-grow-0{flex-grow:0}.univer-cursor-pointer{cursor:pointer}.univer-list-none{list-style-type:none}.univer-flex-row{flex-direction:row}.univer-flex-col{flex-direction:column}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-2{gap:8px}.univer-gap-3{gap:12px}.univer-overflow-hidden{overflow:hidden}.univer-overflow-y-auto{overflow-y:auto}.univer-overflow-x-hidden{overflow-x:hidden}.univer-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-break-words{word-wrap:break-word}.univer-rounded-\[3px\]{border-radius:3px}.univer-rounded-full{border-radius:9999px}.univer-rounded-lg{border-radius:8px}.univer-rounded-md{border-radius:6px}.univer-rounded-sm{border-radius:2px}.univer-rounded-t-md{border-top-left-radius:6px;border-top-right-radius:6px}.\!univer-bg-gray-900{background-color:var(--univer-gray-900)!important}.univer-bg-gray-50{background-color:var(--univer-gray-50)}.univer-bg-white{background-color:var(--univer-white)}.univer-bg-yellow-400{background-color:var(--univer-yellow-400)}.univer-bg-yellow-500{background-color:var(--univer-yellow-500)}.univer-bg-cover{background-size:cover}.univer-bg-center{background-position:center}.univer-bg-no-repeat{background-repeat:no-repeat}.univer-p-1\.5{padding:6px}.univer-p-4{padding:16px}.univer-pb-3{padding-bottom:12px}.univer-pl-\[30px\]{padding-left:30px}.univer-text-base{font-size:16px;line-height:24px}.univer-text-sm{font-size:14px;line-height:20px}.univer-text-xs{font-size:12px;line-height:16px}.univer-text-xs\/normal{font-size:12px;line-height:1.5}.univer-font-medium{font-weight:500}.univer-leading-5{line-height:20px}.univer-text-gray-600{color:var(--univer-gray-600)}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-text-green-500{color:var(--univer-green-500)}.univer-text-primary-600{color:var(--univer-primary-600)}.univer-shadow{--tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, .1), 0 1px 2px -1px rgba(0, 0, 0, .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 3px #0000001a,0 1px 2px -1px #0000001a;box-shadow:var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--tw-shadow)}.hover\:univer-bg-gray-200:hover{background-color:var(--univer-gray-200)}.hover\:univer-bg-gray-50:hover{background-color:var(--univer-gray-50)}.dark\:\!univer-bg-gray-900:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-900)!important}.dark\:\!univer-text-gray-200:where(.univer-dark,.univer-dark *){color:var(--univer-gray-200)!important}.dark\:\!univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.dark\:hover\:\!univer-bg-gray-800:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-800)!important}.\[\&_a\]\:univer-block a{display:block}.\[\&_a\]\:univer-cursor-pointer a{cursor:pointer}.\[\&_a\]\:univer-rounded a{border-radius:4px}.\[\&_a\]\:univer-px-2 a{padding-left:8px;padding-right:8px}.\[\&_a\]\:univer-py-1\.5 a{padding-top:6px;padding-bottom:6px}.\[\&_a\]\:univer-transition-colors a{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}
package/lib/umd/index.js CHANGED
@@ -1,21 +1,13 @@
1
1
  // @univerjs/thread-comment-ui/index
2
- (function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/docs-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","@univerjs/design","react","@univerjs/docs-ui"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverThreadCommentUi={},c.UniverCore,c.UniverThreadComment,c.UniverUi,c.rxjs,c.React,c.UniverDesign,c.React,c.UniverDocsUi))})(this,function(c,a,_,f,X,s,L,d,se){"use strict";var Ke=Object.defineProperty;var Ge=(c,a,_)=>a in c?Ke(c,a,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[a]=_;var Y=(c,a,_)=>Ge(c,typeof a!="symbol"?a+"":a,_);var Se=Object.getOwnPropertyDescriptor,_e=(t,e,n,r)=>{for(var i=r>1?void 0:r?Se(e,n):e,l=t.length-1,v;l>=0;l--)(v=t[l])&&(i=v(i)||i);return i},le=(t,e)=>(n,r)=>e(n,r,t);c.ThreadCommentPanelService=class extends a.Disposable{constructor(n,r){super();Y(this,"_panelVisible",!1);Y(this,"_panelVisible$",new X.BehaviorSubject(!1));Y(this,"_activeCommentId");Y(this,"_activeCommentId$",new X.BehaviorSubject(void 0));Y(this,"panelVisible$",this._panelVisible$.asObservable());Y(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=n,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(X.filter(n=>!n)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(n){this._panelVisible=n,this._panelVisible$.next(n)}setActiveComment(n){this._activeCommentId=n,this._activeCommentId$.next(n)}},c.ThreadCommentPanelService=_e([le(0,a.Inject(f.ISidebarService)),le(1,a.IUniverInstanceService)],c.ThreadCommentPanelService);const oe="thread-comment-panel",Te="UNIVER_THREAD_COMMENT_UI_PLUGIN",de={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(t){const e=t.get(f.ISidebarService),n=t.get(c.ThreadCommentPanelService);return n.panelVisible?(e.close(),n.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:oe},width:330}),n.setPanelVisible(!0)),!0}},z={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(t,e){return t.get(c.ThreadCommentPanelService).setActiveComment(e),!0}},Ne="thread-comment-ui.config",ue={};var Ue=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Oe=(t,e,n)=>e in t?Ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,De=(t,e,n,r)=>{for(var i=r>1?void 0:r?we(e,n):e,l=t.length-1,v;l>=0;l--)(v=t[l])&&(i=v(i)||i);return i},ae=(t,e)=>(n,r)=>e(n,r,t),ce=(t,e,n)=>Oe(t,typeof e!="symbol"?e+"":e,n);c.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ue,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;const{menu:l,...v}=a.merge({},ue,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(Ne,v)}onStarting(){var e;a.mergeOverrideWithDependencies([[c.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(n=>{this._injector.add(n)}),[de,z].forEach(n=>{this._commandService.registerCommand(n)})}},ce(c.UniverThreadCommentUIPlugin,"pluginName",Te),ce(c.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN),c.UniverThreadCommentUIPlugin=De([a.DependentOn(_.UniverThreadCommentPlugin),ae(1,a.Inject(a.Injector)),ae(2,a.ICommandService),ae(3,a.IConfigService)],c.UniverThreadCommentUIPlugin);var E=function(){return E=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},E.apply(this,arguments)},Ee=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n},K=d.forwardRef(function(t,e){var n=t.icon,r=t.id,i=t.className,l=t.extend,v=Ee(t,["icon","id","className","extend"]),C="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),I=d.useRef("_".concat(je()));return ve(n,"".concat(r),{defIds:n.defIds,idSuffix:I.current},E({ref:e,className:C},v),l)});function ve(t,e,n,r,i){return d.createElement(t.tag,E(E({key:e},ke(t,n,i)),r),(Me(t,n).children||[]).map(function(l,v){return ve(l,"".concat(e,"-").concat(t.tag,"-").concat(v),n,void 0,i)}))}function ke(t,e,n){var r=E({},t.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),t.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(l){var v=l[0],C=l[1];v==="mask"&&typeof C=="string"&&(r[v]=C.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(t.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(l){var v=l[0],C=l[1];typeof C=="string"&&(r[v]=C.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Me(t,e){var n,r=e.defIds;return!r||r.length===0?t:t.tag==="defs"&&(!((n=t.children)===null||n===void 0)&&n.length)?E(E({},t),{children:t.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?E(E({},i),{attrs:E(E({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):t}function je(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var Pe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},me=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"delete-single",ref:e,icon:Pe}))});me.displayName="DeleteSingle";var $e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},fe=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"increase-single",ref:e,icon:$e}))});fe.displayName="IncreaseSingle";var He={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},he=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"more-horizontal-single",ref:e,icon:He}))});he.displayName="MoreHorizontalSingle";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},pe=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"reply-to-comment-single",ref:e,icon:Le}))});pe.displayName="ReplyToCommentSingle";var Ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ge=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"resolved-single",ref:e,icon:Ve}))});ge.displayName="ResolvedSingle";var Be={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},Ce=d.forwardRef(function(t,e){return d.createElement(K,Object.assign({},t,{id:"solve-single",ref:e,icon:Be}))});Ce.displayName="SolveSingle";function Ie(t){return{id:"d",body:t,documentStyle:{}}}const be=d.forwardRef((t,e)=>{var V;const{comment:n,onSave:r,id:i,onCancel:l,autoFocus:v,unitId:C,type:I}=t,O=f.useDependency(a.ICommandService),k=f.useDependency(a.LocaleService),[F,M]=d.useState(!1),T=f.useDependency(se.IEditorService),h=d.useRef(null),p=I===a.UniverInstanceType.UNIVER_SHEET?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:C,[j,N]=d.useState(()=>{var m,g,b;return a.BuildTextUtils.transform.getPlainText((b=(g=(m=h.current)==null?void 0:m.getDocumentData().body)==null?void 0:g.dataStream)!=null?b:"")});d.useEffect(()=>{var g,b,U,y;N(a.BuildTextUtils.transform.getPlainText((U=(b=(g=h.current)==null?void 0:g.getDocumentData().body)==null?void 0:b.dataStream)!=null?U:""));const m=(y=h.current)==null?void 0:y.selectionChange$.subscribe(()=>{var o,w,G;N(a.BuildTextUtils.transform.getPlainText((G=(w=(o=h.current)==null?void 0:o.getDocumentData().body)==null?void 0:w.dataStream)!=null?G:""))});return()=>m==null?void 0:m.unsubscribe()},[(V=h.current)==null?void 0:V.selectionChange$]);const q=d.useMemo(()=>({keyCodes:[{keyCode:f.KeyCode.ENTER}],handler:m=>{m===f.KeyCode.ENTER&&O.executeCommand(se.BreakLineCommand.id)}}),[O]);d.useImperativeHandle(e,()=>({reply(m){var b,U;if(!h.current)return;T.focus((b=h.current.getEditorId())!=null?b:"");const g=Ie(m);(U=h.current)==null||U.setDocumentData(g,[{startOffset:g.body.dataStream.length-2,endOffset:g.body.dataStream.length-2,collapsed:!0}])}}));const x=()=>{if(h.current){const m=a.Tools.deepClone(h.current.getDocumentData().body);M(!1),r==null||r({...n,text:m}),h.current.replaceText(""),setTimeout(()=>{var g,b;(g=h.current)==null||g.setSelectionRanges([]),(b=h.current)==null||b.blur()},10)}};return s.jsxs("div",{onClick:m=>m.preventDefault(),children:[s.jsx(se.RichTextEditor,{className:"univer-w-full",editorRef:h,autoFocus:v,keyboardEventConfig:q,placeholder:k.t("threadCommentUI.editor.placeholder"),initialValue:(n==null?void 0:n.text)&&Ie(n.text),onFocusChange:m=>m&&M(m),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{T.focus(p)},30)}}),F?s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-end",children:[s.jsx(L.Button,{style:{marginRight:12},onClick:()=>{var m;l==null||l(),M(!1),(m=h.current)==null||m.replaceText("",!0),O.executeCommand(z.id)},children:k.t("threadCommentUI.editor.cancel")}),s.jsx(L.Button,{variant:"primary",disabled:!j,onClick:x,children:k.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ae=t=>{const{dataStream:e,customRanges:n}=t,r=e.endsWith(`\r
3
- `)?e.length-2:e.length,i=[];let l=0;return n==null||n.forEach(v=>{l<v.startIndex&&i.push({type:"text",content:e.slice(l,v.startIndex)}),i.push({type:"mention",content:{label:e.slice(v.startIndex,v.endIndex+1),id:v.rangeId}}),l=v.endIndex+1}),i.push({type:"text",content:e.slice(l,r)}),i},We=t=>{const{paragraphs:e=[]}=t;let n=0;return e.map(r=>{const i=a.getBodySlice(t,n,r.startIndex);return n=r.startIndex+1,Ae(i)})},Fe=t=>{let e="";const n=[];return t.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const i=e.length;e+=r.content.label;const l=e.length-1;n.push({rangeId:r.content.id,rangeType:a.CustomRangeType.MENTION,startIndex:i,endIndex:l,properties:{},wholeEntity:!0});break}}}),e+=`\r
4
- `,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:n}},ye="__mock__",qe=t=>{const{item:e,unitId:n,subUnitId:r,editing:i,onEditingChange:l,onReply:v,resolved:C,isRoot:I,onClose:O,onDeleteComment:k,type:F}=t,M=f.useDependency(a.ICommandService),T=f.useDependency(a.LocaleService),h=f.useDependency(a.UserManagerService),p=h.getUser(e.personId),j=f.useObservable(h.currentUser$),N=(j==null?void 0:j.userID)===e.personId,q=e.id===ye,[x,V]=d.useState(!1),m=f.useConfigValue(f.UI_PLUGIN_CONFIG_KEY),g=m==null?void 0:m.avatarFallback,b=()=>{(k==null?void 0:k(e))!==!1&&(M.executeCommand(I?_.DeleteCommentTreeCommand.id:_.DeleteCommentCommand.id,{unitId:n,subUnitId:r,commentId:e.id}),I&&(O==null||O()))};return s.jsxs("div",{className:"univer-relative univer-mb-3 univer-pl-[30px]",onMouseLeave:()=>V(!1),onMouseEnter:()=>V(!0),children:[s.jsx("div",{className:"univer-absolute univer-left-0 univer-top-0 univer-h-6 univer-w-6 univer-rounded-full univer-bg-cover univer-bg-center univer-bg-no-repeat",style:{backgroundImage:`url(${(p==null?void 0:p.avatar)||g})`}}),p?s.jsxs("div",{className:"univer-mb-1 univer-flex univer-h-6 univer-items-center univer-justify-between",children:[s.jsx("div",{className:"univer-text-sm univer-font-medium univer-leading-5",children:(p==null?void 0:p.name)||" "}),s.jsxs("div",{children:[q||C?null:x&&p?s.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50",onClick:()=>v(p),children:s.jsx(pe,{})}):null,N&&!q&&!C?s.jsx(L.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg",children:s.jsxs("ul",{className:"univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm [&_a]:univer-block [&_a]:univer-cursor-pointer [&_a]:univer-rounded [&_a]:univer-px-2 [&_a]:univer-py-1.5 [&_a]:univer-transition-colors",children:[s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>l==null?void 0:l(!0),children:T.t("threadCommentUI.item.edit")})}),s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:b,children:T.t("threadCommentUI.item.delete")})})]})}),children:s.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50",children:s.jsx(he,{})})}):null]})]}):null,s.jsx("time",{className:"univer-mb-1 univer-text-xs/normal univer-text-gray-600 dark:univer-text-gray-200",children:e.dT}),i?s.jsx(be,{type:F,id:e.id,comment:e,onCancel:()=>l==null?void 0:l(!1),autoFocus:!0,unitId:n,subUnitId:r,onSave:({text:U,attachments:y})=>{l==null||l(!1),M.executeCommand(_.UpdateCommentCommand.id,{unitId:n,subUnitId:r,payload:{commentId:e.id,text:U,attachments:y}})}}):s.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:univer-text-white",children:We(e.text).map((U,y)=>s.jsx("div",{className:"univer-break-words",children:U.map((o,w)=>{switch(o.type){case"mention":return s.jsxs("a",{className:"univer-text-primary-600",children:[o.content.label," "]},w);default:return o.content}})},y))})]})},xe=t=>{var ie,Q,u;const{id:e,unitId:n,subUnitId:r,refStr:i,showEdit:l=!0,onClick:v,showHighlight:C,onClose:I,getSubUnitName:O,prefix:k,autoFocus:F,onMouseEnter:M,onMouseLeave:T,onAddComment:h,onDeleteComment:p,onResolve:j,type:N,style:q,full:x}=t,V=f.useDependency(_.ThreadCommentModel),[m,g]=d.useState(!1),[b,U]=d.useState(""),y=d.useMemo(()=>V.commentUpdate$.pipe(X.debounceTime(16)),[V]);f.useObservable(y);const o=e?V.getCommentWithChildren(n,r,e):null,w=f.useDependency(a.ICommandService),G=f.useDependency(a.UserManagerService),P=o==null?void 0:o.root.resolved,$=f.useObservable(G.currentUser$),A=d.useRef(null),R=[...o?[o.root]:[{id:ye,text:{dataStream:`
5
- \r`},personId:(ie=$==null?void 0:$.userID)!=null?ie:"",ref:i!=null?i:"",dT:"",unitId:n,subUnitId:r,threadId:""}],...(Q=o==null?void 0:o.children)!=null?Q:[]],B=d.useRef(null),ee=S=>{S.stopPropagation(),P?w.executeCommand(z.id,{unitId:n,subUnitId:r,commentId:e}):w.executeCommand(z.id),w.executeCommand(_.ResolveCommentCommand.id,{unitId:n,subUnitId:r,commentId:e,resolved:!P}),j==null||j(!P)},J=S=>{S.stopPropagation(),w.executeCommand(z.id),!(o!=null&&o.root&&(p==null?void 0:p(o.root))===!1)&&(w.executeCommand(_.DeleteCommentTreeCommand.id,{unitId:n,subUnitId:r,commentId:e}),I==null||I())};d.useEffect(()=>T==null?void 0:T(),[]);const ne=O((u=o==null?void 0:o.root.subUnitId)!=null?u:r),te=l&&!b&&!P,re=`${i||(o==null?void 0:o.root.ref)||""}${ne?" · ":""}${ne}`;return s.jsxs("div",{id:`${k}-${n}-${r}-${e}`,className:L.clsx(`
6
- univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4
7
- dark:univer-bg-gray-900 dark:univer-text-white
8
- `,L.borderClassName,{"univer-w-[278px]":!x,"univer-w-full":x,"univer-shadow":!P&&(C||m||k==="cell")}),style:q,onClick:v,onMouseEnter:()=>{M==null||M(),g(!0)},onMouseLeave:()=>{T==null||T(),g(!1)},children:[!P&&C?s.jsx("div",{className:"univer-absolute univer-left-0 univer-right-0 univer-top-0 univer-h-1.5 univer-rounded-t-md univer-bg-yellow-400"}):null,s.jsxs("div",{className:"univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm univer-leading-5",children:[s.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden",children:[s.jsx("div",{className:"univer-mr-2 univer-h-3.5 univer-w-[3px] univer-flex-shrink-0 univer-flex-grow-0 univer-rounded-sm univer-bg-yellow-500"}),s.jsx(L.Tooltip,{showIfEllipsis:!0,title:re,children:s.jsx("div",{className:"univer-flex-1 univer-truncate",children:re})})]}),o?s.jsxs("div",{className:"univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row",children:[s.jsx("div",{className:L.clsx(`
9
- univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer
10
- univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base
11
- dark:hover:univer-bg-gray-800
12
- hover:univer-bg-gray-50
13
- `,{"univer-text-green-500":P}),onClick:ee,children:P?s.jsx(ge,{}):s.jsx(Ce,{})}),($==null?void 0:$.userID)===o.root.personId?s.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base dark:hover:univer-bg-gray-800 hover:univer-bg-gray-50",onClick:J,children:s.jsx(me,{})}):null]}):null]}),s.jsx("div",{ref:B,className:"univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden",children:R.map(S=>s.jsx(qe,{onClose:I,unitId:n,subUnitId:r,item:S,isRoot:S.id===(o==null?void 0:o.root.id),editing:b===S.id,resolved:o==null?void 0:o.root.resolved,type:N,onEditingChange:H=>{U(H?S.id:"")},onReply:H=>{H&&requestAnimationFrame(()=>{var W;(W=A.current)==null||W.reply(Fe([{type:"mention",content:{id:H.userID,label:`@${H.name}`}},{type:"text",content:" "}]))})},onAddComment:h,onDeleteComment:p},S.id))}),te?s.jsx("div",{children:s.jsx(be,{ref:A,type:N,unitId:n,subUnitId:r,onSave:async({text:S,attachments:H})=>{const W={text:S,attachments:H,dT:_.getDT(),id:a.generateRandomId(),ref:i,personId:$==null?void 0:$.userID,parentId:o==null?void 0:o.root.id,unitId:n,subUnitId:r,threadId:o==null?void 0:o.root.threadId};(h==null?void 0:h(W))!==!1&&(await w.executeCommand(_.AddCommentCommand.id,{unitId:n,subUnitId:r,comment:W}),B.current&&(B.current.scrollTop=B.current.scrollHeight))},autoFocus:F||!o,onCancel:()=>{o||I==null||I()}},`${F}`)}):null]})},ze=t=>{const{unitId:e,subUnitId$:n,type:r,onAdd:i,getSubUnitName:l,onResolve:v,sortComments:C,onItemLeave:I,onItemEnter:O,disableAdd:k,tempComment:F,onAddComment:M,onDeleteComment:T,showComments:h}=t,[p,j]=d.useState("all"),[N,q]=d.useState("all"),x=f.useDependency(a.LocaleService),V=f.useDependency(a.UserManagerService),m=f.useDependency(_.ThreadCommentModel),[g,b]=d.useState(()=>m.getUnit(e)),U=f.useDependency(c.ThreadCommentPanelService),y=f.useObservable(U.activeCommentId$),o=f.useObservable(m.commentUpdate$),w=f.useDependency(a.ICommandService),G=f.useObservable(n),P=d.useRef(!0),$="panel",A=f.useObservable(V.currentUser$),R=d.useMemo(()=>{var W;const u=p==="all"?g:(W=g.filter(D=>D.subUnitId===G))!=null?W:[],S=C!=null?C:D=>D,H=u.map(D=>{var Z;return{...D.root,children:(Z=D.children)!=null?Z:[],users:D.relativeUsers}});if(h){const D=new Map;return H.forEach(Z=>{D.set(Z.id,Z)}),[...h,""].map(Z=>D.get(Z)).filter(Boolean)}else return S(H)},[h,p,g,C,G]),B=d.useMemo(()=>[...R.filter(u=>!u.resolved),...R.filter(u=>u.resolved)],[R]),ee=d.useMemo(()=>N==="resolved"?B.filter(u=>u.resolved):N==="unsolved"?B.filter(u=>!u.resolved):N==="concern_me"&&A!=null&&A.userID?B.filter(u=>u==null?void 0:u.users.has(A.userID)):B,[B,A==null?void 0:A.userID,N]),J=F?[F,...ee]:ee,ne=J.filter(u=>!u.resolved),te=J.filter(u=>u.resolved),re=N!=="all"||p!=="all",ie=()=>{q("all"),j("all")};d.useEffect(()=>{e&&b(m.getUnit(e))},[e,m,o]),d.useEffect(()=>{var D;if(!y)return;if(!P.current){P.current=!0;return}const{unitId:u,subUnitId:S,commentId:H}=y,W=`${$}-${u}-${S}-${H}`;(D=document.getElementById(W))==null||D.scrollIntoView({block:"center"})},[y]);const Q=u=>s.jsx(xe,{full:!0,prefix:$,getSubUnitName:l,id:u.id,unitId:u.unitId,subUnitId:u.subUnitId,refStr:u.ref,type:r,showEdit:(y==null?void 0:y.commentId)===u.id,showHighlight:(y==null?void 0:y.commentId)===u.id,onClick:()=>{P.current=!1,u.resolved?w.executeCommand(z.id):w.executeCommand(z.id,{unitId:u.unitId,subUnitId:u.subUnitId,commentId:u.id,temp:!1})},onMouseEnter:()=>O==null?void 0:O(u),onMouseLeave:()=>I==null?void 0:I(u),onAddComment:M,onDeleteComment:T,onResolve:S=>v==null?void 0:v(u.id,S)},u.id);return s.jsxs("div",{className:"univer-flex univer-min-h-full univer-flex-col univer-pb-3",children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-between",children:[r===a.UniverInstanceType.UNIVER_SHEET?s.jsx(L.Select,{borderless:!0,value:p,options:[{value:"current",label:x.t("threadCommentUI.filter.sheet.current")},{value:"all",label:x.t("threadCommentUI.filter.sheet.all")}],onChange:j}):null,s.jsx(L.Select,{borderless:!0,value:N,options:[{value:"all",label:x.t("threadCommentUI.filter.status.all")},{value:"resolved",label:x.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:x.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:x.t("threadCommentUI.filter.status.concernMe")}],onChange:q})]}),J.length===0?s.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:[x.t("threadCommentUI.panel.empty"),re?s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsx(L.Button,{onClick:ie,children:x.t("threadCommentUI.panel.reset")})}):k?null:s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsxs(L.Button,{onClick:i,children:[s.jsx(fe,{className:"univer-mr-1.5"}),x.t("threadCommentUI.panel.add")]})})]}):s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-col univer-gap-3",children:[ne.map(Q),te.length>0&&s.jsx("div",{className:"univer-text-xs",children:x.t("threadCommentUI.panel.solved")}),te.map(Q)]})]})};c.SetActiveCommentOperation=z,c.THREAD_COMMENT_PANEL=oe,c.ThreadCommentPanel=ze,c.ThreadCommentTree=xe,c.ToggleSheetCommentPanelOperation=de,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
2
+ (function(u,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/docs-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","@univerjs/design","react","@univerjs/docs-ui"],a):(u=typeof globalThis<"u"?globalThis:u||self,a(u.UniverThreadCommentUi={},u.UniverCore,u.UniverThreadComment,u.UniverUi,u.rxjs,u.React,u.UniverDesign,u.React,u.UniverDocsUi))})(this,function(u,a,w,f,X,s,O,d,se){"use strict";var Ke=Object.defineProperty;var Ge=(u,a,w)=>a in u?Ke(u,a,{enumerable:!0,configurable:!0,writable:!0,value:w}):u[a]=w;var Y=(u,a,w)=>Ge(u,typeof a!="symbol"?a+"":a,w);var Se=Object.getOwnPropertyDescriptor,we=(n,e,t,r)=>{for(var i=r>1?void 0:r?Se(e,t):e,o=n.length-1,v;o>=0;o--)(v=n[o])&&(i=v(i)||i);return i},oe=(n,e)=>(t,r)=>e(t,r,n);u.ThreadCommentPanelService=class extends a.Disposable{constructor(t,r){super();Y(this,"_panelVisible",!1);Y(this,"_panelVisible$",new X.BehaviorSubject(!1));Y(this,"_activeCommentId");Y(this,"_activeCommentId$",new X.BehaviorSubject(void 0));Y(this,"panelVisible$",this._panelVisible$.asObservable());Y(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(X.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}},u.ThreadCommentPanelService=we([oe(0,a.Inject(f.ISidebarService)),oe(1,a.IUniverInstanceService)],u.ThreadCommentPanelService);const le="thread-comment-panel",_e="UNIVER_THREAD_COMMENT_UI_PLUGIN",de={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(n){const e=n.get(f.ISidebarService),t=n.get(u.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:le},width:330}),t.setPanelVisible(!0)),!0}},q={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(n,e){return n.get(u.ThreadCommentPanelService).setActiveComment(e),!0}},Te="thread-comment-ui.config",ce={};var Ne=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Oe=(n,e,t)=>e in n?Ne(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,De=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ue(e,t):e,o=n.length-1,v;o>=0;o--)(v=n[o])&&(i=v(i)||i);return i},ae=(n,e)=>(t,r)=>e(t,r,n),ue=(n,e,t)=>Oe(n,typeof e!="symbol"?e+"":e,t);u.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ce,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;const{menu:o,...v}=a.merge({},ce,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Te,v)}onStarting(){var e;a.mergeOverrideWithDependencies([[u.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[de,q].forEach(t=>{this._commandService.registerCommand(t)})}},ue(u.UniverThreadCommentUIPlugin,"pluginName",_e),ue(u.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN),u.UniverThreadCommentUIPlugin=De([a.DependentOn(w.UniverThreadCommentPlugin),ae(1,a.Inject(a.Injector)),ae(2,a.ICommandService),ae(3,a.IConfigService)],u.UniverThreadCommentUIPlugin);var k=function(){return k=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},k.apply(this,arguments)},Ee=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},K=d.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,o=n.extend,v=Ee(n,["icon","id","className","extend"]),g="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),I=d.useRef("_".concat(je()));return ve(t,"".concat(r),{defIds:t.defIds,idSuffix:I.current},k({ref:e,className:g},v),o)});function ve(n,e,t,r,i){return d.createElement(n.tag,k(k({key:e},ke(n,t,i)),r),(Me(n,t).children||[]).map(function(o,v){return ve(o,"".concat(e,"-").concat(n.tag,"-").concat(v),t,void 0,i)}))}function ke(n,e,t){var r=k({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(o){var v=o[0],g=o[1];v==="mask"&&typeof g=="string"&&(r[v]=g.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(o){var v=o[0],g=o[1];typeof g=="string"&&(r[v]=g.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Me(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?k(k({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.includes(i.attrs.id)?k(k({},i),{attrs:k(k({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function je(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},me=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"delete-icon",ref:e,icon:Pe}))});me.displayName="DeleteIcon";var $e={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},fe=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"increase-icon",ref:e,icon:$e}))});fe.displayName="IncreaseIcon";var Le={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8C4 7.44772 3.55228 7 3 7C2.44772 7 2 7.44772 2 8C2 8.55228 2.44772 9 3 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8 9C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7C7.44772 7 7 7.44772 7 8C7 8.55228 7.44772 9 8 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M13 9C13.5523 9 14 8.55228 14 8C14 7.44772 13.5523 7 13 7C12.4477 7 12 7.44772 12 8C12 8.55228 12.4477 9 13 9Z"}}]},he=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"more-horizontal-icon",ref:e,icon:Le}))});he.displayName="MoreHorizontalIcon";var He={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813",strokeLinecap:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M8.91626 6.1311H9.27424",strokeLinecap:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},pe=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"reply-to-comment-icon",ref:e,icon:He}))});pe.displayName="ReplyToCommentIcon";var Ve={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ce=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"resolved-icon",ref:e,icon:Ve}))});Ce.displayName="ResolvedIcon";var Be={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},ge=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"solve-icon",ref:e,icon:Be}))});ge.displayName="SolveIcon";function Ie(n){return{id:"d",body:n,documentStyle:{}}}const be=d.forwardRef((n,e)=>{var V;const{comment:t,onSave:r,id:i,onCancel:o,autoFocus:v,unitId:g,type:I}=n,D=f.useDependency(a.ICommandService),M=f.useDependency(a.LocaleService),[Z,j]=d.useState(!1),_=f.useDependency(se.IEditorService),h=d.useRef(null),p=I===a.UniverInstanceType.UNIVER_SHEET?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:g,[P,T]=d.useState(()=>{var m,C,b;return a.BuildTextUtils.transform.getPlainText((b=(C=(m=h.current)==null?void 0:m.getDocumentData().body)==null?void 0:C.dataStream)!=null?b:"")});d.useEffect(()=>{var C,b,N,x;T(a.BuildTextUtils.transform.getPlainText((N=(b=(C=h.current)==null?void 0:C.getDocumentData().body)==null?void 0:b.dataStream)!=null?N:""));const m=(x=h.current)==null?void 0:x.selectionChange$.subscribe(()=>{var l,U,G;T(a.BuildTextUtils.transform.getPlainText((G=(U=(l=h.current)==null?void 0:l.getDocumentData().body)==null?void 0:U.dataStream)!=null?G:""))});return()=>m==null?void 0:m.unsubscribe()},[(V=h.current)==null?void 0:V.selectionChange$]);const F=d.useMemo(()=>({keyCodes:[{keyCode:f.KeyCode.ENTER}],handler:m=>{m===f.KeyCode.ENTER&&D.executeCommand(se.BreakLineCommand.id)}}),[D]);d.useImperativeHandle(e,()=>({reply(m){var b,N;if(!h.current)return;_.focus((b=h.current.getEditorId())!=null?b:"");const C=Ie(m);(N=h.current)==null||N.setDocumentData(C,[{startOffset:C.body.dataStream.length-2,endOffset:C.body.dataStream.length-2,collapsed:!0}])}}));const y=()=>{if(h.current){const m=a.Tools.deepClone(h.current.getDocumentData().body);j(!1),r==null||r({...t,text:m}),h.current.replaceText(""),setTimeout(()=>{var C,b;(C=h.current)==null||C.setSelectionRanges([]),(b=h.current)==null||b.blur()},10)}};return s.jsxs("div",{onClick:m=>m.preventDefault(),children:[s.jsx(se.RichTextEditor,{className:"univer-w-full",editorRef:h,autoFocus:v,keyboardEventConfig:F,placeholder:M.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&Ie(t.text),onFocusChange:m=>m&&j(m),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{_.focus(p)},30)}}),Z?s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[s.jsx(O.Button,{onClick:()=>{var m;o==null||o(),j(!1),(m=h.current)==null||m.replaceText("",!0),D.executeCommand(q.id)},children:M.t("threadCommentUI.editor.cancel")}),s.jsx(O.Button,{variant:"primary",disabled:!P,onClick:y,children:M.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ae=n=>{const{dataStream:e,customRanges:t}=n,r=e.endsWith(`\r
3
+ `)?e.length-2:e.length,i=[];let o=0;return t==null||t.forEach(v=>{o<v.startIndex&&i.push({type:"text",content:e.slice(o,v.startIndex)}),i.push({type:"mention",content:{label:e.slice(v.startIndex,v.endIndex+1),id:v.rangeId}}),o=v.endIndex+1}),i.push({type:"text",content:e.slice(o,r)}),i},We=n=>{const{paragraphs:e=[]}=n;let t=0;return e.map(r=>{const i=a.getBodySlice(n,t,r.startIndex);return t=r.startIndex+1,Ae(i)})},Ze=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const i=e.length;e+=r.content.label;const o=e.length-1;t.push({rangeId:r.content.id,rangeType:a.CustomRangeType.MENTION,startIndex:i,endIndex:o,properties:{},wholeEntity:!0});break}}}),e+=`\r
4
+ `,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},xe="__mock__",Fe=n=>{const{item:e,unitId:t,subUnitId:r,editing:i,onEditingChange:o,onReply:v,resolved:g,isRoot:I,onClose:D,onDeleteComment:M,type:Z}=n,j=f.useDependency(a.ICommandService),_=f.useDependency(a.LocaleService),h=f.useDependency(a.UserManagerService),p=h.getUser(e.personId),P=f.useObservable(h.currentUser$),T=(P==null?void 0:P.userID)===e.personId,F=e.id===xe,[y,V]=d.useState(!1),m=f.useConfigValue(f.UI_PLUGIN_CONFIG_KEY),C=m==null?void 0:m.avatarFallback,b=()=>{(M==null?void 0:M(e))!==!1&&(j.executeCommand(I?w.DeleteCommentTreeCommand.id:w.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),I&&(D==null||D()))};return s.jsxs("div",{className:"univer-relative univer-mb-3 univer-pl-[30px]",onMouseLeave:()=>V(!1),onMouseEnter:()=>V(!0),children:[s.jsx("div",{className:"univer-absolute univer-left-0 univer-top-0 univer-h-6 univer-w-6 univer-rounded-full univer-bg-cover univer-bg-center univer-bg-no-repeat",style:{backgroundImage:`url(${(p==null?void 0:p.avatar)||C})`}}),p?s.jsxs("div",{className:"univer-mb-1 univer-flex univer-h-6 univer-items-center univer-justify-between",children:[s.jsx("div",{className:"univer-text-sm univer-font-medium univer-leading-5",children:(p==null?void 0:p.name)||" "}),s.jsxs("div",{children:[F||g?null:y&&p?s.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50",onClick:()=>v(p),children:s.jsx(pe,{})}):null,T&&!F&&!g?s.jsx(O.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg",children:s.jsxs("ul",{className:"univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm [&_a]:univer-block [&_a]:univer-cursor-pointer [&_a]:univer-rounded [&_a]:univer-px-2 [&_a]:univer-py-1.5 [&_a]:univer-transition-colors",children:[s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>o==null?void 0:o(!0),children:_.t("threadCommentUI.item.edit")})}),s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:b,children:_.t("threadCommentUI.item.delete")})})]})}),children:s.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-text-base hover:univer-bg-gray-50",children:s.jsx(he,{})})}):null]})]}):null,s.jsx("time",{className:"univer-mb-1 univer-text-xs/normal univer-text-gray-600 dark:!univer-text-gray-200",children:e.dT}),i?s.jsx(be,{type:Z,id:e.id,comment:e,onCancel:()=>o==null?void 0:o(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:N,attachments:x})=>{o==null||o(!1),j.executeCommand(w.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:N,attachments:x}})}}):s.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:We(e.text).map((N,x)=>s.jsx("div",{className:"univer-break-words",children:N.map((l,U)=>{switch(l.type){case"mention":return s.jsxs("a",{className:"univer-text-primary-600",children:[l.content.label," "]},U);default:return l.content}})},x))})]})},ye=n=>{var ie,Q,c;const{id:e,unitId:t,subUnitId:r,refStr:i,showEdit:o=!0,onClick:v,showHighlight:g,onClose:I,getSubUnitName:D,prefix:M,autoFocus:Z,onMouseEnter:j,onMouseLeave:_,onAddComment:h,onDeleteComment:p,onResolve:P,type:T,style:F,full:y}=n,V=f.useDependency(w.ThreadCommentModel),[m,C]=d.useState(!1),[b,N]=d.useState(""),x=d.useMemo(()=>V.commentUpdate$.pipe(X.debounceTime(16)),[V]);f.useObservable(x);const l=e?V.getCommentWithChildren(t,r,e):null,U=f.useDependency(a.ICommandService),G=f.useDependency(a.UserManagerService),$=l==null?void 0:l.root.resolved,L=f.useObservable(G.currentUser$),A=d.useRef(null),R=[...l?[l.root]:[{id:xe,text:{dataStream:`
5
+ \r`},personId:(ie=L==null?void 0:L.userID)!=null?ie:"",ref:i!=null?i:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(Q=l==null?void 0:l.children)!=null?Q:[]],B=d.useRef(null),ee=S=>{S.stopPropagation(),$?U.executeCommand(q.id,{unitId:t,subUnitId:r,commentId:e}):U.executeCommand(q.id),U.executeCommand(w.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!$}),P==null||P(!$)},J=S=>{S.stopPropagation(),U.executeCommand(q.id),!(l!=null&&l.root&&(p==null?void 0:p(l.root))===!1)&&(U.executeCommand(w.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),I==null||I())};d.useEffect(()=>_==null?void 0:_(),[]);const te=D((c=l==null?void 0:l.root.subUnitId)!=null?c:r),ne=o&&!b&&!$,re=`${i||(l==null?void 0:l.root.ref)||""}${te?" · ":""}${te}`;return s.jsxs("div",{id:`${M}-${t}-${r}-${e}`,className:O.clsx("univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4 dark:!univer-bg-gray-900 dark:!univer-text-white",O.borderClassName,{"univer-w-[278px]":!y,"univer-w-full":y,"univer-shadow":!$&&(g||m||M==="cell")}),style:F,onClick:v,onMouseEnter:()=>{j==null||j(),C(!0)},onMouseLeave:()=>{_==null||_(),C(!1)},children:[!$&&g&&s.jsx("div",{className:"univer-absolute univer-left-0 univer-right-0 univer-top-0 univer-h-1.5 univer-rounded-t-md univer-bg-yellow-400"}),s.jsxs("div",{className:"univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm univer-leading-5",children:[s.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden",children:[s.jsx("div",{className:"univer-mr-2 univer-h-3.5 univer-w-[3px] univer-flex-shrink-0 univer-flex-grow-0 univer-rounded-sm univer-bg-yellow-500"}),s.jsx(O.Tooltip,{showIfEllipsis:!0,title:re,children:s.jsx("div",{className:"univer-flex-1 univer-truncate",children:re})})]}),!!l&&s.jsxs("div",{className:"univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row",children:[s.jsx("div",{className:O.clsx("univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base dark:hover:!univer-bg-gray-800 hover:univer-bg-gray-50",{"univer-text-green-500":$}),onClick:ee,children:$?s.jsx(Ce,{}):s.jsx(ge,{})}),(L==null?void 0:L.userID)===l.root.personId?s.jsx("div",{className:"univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-text-base dark:hover:!univer-bg-gray-800 hover:univer-bg-gray-50",onClick:J,children:s.jsx(me,{})}):null]})]}),s.jsx("div",{ref:B,className:O.clsx("univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden",O.scrollbarClassName),children:R.map(S=>s.jsx(Fe,{unitId:t,subUnitId:r,item:S,isRoot:S.id===(l==null?void 0:l.root.id),editing:b===S.id,resolved:l==null?void 0:l.root.resolved,type:T,onClose:I,onEditingChange:H=>{N(H?S.id:"")},onReply:H=>{H&&requestAnimationFrame(()=>{var W;(W=A.current)==null||W.reply(Ze([{type:"mention",content:{id:H.userID,label:`@${H.name}`}},{type:"text",content:" "}]))})},onAddComment:h,onDeleteComment:p},S.id))}),ne&&s.jsx("div",{children:s.jsx(be,{ref:A,type:T,unitId:t,subUnitId:r,onSave:async({text:S,attachments:H})=>{const W={text:S,attachments:H,dT:w.getDT(),id:a.generateRandomId(),ref:i,personId:L==null?void 0:L.userID,parentId:l==null?void 0:l.root.id,unitId:t,subUnitId:r,threadId:l==null?void 0:l.root.threadId};(h==null?void 0:h(W))!==!1&&(await U.executeCommand(w.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:W}),B.current&&(B.current.scrollTop=B.current.scrollHeight))},autoFocus:Z||!l,onCancel:()=>{l||I==null||I()}},`${Z}`)})]})},qe=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:i,getSubUnitName:o,onResolve:v,sortComments:g,onItemLeave:I,onItemEnter:D,disableAdd:M,tempComment:Z,onAddComment:j,onDeleteComment:_,showComments:h}=n,[p,P]=d.useState("all"),[T,F]=d.useState("all"),y=f.useDependency(a.LocaleService),V=f.useDependency(a.UserManagerService),m=f.useDependency(w.ThreadCommentModel),[C,b]=d.useState(()=>m.getUnit(e)),N=f.useDependency(u.ThreadCommentPanelService),x=f.useObservable(N.activeCommentId$),l=f.useObservable(m.commentUpdate$),U=f.useDependency(a.ICommandService),G=f.useObservable(t),$=d.useRef(!0),L="panel",A=f.useObservable(V.currentUser$),R=d.useMemo(()=>{var W;const c=p==="all"?C:(W=C.filter(E=>E.subUnitId===G))!=null?W:[],S=g!=null?g:E=>E,H=c.map(E=>{var z;return{...E.root,children:(z=E.children)!=null?z:[],users:E.relativeUsers}});if(h){const E=new Map;return H.forEach(z=>{E.set(z.id,z)}),[...h,""].map(z=>E.get(z)).filter(Boolean)}else return S(H)},[h,p,C,g,G]),B=d.useMemo(()=>[...R.filter(c=>!c.resolved),...R.filter(c=>c.resolved)],[R]),ee=d.useMemo(()=>T==="resolved"?B.filter(c=>c.resolved):T==="unsolved"?B.filter(c=>!c.resolved):T==="concern_me"&&A!=null&&A.userID?B.filter(c=>c==null?void 0:c.users.has(A.userID)):B,[B,A==null?void 0:A.userID,T]),J=Z?[Z,...ee]:ee,te=J.filter(c=>!c.resolved),ne=J.filter(c=>c.resolved),re=T!=="all"||p!=="all",ie=()=>{F("all"),P("all")};d.useEffect(()=>{e&&b(m.getUnit(e))},[e,m,l]),d.useEffect(()=>{var E;if(!x)return;if(!$.current){$.current=!0;return}const{unitId:c,subUnitId:S,commentId:H}=x,W=`${L}-${c}-${S}-${H}`;(E=document.getElementById(W))==null||E.scrollIntoView({block:"center"})},[x]);const Q=c=>s.jsx(ye,{full:!0,prefix:L,getSubUnitName:o,id:c.id,unitId:c.unitId,subUnitId:c.subUnitId,refStr:c.ref,type:r,showEdit:(x==null?void 0:x.commentId)===c.id,showHighlight:(x==null?void 0:x.commentId)===c.id,onClick:()=>{$.current=!1,c.resolved?U.executeCommand(q.id):U.executeCommand(q.id,{unitId:c.unitId,subUnitId:c.subUnitId,commentId:c.id,temp:!1})},onMouseEnter:()=>D==null?void 0:D(c),onMouseLeave:()=>I==null?void 0:I(c),onAddComment:j,onDeleteComment:_,onResolve:S=>v==null?void 0:v(c.id,S)},c.id);return s.jsxs("div",{className:"univer-flex univer-min-h-full univer-flex-col univer-pb-3",children:[s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-row univer-justify-between",children:[r===a.UniverInstanceType.UNIVER_SHEET?s.jsx(O.Select,{borderless:!0,value:p,options:[{value:"current",label:y.t("threadCommentUI.filter.sheet.current")},{value:"all",label:y.t("threadCommentUI.filter.sheet.all")}],onChange:P}):null,s.jsx(O.Select,{borderless:!0,value:T,options:[{value:"all",label:y.t("threadCommentUI.filter.status.all")},{value:"resolved",label:y.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:y.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:y.t("threadCommentUI.filter.status.concernMe")}],onChange:F})]}),J.length===0?s.jsxs("div",{className:"univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[y.t("threadCommentUI.panel.empty"),re?s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsx(O.Button,{onClick:ie,children:y.t("threadCommentUI.panel.reset")})}):M?null:s.jsx("div",{className:"univer-mt-2 univer-flex univer-flex-row",children:s.jsxs(O.Button,{onClick:i,children:[s.jsx(fe,{className:"univer-mr-1.5"}),y.t("threadCommentUI.panel.add")]})})]}):s.jsxs("div",{className:"univer-mt-3 univer-flex univer-flex-col univer-gap-3",children:[te.map(Q),ne.length>0&&s.jsx("div",{className:"univer-text-xs",children:y.t("threadCommentUI.panel.solved")}),ne.map(Q)]})]})};u.SetActiveCommentOperation=q,u.THREAD_COMMENT_PANEL=le,u.ThreadCommentPanel=qe,u.ThreadCommentTree=ye,u.ToggleSheetCommentPanelOperation=de,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
14
6
 
15
7
 
16
8
  // @univerjs/docs-thread-comment-ui/index
17
- (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/thread-comment-ui"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/thread-comment-ui","@univerjs/docs","@univerjs/docs-ui","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","react"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverDocsThreadCommentUi={},c.UniverCore,c.UniverEngineRender,c.UniverThreadCommentUi,c.UniverDocs,c.UniverDocsUi,c.UniverThreadComment,c.UniverUi,c.rxjs,c.React,c.React))})(this,function(c,o,S,O,T,A,w,u,U,ie,D){"use strict";var be=Object.defineProperty;var Ue=(c,o,S)=>o in c?be(c,o,{enumerable:!0,configurable:!0,writable:!0,value:S}):c[o]=S;var k=(c,o,S)=>Ue(c,typeof o!="symbol"?o+"":o,S);const re="DOC_THREAD_COMMENT_UI_PLUGIN",M="default_doc",oe="docs-thread-comment-ui.config",J={};var se=Object.getOwnPropertyDescriptor,de=(e,t,i,n)=>{for(var r=n>1?void 0:n?se(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},Y=(e,t)=>(i,n)=>t(i,n,e);let x=class extends o.Disposable{constructor(t,i){super();k(this,"_addingComment$",new U.BehaviorSubject(void 0));k(this,"addingComment$",this._addingComment$.asObservable());this._sidebarService=t,this._threadCommentPanelService=i,this.disposeWithMe(()=>{this._addingComment$.complete()})}get addingComment(){return this._addingComment$.getValue()}startAdd(t){this._addingComment$.next(t)}endAdd(){this._addingComment$.next(void 0)}};x=de([Y(0,u.ISidebarService),Y(1,o.Inject(O.ThreadCommentPanelService))],x);const H={id:"docs.command.add-comment",type:o.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{comment:i,unitId:n}=t,s=await e.get(w.IThreadCommentDataSourceService).addComment(i),d=e.get(o.ICommandService),a=A.addCustomDecorationBySelectionFactory(e,{id:s.threadId,type:o.CustomDecorationType.COMMENT,unitId:n});if(a){const C={id:w.AddCommentMutation.id,params:{unitId:n,subUnitId:M,comment:s}},h={id:O.SetActiveCommentOperation.id,params:{unitId:n,subUnitId:M,commentId:s.id}};return(await o.sequenceExecute([C,a,h],d)).result}return!1}},L={id:"docs.command.delete-comment",type:o.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{commentId:i,unitId:n}=t,r=e.get(o.ICommandService),s=A.deleteCustomDecorationFactory(e,{id:i,unitId:n});return s?(await o.sequenceExecute([s],r)).result:!1}},Q=e=>{var d;const t=e.get(S.IRenderManagerService),i=e.get(T.DocSelectionManagerService),n=(d=S.withCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_DOC,T.DocSkeletonManagerService,e.get(o.IUniverInstanceService),t))==null?void 0:d.getSkeleton(),r=n==null?void 0:n.getViewModel().getEditArea();if(r===S.DocumentEditArea.FOOTER||r===S.DocumentEditArea.HEADER)return!0;const s=i.getActiveTextRange();return!!(s==null||s.collapsed)};function ae(e){return{id:V.id,type:u.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:u.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,void 0,o.SHEET_EDITOR_UNITS),disabled$:new U.Observable(function(t){const n=e.get(T.DocSelectionManagerService).textSelection$.pipe(U.debounceTime(16)).subscribe(()=>{t.next(Q(e))});return()=>{n.unsubscribe()}})}}function ce(e){return{id:W.id,type:u.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:u.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC)}}const R=()=>{const e=u.useDependency(o.IUniverInstanceService),t=u.useDependency(o.Injector),i=D.useMemo(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_DOC).pipe(U.filter(m=>!!m&&!o.isInternalEditorID(m.getUnitId()))),[e]),n=u.useObservable(i),r=D.useMemo(()=>new U.Observable(m=>m.next(M)),[]),s=u.useDependency(T.DocSelectionManagerService),d=D.useMemo(()=>s.textSelection$.pipe(U.debounceTime(16)),[s.textSelection$]);u.useObservable(d);const a=u.useDependency(o.ICommandService),C=u.useDependency(x),h=u.useObservable(C.addingComment$),[l,I]=D.useState([]);if(D.useEffect(()=>{var j;const m=new Set,v=n==null?void 0:n.getCustomDecorations();I((j=v==null?void 0:v.map(f=>f.id).filter(f=>{const b=m.has(f);return m.add(f),!b}))!=null?j:[]);const y=a.onCommandExecuted(f=>{var b;if(f.id===T.RichTextEditingMutation.id){const $=new Set,z=n==null?void 0:n.getCustomDecorations();I((b=z==null?void 0:z.map(F=>F.id).filter(F=>{const ye=$.has(F);return $.add(F),!ye}))!=null?b:[])}});return()=>{y.dispose()}},[a,n]),!n)return null;const _=Q(t),g=n.getUnitId();return ie.jsx(O.ThreadCommentPanel,{unitId:g,subUnitId$:r,type:o.UniverInstanceType.UNIVER_DOC,onAdd:()=>{a.executeCommand(V.id)},getSubUnitName:()=>"",disableAdd:_,tempComment:h,onAddComment:m=>{if(!m.parentId){const v={unitId:g,range:h,comment:m};return a.executeCommand(H.id,v),C.endAdd(),!1}return!0},onDeleteComment:m=>{if(!m.parentId){const v={unitId:g,commentId:m.id};return a.executeCommand(L.id,v),!1}return!0},showComments:l})};R.componentKey="univer.doc.thread-comment-panel";const N={id:"docs.operation.show-comment-panel",type:o.CommandType.OPERATION,handler(e,t){var r;const i=e.get(O.ThreadCommentPanelService),n=e.get(u.ISidebarService);return(!i.panelVisible||((r=n.options.children)==null?void 0:r.label)!==R.componentKey)&&(n.open({header:{title:"threadCommentUI.panel.title"},children:{label:R.componentKey},width:320,onClose:()=>i.setPanelVisible(!1)}),i.setPanelVisible(!0)),t&&i.setActiveComment(t==null?void 0:t.activeComment),!0}},W={id:"docs.operation.toggle-comment-panel",type:o.CommandType.OPERATION,handler(e){var n;const t=e.get(O.ThreadCommentPanelService),i=e.get(u.ISidebarService);return!t.panelVisible||((n=i.options.children)==null?void 0:n.label)!==R.componentKey?(i.open({header:{title:"threadCommentUI.panel.title"},children:{label:R.componentKey},width:320,onClose:()=>t.setPanelVisible(!1)}),t.setPanelVisible(!0)):(i.close(),t.setPanelVisible(!1),t.setActiveComment(null)),!0}},V={id:"docs.operation.start-add-comment",type:o.CommandType.OPERATION,handler(e){var f,b,$;const t=e.get(O.ThreadCommentPanelService),n=e.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),r=e.get(T.DocSelectionManagerService),s=e.get(S.IRenderManagerService),d=e.get(o.UserManagerService),a=e.get(x),C=e.get(o.ICommandService),h=e.get(u.ISidebarService),l=r.getActiveTextRange();if(!n||!l)return!1;const I=(f=s.getRenderById(n.getUnitId()))==null?void 0:f.with(A.DocSelectionRenderService);if(I==null||I.setReserveRangesStatus(!0),l.collapsed)return t.panelVisible?(t.setPanelVisible(!1),h.close()):C.executeCommand(N.id),!0;C.executeCommand(N.id);const _=n.getUnitId(),g=(($=(b=n.getBody())==null?void 0:b.dataStream)!=null?$:"").slice(l.startOffset,l.endOffset),m=o.BuildTextUtils.transform.getPlainText(g),v=M,y="",j={unitId:_,subUnitId:v,id:y,ref:m,dT:w.getDT(),personId:d.getCurrentUser().userID,text:{dataStream:`\r
18
- `},startOffset:l.startOffset,endOffset:l.endOffset,collapsed:!0,threadId:y};return I==null||I.blur(),a.startAdd(j),t.setActiveComment({unitId:_,subUnitId:v,commentId:y}),!0}};var me=Object.getOwnPropertyDescriptor,le=(e,t,i,n)=>{for(var r=n>1?void 0:n?me(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},E=(e,t)=>(i,n)=>t(i,n,e);let B=class extends o.Disposable{constructor(e,t,i,n,r,s){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=i,this._docThreadCommentService=n,this._renderManagerService=r,this._threadCommentModel=s,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var i,n,r,s;if(t.id===T.SetTextSelectionsOperation.id){const d=t.params,{unitId:a,ranges:C}=d;if(o.isInternalEditorID(a))return;const h=this._univerInstanceService.getUnit(a,o.UniverInstanceType.UNIVER_DOC),l=C[0];if((e==null?void 0:e.startOffset)===(l==null?void 0:l.startOffset)&&(e==null?void 0:e.endOffset)===(l==null?void 0:l.endOffset))return;if(e=l,l&&h){const{startOffset:I,endOffset:_,collapsed:g}=l;let m;if(g?m=(n=(i=h.getBody())==null?void 0:i.customDecorations)==null?void 0:n.find(v=>v.startIndex<=I&&v.endIndex>=_-1):m=(s=(r=h.getBody())==null?void 0:r.customDecorations)==null?void 0:s.find(v=>v.startIndex<=I&&v.endIndex>=_-1),m){const v=this._threadCommentModel.getComment(a,M,m.id);v&&!v.resolved&&this._commandService.executeCommand(N.id,{activeComment:{unitId:a,subUnitId:M,commentId:m.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(O.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t,i,n,r;if(e){const s=this._univerInstanceService.getUnit(e.unitId);if(s){const d=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with(A.DocBackScrollRenderController),a=(n=(i=s.getBody())==null?void 0:i.customDecorations)==null?void 0:n.find(C=>C.id===e.commentId);a&&d&&d.scrollToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1})}}(!e||e.commentId!==((r=this._docThreadCommentService.addingComment)==null?void 0:r.id))&&this._docThreadCommentService.endAdd()}))}};B=le([E(0,o.Inject(O.ThreadCommentPanelService)),E(1,o.IUniverInstanceService),E(2,o.ICommandService),E(3,o.Inject(x)),E(4,S.IRenderManagerService),E(5,o.Inject(w.ThreadCommentModel))],B);var p=function(){return p=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},p.apply(this,arguments)},ue=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(i[n[r]]=e[n[r]]);return i},X=D.forwardRef(function(e,t){var i=e.icon,n=e.id,r=e.className,s=e.extend,d=ue(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),C=D.useRef("_".concat(fe()));return ee(i,"".concat(n),{defIds:i.defIds,idSuffix:C.current},p({ref:t,className:a},d),s)});function ee(e,t,i,n,r){return D.createElement(e.tag,p(p({key:t},ve(e,i,r)),n),(Ce(e,i).children||[]).map(function(s,d){return ee(s,"".concat(t,"-").concat(e.tag,"-").concat(d),i,void 0,r)}))}function ve(e,t,i){var n=p({},e.attrs);i!=null&&i.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=i.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(s){var d=s[0],a=s[1];d==="mask"&&typeof a=="string"&&(n[d]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var r=t.defIds;return!r||r.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var d=s[0],a=s[1];typeof a=="string"&&(n[d]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Ce(e,t){var i,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((i=e.children)===null||i===void 0)&&i.length)?p(p({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?p(p({},r),{attrs:p(p({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function fe(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var he={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},te=D.forwardRef(function(e,t){return D.createElement(X,Object.assign({},e,{id:"comment-single",ref:t,icon:he}))});te.displayName="CommentSingle";const Ie={[u.RibbonStartGroup.OTHERS]:{[W.id]:{order:1,menuItemFactory:ce}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.DATA]:{[V.id]:{order:1,menuItemFactory:ae}}}};var ge=Object.getOwnPropertyDescriptor,Se=(e,t,i,n)=>{for(var r=n>1?void 0:n?ge(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},K=(e,t)=>(i,n)=>t(i,n,e);let q=class extends o.Disposable{constructor(e,t,i){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=i,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[H,L,N,V,W].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Ie)}_initComponents(){[R].forEach(e=>{this.disposeWithMe(this._componentManager.register(e.componentKey,e))}),this.disposeWithMe(this._componentManager.register("CommentSingle",te))}};q=Se([K(0,o.ICommandService),K(1,u.IMenuManagerService),K(2,o.Inject(u.ComponentManager))],q);var pe=Object.getOwnPropertyDescriptor,_e=(e,t,i,n)=>{for(var r=n>1?void 0:n?pe(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},P=(e,t)=>(i,n)=>t(i,n,e);let G=class extends o.Disposable{constructor(e,t,i,n,r,s,d){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=i,this._docRenderController=n,this._univerInstanceService=r,this._threadCommentModel=s,this._commandService=d,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var i;if(e){this._docRenderController.reRender(e.unitId);return}const t=(i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:i.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(T.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,i)=>{if(!e)return i(e);const{unitId:n,index:r,customDecorations:s}=t,d=this._threadCommentPanelService.activeCommentId,{commentId:a,unitId:C}=d||{},h=s.find(g=>g.id===a),l=this._threadCommentModel.getComment(n,M,e.id);if(!l)return i({...e,show:!1});const I=h&&r>=h.startIndex&&r<=h.endIndex,_=C===n&&e.id===a;return i({...e,active:_||I,show:!l.resolved})}})}_initSyncComments(){var r,s,d;const e=this._context.unit.getUnitId(),t=M,i=(d=(s=(r=this._context.unit.getBody())==null?void 0:r.customDecorations)==null?void 0:s.filter(a=>a.type===o.CustomDecorationType.COMMENT).map(a=>a.id))!=null?d:[];i.forEach(a=>{this._threadCommentModel.getComment(e,t,a)||this._threadCommentModel.addComment(e,t,{id:a,threadId:a,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),i.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),M,i);let n=i.sort();this.disposeWithMe(this._commandService.onCommandExecuted(a=>{var C,h,l;if(a.id===T.RichTextEditingMutation.id){if(a.params.unitId!==this._context.unit.getUnitId())return;const _=(l=(h=(C=this._context.unit.getBody())==null?void 0:C.customDecorations)==null?void 0:h.filter(m=>m.type===o.CustomDecorationType.COMMENT).map(m=>m.id))!=null?l:[],g=_.sort();if(JSON.stringify(n)!==JSON.stringify(g)){const m=new Set(n),v=new Set(g),y=new Set,j=new Set;_.forEach(f=>{m.has(f)||y.add(f)}),n.forEach(f=>{v.has(f)||j.add(f)}),n=g,y.forEach(f=>{this._threadCommentModel.getComment(e,t,f)||this._threadCommentModel.addComment(e,t,{id:f,threadId:f,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...y])}}}))}};G=_e([P(1,o.Inject(T.DocInterceptorService)),P(2,o.Inject(O.ThreadCommentPanelService)),P(3,o.Inject(A.DocRenderController)),P(4,o.IUniverInstanceService),P(5,o.Inject(w.ThreadCommentModel)),P(6,o.ICommandService)],G);var Oe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,De=(e,t,i)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Me=(e,t,i,n)=>{for(var r=n>1?void 0:n?Te(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},Z=(e,t)=>(i,n)=>t(i,n,e),ne=(e,t,i)=>De(e,typeof t!="symbol"?t+"":t,i);c.UniverDocsThreadCommentUIPlugin=class extends o.Plugin{constructor(t=J,i,n,r){super(),this._config=t,this._injector=i,this._renderManagerSrv=n,this._configService=r;const{menu:s,...d}=o.merge({},J,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(oe,d)}onStarting(){[[q],[B],[x]].forEach(t=>{this._injector.add(t)})}onRendered(){this._initRenderModule(),this._injector.get(B),this._injector.get(q)}_initRenderModule(){[G].forEach(t=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,t)})}},ne(c.UniverDocsThreadCommentUIPlugin,"pluginName",re),ne(c.UniverDocsThreadCommentUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),c.UniverDocsThreadCommentUIPlugin=Me([o.DependentOn(O.UniverThreadCommentUIPlugin),Z(1,o.Inject(o.Injector)),Z(2,S.IRenderManagerService),Z(3,o.IConfigService)],c.UniverDocsThreadCommentUIPlugin),c.AddDocCommentComment=H,c.DeleteDocCommentComment=L,c.ShowCommentPanelOperation=N,c.StartAddCommentOperation=V,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
9
+ (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/thread-comment-ui"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/thread-comment-ui","@univerjs/docs","@univerjs/docs-ui","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","react"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverDocsThreadCommentUi={},c.UniverCore,c.UniverEngineRender,c.UniverThreadCommentUi,c.UniverDocs,c.UniverDocsUi,c.UniverThreadComment,c.UniverUi,c.rxjs,c.React,c.React))})(this,function(c,o,p,O,T,w,A,u,x,re,D){"use strict";var be=Object.defineProperty;var Ue=(c,o,p)=>o in c?be(c,o,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[o]=p;var J=(c,o,p)=>Ue(c,typeof o!="symbol"?o+"":o,p);const ie="DOC_THREAD_COMMENT_UI_PLUGIN",M="default_doc",oe="docs-thread-comment-ui.config",Y={};var se=Object.getOwnPropertyDescriptor,ae=(e,t,r,n)=>{for(var i=n>1?void 0:n?se(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=a(i)||i);return i},z=(e,t)=>(r,n)=>t(r,n,e);let E=class extends o.Disposable{constructor(t,r){super();J(this,"_addingComment$",new x.BehaviorSubject(void 0));J(this,"addingComment$",this._addingComment$.asObservable());this._sidebarService=t,this._threadCommentPanelService=r,this.disposeWithMe(()=>{this._addingComment$.complete()})}get addingComment(){return this._addingComment$.getValue()}startAdd(t){this._addingComment$.next(t)}endAdd(){this._addingComment$.next(void 0)}};E=ae([z(0,u.ISidebarService),z(1,o.Inject(O.ThreadCommentPanelService))],E);const H={id:"docs.command.add-comment",type:o.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{comment:r,unitId:n}=t,s=await e.get(A.IThreadCommentDataSourceService).addComment(r),a=e.get(o.ICommandService),d=w.addCustomDecorationBySelectionFactory(e,{id:s.threadId,type:o.CustomDecorationType.COMMENT,unitId:n});if(d){const C={id:A.AddCommentMutation.id,params:{unitId:n,subUnitId:M,comment:s}},h={id:O.SetActiveCommentOperation.id,params:{unitId:n,subUnitId:M,commentId:s.id}};return(await o.sequenceExecute([C,d,h],a)).result}return!1}},L={id:"docs.command.delete-comment",type:o.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{commentId:r,unitId:n}=t,i=e.get(o.ICommandService),s=w.deleteCustomDecorationFactory(e,{id:r,unitId:n});return s?(await o.sequenceExecute([s],i)).result:!1}},Q=e=>{var a;const t=e.get(p.IRenderManagerService),r=e.get(T.DocSelectionManagerService),n=(a=p.withCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_DOC,T.DocSkeletonManagerService,e.get(o.IUniverInstanceService),t))==null?void 0:a.getSkeleton(),i=n==null?void 0:n.getViewModel().getEditArea();if(i===p.DocumentEditArea.FOOTER||i===p.DocumentEditArea.HEADER)return!0;const s=r.getActiveTextRange();return!!(s==null||s.collapsed)};function de(e){return{id:V.id,type:u.MenuItemType.BUTTON,icon:"CommentIcon",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:u.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,void 0,o.SHEET_EDITOR_UNITS),disabled$:new x.Observable(function(t){const n=e.get(T.DocSelectionManagerService).textSelection$.pipe(x.debounceTime(16)).subscribe(()=>{t.next(Q(e))});return()=>{n.unsubscribe()}})}}function ce(e){return{id:W.id,type:u.MenuItemType.BUTTON,icon:"CommentIcon",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:u.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC)}}const U=()=>{const e=u.useDependency(o.IUniverInstanceService),t=u.useDependency(o.Injector),r=D.useMemo(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_DOC).pipe(x.filter(m=>!!m&&!o.isInternalEditorID(m.getUnitId()))),[e]),n=u.useObservable(r),i=D.useMemo(()=>new x.Observable(m=>m.next(M)),[]),s=u.useDependency(T.DocSelectionManagerService),a=D.useMemo(()=>s.textSelection$.pipe(x.debounceTime(16)),[s.textSelection$]);u.useObservable(a);const d=u.useDependency(o.ICommandService),C=u.useDependency(E),h=u.useObservable(C.addingComment$),[l,I]=D.useState([]);if(D.useEffect(()=>{var j;const m=new Set,v=n==null?void 0:n.getCustomDecorations();I((j=v==null?void 0:v.map(f=>f.id).filter(f=>{const b=m.has(f);return m.add(f),!b}))!=null?j:[]);const y=d.onCommandExecuted(f=>{var b;if(f.id===T.RichTextEditingMutation.id){const $=new Set,k=n==null?void 0:n.getCustomDecorations();I((b=k==null?void 0:k.map(F=>F.id).filter(F=>{const ye=$.has(F);return $.add(F),!ye}))!=null?b:[])}});return()=>{y.dispose()}},[d,n]),!n)return null;const _=Q(t),g=n.getUnitId();return re.jsx(O.ThreadCommentPanel,{unitId:g,subUnitId$:i,type:o.UniverInstanceType.UNIVER_DOC,onAdd:()=>{d.executeCommand(V.id)},getSubUnitName:()=>"",disableAdd:_,tempComment:h,onAddComment:m=>{if(!m.parentId){const v={unitId:g,range:h,comment:m};return d.executeCommand(H.id,v),C.endAdd(),!1}return!0},onDeleteComment:m=>{if(!m.parentId){const v={unitId:g,commentId:m.id};return d.executeCommand(L.id,v),!1}return!0},showComments:l})};U.componentKey="univer.doc.thread-comment-panel";const N={id:"docs.operation.show-comment-panel",type:o.CommandType.OPERATION,handler(e,t){var i;const r=e.get(O.ThreadCommentPanelService),n=e.get(u.ISidebarService);return(!r.panelVisible||((i=n.options.children)==null?void 0:i.label)!==U.componentKey)&&(n.open({header:{title:"threadCommentUI.panel.title"},children:{label:U.componentKey},width:320,onClose:()=>r.setPanelVisible(!1)}),r.setPanelVisible(!0)),t&&r.setActiveComment(t==null?void 0:t.activeComment),!0}},W={id:"docs.operation.toggle-comment-panel",type:o.CommandType.OPERATION,handler(e){var n;const t=e.get(O.ThreadCommentPanelService),r=e.get(u.ISidebarService);return!t.panelVisible||((n=r.options.children)==null?void 0:n.label)!==U.componentKey?(r.open({header:{title:"threadCommentUI.panel.title"},children:{label:U.componentKey},width:320,onClose:()=>t.setPanelVisible(!1)}),t.setPanelVisible(!0)):(r.close(),t.setPanelVisible(!1),t.setActiveComment(null)),!0}},V={id:"docs.operation.start-add-comment",type:o.CommandType.OPERATION,handler(e){var f,b,$;const t=e.get(O.ThreadCommentPanelService),n=e.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),i=e.get(T.DocSelectionManagerService),s=e.get(p.IRenderManagerService),a=e.get(o.UserManagerService),d=e.get(E),C=e.get(o.ICommandService),h=e.get(u.ISidebarService),l=i.getActiveTextRange();if(!n||!l)return!1;const I=(f=s.getRenderById(n.getUnitId()))==null?void 0:f.with(w.DocSelectionRenderService);if(I==null||I.setReserveRangesStatus(!0),l.collapsed)return t.panelVisible?(t.setPanelVisible(!1),h.close()):C.executeCommand(N.id),!0;C.executeCommand(N.id);const _=n.getUnitId(),g=(($=(b=n.getBody())==null?void 0:b.dataStream)!=null?$:"").slice(l.startOffset,l.endOffset),m=o.BuildTextUtils.transform.getPlainText(g),v=M,y="",j={unitId:_,subUnitId:v,id:y,ref:m,dT:A.getDT(),personId:a.getCurrentUser().userID,text:{dataStream:`\r
10
+ `},startOffset:l.startOffset,endOffset:l.endOffset,collapsed:!0,threadId:y};return I==null||I.blur(),d.startAdd(j),t.setActiveComment({unitId:_,subUnitId:v,commentId:y}),!0}};var me=Object.getOwnPropertyDescriptor,le=(e,t,r,n)=>{for(var i=n>1?void 0:n?me(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=a(i)||i);return i},R=(e,t)=>(r,n)=>t(r,n,e);let B=class extends o.Disposable{constructor(e,t,r,n,i,s){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=r,this._docThreadCommentService=n,this._renderManagerService=i,this._threadCommentModel=s,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var r,n,i,s;if(t.id===T.SetTextSelectionsOperation.id){const a=t.params,{unitId:d,ranges:C}=a;if(o.isInternalEditorID(d))return;const h=this._univerInstanceService.getUnit(d,o.UniverInstanceType.UNIVER_DOC),l=C[0];if((e==null?void 0:e.startOffset)===(l==null?void 0:l.startOffset)&&(e==null?void 0:e.endOffset)===(l==null?void 0:l.endOffset))return;if(e=l,l&&h){const{startOffset:I,endOffset:_,collapsed:g}=l;let m;if(g?m=(n=(r=h.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(v=>v.startIndex<=I&&v.endIndex>=_-1):m=(s=(i=h.getBody())==null?void 0:i.customDecorations)==null?void 0:s.find(v=>v.startIndex<=I&&v.endIndex>=_-1),m){const v=this._threadCommentModel.getComment(d,M,m.id);v&&!v.resolved&&this._commandService.executeCommand(N.id,{activeComment:{unitId:d,subUnitId:M,commentId:m.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(O.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t,r,n,i;if(e){const s=this._univerInstanceService.getUnit(e.unitId);if(s){const a=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with(w.DocBackScrollRenderController),d=(n=(r=s.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(C=>C.id===e.commentId);d&&a&&a.scrollToRange({startOffset:d.startIndex,endOffset:d.endIndex,collapsed:!1})}}(!e||e.commentId!==((i=this._docThreadCommentService.addingComment)==null?void 0:i.id))&&this._docThreadCommentService.endAdd()}))}};B=le([R(0,o.Inject(O.ThreadCommentPanelService)),R(1,o.IUniverInstanceService),R(2,o.ICommandService),R(3,o.Inject(E)),R(4,p.IRenderManagerService),R(5,o.Inject(A.ThreadCommentModel))],B);var S=function(){return S=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},S.apply(this,arguments)},ue=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},X=D.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,s=e.extend,a=ue(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),C=D.useRef("_".concat(fe()));return ee(r,"".concat(n),{defIds:r.defIds,idSuffix:C.current},S({ref:t,className:d},a),s)});function ee(e,t,r,n,i){return D.createElement(e.tag,S(S({key:t},ve(e,r,i)),n),(Ce(e,r).children||[]).map(function(s,a){return ee(s,"".concat(t,"-").concat(e.tag,"-").concat(a),r,void 0,i)}))}function ve(e,t,r){var n=S({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],d=s[1];a==="mask"&&typeof d=="string"&&(n[a]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],d=s[1];typeof d=="string"&&(n[a]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Ce(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?S(S({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.includes(i.attrs.id)?S(S({},i),{attrs:S(S({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function fe(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var he={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},te=D.forwardRef(function(e,t){return D.createElement(X,Object.assign({},e,{id:"comment-icon",ref:t,icon:he}))});te.displayName="CommentIcon";const Ie={[u.RibbonInsertGroup.MEDIA]:{[W.id]:{order:3,menuItemFactory:ce}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.DATA]:{[V.id]:{order:1,menuItemFactory:de}}}};var ge=Object.getOwnPropertyDescriptor,pe=(e,t,r,n)=>{for(var i=n>1?void 0:n?ge(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=a(i)||i);return i},Z=(e,t)=>(r,n)=>t(r,n,e);let q=class extends o.Disposable{constructor(e,t,r){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=r,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[H,L,N,V,W].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Ie)}_initComponents(){[[U.componentKey,U],["CommentIcon",te]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};q=pe([Z(0,o.ICommandService),Z(1,u.IMenuManagerService),Z(2,o.Inject(u.ComponentManager))],q);var Se=Object.getOwnPropertyDescriptor,_e=(e,t,r,n)=>{for(var i=n>1?void 0:n?Se(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=a(i)||i);return i},P=(e,t)=>(r,n)=>t(r,n,e);let K=class extends o.Disposable{constructor(e,t,r,n,i,s,a){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=r,this._docRenderController=n,this._univerInstanceService=i,this._threadCommentModel=s,this._commandService=a,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var r;if(e){this._docRenderController.reRender(e.unitId);return}const t=(r=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:r.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(T.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,r)=>{if(!e)return r(e);const{unitId:n,index:i,customDecorations:s}=t,a=this._threadCommentPanelService.activeCommentId,{commentId:d,unitId:C}=a||{},h=s.find(g=>g.id===d),l=this._threadCommentModel.getComment(n,M,e.id);if(!l)return r({...e,show:!1});const I=h&&i>=h.startIndex&&i<=h.endIndex,_=C===n&&e.id===d;return r({...e,active:_||I,show:!l.resolved})}})}_initSyncComments(){var i,s,a;const e=this._context.unit.getUnitId(),t=M,r=(a=(s=(i=this._context.unit.getBody())==null?void 0:i.customDecorations)==null?void 0:s.filter(d=>d.type===o.CustomDecorationType.COMMENT).map(d=>d.id))!=null?a:[];r.forEach(d=>{this._threadCommentModel.getComment(e,t,d)||this._threadCommentModel.addComment(e,t,{id:d,threadId:d,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),r.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),M,r);let n=r.sort();this.disposeWithMe(this._commandService.onCommandExecuted(d=>{var C,h,l;if(d.id===T.RichTextEditingMutation.id){if(d.params.unitId!==this._context.unit.getUnitId())return;const _=(l=(h=(C=this._context.unit.getBody())==null?void 0:C.customDecorations)==null?void 0:h.filter(m=>m.type===o.CustomDecorationType.COMMENT).map(m=>m.id))!=null?l:[],g=_.sort();if(JSON.stringify(n)!==JSON.stringify(g)){const m=new Set(n),v=new Set(g),y=new Set,j=new Set;_.forEach(f=>{m.has(f)||y.add(f)}),n.forEach(f=>{v.has(f)||j.add(f)}),n=g,y.forEach(f=>{this._threadCommentModel.getComment(e,t,f)||this._threadCommentModel.addComment(e,t,{id:f,threadId:f,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...y])}}}))}};K=_e([P(1,o.Inject(T.DocInterceptorService)),P(2,o.Inject(O.ThreadCommentPanelService)),P(3,o.Inject(w.DocRenderController)),P(4,o.IUniverInstanceService),P(5,o.Inject(A.ThreadCommentModel)),P(6,o.ICommandService)],K);var Oe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,De=(e,t,r)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Me=(e,t,r,n)=>{for(var i=n>1?void 0:n?Te(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(i=a(i)||i);return i},G=(e,t)=>(r,n)=>t(r,n,e),ne=(e,t,r)=>De(e,typeof t!="symbol"?t+"":t,r);c.UniverDocsThreadCommentUIPlugin=class extends o.Plugin{constructor(t=Y,r,n,i){super(),this._config=t,this._injector=r,this._renderManagerSrv=n,this._configService=i;const{menu:s,...a}=o.merge({},Y,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(oe,a)}onStarting(){[[q],[B],[E]].forEach(t=>{this._injector.add(t)})}onRendered(){this._initRenderModule(),this._injector.get(B),this._injector.get(q)}_initRenderModule(){[K].forEach(t=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,t)})}},ne(c.UniverDocsThreadCommentUIPlugin,"pluginName",ie),ne(c.UniverDocsThreadCommentUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),c.UniverDocsThreadCommentUIPlugin=Me([o.DependentOn(O.UniverThreadCommentUIPlugin),G(1,o.Inject(o.Injector)),G(2,p.IRenderManagerService),G(3,o.IConfigService)],c.UniverDocsThreadCommentUIPlugin),c.AddDocCommentComment=H,c.DeleteDocCommentComment=L,c.ShowCommentPanelOperation=N,c.StartAddCommentOperation=V,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
19
11
 
20
12
 
21
13
  // index
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-docs-thread-comment",
3
- "version": "0.7.0",
3
+ "version": "0.8.0-beta.1",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -57,16 +57,16 @@
57
57
  "rxjs": ">=7.0.0"
58
58
  },
59
59
  "dependencies": {
60
- "@univerjs/docs-thread-comment-ui": "0.7.0",
61
- "@univerjs/thread-comment-ui": "0.7.0"
60
+ "@univerjs/docs-thread-comment-ui": "0.8.0-beta.1",
61
+ "@univerjs/thread-comment-ui": "0.8.0-beta.1"
62
62
  },
63
63
  "devDependencies": {
64
- "@univerjs/core": "0.7.0",
64
+ "@univerjs/core": "0.8.0-beta.1",
65
65
  "react": "18.3.1",
66
66
  "react-dom": "18.3.1",
67
67
  "rxjs": "7.8.2",
68
68
  "typescript": "^5.8.3",
69
- "@univerjs-infra/shared": "0.7.0"
69
+ "@univerjs-infra/shared": "0.8.0-beta.1"
70
70
  },
71
71
  "scripts": {
72
72
  "prebuild:preset": "tsx prepare.ts",