@univerjs/thread-comment-ui 1.0.0 → 1.0.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/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
- package/lib/types/views/thread-comment-editor/index.d.ts +0 -37
- package/lib/types/views/thread-comment-panel/index.d.ts +0 -37
- package/lib/types/views/thread-comment-tree/index.d.ts +0 -59
package/lib/cjs/index.js
CHANGED
package/lib/es/index.js
CHANGED
package/lib/index.js
CHANGED
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/docs-ui"),require("@univerjs/thread-comment"),require("@univerjs/engine-render"),require("@univerjs/design"),require("react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/ui`,`rxjs`,`@univerjs/docs-ui`,`@univerjs/thread-comment`,`@univerjs/engine-render`,`@univerjs/design`,`react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverThreadCommentUi={},e.UniverCore,e.UniverUi,e.rxjs,e.UniverDocsUi,e.UniverThreadComment,e.UniverEngineRender,e.UniverDesign,e.React,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function u(e){"@babel/helpers - typeof";return u=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e,t){return function(n,r){t(n,r,e)}}function h(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let g=class extends t.Disposable{constructor(e){super(),this._sidebarService=e,p(this,`_panelVisible`,!1),p(this,`_panelVisible$`,new r.BehaviorSubject(!1)),p(this,`_activeCommentId`,void 0),p(this,`_activeCommentId$`,new r.BehaviorSubject(void 0)),p(this,`_hoveredCommentId`,void 0),p(this,`_hoveredCommentId$`,new r.BehaviorSubject(void 0)),p(this,`panelVisible$`,this._panelVisible$.asObservable()),p(this,`activeCommentId$`,this._activeCommentId$.asObservable()),p(this,`hoveredCommentId$`,this._hoveredCommentId$.asObservable()),this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._hoveredCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.visible||this.setPanelVisible(!1)}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}get hoveredCommentId(){return this._hoveredCommentId}setPanelVisible(e){this._panelVisible=e,this._panelVisible$.next(e),e||this.setHoveredComment(void 0)}setActiveComment(e){this._activeCommentId=e,this._activeCommentId$.next(e)}setHoveredComment(e){this._hoveredCommentId=e,this._hoveredCommentId$.next(e)}};g=h([m(0,(0,t.Inject)(n.ISidebarService))],g);let _={id:`thread-comment-ui.operation.set-active-comment`,type:t.CommandType.OPERATION,handler(e,t){return e.get(g).setActiveComment(t),!0}};var v=`@univerjs/thread-comment-ui`,y=`1.0.0`;let b=`thread-comment-ui.config`,x={},S=class extends t.Disposable{constructor(e,n){if(super(),this._userManagerService=n,p(this,`_placementType$`,new r.BehaviorSubject(null)),p(this,`_draft$`,new r.BehaviorSubject(null)),p(this,`_placementUnitId`,void 0),p(this,`_ownerUserId`,void 0),p(this,`placementType$`,this._placementType$.asObservable()),p(this,`draft$`,this._draft$.asObservable()),this.disposeWithMe(e.unitDisposed$.subscribe(e=>{var t;(((t=this.draft)==null?void 0:t.unitId)===e.getUnitId()||this._placementUnitId===e.getUnitId())&&this.cancel()})),this.disposeWithMe(e.focused$.subscribe(e=>{e&&this._placementUnitId&&e!==this._placementUnitId&&this.cancel()})),this.disposeWithMe(this._userManagerService.currentUser$.subscribe(e=>{this._ownerUserId&&(e==null?void 0:e.userID)!==this._ownerUserId&&this.cancel()})),typeof window<`u`){let e=e=>{e.key===`Escape`&&(this.placementType||this.draft)&&this.cancel()};window.addEventListener(`keydown`,e),this.disposeWithMe((0,t.toDisposable)(()=>window.removeEventListener(`keydown`,e)))}}get placementType(){return this._placementType$.value}get draft(){return this._draft$.value}startPlacement(e,t){if(this.placementType===e&&this._placementUnitId===t){this.cancel();return}this._ownerUserId=this._userManagerService.getCurrentUser().userID,this._placementUnitId=t,this._draft$.next(null),this._placementType$.next(e)}place(e){this._ownerUserId=this._userManagerService.getCurrentUser().userID,this._placementUnitId=void 0,this._placementType$.next(null),this._draft$.next(e)}cancel(){this._ownerUserId=void 0,this._placementUnitId=void 0,this._placementType$.next(null),this._draft$.next(null)}dispose(){this._placementType$.complete(),this._draft$.complete(),super.dispose()}};S=h([m(0,t.IUniverInstanceService),m(1,(0,t.Inject)(t.UserManagerService))],S);let C=`UNIVER_THREAD_COMMENT_UI_PLUGIN`,w=class extends t.Plugin{constructor(e=x,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},x,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(b,o)}onStarting(){var e;(0,t.mergeOverrideWithDependencies)([[S],[g]],(e=this._config)==null?void 0:e.overrides).forEach(e=>{this._injector.add(e)}),this._commandService.registerCommand(_)}};p(w,`pluginName`,C),p(w,`packageName`,v),p(w,`version`,y),p(w,`type`,t.UniverInstanceType.UNIVER_UNKNOWN),w=h([(0,t.DependentOn)(a.UniverThreadCommentPlugin,i.UniverDocsUIPlugin,n.UniverMobileUIPlugin),m(1,(0,t.Inject)(t.Injector)),m(2,t.ICommandService),m(3,t.IConfigService)],w);let T=class extends t.Plugin{constructor(e=x,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},x,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(b,o)}onStarting(){var e;(0,t.mergeOverrideWithDependencies)([[S],[g]],(e=this._config)==null?void 0:e.overrides).forEach(e=>{this._injector.add(e)}),[_].forEach(e=>{this._commandService.registerCommand(e)})}};p(T,`pluginName`,C),p(T,`packageName`,v),p(T,`version`,y),p(T,`type`,t.UniverInstanceType.UNIVER_UNKNOWN),T=h([(0,t.DependentOn)(a.UniverThreadCommentPlugin,i.UniverDocsUIPlugin),m(1,(0,t.Inject)(t.Injector)),m(2,t.ICommandService),m(3,t.IConfigService)],T);let E=.42;var D=class extends o.BaseObject{constructor(e,t){super(e),p(this,`_state`,void 0),p(this,`_hoveredCommentId`,null),p(this,`_hitCommentId`,null),this.evented=!0,this._state=t,this.show()}get hitCommentId(){return this._hitCommentId}updateState(e){this._state={...this._state,...e},this._hitCommentId&&!this._containsComment(this._hitCommentId)&&(this._hitCommentId=null),this._hoveredCommentId&&!this._containsComment(this._hoveredCommentId)&&(this._hoveredCommentId=null),`previewMarker`in e||`previewUnderline`in e?this.makeDirtyNoDebounce(!0):this.makeDirty(!0)}clearHover(){this._hoveredCommentId&&(this._hoveredCommentId=null,this.makeDirty(!0)),this._hitCommentId=null}isHit(e){let t=this._getZoomRatio(),n=24/t/2,r;for(let t=this._state.markers.length-1;t>=0;--t){let i=this._state.markers[t];if(i&&e.x>=i.x-n&&e.x<=i.x+n&&e.y>=i.y-n&&e.y<=i.y+n){r=i;break}}let i;if(!r)for(let n=this._state.underlines.length-1;n>=0;--n){let r=this._state.underlines[n];if(r&&e.x>=r.left&&e.x<=r.left+r.width&&Math.abs(e.y-r.top)<=4/t){i=r;break}}let a=(r==null?void 0:r.commentId)??(i==null?void 0:i.commentId)??null;return this._hitCommentId=a,a!==this._hoveredCommentId&&(this._hoveredCommentId=a,this.makeDirty(!0)),a!==null}render(e,t){var n;let r=this._getZoomRatio();return this._state.underlines.forEach(t=>this._renderUnderline(e,t,r,1)),(n=this._state.focusOutlines)==null||n.forEach(t=>this._renderOutline(e,t,r)),this._state.previewUnderline&&this._renderUnderline(e,this._state.previewUnderline,r,E),this._state.markers.forEach(t=>{var n;return this._renderMarker(e,t,r,this._markerContainsComment(t,this._hoveredCommentId)||(n=this._state.focusedCommentIds)!=null&&n.some(e=>this._markerContainsComment(t,e))?1:.58)}),this._state.previewMarker&&this._renderMarker(e,this._state.previewMarker,r,E),this.makeDirty(!1),this}_getZoomRatio(){return Number.isFinite(this._state.zoomRatio)&&this._state.zoomRatio>0?this._state.zoomRatio:1}_containsComment(e){return this._state.markers.some(t=>this._markerContainsComment(t,e))||this._state.underlines.some(t=>t.commentId===e)}_markerContainsComment(e,t){var n;return t!=null&&(e.commentId===t||((n=e.commentIds)==null?void 0:n.includes(t))===!0)}_renderUnderline(e,t,n,r){e.save(),e.globalAlpha=r,e.strokeStyle=this._state.accentColor,e.lineWidth=2/n,e.beginPath(),e.moveTo(t.left,t.top),e.lineTo(t.left+t.width,t.top),e.stroke(),e.restore()}_renderOutline(e,t,n){let r=2/n;e.save(),e.strokeStyle=this._state.accentColor,e.lineWidth=2/n,e.strokeRect(t.left-r,t.top-r,t.width+r*2,t.height+r*2),e.restore()}_renderMarker(e,t,n,r){let i=24/n,a=t.x-i/2,s=t.y-i/2,c=4/n,l=4/n;if(e.save(),e.globalAlpha=r,e.fillStyle=this._state.accentColor,e.strokeStyle=this._state.outlineColor,e.lineWidth=1.5/n,e.beginPath(),e.moveTo(a+c,s),e.lineTo(a+i-c,s),e.quadraticCurveTo(a+i,s,a+i,s+c),e.lineTo(a+i,s+i-l-c),e.quadraticCurveTo(a+i,s+i-l,a+i-c,s+i-l),e.lineTo(a+i/2+l,s+i-l),e.lineTo(a+i/2,s+i),e.lineTo(a+i/2-l,s+i-l),e.lineTo(a+c,s+i-l),e.quadraticCurveTo(a,s+i-l,a,s+i-l-c),e.lineTo(a,s+c),e.quadraticCurveTo(a,s,a+c,s),e.closePath(),e.fill(),e.stroke(),e.fillStyle=this._state.foregroundColor,(t.count??1)>1)e.font=`600 ${11/n}px ${o.DEFAULT_FONTFACE_PLANE}`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(String(t.count),t.x,s+i*.42);else{let t=1.2/n,r=s+i*.43;[.32,.5,.68].forEach(n=>{e.beginPath(),e.arc(a+i*n,r,t,0,Math.PI*2),e.fill()})}e.restore()}};function O({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,l=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,c.useId)()}`,d=(0,c.useRef)(null);return(0,c.useImperativeHandle)(e,()=>d.current),(0,c.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return M(d.current)},[n,r]),k(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:l,...s},o)}function k(e,t,n,r,i){return(0,c.createElement)(e.tag,{key:t,...A(e,n,i),...r},(j(e,n).children||[]).map((r,a)=>k(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function A(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function j(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function M(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:N(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(P(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function N(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function P(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}O.displayName=`UniverIcon`;let F={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`}}]},I=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`delete-icon`,ref:t,icon:F}))});I.displayName=`DeleteIcon`;let L={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`}}]},R=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`increase-icon`,ref:t,icon:L}))});R.displayName=`IncreaseIcon`;let z={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`}}]},B=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`more-horizontal-icon`,ref:t,icon:z}))});B.displayName=`MoreHorizontalIcon`;let V={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M10.3536 12.3536C10.1583 12.5488 9.84171 12.5488 9.64645 12.3536L6.64645 9.35355C6.45118 9.15829 6.45118 8.84171 6.64645 8.64645L9.64645 5.64645C9.84171 5.45118 10.1583 5.45118 10.3536 5.64645C10.5488 5.84171 10.5488 6.15829 10.3536 6.35355L7.70711 9L10.3536 11.6464C10.5488 11.8417 10.5488 12.1583 10.3536 12.3536Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},H=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`more-left-icon`,ref:t,icon:V}))});H.displayName=`MoreLeftIcon`;let U={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}}]},W=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`reply-to-comment-icon`,ref:t,icon:U}))});W.displayName=`ReplyToCommentIcon`;let G={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 15C11.866 15 15 11.866 15 8C15 4.13401 11.866 1 8 1C4.13401 1 1 4.13401 1 8C1 11.866 4.13401 15 8 15ZM11.7245 6.42417C11.9588 6.18985 11.9588 5.80995 11.7245 5.57564C11.4901 5.34132 11.1102 5.34132 10.8759 5.57564L7.3002 9.15137L5.72446 7.57564C5.49014 7.34132 5.11025 7.34132 4.87593 7.57564C4.64162 7.80995 4.64162 8.18985 4.87593 8.42417L6.87593 10.4242C7.11025 10.6585 7.49014 10.6585 7.72446 10.4242L11.7245 6.42417Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},K=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`success-icon`,ref:t,icon:G}))});K.displayName=`SuccessIcon`;let q={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}}]},J=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`success-outline-icon`,ref:t,icon:q}))});J.displayName=`SuccessOutlineIcon`;function Y(e,t){return(e==null?void 0:e.unitId)===t.unitId&&e.subUnitId===t.subUnitId&&e.commentId===t.id}function X(e,t,n){return e?e.unitId!==t||!n:!1}function ee(e,t,n){return e.id?e.id:[`thread-comment-panel-temp`,n,e.unitId,e.subUnitId,e.threadId,e.ref,e.dT,t].join(`-`)}let Z=e=>{let{dataStream:t,customRanges:n}=e,r=t.endsWith(`\r
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/docs-ui"),require("@univerjs/thread-comment"),require("@univerjs/engine-render"),require("@univerjs/design"),require("react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/ui`,`rxjs`,`@univerjs/docs-ui`,`@univerjs/thread-comment`,`@univerjs/engine-render`,`@univerjs/design`,`react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverThreadCommentUi={},e.UniverCore,e.UniverUi,e.rxjs,e.UniverDocsUi,e.UniverThreadComment,e.UniverEngineRender,e.UniverDesign,e.React,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function u(e){"@babel/helpers - typeof";return u=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e,t){return function(n,r){t(n,r,e)}}function h(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let g=class extends t.Disposable{constructor(e){super(),this._sidebarService=e,p(this,`_panelVisible`,!1),p(this,`_panelVisible$`,new r.BehaviorSubject(!1)),p(this,`_activeCommentId`,void 0),p(this,`_activeCommentId$`,new r.BehaviorSubject(void 0)),p(this,`_hoveredCommentId`,void 0),p(this,`_hoveredCommentId$`,new r.BehaviorSubject(void 0)),p(this,`panelVisible$`,this._panelVisible$.asObservable()),p(this,`activeCommentId$`,this._activeCommentId$.asObservable()),p(this,`hoveredCommentId$`,this._hoveredCommentId$.asObservable()),this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._hoveredCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.visible||this.setPanelVisible(!1)}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}get hoveredCommentId(){return this._hoveredCommentId}setPanelVisible(e){this._panelVisible=e,this._panelVisible$.next(e),e||this.setHoveredComment(void 0)}setActiveComment(e){this._activeCommentId=e,this._activeCommentId$.next(e)}setHoveredComment(e){this._hoveredCommentId=e,this._hoveredCommentId$.next(e)}};g=h([m(0,(0,t.Inject)(n.ISidebarService))],g);let _={id:`thread-comment-ui.operation.set-active-comment`,type:t.CommandType.OPERATION,handler(e,t){return e.get(g).setActiveComment(t),!0}};var v=`@univerjs/thread-comment-ui`,y=`1.0.1`;let b=`thread-comment-ui.config`,x={},S=class extends t.Disposable{constructor(e,n){if(super(),this._userManagerService=n,p(this,`_placementType$`,new r.BehaviorSubject(null)),p(this,`_draft$`,new r.BehaviorSubject(null)),p(this,`_placementUnitId`,void 0),p(this,`_ownerUserId`,void 0),p(this,`placementType$`,this._placementType$.asObservable()),p(this,`draft$`,this._draft$.asObservable()),this.disposeWithMe(e.unitDisposed$.subscribe(e=>{var t;(((t=this.draft)==null?void 0:t.unitId)===e.getUnitId()||this._placementUnitId===e.getUnitId())&&this.cancel()})),this.disposeWithMe(e.focused$.subscribe(e=>{e&&this._placementUnitId&&e!==this._placementUnitId&&this.cancel()})),this.disposeWithMe(this._userManagerService.currentUser$.subscribe(e=>{this._ownerUserId&&(e==null?void 0:e.userID)!==this._ownerUserId&&this.cancel()})),typeof window<`u`){let e=e=>{e.key===`Escape`&&(this.placementType||this.draft)&&this.cancel()};window.addEventListener(`keydown`,e),this.disposeWithMe((0,t.toDisposable)(()=>window.removeEventListener(`keydown`,e)))}}get placementType(){return this._placementType$.value}get draft(){return this._draft$.value}startPlacement(e,t){if(this.placementType===e&&this._placementUnitId===t){this.cancel();return}this._ownerUserId=this._userManagerService.getCurrentUser().userID,this._placementUnitId=t,this._draft$.next(null),this._placementType$.next(e)}place(e){this._ownerUserId=this._userManagerService.getCurrentUser().userID,this._placementUnitId=void 0,this._placementType$.next(null),this._draft$.next(e)}cancel(){this._ownerUserId=void 0,this._placementUnitId=void 0,this._placementType$.next(null),this._draft$.next(null)}dispose(){this._placementType$.complete(),this._draft$.complete(),super.dispose()}};S=h([m(0,t.IUniverInstanceService),m(1,(0,t.Inject)(t.UserManagerService))],S);let C=`UNIVER_THREAD_COMMENT_UI_PLUGIN`,w=class extends t.Plugin{constructor(e=x,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},x,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(b,o)}onStarting(){var e;(0,t.mergeOverrideWithDependencies)([[S],[g]],(e=this._config)==null?void 0:e.overrides).forEach(e=>{this._injector.add(e)}),this._commandService.registerCommand(_)}};p(w,`pluginName`,C),p(w,`packageName`,v),p(w,`version`,y),p(w,`type`,t.UniverInstanceType.UNIVER_UNKNOWN),w=h([(0,t.DependentOn)(a.UniverThreadCommentPlugin,i.UniverDocsUIPlugin,n.UniverMobileUIPlugin),m(1,(0,t.Inject)(t.Injector)),m(2,t.ICommandService),m(3,t.IConfigService)],w);let T=class extends t.Plugin{constructor(e=x,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},x,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(b,o)}onStarting(){var e;(0,t.mergeOverrideWithDependencies)([[S],[g]],(e=this._config)==null?void 0:e.overrides).forEach(e=>{this._injector.add(e)}),[_].forEach(e=>{this._commandService.registerCommand(e)})}};p(T,`pluginName`,C),p(T,`packageName`,v),p(T,`version`,y),p(T,`type`,t.UniverInstanceType.UNIVER_UNKNOWN),T=h([(0,t.DependentOn)(a.UniverThreadCommentPlugin,i.UniverDocsUIPlugin),m(1,(0,t.Inject)(t.Injector)),m(2,t.ICommandService),m(3,t.IConfigService)],T);let E=.42;var D=class extends o.BaseObject{constructor(e,t){super(e),p(this,`_state`,void 0),p(this,`_hoveredCommentId`,null),p(this,`_hitCommentId`,null),this.evented=!0,this._state=t,this.show()}get hitCommentId(){return this._hitCommentId}updateState(e){this._state={...this._state,...e},this._hitCommentId&&!this._containsComment(this._hitCommentId)&&(this._hitCommentId=null),this._hoveredCommentId&&!this._containsComment(this._hoveredCommentId)&&(this._hoveredCommentId=null),`previewMarker`in e||`previewUnderline`in e?this.makeDirtyNoDebounce(!0):this.makeDirty(!0)}clearHover(){this._hoveredCommentId&&(this._hoveredCommentId=null,this.makeDirty(!0)),this._hitCommentId=null}isHit(e){let t=this._getZoomRatio(),n=24/t/2,r;for(let t=this._state.markers.length-1;t>=0;--t){let i=this._state.markers[t];if(i&&e.x>=i.x-n&&e.x<=i.x+n&&e.y>=i.y-n&&e.y<=i.y+n){r=i;break}}let i;if(!r)for(let n=this._state.underlines.length-1;n>=0;--n){let r=this._state.underlines[n];if(r&&e.x>=r.left&&e.x<=r.left+r.width&&Math.abs(e.y-r.top)<=4/t){i=r;break}}let a=(r==null?void 0:r.commentId)??(i==null?void 0:i.commentId)??null;return this._hitCommentId=a,a!==this._hoveredCommentId&&(this._hoveredCommentId=a,this.makeDirty(!0)),a!==null}render(e,t){var n;let r=this._getZoomRatio();return this._state.underlines.forEach(t=>this._renderUnderline(e,t,r,1)),(n=this._state.focusOutlines)==null||n.forEach(t=>this._renderOutline(e,t,r)),this._state.previewUnderline&&this._renderUnderline(e,this._state.previewUnderline,r,E),this._state.markers.forEach(t=>{var n;return this._renderMarker(e,t,r,this._markerContainsComment(t,this._hoveredCommentId)||(n=this._state.focusedCommentIds)!=null&&n.some(e=>this._markerContainsComment(t,e))?1:.58)}),this._state.previewMarker&&this._renderMarker(e,this._state.previewMarker,r,E),this.makeDirty(!1),this}_getZoomRatio(){return Number.isFinite(this._state.zoomRatio)&&this._state.zoomRatio>0?this._state.zoomRatio:1}_containsComment(e){return this._state.markers.some(t=>this._markerContainsComment(t,e))||this._state.underlines.some(t=>t.commentId===e)}_markerContainsComment(e,t){var n;return t!=null&&(e.commentId===t||((n=e.commentIds)==null?void 0:n.includes(t))===!0)}_renderUnderline(e,t,n,r){e.save(),e.globalAlpha=r,e.strokeStyle=this._state.accentColor,e.lineWidth=2/n,e.beginPath(),e.moveTo(t.left,t.top),e.lineTo(t.left+t.width,t.top),e.stroke(),e.restore()}_renderOutline(e,t,n){let r=2/n;e.save(),e.strokeStyle=this._state.accentColor,e.lineWidth=2/n,e.strokeRect(t.left-r,t.top-r,t.width+r*2,t.height+r*2),e.restore()}_renderMarker(e,t,n,r){let i=24/n,a=t.x-i/2,s=t.y-i/2,c=4/n,l=4/n;if(e.save(),e.globalAlpha=r,e.fillStyle=this._state.accentColor,e.strokeStyle=this._state.outlineColor,e.lineWidth=1.5/n,e.beginPath(),e.moveTo(a+c,s),e.lineTo(a+i-c,s),e.quadraticCurveTo(a+i,s,a+i,s+c),e.lineTo(a+i,s+i-l-c),e.quadraticCurveTo(a+i,s+i-l,a+i-c,s+i-l),e.lineTo(a+i/2+l,s+i-l),e.lineTo(a+i/2,s+i),e.lineTo(a+i/2-l,s+i-l),e.lineTo(a+c,s+i-l),e.quadraticCurveTo(a,s+i-l,a,s+i-l-c),e.lineTo(a,s+c),e.quadraticCurveTo(a,s,a+c,s),e.closePath(),e.fill(),e.stroke(),e.fillStyle=this._state.foregroundColor,(t.count??1)>1)e.font=`600 ${11/n}px ${o.DEFAULT_FONTFACE_PLANE}`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(String(t.count),t.x,s+i*.42);else{let t=1.2/n,r=s+i*.43;[.32,.5,.68].forEach(n=>{e.beginPath(),e.arc(a+i*n,r,t,0,Math.PI*2),e.fill()})}e.restore()}};function O({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,l=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,c.useId)()}`,d=(0,c.useRef)(null);return(0,c.useImperativeHandle)(e,()=>d.current),(0,c.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return M(d.current)},[n,r]),k(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:l,...s},o)}function k(e,t,n,r,i){return(0,c.createElement)(e.tag,{key:t,...A(e,n,i),...r},(j(e,n).children||[]).map((r,a)=>k(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function A(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function j(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function M(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:N(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(P(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function N(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function P(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}O.displayName=`UniverIcon`;let F={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`}}]},I=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`delete-icon`,ref:t,icon:F}))});I.displayName=`DeleteIcon`;let L={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`}}]},R=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`increase-icon`,ref:t,icon:L}))});R.displayName=`IncreaseIcon`;let z={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`}}]},B=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`more-horizontal-icon`,ref:t,icon:z}))});B.displayName=`MoreHorizontalIcon`;let V={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M10.3536 12.3536C10.1583 12.5488 9.84171 12.5488 9.64645 12.3536L6.64645 9.35355C6.45118 9.15829 6.45118 8.84171 6.64645 8.64645L9.64645 5.64645C9.84171 5.45118 10.1583 5.45118 10.3536 5.64645C10.5488 5.84171 10.5488 6.15829 10.3536 6.35355L7.70711 9L10.3536 11.6464C10.5488 11.8417 10.5488 12.1583 10.3536 12.3536Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},H=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`more-left-icon`,ref:t,icon:V}))});H.displayName=`MoreLeftIcon`;let U={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}}]},W=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`reply-to-comment-icon`,ref:t,icon:U}))});W.displayName=`ReplyToCommentIcon`;let G={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 15C11.866 15 15 11.866 15 8C15 4.13401 11.866 1 8 1C4.13401 1 1 4.13401 1 8C1 11.866 4.13401 15 8 15ZM11.7245 6.42417C11.9588 6.18985 11.9588 5.80995 11.7245 5.57564C11.4901 5.34132 11.1102 5.34132 10.8759 5.57564L7.3002 9.15137L5.72446 7.57564C5.49014 7.34132 5.11025 7.34132 4.87593 7.57564C4.64162 7.80995 4.64162 8.18985 4.87593 8.42417L6.87593 10.4242C7.11025 10.6585 7.49014 10.6585 7.72446 10.4242L11.7245 6.42417Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},K=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`success-icon`,ref:t,icon:G}))});K.displayName=`SuccessIcon`;let q={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}}]},J=(0,c.forwardRef)(function(e,t){return(0,c.createElement)(O,Object.assign({},e,{id:`success-outline-icon`,ref:t,icon:q}))});J.displayName=`SuccessOutlineIcon`;function Y(e,t){return(e==null?void 0:e.unitId)===t.unitId&&e.subUnitId===t.subUnitId&&e.commentId===t.id}function X(e,t,n){return e?e.unitId!==t||!n:!1}function ee(e,t,n){return e.id?e.id:[`thread-comment-panel-temp`,n,e.unitId,e.subUnitId,e.threadId,e.ref,e.dT,t].join(`-`)}let Z=e=>{let{dataStream:t,customRanges:n}=e,r=t.endsWith(`\r
|
|
2
2
|
`)?t.length-2:t.length,i=[],a=0;return n==null||n.forEach(e=>{a<e.startIndex&&i.push({type:`text`,content:t.slice(a,e.startIndex)}),i.push({type:`mention`,content:{label:t.slice(e.startIndex,e.endIndex+1),id:e.rangeId}}),a=e.endIndex+1}),i.push({type:`text`,content:t.slice(a,r)}),i},Q=e=>{if(!e)return[];let{paragraphs:n=[]}=e;return n.map((r,i)=>{let a=i===0?0:n[i-1].startIndex+1,o=(0,t.getBodySlice)(e,a,r.startIndex);return Z(o)})},te=e=>{let n=``,r=[];return e.forEach(e=>{switch(e.type){case`text`:n+=e.content;break;case`mention`:{let i=n.length;n+=e.content.label;let a=n.length-1;r.push({rangeId:e.content.id,rangeType:t.CustomRangeType.MENTION,startIndex:i,endIndex:a,properties:{},wholeEntity:!0});break}}}),n+=`\r
|
|
3
3
|
`,{textRuns:[],paragraphs:[{startIndex:n.length-2,paragraphId:(0,t.createParagraphId)(new Set),paragraphStyle:{}}],sectionBreaks:[{sectionId:(0,t.createSectionId)(new Set),startIndex:n.length-1}],dataStream:n,customRanges:r}};function $(e,t,n){e.focus(t),n==null||n.focus()}function ne(e){let{location:n,unitId:r,subUnitId:i,commentId:a,fallbackId:o}=e;return`${t.DOCS_COMMENT_EDITOR_UNIT_ID_KEY}_${n}_${r}_${i}_${a||o}`}function re(e){return{id:`d`,body:e,documentStyle:{}}}let ie=(0,c.forwardRef)((e,r)=>{let{comment:a,onSave:o,id:u,onCancel:d,autoFocus:f,unitId:p,type:m,editorId:h,ActionRowComponent:g=s.ActionRow}=e,v=(0,n.useDependency)(t.ICommandService),y=(0,n.useDependency)(t.LocaleService),[b,x]=(0,c.useState)(!1),[S,C]=(0,c.useState)(!1),w=(0,c.useRef)(!1),T=(0,c.useRef)(!0),E=(0,n.useDependency)(i.IEditorService),D=(0,c.useRef)(null),O=m===t.UniverInstanceType.UNIVER_DOC?t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:p,[k,A]=(0,c.useState)(()=>{var e;return t.BuildTextUtils.transform.getPlainText((a==null||(e=a.text)==null?void 0:e.dataStream)??``)}),j=(0,c.useMemo)(()=>({keyCodes:[{keyCode:n.KeyCode.ENTER},{keyCode:n.KeyCode.BACKSPACE},{keyCode:n.KeyCode.DELETE}],handler:e=>{let r;switch(e){case n.KeyCode.ENTER:r=i.BreakLineCommand.id;break;case n.KeyCode.BACKSPACE:r=i.DeleteLeftCommand.id;break;case n.KeyCode.DELETE:r=i.DeleteRightCommand.id;break;default:return}$(E,h,D.current),v.executeCommand(r).then(()=>{if(e!==n.KeyCode.ENTER&&T.current){var r;let e=((r=D.current)==null||(r=r.getDocumentData().body)==null?void 0:r.dataStream)??``;A(t.BuildTextUtils.transform.getPlainText(e))}})}}),[v,h,E]);return(0,c.useImperativeHandle)(r,()=>({reply(e){var n;if(!D.current)return;$(E,h,D.current);let r=re(e);(n=D.current)==null||n.setDocumentData(r,[{startOffset:r.body.dataStream.length-2,endOffset:r.body.dataStream.length-2,collapsed:!0}]),A(t.BuildTextUtils.transform.getPlainText(r.body.dataStream)),x(!0)}})),(0,c.useEffect)(()=>(T.current=!0,()=>{T.current=!1}),[]),(0,c.useEffect)(()=>{if(!f)return;let e=setTimeout(()=>{$(E,h,D.current)});return()=>clearTimeout(e)},[f,h,E]),(0,l.jsxs)(`div`,{onClick:e=>e.preventDefault(),children:[(0,l.jsx)(`div`,{onMouseDown:()=>{$(E,h,D.current),x(!0)},children:(0,l.jsx)(i.RichTextEditor,{className:`univer-w-full`,editorRef:D,editorId:h,preserveHostFocus:!0,autoFocus:f,keyboardEventConfig:j,placeholder:y.t(`thread-comment-ui.editor.placeholder`),initialValue:(a==null?void 0:a.text)&&re(a.text),onChange:e=>{var n;return A(t.BuildTextUtils.transform.getPlainText(((n=e.body)==null?void 0:n.dataStream)??``))},onFocusChange:e=>e&&x(e),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{E.focus(O)},30)}})}),b?(0,l.jsxs)(g,{className:`univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[(0,l.jsx)(s.Button,{type:`button`,onClick:()=>{let e=D.current;e==null||e.blur(),e==null||e.replaceText(``,!1),e==null||e.setSelectionRanges([],!1),A(``),d==null||d(),x(!1),v.executeCommand(_.id)},children:y.t(`thread-comment-ui.editor.cancel`)}),(0,l.jsx)(s.Button,{type:`button`,variant:`primary`,disabled:!k||S,onClick:async()=>{let e=D.current;if(!e||w.current)return;let n=t.Tools.deepClone(e.getDocumentData().body);w.current=!0,C(!0);try{if(await(o==null?void 0:o({...a,text:n}))===!1||!T.current)return;e.blur(),e.replaceText(``,!1),e.setSelectionRanges([],!1),A(``),x(!1)}catch{return}finally{w.current=!1,T.current&&C(!1)}},children:y.t(u?`thread-comment-ui.editor.save`:`thread-comment-ui.editor.reply`)})]}):null]})}),ae=function(e){return e.CELL=`CELL`,e.PANEL=`PANEL`,e}({}),oe=`__mock__`;function se(e,n){let r=(0,t.dateKit)(e),i=t.LOCALE_META[n].tag;return r.formatIntl(i,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1,numberingSystem:`latn`})}let ce=e=>{let{item:r,unitId:i,subUnitId:o,editing:s,onEditingChange:u,onReply:d,resolved:f,isRoot:p,onClose:m,onDeleteComment:h,onAfterDeleteComment:g,type:_,threadCommentEditorId:v,DropdownComponent:y,EditorComponent:b}=e,x=(0,n.useDependency)(t.ICommandService),S=(0,n.useDependency)(t.LocaleService),C=(0,n.useDependency)(t.RegionService),w=(0,n.useDependency)(t.UserManagerService);(0,n.useObservable)(w.userChange$);let T=w.getUser(r.personId),E=(0,n.useObservable)(w.currentUser$),D=(E==null?void 0:E.userID)===r.personId,O=r.id===oe,[k,A]=(0,c.useState)(!1),j=(0,n.useConfigValue)(n.UI_PLUGIN_CONFIG_KEY),M=j==null?void 0:j.avatarFallback,N=(0,n.useObservable)(C.currentRegion$,C.getCurrentRegion()),P=(0,n.useObservable)(S.direction$,S.getDirection()),F=O?null:se(r.dT,N);return(0,l.jsxs)(`div`,{className:`univer-relative univer-mb-3 univer-pl-[30px] rtl:univer-pl-0 rtl:univer-pr-[30px]`,onMouseLeave:()=>A(!1),onMouseEnter:()=>A(!0),children:[(0,l.jsx)(`div`,{className:`univer-absolute univer-left-0 univer-top-0 univer-size-6 univer-rounded-full univer-bg-cover univer-bg-center univer-bg-no-repeat rtl:univer-left-auto rtl:univer-right-0`,style:{backgroundImage:`url(${(T==null?void 0:T.avatar)||M})`}}),T||r.authorName?(0,l.jsxs)(`div`,{className:`univer-mb-1 univer-flex univer-h-6 univer-items-center univer-justify-between`,children:[(0,l.jsx)(`div`,{className:`univer-text-sm univer-font-medium univer-leading-5`,children:(T==null?void 0:T.name)||r.authorName||` `}),(0,l.jsxs)(`div`,{children:[O||f?null:k&&T?(0,l.jsx)(`button`,{type:`button`,"aria-label":S.t(`thread-comment-ui.editor.reply`),className:`univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-border-0 univer-bg-transparent univer-p-0 univer-text-base hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800`,onClick:()=>d(T),children:(0,l.jsx)(W,{})}):null,D&&!O&&!f?(0,l.jsx)(y,{overlay:(0,l.jsx)(`div`,{dir:P,className:`univer-rounded-lg`,children:(0,l.jsxs)(`ul`,{className:`univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm rtl:univer-text-right [&_button]:univer-block [&_button]:univer-w-full [&_button]:univer-cursor-pointer [&_button]:univer-rounded [&_button]:univer-border-0 [&_button]:univer-bg-transparent [&_button]:univer-px-2 [&_button]:univer-py-1.5 [&_button]:univer-text-left [&_button]:univer-transition-colors rtl:[&_button]:univer-text-right`,children:[(0,l.jsx)(`li`,{children:(0,l.jsx)(`button`,{type:`button`,className:`hover:univer-bg-gray-200`,onClick:()=>u==null?void 0:u(!0),children:S.t(`thread-comment-ui.item.edit`)})}),(0,l.jsx)(`li`,{children:(0,l.jsx)(`button`,{type:`button`,className:`hover:univer-bg-gray-200`,onClick:async()=>{if((h==null?void 0:h(r))!==!1)try{if(await x.executeCommand(p?a.DeleteCommentTreeCommand.id:a.DeleteCommentCommand.id,{unitId:i,subUnitId:o,commentId:r.id})){try{await(g==null?void 0:g(r))}catch{}p&&(m==null||m())}}catch{}},children:S.t(`thread-comment-ui.item.delete`)})})]})}),children:(0,l.jsx)(`button`,{type:`button`,"aria-label":S.t(`thread-comment-ui.item.more`),className:`univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-border-0 univer-bg-transparent univer-p-0 univer-text-base hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800`,children:(0,l.jsx)(B,{})})}):null]})]}):null,F&&(0,l.jsx)(`time`,{className:`univer-mb-1 univer-block univer-text-xs/normal univer-text-gray-600 rtl:univer-text-right dark:!univer-text-gray-200`,children:(0,l.jsx)(`bdo`,{dir:`ltr`,children:F})}),s?(0,l.jsx)(b,{type:_,id:r.id,comment:r,onCancel:()=>u==null?void 0:u(!1),autoFocus:!0,unitId:i,subUnitId:o,editorId:v,onSave:async({text:e,attachments:t})=>{let n=await x.executeCommand(a.UpdateCommentCommand.id,{unitId:i,subUnitId:o,payload:{commentId:r.id,text:e,attachments:t}});return n&&(u==null||u(!1)),n}}):(0,l.jsx)(`div`,{className:`univer-text-sm univer-text-gray-900 dark:!univer-text-gray-0`,children:Q(r.text).map((e,t)=>{var n;let i=0;return(0,l.jsx)(`div`,{className:`univer-break-words`,children:e.map(e=>{let t=i;switch(i+=e.type===`mention`?e.content.label.length:e.content.length,e.type){case`mention`:return(0,l.jsxs)(`a`,{className:`univer-text-primary-600`,children:[e.content.label,` `]},t);default:return e.content}})},(n=r.text.paragraphs)==null||(n=n[t])==null?void 0:n.paragraphId)})})]})},le=e=>{let{id:i,unitId:o,subUnitId:u,refStr:d,displayRef:f,showEdit:p=!0,onClick:m,showHighlight:h,onClose:g,getSubUnitName:v,location:y,autoFocus:b,onMouseEnter:x,onMouseLeave:S,onAddComment:C,onDeleteComment:w,onAfterDeleteComment:T,onResolve:E,type:D,style:O,full:k,DropdownComponent:A=s.Dropdown,EditorComponent:j=ie}=e,M=(0,n.useDependency)(a.ThreadCommentModel),[N,P]=(0,c.useState)(!1),[F,L]=(0,c.useState)(``),R=(0,c.useMemo)(()=>M.commentUpdate$.pipe((0,r.debounceTime)(16)),[M]),z=(0,n.useObservable)(()=>i?R.pipe((0,r.map)(()=>M.getCommentWithChildren(o,u,i)),(0,r.startWith)(M.getCommentWithChildren(o,u,i))):(0,r.of)(null),null,!1,[i,u,M,o,R]),B=(0,n.useDependency)(t.ICommandService),V=(0,n.useDependency)(t.LocaleService),H=(0,n.useDependency)(t.UserManagerService),U=z==null?void 0:z.root.resolved,W=(0,n.useObservable)(H.currentUser$),G=(0,c.useRef)(null),q=(0,c.useMemo)(()=>(0,t.generateRandomId)(6),[]),Y=[...z?[z.root]:[{id:oe,text:{dataStream:`
|
|
4
4
|
\r`},personId:(W==null?void 0:W.userID)??``,ref:d??``,dT:``,unitId:o,subUnitId:u,threadId:``}],...(z==null?void 0:z.children)??[]],X=(0,c.useRef)(null),ee=(0,n.useEvent)(S),Z=async e=>{e.stopPropagation();try{if(!await B.executeCommand(a.ResolveCommentCommand.id,{unitId:o,subUnitId:u,commentId:i,resolved:!U}))return;await B.executeCommand(_.id,U?{unitId:o,subUnitId:u,commentId:i}:void 0),E==null||E(!U)}catch{}},Q=async e=>{e.stopPropagation();let t=z==null?void 0:z.root;if(t&&(w==null?void 0:w(t))!==!1)try{if(await B.executeCommand(a.DeleteCommentTreeCommand.id,{unitId:o,subUnitId:u,commentId:i})){try{await(T==null?void 0:T(t))}catch{}await B.executeCommand(_.id),g==null||g()}}catch{}};(0,c.useEffect)(()=>ee,[ee]);let $=v((z==null?void 0:z.root.subUnitId)??u),re=p&&!F&&!U,ae=`${f??d??(z==null?void 0:z.root.ref)??``}${$?` · `:``}${$}`,se=ne({location:y,unitId:o,subUnitId:u,commentId:i,fallbackId:q});return(0,l.jsxs)(`div`,{id:`${y}-${o}-${u}-${i}`,className:(0,s.clsx)(`univer-relative univer-box-border univer-rounded-md univer-bg-gray-0 univer-p-4 univer-text-gray-900 dark:!univer-bg-gray-900 dark:!univer-text-gray-0`,s.borderClassName,{"univer-w-[278px]":!k,"univer-w-full":k,"univer-shadow":!U&&(h||N||y===`CELL`)}),style:O,onClick:m,onMouseEnter:()=>{x==null||x(),P(!0)},onMouseLeave:()=>{S==null||S(),P(!1)},children:[!U&&h&&(0,l.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`}),(0,l.jsxs)(`div`,{className:`univer-mb-4 univer-flex univer-flex-row univer-items-center univer-justify-between univer-text-sm univer-leading-5`,children:[(0,l.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-row univer-items-center univer-overflow-hidden`,children:[(0,l.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 rtl:univer-ml-2 rtl:univer-mr-0`}),(0,l.jsx)(s.Tooltip,{showIfEllipsis:!0,title:ae,children:(0,l.jsx)(`span`,{className:`univer-flex-1 univer-truncate`,children:ae})})]}),!!z&&(0,l.jsxs)(`div`,{className:`univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row`,children:[(0,l.jsx)(`button`,{type:`button`,"aria-label":V.t(U?`thread-comment-ui.filter.status.unsolved`:`thread-comment-ui.filter.status.resolved`),className:(0,s.clsx)(`univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-border-0 univer-bg-transparent univer-p-0 univer-text-base hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800`,{"univer-text-green-500":U}),onClick:Z,children:U?(0,l.jsx)(K,{}):(0,l.jsx)(J,{})}),(W==null?void 0:W.userID)===z.root.personId?(0,l.jsx)(`button`,{type:`button`,"aria-label":V.t(`thread-comment-ui.item.delete`),className:`univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-border-0 univer-bg-transparent univer-p-0 univer-text-base hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800`,onClick:Q,children:(0,l.jsx)(I,{})}):null]})]}),(0,l.jsx)(`div`,{ref:X,className:(0,s.clsx)(`univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden`,s.scrollbarClassName,y===`PANEL`&&`-univer-mx-4 univer-px-4`),children:Y.map(e=>(0,l.jsx)(ce,{unitId:o,subUnitId:u,item:e,isRoot:e.id===(z==null?void 0:z.root.id),editing:F===e.id,resolved:z==null?void 0:z.root.resolved,type:D,threadCommentEditorId:se,DropdownComponent:A,EditorComponent:j,onClose:g,onEditingChange:t=>{L(t?e.id:``)},onReply:e=>{e&&requestAnimationFrame(()=>{var t;(t=G.current)==null||t.reply(te([{type:`mention`,content:{id:e.userID,label:`@${e.name}`}},{type:`text`,content:` `}]))})},onDeleteComment:w,onAfterDeleteComment:T},e.id))}),re&&(0,l.jsx)(`div`,{children:(0,l.jsx)(j,{ref:G,type:D,unitId:o,subUnitId:u,editorId:se,onSave:async({text:e,attachments:n})=>{let r={text:e,attachments:n,dT:(0,a.getDT)(),id:(0,t.generateRandomId)(),ref:d,personId:(W==null?void 0:W.userID)??``,parentId:z==null?void 0:z.root.id,unitId:o,subUnitId:u,threadId:(z==null?void 0:z.root.threadId)??``};if(await(C==null?void 0:C(r))===!1)return z||g==null||g(),!0;let i=await B.executeCommand(a.AddCommentCommand.id,{unitId:o,subUnitId:u,comment:r});return i&&X.current&&(X.current.scrollTop=X.current.scrollHeight),i&&!z&&(g==null||g()),i},autoFocus:b||!z,onCancel:()=>{z||g==null||g()}},`${b}`)})]})},ue=(0,c.forwardRef)((e,t)=>(0,l.jsx)(ie,{...e,ref:t,ActionRowComponent:s.MobileActionRowGroup}));function de(e){return(0,l.jsx)(le,{...e,DropdownComponent:s.MobileDropdown,EditorComponent:ue})}function fe({value:e,options:t=[],onChange:n}){return(0,l.jsx)(`div`,{className:`univer-flex univer-gap-1 univer-overflow-x-auto univer-rounded-xl univer-bg-gray-100 univer-p-1 dark:!univer-bg-gray-800`,children:t.flatMap(e=>e.options??[e]).map(t=>(0,l.jsx)(`button`,{type:`button`,"aria-pressed":t.value===e,className:(0,s.clsx)(s.resetButtonClassName,`univer-h-10 univer-shrink-0 univer-rounded-lg univer-px-3 univer-text-sm univer-text-gray-700 active:univer-scale-95 dark:!univer-text-gray-200`,t.value===e&&`univer-bg-gray-0 univer-font-medium univer-text-primary-600 univer-shadow-sm dark:!univer-bg-gray-700 dark:!univer-text-primary-300`),onClick:()=>t.value!=null&&(n==null?void 0:n(t.value)),children:t.label},t.value))})}function pe({comment:e,displayRef:r}){let i=(0,n.useDependency)(t.LocaleService),a=(0,n.useDependency)(t.ICommandService);return(0,l.jsxs)(`div`,{className:`univer-mt-2 univer-flex univer-min-h-12 univer-items-center univer-gap-2 univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-pb-2 dark:!univer-border-gray-700`,children:[(0,l.jsx)(`button`,{type:`button`,"aria-label":i.t(`thread-comment-ui.mobile.back`),className:`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/thread-comment-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared thread comment UI components and services for Univer.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -58,16 +58,16 @@
|
|
|
58
58
|
"rxjs": ">=7.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/core": "1.0.
|
|
62
|
-
"@univerjs/design": "1.0.
|
|
63
|
-
"@univerjs/docs-ui": "1.0.
|
|
64
|
-
"@univerjs/engine-render": "1.0.
|
|
61
|
+
"@univerjs/core": "1.0.1",
|
|
62
|
+
"@univerjs/design": "1.0.1",
|
|
63
|
+
"@univerjs/docs-ui": "1.0.1",
|
|
64
|
+
"@univerjs/engine-render": "1.0.1",
|
|
65
65
|
"@univerjs/icons": "1.43.0",
|
|
66
|
-
"@univerjs/thread-comment": "1.0.
|
|
67
|
-
"@univerjs/ui": "1.0.
|
|
66
|
+
"@univerjs/thread-comment": "1.0.1",
|
|
67
|
+
"@univerjs/ui": "1.0.1"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@univerjs-infra/shared": "1.0.
|
|
70
|
+
"@univerjs-infra/shared": "1.0.1",
|
|
71
71
|
"postcss": "^8.5.28",
|
|
72
72
|
"react": "18.3.1",
|
|
73
73
|
"rxjs": "^7.8.2",
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import type { IDocumentBody, IUser } from '@univerjs/core';
|
|
17
|
-
import type { IThreadComment } from '@univerjs/thread-comment';
|
|
18
|
-
import { UniverInstanceType } from '@univerjs/core';
|
|
19
|
-
export interface IThreadCommentEditorProps {
|
|
20
|
-
id?: string;
|
|
21
|
-
comment?: Pick<IThreadComment, 'attachments' | 'text' | 'mentions'>;
|
|
22
|
-
onSave?: (comment: Pick<IThreadComment, 'attachments' | 'text'>) => void;
|
|
23
|
-
onCancel?: () => void;
|
|
24
|
-
autoFocus?: boolean;
|
|
25
|
-
unitId: string;
|
|
26
|
-
subUnitId: string;
|
|
27
|
-
type: UniverInstanceType;
|
|
28
|
-
editorId: string;
|
|
29
|
-
}
|
|
30
|
-
export interface IThreadCommentEditorInstance {
|
|
31
|
-
reply: (text: IDocumentBody) => void;
|
|
32
|
-
}
|
|
33
|
-
export declare const ThreadCommentEditor: import("react").ForwardRefExoticComponent<IThreadCommentEditorProps & import("react").RefAttributes<IThreadCommentEditorInstance>>;
|
|
34
|
-
export declare const ThreadCommentSuggestion: ({ active, user }: {
|
|
35
|
-
active: boolean;
|
|
36
|
-
user: IUser;
|
|
37
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import type { Nullable } from '@univerjs/core';
|
|
17
|
-
import type { IThreadComment } from '@univerjs/thread-comment';
|
|
18
|
-
import type { Observable } from 'rxjs';
|
|
19
|
-
import type { IThreadCommentTreeProps } from '../thread-comment-tree';
|
|
20
|
-
import { UniverInstanceType } from '@univerjs/core';
|
|
21
|
-
export interface IThreadCommentPanelProps {
|
|
22
|
-
unitId: string;
|
|
23
|
-
subUnitId$: Observable<string | undefined>;
|
|
24
|
-
type: UniverInstanceType;
|
|
25
|
-
onAdd: () => void;
|
|
26
|
-
getSubUnitName: (subUnitId: string) => string;
|
|
27
|
-
onResolve?: (id: string, resolved: boolean) => void;
|
|
28
|
-
sortComments?: (comments: IThreadComment[]) => IThreadComment[];
|
|
29
|
-
onItemLeave?: (comment: IThreadComment) => void;
|
|
30
|
-
onItemEnter?: (comment: IThreadComment) => void;
|
|
31
|
-
disableAdd?: boolean;
|
|
32
|
-
tempComment?: Nullable<IThreadComment>;
|
|
33
|
-
onAddComment?: IThreadCommentTreeProps['onAddComment'];
|
|
34
|
-
onDeleteComment?: IThreadCommentTreeProps['onDeleteComment'];
|
|
35
|
-
showComments?: string[];
|
|
36
|
-
}
|
|
37
|
-
export declare const ThreadCommentPanel: (props: IThreadCommentPanelProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import type { IUser, UniverInstanceType } from '@univerjs/core';
|
|
17
|
-
import type { IThreadComment } from '@univerjs/thread-comment';
|
|
18
|
-
export declare enum ThreadCommentTreeLocation {
|
|
19
|
-
CELL = "CELL",
|
|
20
|
-
PANEL = "PANEL"
|
|
21
|
-
}
|
|
22
|
-
export interface IThreadCommentTreeProps {
|
|
23
|
-
full?: boolean;
|
|
24
|
-
id?: string;
|
|
25
|
-
unitId: string;
|
|
26
|
-
subUnitId: string;
|
|
27
|
-
type: UniverInstanceType;
|
|
28
|
-
refStr?: string;
|
|
29
|
-
showEdit?: boolean;
|
|
30
|
-
onClick?: () => void;
|
|
31
|
-
showHighlight?: boolean;
|
|
32
|
-
onClose?: () => void;
|
|
33
|
-
getSubUnitName: (subUnitId: string) => string;
|
|
34
|
-
location: ThreadCommentTreeLocation;
|
|
35
|
-
autoFocus?: boolean;
|
|
36
|
-
onMouseEnter?: () => void;
|
|
37
|
-
onMouseLeave?: () => void;
|
|
38
|
-
onAddComment?: (comment: IThreadComment) => boolean;
|
|
39
|
-
onDeleteComment?: (comment: IThreadComment) => boolean;
|
|
40
|
-
onResolve?: (resolved: boolean) => void;
|
|
41
|
-
style?: React.CSSProperties;
|
|
42
|
-
}
|
|
43
|
-
export interface IThreadCommentItemProps {
|
|
44
|
-
item: IThreadComment;
|
|
45
|
-
unitId: string;
|
|
46
|
-
subUnitId: string;
|
|
47
|
-
onEditingChange?: (editing: boolean) => void;
|
|
48
|
-
editing?: boolean;
|
|
49
|
-
onClick?: () => void;
|
|
50
|
-
resolved?: boolean;
|
|
51
|
-
onReply: (user: IUser | undefined) => void;
|
|
52
|
-
isRoot?: boolean;
|
|
53
|
-
onClose?: () => void;
|
|
54
|
-
onAddComment?: (comment: IThreadComment) => boolean;
|
|
55
|
-
onDeleteComment?: (comment: IThreadComment) => boolean;
|
|
56
|
-
type: UniverInstanceType;
|
|
57
|
-
threadCommentEditorId: string;
|
|
58
|
-
}
|
|
59
|
-
export declare const ThreadCommentTree: (props: IThreadCommentTreeProps) => import("react/jsx-runtime").JSX.Element;
|