@univerjs/sheets-thread-comment 0.2.2 → 0.2.3
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/README.md +15 -6
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +138 -138
- package/lib/locale/vi-VN.json +8 -0
- package/lib/locale/zh-TW.json +8 -0
- package/lib/types/locale/vi-VN.d.ts +24 -0
- package/lib/types/locale/zh-TW.d.ts +24 -0
- package/lib/umd/index.js +1 -1
- package/package.json +18 -18
package/README.md
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# @univerjs/sheets-thread-comment
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
## Package Overview
|
|
4
|
+
|
|
5
|
+
| Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
|
|
6
|
+
| --- | --- | --- | --- | --- | :---: | :---: |
|
|
7
|
+
| `@univerjs/sheets-thread-comment` | `UniverSheetsThreadComment` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ⭕️ | ⭕️ |
|
|
5
8
|
|
|
6
9
|
## Introduction
|
|
7
10
|
|
|
8
11
|
`@univerjs/sheets-thread-comment` provides the comment/annotation function of Univer Sheets.
|
|
9
12
|
|
|
10
|
-
|
|
11
13
|
## Usage
|
|
12
14
|
|
|
13
|
-
###
|
|
15
|
+
### Installation
|
|
14
16
|
|
|
15
17
|
```shell
|
|
16
18
|
# Use npm
|
|
@@ -20,8 +22,9 @@ npm install @univerjs/sheets-thread-comment
|
|
|
20
22
|
pnpm add @univerjs/sheets-thread-comment
|
|
21
23
|
```
|
|
22
24
|
|
|
23
|
-
###
|
|
24
|
-
|
|
25
|
+
### Register the plugin
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
25
28
|
import { UniverSheetsThreadCommentPlugin, IThreadCommentMentionDataService} from '@univerjs/sheets-thread-comment';
|
|
26
29
|
|
|
27
30
|
const mockUser = {
|
|
@@ -58,3 +61,9 @@ univer.registerPlugin(UniverSheetsThreadCommentPlugin, {
|
|
|
58
61
|
overrides: [[IThreadCommentMentionDataService, { useClass: CustomMentionDataService }]],
|
|
59
62
|
});
|
|
60
63
|
```
|
|
64
|
+
|
|
65
|
+
<!-- Links -->
|
|
66
|
+
[npm-version-shield]: https://img.shields.io/npm/v/@univerjs/sheets-thread-comment?style=flat-square
|
|
67
|
+
[npm-version-link]: https://npmjs.com/package/@univerjs/sheets-thread-comment
|
|
68
|
+
[npm-license-shield]: https://img.shields.io/npm/l/@univerjs/sheets-thread-comment?style=flat-square
|
|
69
|
+
[npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/sheets-thread-comment?style=flat-square
|
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var se=Object.defineProperty;var ae=(o,r,n)=>r in o?se(o,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[r]=n;var N=(o,r,n)=>ae(o,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@wendellhu/redi"),a=require("@univerjs/core"),M=require("@univerjs/thread-comment-ui"),S=require("@univerjs/ui"),C=require("@univerjs/sheets"),x=require("@univerjs/engine-formula"),y=require("@univerjs/thread-comment"),w=require("@univerjs/sheets-ui"),D=require("@univerjs/sheets-thread-comment-base"),R=require("@wendellhu/redi/react-bindings"),T=require("react"),z=require("rxjs"),ce=require("@univerjs/engine-render");var b=function(){return b=Object.assign||function(o){for(var r,n=1,e=arguments.length;n<e;n++){r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(o[t]=r[t])}return o},b.apply(this,arguments)},me=function(o,r){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&r.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(o);t<e.length;t++)r.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(o,e[t])&&(n[e[t]]=o[e[t]]);return n},Q=T.forwardRef(function(o,r){var n=o.icon,e=o.id,t=o.className,i=o.extend,s=me(o,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),m=T.useRef("_".concat(he()));return ee(n,"".concat(e),{defIds:n.defIds,idSuffix:m.current},b({ref:r,className:c},s),i)});function ee(o,r,n,e,t){return T.createElement(o.tag,b(b({key:r},de(o,n,t)),e),(ue(o,n).children||[]).map(function(i,s){return ee(i,"".concat(r,"-").concat(o.tag,"-").concat(s),n,void 0,t)}))}function de(o,r,n){var e=b({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=r.defIds;return!t||t.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],c=i[1];typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function ue(o,r){var n,e=r.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?b(b({},o),{children:o.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?b(b({},t),{attrs:b(b({},t.attrs),{id:t.attrs.id+r.idSuffix})}):t})}):o}function he(){return Math.random().toString(36).substring(2,8)}Q.displayName="UniverIcon";var le={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=T.forwardRef(function(o,r){return T.createElement(Q,Object.assign({},o,{id:"comment-single",ref:r,icon:le}))});te.displayName="CommentSingle";const ne="univer.sheet.thread-comment-modal",G="comment-single",K="SHEET_THREAD_COMMENT";var pe=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,ve=(o,r,n,e)=>{for(var t=e>1?void 0:e?Ce(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&pe(r,n,t),t},X=(o,r)=>(n,e)=>r(n,e,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new z.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible()}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var p;const{row:t,col:i,unitId:s,subUnitId:c}=n;if(this._activePopup&&t===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((p=this.activePopup)==null?void 0:p.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._canvasPopupManagerService.attachPopupToCell(t,i,{componentKey:ne,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new a.DisposableCollection;h.add(m),h.add({dispose:()=>{e==null||e()}}),this._lastPopup=h}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=ve([X(0,l.Inject(w.SheetCanvasPopManagerService)),X(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const Se=()=>{const o=R.useDependency(a.IUniverInstanceService),r=R.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(r.activePopup$),e=R.useDependency(D.SheetsThreadCommentModel);if(S.useObservable(e.commentUpdate$),!n)return null;const{row:t,col:i,unitId:s,subUnitId:c,trigger:m}=n,h=e.getByLocation(s,c,t,i),p=`${a.Tools.chatAtABC(i)}${t+1}`,u=()=>{r.hidePopup()},f=v=>{var g,_,$;return($=(_=(g=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:g.getSheetBySheetId(v))==null?void 0:_.getName())!=null?$:""};return T.createElement(M.ThreadCommentTree,{onClick:()=>{r.persistPopup()},prefix:"cell",id:h,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:p,onClose:u,getSubUnitName:f,autoFocus:m==="context-menu"})},H={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var _;const r=o.get(C.SelectionManagerService),n=o.get(a.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),t=o.get(M.ThreadCommentPanelService),i=(_=r.getFirst())==null?void 0:_.primary,s=r.getCurrent(),c=o.get(D.SheetsThreadCommentModel);if(!s||!i)return!1;const{unitId:m,sheetId:h}=s,p=C.getSheetCommandTarget(n,{unitId:m,subUnitId:h});if(!p)return!1;const{workbook:u,worksheet:f}=p,v={workbook:u,worksheet:f,unitId:m,subUnitId:h,row:i.startRow,col:i.startColumn};e.showPopup(v);const g=c.getByLocation(m,h,i.startRow,i.startColumn);return g&&t.setActiveComment({unitId:m,subUnitId:h,commentId:g,trigger:"context-menu"}),!0}},fe=()=>{var B;const o=R.useDependency(w.IMarkSelectionService),r=R.useDependency(a.IUniverInstanceService),n=R.useDependency(y.ThreadCommentModel),e=R.useDependency(exports.SheetsThreadCommentPopupService),t=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return null;const i=t.getUnitId(),s=R.useDependency(a.ICommandService),c=T.useMemo(()=>t.activeSheet$.pipe(z.map(d=>d==null?void 0:d.getSheetId())),[t.activeSheet$]),m=S.useObservable(c,(B=t.getActiveSheet())==null?void 0:B.getSheetId()),h=T.useRef(),p=R.useDependency(M.ThreadCommentPanelService),u=S.useObservable(p.activeCommentId$),f=T.useCallback(d=>{const I=t.getSheets(),P={};I.forEach((U,O)=>{P[U.getSheetId()]=O});const V=U=>U.map(O=>{var Y;const j=x.singleReferenceToGrid(O.ref),ie=[(Y=P[O.subUnitId])!=null?Y:0,j.row,j.column];return{...O,p:ie}}).sort((O,j)=>O.p[0]===j.p[0]?O.p[1]===j.p[1]?O.p[2]-j.p[2]:O.p[1]-j.p[1]:O.p[0]-j.p[0]);return[...V(d.filter(U=>!U.resolved)),...V(d.filter(U=>U.resolved))]},[t]),v=T.useCallback(d=>{if(d.unitId===i&&d.subUnitId===m&&!d.resolved){const{row:I,column:P}=x.singleReferenceToGrid(d.ref);if(!Number.isNaN(I)&&!Number.isNaN(P))return o.addShape({range:{startColumn:P,endColumn:P,startRow:I,endRow:I},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,m,i]),g=d=>{var I,P;return(P=(I=t.getSheetBySheetId(d))==null?void 0:I.getName())!=null?P:""},_=()=>{s.executeCommand(H.id)},$=d=>{u&&u.unitId===d.unitId&&u.subUnitId===d.subUnitId&&u.commentId===d.id||(h.current&&(o.removeShape(h.current),h.current=null),h.current=v(d))},A=()=>{h.current&&(o.removeShape(h.current),h.current=null)},L=(d,I)=>{I&&e.hidePopup()};return T.useEffect(()=>{if(!u)return;const d=n.getComment(u.unitId,u.subUnitId,u.commentId);if(!d)return;const I=v(d);return()=>{I&&o.removeShape(I)}},[v,u,n,o]),T.createElement(M.ThreadCommentPanel,{unitId:i,subUnitId$:c,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:_,getSubUnitName:g,onResolve:L,sortComments:f,onItemEnter:$,onItemLeave:A,onDeleteComment:()=>(A(),!0)})},_e=o=>({id:H.id,type:S.MenuItemType.BUTTON,positions:[S.MenuPosition.CONTEXT_MENU],icon:G,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET),disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Ie=o=>({id:M.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:G,tooltip:"sheetThreadComment.menu.commentManagement",positions:S.MenuPosition.TOOLBAR_START,group:S.MenuGroup.TOOLBAR_OTHERS,disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET)}),ge={id:H.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:w.whenSheetEditorFocused};var Pe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,be=(o,r,n,e)=>{for(var t=e>1?void 0:e?Te(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&Pe(r,n,t),t},E=(o,r)=>(n,e)=>r(n,e,o);const ye={};exports.SheetsThreadCommentController=class extends a.Disposable{constructor(r,n,e,t,i,s,c,m,h,p,u){super(),this._config=r,this._menuService=n,this._injector=e,this._componentManager=t,this._commandService=i,this._sheetsThreadCommentPopupService=s,this._sheetsThreadCommentModel=c,this._threadCommentPanelService=m,this._shortcutService=h,this._univerInstanceService=p,this._sheetPermissionInterceptorBaseController=u,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener()}_initShortcut(){this._shortcutService.registerShortcut(ge)}_initCommandListener(){this._commandService.onCommandExecuted(r=>{if(r.id===C.SetSelectionsOperation.id){const n=r.params,{unitId:e,subUnitId:t,selections:i,type:s}=n;if((s===C.SelectionMoveType.MOVE_END||s===void 0)&&i[0].primary){const c=i[0].primary.actualRow,m=i[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(e,t,c,m)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(M.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(e,t,c,m);h&&this._commandService.executeCommand(M.SetActiveCommentOperation.id,{unitId:e,subUnitId:t,commentId:h})}}if(r.id===y.DeleteCommentMutation.id){const n=r.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:t,subUnitId:i,commentId:s}=e;n.unitId===t&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:r={}}=this._config;[_e,Ie].forEach(n=>{this._menuService.addMenuItem(n(this._injector),r)})}_initComponent(){[[ne,Se],[M.THREAD_COMMENT_PANEL,fe],[G,te]].forEach(([r,n])=>{this._componentManager.register(r,n)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async r=>{var n;if(r){const{unitId:e,subUnitId:t,commentId:i,trigger:s}=r,c=this._sheetsThreadCommentModel.getComment(e,t,i);if(!c||c.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==e)return;((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==t&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t});const u=x.singleReferenceToGrid(c.ref),{row:f,column:v}=u;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:f,startColumn:v,endRow:f,endColumn:v}]))return;const _=1;await this._commandService.executeCommand(w.ScrollToRangeOperation.id,{range:{startRow:Math.max(u.row-_,0),endRow:u.row+_,startColumn:Math.max(u.column-_,0),endColumn:u.column+_}}),this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:t,row:u.row,col:u.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}};exports.SheetsThreadCommentController=be([a.OnLifecycle(a.LifecycleStages.Starting,exports.SheetsThreadCommentController),E(1,S.IMenuService),E(2,l.Inject(l.Injector)),E(3,l.Inject(S.ComponentManager)),E(4,a.ICommandService),E(5,l.Inject(exports.SheetsThreadCommentPopupService)),E(6,l.Inject(D.SheetsThreadCommentModel)),E(7,l.Inject(M.ThreadCommentPanelService)),E(8,S.IShortcutService),E(9,a.IUniverInstanceService),E(10,l.Inject(w.SheetPermissionInterceptorBaseController))],exports.SheetsThreadCommentController);var Me=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Oe=(o,r,n,e)=>{for(var t=e>1?void 0:e?we(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&Me(r,n,t),t},k=(o,r)=>(n,e)=>r(n,e,o);let q=class extends a.Disposable{constructor(o,r,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=r,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(o,r,n)=>{const{row:e,col:t,unitId:i,subUnitId:s}=r;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,t)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var s;const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return;const n=r.getUnitId(),e=(s=r.getActiveSheet())==null?void 0:s.getSheetId();if(!e){console.warn("No active sheet found");return}const t=this._renderManagerService.getRenderById(n),i=t==null?void 0:t.with(w.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:e});i==null||i.makeDirty(!0),i==null||i.calculate(),t&&t.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(r=>{o()}))}};q=Oe([a.OnLifecycle(a.LifecycleStages.Ready,q),k(0,l.Inject(C.SheetInterceptorService)),k(1,l.Inject(D.SheetsThreadCommentModel)),k(2,a.IUniverInstanceService),k(3,ce.IRenderManagerService)],q);var Ue=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Re=(o,r,n,e)=>{for(var t=e>1?void 0:e?Ee(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&Ue(r,n,t),t},Z=(o,r)=>(n,e)=>r(n,e,o);const je=(o,r,n)=>{const e=x.singleReferenceToGrid(o),t=n.row-r.row,i=n.column-r.column,s={startColumn:e.column+i,startRow:e.row+t,endColumn:e.column+i,endRow:e.row+t};return x.serializeRange(s)};exports.SheetsThreadCommentCopyPasteController=class extends a.Disposable{constructor(n,e,t){super();N(this,"_copyInfo");this._sheetClipboardService=n,this._sheetsThreadCommentModel=e,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:K,onBeforeCopy:(n,e,t)=>{this._copyInfo={unitId:n,subUnitId:e,range:t}},onPasteCells:(n,e,t,i)=>{const{unitId:s,subUnitId:c,range:m}=e,h={row:m.rows[0],column:m.cols[0]};if(i.copyType===w.COPY_TYPE.CUT&&this._copyInfo){const{range:p,unitId:u,subUnitId:f}=this._copyInfo,v={row:p.startRow,column:p.startColumn};if(!(s===u&&c===f)){const g=[];a.Range.foreach(p,(d,I)=>{const P=this._sheetsThreadCommentModel.getAllByLocation(u,f,d,I);this._threadCommentDataSourceService.syncUpdateMutationToColla?P.forEach(V=>{g.push(V)}):P.forEach(({children:V,...U})=>{U.parentId||g.push(U)})});const _=[],$=[],A=[],L=[],B=d=>{_.unshift({id:y.DeleteCommentMutation.id,params:{unitId:u,subUnitId:f,commentId:d.id}}),A.push({id:y.AddCommentMutation.id,params:{unitId:s,subUnitId:c,comment:{...d,ref:je(d.ref,v,h),unitId:s,subUnitId:c},sync:!0}}),$.push({id:y.AddCommentMutation.id,params:{unitId:u,subUnitId:f,comment:d,sync:!0}}),L.unshift({id:y.DeleteCommentMutation.id,params:{unitId:s,subUnitId:c,commentId:d.id}})};return g.forEach(d=>{B(d)}),{redos:[..._,...A],undos:[...L,...$]}}}return{redos:[],undos:[]}}}))}};exports.SheetsThreadCommentCopyPasteController=Re([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsThreadCommentCopyPasteController),Z(0,l.Inject(w.ISheetClipboardService)),Z(1,l.Inject(D.SheetsThreadCommentModel)),Z(2,y.IThreadCommentDataSourceService)],exports.SheetsThreadCommentCopyPasteController);var De=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Ne=(o,r,n,e)=>{for(var t=e>1?void 0:e?$e(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&De(r,n,t),t},F=(o,r)=>(n,e)=>r(n,e,o);exports.SheetsThreadCommentHoverController=class extends a.Disposable{constructor(r,n,e,t){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._sheetPermissionInterceptorBaseController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(z.debounceTime(100)).subscribe(r=>{const n=this._sheetsThreadCommentPopupService.activePopup;if(r&&(n&&n.temp||!n)){const{location:e}=r,{unitId:t,subUnitId:i,row:s,col:c}=e,m=this._sheetsThreadCommentModel.getByLocation(t,i,s,c);if(m){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:s,startColumn:c,endRow:s,endColumn:c}]))return;const p=this._sheetsThreadCommentModel.getComment(t,i,m);p&&!p.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:i,row:s,col:c,commentId:m,temp:!0})}else n&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};exports.SheetsThreadCommentHoverController=Ne([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsThreadCommentHoverController),F(0,l.Inject(w.HoverManagerService)),F(1,l.Inject(exports.SheetsThreadCommentPopupService)),F(2,l.Inject(D.SheetsThreadCommentModel)),F(3,l.Inject(w.SheetPermissionInterceptorBaseController))],exports.SheetsThreadCommentHoverController);var Ae=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,xe=(o,r,n,e)=>{for(var t=e>1?void 0:e?Ve(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&Ae(r,n,t),t},W=(o,r)=>(n,e)=>r(n,e,o);exports.ThreadCommentRemoveSheetsController=class extends a.Disposable{constructor(r,n,e,t){super(),this._sheetInterceptorService=r,this._univerInstanceService=n,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var n;if(r.id===C.RemoveSheetCommand.id){const e=r.params,t=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return{redos:[],undos:[]};const i=t.getUnitId(),s=e.subUnitId||((n=t.getActiveSheet())==null?void 0:n.getSheetId());if(!s)return{redos:[],undos:[]};const{commentMap:c}=this._threadCommentModel.ensureMap(i,s),m=Array.from(Object.values(c)).filter(v=>!v.parentId),h=m.map(v=>v.id),p=this._threadCommentDataSourceService.syncUpdateMutationToColla,u=h.map(v=>({id:y.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:v}})),f=m.map(({children:v,...g})=>({id:y.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...g,children:p?v:void 0},sync:!p}}));return{redos:u,undos:f}}return{redos:[],undos:[]}}}))}};exports.ThreadCommentRemoveSheetsController=xe([a.OnLifecycle(a.LifecycleStages.Ready,exports.ThreadCommentRemoveSheetsController),W(0,l.Inject(C.SheetInterceptorService)),W(1,a.IUniverInstanceService),W(2,l.Inject(y.ThreadCommentModel)),W(3,y.IThreadCommentDataSourceService)],exports.ThreadCommentRemoveSheetsController);var re=Object.defineProperty,He=Object.getOwnPropertyDescriptor,Le=(o,r,n)=>r in o?re(o,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[r]=n,Be=(o,r,n,e)=>{for(var t=e>1?void 0:e?He(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&re(r,n,t),t},J=(o,r)=>(n,e)=>r(n,e,o),oe=(o,r,n)=>Le(o,typeof r!="symbol"?r+"":r,n);exports.UniverSheetsThreadCommentPlugin=class extends a.Plugin{constructor(n={},e,t){super();N(this,"_pluginConfig");this._injector=e,this._commandService=t,this._pluginConfig=a.Tools.deepMerge({},ye,n)}onStarting(n){[[exports.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(exports.SheetsThreadCommentController,this._pluginConfig)}],[q],[exports.SheetsThreadCommentCopyPasteController],[exports.SheetsThreadCommentHoverController],[exports.ThreadCommentRemoveSheetsController],[exports.SheetsThreadCommentPopupService]].forEach(e=>{n.add(e)}),[H].forEach(e=>{this._commandService.registerCommand(e)})}};oe(exports.UniverSheetsThreadCommentPlugin,"pluginName",K);oe(exports.UniverSheetsThreadCommentPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentPlugin=Be([a.DependentOn(M.UniverThreadCommentUIPlugin,D.UniverSheetsThreadCommentBasePlugin),J(1,l.Inject(l.Injector)),J(2,l.Inject(a.ICommandService))],exports.UniverSheetsThreadCommentPlugin);Object.defineProperty(exports,"Inject",{enumerable:!0,get:()=>l.Inject});Object.defineProperty(exports,"Injector",{enumerable:!0,get:()=>l.Injector});Object.defineProperty(exports,"ICommandService",{enumerable:!0,get:()=>a.ICommandService});Object.defineProperty(exports,"Plugin",{enumerable:!0,get:()=>a.Plugin});Object.defineProperty(exports,"UniverInstanceType",{enumerable:!0,get:()=>a.UniverInstanceType});Object.defineProperty(exports,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>M.IThreadCommentMentionDataService});Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>M.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>y.IThreadCommentDataSourceService});Object.defineProperty(exports,"SheetsThreadCommentModel",{enumerable:!0,get:()=>D.SheetsThreadCommentModel});exports.SHEETS_THREAD_COMMENT=K;exports.ShowAddSheetCommentModalOperation=H;
|
|
1
|
+
"use strict";var se=Object.defineProperty;var ae=(o,r,n)=>r in o?se(o,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[r]=n;var N=(o,r,n)=>ae(o,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@wendellhu/redi"),a=require("@univerjs/core"),M=require("@univerjs/thread-comment-ui"),S=require("@univerjs/ui"),v=require("@univerjs/sheets"),x=require("@univerjs/engine-formula"),y=require("@univerjs/thread-comment"),w=require("@univerjs/sheets-ui"),D=require("@univerjs/sheets-thread-comment-base"),R=require("@wendellhu/redi/react-bindings"),T=require("react"),z=require("rxjs"),ce=require("@univerjs/engine-render");var b=function(){return b=Object.assign||function(o){for(var r,n=1,e=arguments.length;n<e;n++){r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(o[t]=r[t])}return o},b.apply(this,arguments)},me=function(o,r){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&r.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(o);t<e.length;t++)r.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(o,e[t])&&(n[e[t]]=o[e[t]]);return n},Q=T.forwardRef(function(o,r){var n=o.icon,e=o.id,t=o.className,i=o.extend,s=me(o,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),u=T.useRef("_".concat(he()));return ee(n,"".concat(e),{defIds:n.defIds,idSuffix:u.current},b({ref:r,className:c},s),i)});function ee(o,r,n,e,t){return T.createElement(o.tag,b(b({key:r},de(o,n,t)),e),(ue(o,n).children||[]).map(function(i,s){return ee(i,"".concat(r,"-").concat(o.tag,"-").concat(s),n,void 0,t)}))}function de(o,r,n){var e=b({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=r.defIds;return!t||t.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],c=i[1];typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function ue(o,r){var n,e=r.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?b(b({},o),{children:o.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?b(b({},t),{attrs:b(b({},t.attrs),{id:t.attrs.id+r.idSuffix})}):t})}):o}function he(){return Math.random().toString(36).substring(2,8)}Q.displayName="UniverIcon";var le={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=T.forwardRef(function(o,r){return T.createElement(Q,Object.assign({},o,{id:"comment-single",ref:r,icon:le}))});te.displayName="CommentSingle";const ne="univer.sheet.thread-comment-modal",G="comment-single",K="SHEET_THREAD_COMMENT";var pe=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,ve=(o,r,n,e)=>{for(var t=e>1?void 0:e?Ce(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&pe(r,n,t),t},X=(o,r)=>(n,e)=>r(n,e,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new z.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible()}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var l;const{row:t,col:i,unitId:s,subUnitId:c}=n;if(this._activePopup&&t===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const u=this._canvasPopupManagerService.attachPopupToCell(t,i,{componentKey:ne,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const h=new a.DisposableCollection;h.add(u),h.add({dispose:()=>{e==null||e()}}),this._lastPopup=h}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=ve([X(0,p.Inject(w.SheetCanvasPopManagerService)),X(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const Se=()=>{const o=R.useDependency(a.IUniverInstanceService),r=R.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(r.activePopup$),e=R.useDependency(D.SheetsThreadCommentModel);if(S.useObservable(e.commentUpdate$),!n)return null;const{row:t,col:i,unitId:s,subUnitId:c,trigger:u}=n,h=e.getByLocation(s,c,t,i),l=`${a.Tools.chatAtABC(i)}${t+1}`,m=()=>{r.hidePopup()},f=C=>{var I,P,$;return($=(P=(I=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:I.getSheetBySheetId(C))==null?void 0:P.getName())!=null?$:""};return T.createElement(M.ThreadCommentTree,{onClick:()=>{r.persistPopup()},prefix:"cell",id:h,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:m,getSubUnitName:f,autoFocus:u==="context-menu"})},H={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var I;const r=o.get(v.SheetsSelectionsService),n=o.get(a.IUniverInstanceService),e=o.get(exports.SheetsThreadCommentPopupService),t=o.get(M.ThreadCommentPanelService),i=(I=r.getCurrentLastSelection())==null?void 0:I.primary,s=o.get(D.SheetsThreadCommentModel);if(!i)return!1;const c=v.getSheetCommandTarget(n);if(!c)return!1;const{workbook:u,worksheet:h,unitId:l,subUnitId:m}=c,f={workbook:u,worksheet:h,unitId:l,subUnitId:m,row:i.startRow,col:i.startColumn};e.showPopup(f);const C=s.getByLocation(l,m,i.startRow,i.startColumn);return C&&t.setActiveComment({unitId:l,subUnitId:m,commentId:C,trigger:"context-menu"}),!0}},fe=()=>{var B;const o=R.useDependency(w.IMarkSelectionService),r=R.useDependency(a.IUniverInstanceService),n=R.useDependency(y.ThreadCommentModel),e=R.useDependency(exports.SheetsThreadCommentPopupService),t=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return null;const i=t.getUnitId(),s=R.useDependency(a.ICommandService),c=T.useMemo(()=>t.activeSheet$.pipe(z.map(d=>d==null?void 0:d.getSheetId())),[t.activeSheet$]),u=S.useObservable(c,(B=t.getActiveSheet())==null?void 0:B.getSheetId()),h=T.useRef(),l=R.useDependency(M.ThreadCommentPanelService),m=S.useObservable(l.activeCommentId$),f=T.useCallback(d=>{const _=t.getSheets(),g={};_.forEach((U,O)=>{g[U.getSheetId()]=O});const V=U=>U.map(O=>{var Y;const j=x.singleReferenceToGrid(O.ref),ie=[(Y=g[O.subUnitId])!=null?Y:0,j.row,j.column];return{...O,p:ie}}).sort((O,j)=>O.p[0]===j.p[0]?O.p[1]===j.p[1]?O.p[2]-j.p[2]:O.p[1]-j.p[1]:O.p[0]-j.p[0]);return[...V(d.filter(U=>!U.resolved)),...V(d.filter(U=>U.resolved))]},[t]),C=T.useCallback(d=>{if(d.unitId===i&&d.subUnitId===u&&!d.resolved){const{row:_,column:g}=x.singleReferenceToGrid(d.ref);if(!Number.isNaN(_)&&!Number.isNaN(g))return o.addShape({range:{startColumn:g,endColumn:g,startRow:_,endRow:_},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,u,i]),I=d=>{var _,g;return(g=(_=t.getSheetBySheetId(d))==null?void 0:_.getName())!=null?g:""},P=()=>{s.executeCommand(H.id)},$=d=>{m&&m.unitId===d.unitId&&m.subUnitId===d.subUnitId&&m.commentId===d.id||(h.current&&(o.removeShape(h.current),h.current=null),h.current=C(d))},A=()=>{h.current&&(o.removeShape(h.current),h.current=null)},L=(d,_)=>{_&&e.hidePopup()};return T.useEffect(()=>{if(!m)return;const d=n.getComment(m.unitId,m.subUnitId,m.commentId);if(!d)return;const _=C(d);return()=>{_&&o.removeShape(_)}},[C,m,n,o]),T.createElement(M.ThreadCommentPanel,{unitId:i,subUnitId$:c,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:P,getSubUnitName:I,onResolve:L,sortComments:f,onItemEnter:$,onItemLeave:A,onDeleteComment:()=>(A(),!0)})},_e=o=>({id:H.id,type:S.MenuItemType.BUTTON,positions:[S.MenuPosition.CONTEXT_MENU],icon:G,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET),disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]})}),Ie=o=>({id:M.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:G,tooltip:"sheetThreadComment.menu.commentManagement",positions:S.MenuPosition.TOOLBAR_START,group:S.MenuGroup.TOOLBAR_OTHERS,disabled$:w.getCurrentRangeDisable$(o,{workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET)}),Pe={id:H.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:w.whenSheetEditorFocused};var ge=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,be=(o,r,n,e)=>{for(var t=e>1?void 0:e?Te(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&ge(r,n,t),t},E=(o,r)=>(n,e)=>r(n,e,o);const ye={};exports.SheetsThreadCommentController=class extends a.Disposable{constructor(r,n,e,t,i,s,c,u,h,l,m){super(),this._config=r,this._menuService=n,this._injector=e,this._componentManager=t,this._commandService=i,this._sheetsThreadCommentPopupService=s,this._sheetsThreadCommentModel=c,this._threadCommentPanelService=u,this._shortcutService=h,this._univerInstanceService=l,this._sheetPermissionInterceptorBaseController=m,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener()}_initShortcut(){this._shortcutService.registerShortcut(Pe)}_initCommandListener(){this._commandService.onCommandExecuted(r=>{if(r.id===v.SetSelectionsOperation.id){const n=r.params,{unitId:e,subUnitId:t,selections:i,type:s}=n;if((s===v.SelectionMoveType.MOVE_END||s===void 0)&&i[0].primary){const c=i[0].primary.actualRow,u=i[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(e,t,c,u)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(M.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(e,t,c,u);h&&this._commandService.executeCommand(M.SetActiveCommentOperation.id,{unitId:e,subUnitId:t,commentId:h})}}if(r.id===y.DeleteCommentMutation.id){const n=r.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:t,subUnitId:i,commentId:s}=e;n.unitId===t&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:r={}}=this._config;[_e,Ie].forEach(n=>{this._menuService.addMenuItem(n(this._injector),r)})}_initComponent(){[[ne,Se],[M.THREAD_COMMENT_PANEL,fe],[G,te]].forEach(([r,n])=>{this._componentManager.register(r,n)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async r=>{var n;if(r){const{unitId:e,subUnitId:t,commentId:i,trigger:s}=r,c=this._sheetsThreadCommentModel.getComment(e,t,i);if(!c||c.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;((n=u.getActiveSheet())==null?void 0:n.getSheetId())!==t&&await this._commandService.executeCommand(v.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t});const m=x.singleReferenceToGrid(c.ref),{row:f,column:C}=m;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:f,startColumn:C,endRow:f,endColumn:C}]))return;const P=1;await this._commandService.executeCommand(w.ScrollToRangeOperation.id,{range:{startRow:Math.max(m.row-P,0),endRow:m.row+P,startColumn:Math.max(m.column-P,0),endColumn:m.column+P}}),this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:t,row:m.row,col:m.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}};exports.SheetsThreadCommentController=be([a.OnLifecycle(a.LifecycleStages.Starting,exports.SheetsThreadCommentController),E(1,S.IMenuService),E(2,p.Inject(p.Injector)),E(3,p.Inject(S.ComponentManager)),E(4,a.ICommandService),E(5,p.Inject(exports.SheetsThreadCommentPopupService)),E(6,p.Inject(D.SheetsThreadCommentModel)),E(7,p.Inject(M.ThreadCommentPanelService)),E(8,S.IShortcutService),E(9,a.IUniverInstanceService),E(10,p.Inject(w.SheetPermissionInterceptorBaseController))],exports.SheetsThreadCommentController);var Me=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Oe=(o,r,n,e)=>{for(var t=e>1?void 0:e?we(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&Me(r,n,t),t},k=(o,r)=>(n,e)=>r(n,e,o);let q=class extends a.Disposable{constructor(o,r,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=r,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(o,r,n)=>{const{row:e,col:t,unitId:i,subUnitId:s}=r;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,t)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var s;const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return;const n=r.getUnitId(),e=(s=r.getActiveSheet())==null?void 0:s.getSheetId();if(!e){console.warn("No active sheet found");return}const t=this._renderManagerService.getRenderById(n),i=t==null?void 0:t.with(w.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:e});i==null||i.makeDirty(!0),i==null||i.calculate(),t&&t.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(r=>{o()}))}};q=Oe([a.OnLifecycle(a.LifecycleStages.Ready,q),k(0,p.Inject(v.SheetInterceptorService)),k(1,p.Inject(D.SheetsThreadCommentModel)),k(2,a.IUniverInstanceService),k(3,ce.IRenderManagerService)],q);var Ue=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,Re=(o,r,n,e)=>{for(var t=e>1?void 0:e?Ee(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&Ue(r,n,t),t},Z=(o,r)=>(n,e)=>r(n,e,o);const je=(o,r,n)=>{const e=x.singleReferenceToGrid(o),t=n.row-r.row,i=n.column-r.column,s={startColumn:e.column+i,startRow:e.row+t,endColumn:e.column+i,endRow:e.row+t};return x.serializeRange(s)};exports.SheetsThreadCommentCopyPasteController=class extends a.Disposable{constructor(n,e,t){super();N(this,"_copyInfo");this._sheetClipboardService=n,this._sheetsThreadCommentModel=e,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:K,onBeforeCopy:(n,e,t)=>{this._copyInfo={unitId:n,subUnitId:e,range:t}},onPasteCells:(n,e,t,i)=>{const{unitId:s,subUnitId:c,range:u}=e,h={row:u.rows[0],column:u.cols[0]};if(i.copyType===w.COPY_TYPE.CUT&&this._copyInfo){const{range:l,unitId:m,subUnitId:f}=this._copyInfo,C={row:l.startRow,column:l.startColumn};if(!(s===m&&c===f)){const I=[];a.Range.foreach(l,(d,_)=>{const g=this._sheetsThreadCommentModel.getAllByLocation(m,f,d,_);this._threadCommentDataSourceService.syncUpdateMutationToColla?g.forEach(V=>{I.push(V)}):g.forEach(({children:V,...U})=>{U.parentId||I.push(U)})});const P=[],$=[],A=[],L=[],B=d=>{P.unshift({id:y.DeleteCommentMutation.id,params:{unitId:m,subUnitId:f,commentId:d.id}}),A.push({id:y.AddCommentMutation.id,params:{unitId:s,subUnitId:c,comment:{...d,ref:je(d.ref,C,h),unitId:s,subUnitId:c},sync:!0}}),$.push({id:y.AddCommentMutation.id,params:{unitId:m,subUnitId:f,comment:d,sync:!0}}),L.unshift({id:y.DeleteCommentMutation.id,params:{unitId:s,subUnitId:c,commentId:d.id}})};return I.forEach(d=>{B(d)}),{redos:[...P,...A],undos:[...L,...$]}}}return{redos:[],undos:[]}}}))}};exports.SheetsThreadCommentCopyPasteController=Re([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsThreadCommentCopyPasteController),Z(0,p.Inject(w.ISheetClipboardService)),Z(1,p.Inject(D.SheetsThreadCommentModel)),Z(2,y.IThreadCommentDataSourceService)],exports.SheetsThreadCommentCopyPasteController);var De=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Ne=(o,r,n,e)=>{for(var t=e>1?void 0:e?$e(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&De(r,n,t),t},F=(o,r)=>(n,e)=>r(n,e,o);exports.SheetsThreadCommentHoverController=class extends a.Disposable{constructor(r,n,e,t){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._sheetPermissionInterceptorBaseController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(z.debounceTime(100)).subscribe(r=>{const n=this._sheetsThreadCommentPopupService.activePopup;if(r&&(n&&n.temp||!n)){const{location:e}=r,{unitId:t,subUnitId:i,row:s,col:c}=e,u=this._sheetsThreadCommentModel.getByLocation(t,i,s,c);if(u){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[v.WorkbookCommentPermission],worksheetTypes:[v.WorksheetViewPermission],rangeTypes:[v.RangeProtectionPermissionViewPoint]},[{startRow:s,startColumn:c,endRow:s,endColumn:c}]))return;const l=this._sheetsThreadCommentModel.getComment(t,i,u);l&&!l.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:i,row:s,col:c,commentId:u,temp:!0})}else n&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};exports.SheetsThreadCommentHoverController=Ne([a.OnLifecycle(a.LifecycleStages.Rendered,exports.SheetsThreadCommentHoverController),F(0,p.Inject(w.HoverManagerService)),F(1,p.Inject(exports.SheetsThreadCommentPopupService)),F(2,p.Inject(D.SheetsThreadCommentModel)),F(3,p.Inject(w.SheetPermissionInterceptorBaseController))],exports.SheetsThreadCommentHoverController);var Ae=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,xe=(o,r,n,e)=>{for(var t=e>1?void 0:e?Ve(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&Ae(r,n,t),t},W=(o,r)=>(n,e)=>r(n,e,o);exports.ThreadCommentRemoveSheetsController=class extends a.Disposable{constructor(r,n,e,t){super(),this._sheetInterceptorService=r,this._univerInstanceService=n,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var n;if(r.id===v.RemoveSheetCommand.id){const e=r.params,t=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return{redos:[],undos:[]};const i=t.getUnitId(),s=e.subUnitId||((n=t.getActiveSheet())==null?void 0:n.getSheetId());if(!s)return{redos:[],undos:[]};const{commentMap:c}=this._threadCommentModel.ensureMap(i,s),u=Array.from(Object.values(c)).filter(C=>!C.parentId),h=u.map(C=>C.id),l=this._threadCommentDataSourceService.syncUpdateMutationToColla,m=h.map(C=>({id:y.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:C}})),f=u.map(({children:C,...I})=>({id:y.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...I,children:l?C:void 0},sync:!l}}));return{redos:m,undos:f}}return{redos:[],undos:[]}}}))}};exports.ThreadCommentRemoveSheetsController=xe([a.OnLifecycle(a.LifecycleStages.Ready,exports.ThreadCommentRemoveSheetsController),W(0,p.Inject(v.SheetInterceptorService)),W(1,a.IUniverInstanceService),W(2,p.Inject(y.ThreadCommentModel)),W(3,y.IThreadCommentDataSourceService)],exports.ThreadCommentRemoveSheetsController);var re=Object.defineProperty,He=Object.getOwnPropertyDescriptor,Le=(o,r,n)=>r in o?re(o,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[r]=n,Be=(o,r,n,e)=>{for(var t=e>1?void 0:e?He(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&re(r,n,t),t},J=(o,r)=>(n,e)=>r(n,e,o),oe=(o,r,n)=>Le(o,typeof r!="symbol"?r+"":r,n);exports.UniverSheetsThreadCommentPlugin=class extends a.Plugin{constructor(n={},e,t){super();N(this,"_pluginConfig");this._injector=e,this._commandService=t,this._pluginConfig=a.Tools.deepMerge({},ye,n)}onStarting(n){[[exports.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(exports.SheetsThreadCommentController,this._pluginConfig)}],[q],[exports.SheetsThreadCommentCopyPasteController],[exports.SheetsThreadCommentHoverController],[exports.ThreadCommentRemoveSheetsController],[exports.SheetsThreadCommentPopupService]].forEach(e=>{n.add(e)}),[H].forEach(e=>{this._commandService.registerCommand(e)})}};oe(exports.UniverSheetsThreadCommentPlugin,"pluginName",K);oe(exports.UniverSheetsThreadCommentPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentPlugin=Be([a.DependentOn(M.UniverThreadCommentUIPlugin,D.UniverSheetsThreadCommentBasePlugin),J(1,p.Inject(p.Injector)),J(2,p.Inject(a.ICommandService))],exports.UniverSheetsThreadCommentPlugin);Object.defineProperty(exports,"Inject",{enumerable:!0,get:()=>p.Inject});Object.defineProperty(exports,"Injector",{enumerable:!0,get:()=>p.Injector});Object.defineProperty(exports,"ICommandService",{enumerable:!0,get:()=>a.ICommandService});Object.defineProperty(exports,"Plugin",{enumerable:!0,get:()=>a.Plugin});Object.defineProperty(exports,"UniverInstanceType",{enumerable:!0,get:()=>a.UniverInstanceType});Object.defineProperty(exports,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>M.IThreadCommentMentionDataService});Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>M.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>y.IThreadCommentDataSourceService});Object.defineProperty(exports,"SheetsThreadCommentModel",{enumerable:!0,get:()=>D.SheetsThreadCommentModel});exports.SHEETS_THREAD_COMMENT=K;exports.ShowAddSheetCommentModalOperation=H;
|
package/lib/es/index.js
CHANGED
|
@@ -3,20 +3,20 @@ var xe = (t, e, n) => e in t ? De(t, e, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var U = (t, e, n) => xe(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
4
|
import { Inject as p, Injector as he } from "@wendellhu/redi";
|
|
5
5
|
import { Inject as Cn, Injector as fn } from "@wendellhu/redi";
|
|
6
|
-
import { Disposable as R, DisposableCollection as Ae, IUniverInstanceService as $, Tools as pe, UniverInstanceType as
|
|
6
|
+
import { Disposable as R, DisposableCollection as Ae, IUniverInstanceService as $, Tools as pe, UniverInstanceType as T, CommandType as je, ICommandService as re, OnLifecycle as j, LifecycleStages as V, Range as Ve, DependentOn as He, Plugin as Le } from "@univerjs/core";
|
|
7
7
|
import { ICommandService as In, Plugin as gn, UniverInstanceType as Pn } from "@univerjs/core";
|
|
8
|
-
import { ThreadCommentTree as
|
|
9
|
-
import { IThreadCommentMentionDataService as bn, UniverThreadCommentUIPlugin as
|
|
8
|
+
import { ThreadCommentTree as Be, ThreadCommentPanelService as oe, ThreadCommentPanel as Fe, ToggleSheetCommentPanelOperation as ke, SetActiveCommentOperation as ae, THREAD_COMMENT_PANEL as We, UniverThreadCommentUIPlugin as Ze } from "@univerjs/thread-comment-ui";
|
|
9
|
+
import { IThreadCommentMentionDataService as bn, UniverThreadCommentUIPlugin as wn } from "@univerjs/thread-comment-ui";
|
|
10
10
|
import { IZenZoneService as ze, useObservable as z, KeyCode as Ge, MetaKeys as ce, MenuItemType as le, MenuPosition as ve, getMenuHiddenObservable as _e, MenuGroup as Ke, ComponentManager as Ye, IMenuService as qe, IShortcutService as Xe } from "@univerjs/ui";
|
|
11
|
-
import {
|
|
11
|
+
import { SheetsSelectionsService as Je, getSheetCommandTarget as Qe, WorkbookCommentPermission as q, WorksheetViewPermission as X, RangeProtectionPermissionViewPoint as J, SetSelectionsOperation as et, SelectionMoveType as tt, SetWorksheetActiveOperation as nt, SheetInterceptorService as Ce, INTERCEPTOR_POINT as rt, RemoveSheetCommand as ot } from "@univerjs/sheets";
|
|
12
12
|
import { singleReferenceToGrid as G, serializeRange as it } from "@univerjs/engine-formula";
|
|
13
13
|
import { ThreadCommentModel as fe, DeleteCommentMutation as K, IThreadCommentDataSourceService as Se, AddCommentMutation as ne } from "@univerjs/thread-comment";
|
|
14
14
|
import { IThreadCommentDataSourceService as yn } from "@univerjs/thread-comment";
|
|
15
15
|
import { SheetCanvasPopManagerService as st, IMarkSelectionService as at, whenSheetEditorFocused as ct, getCurrentRangeDisable$ as Ie, SheetPermissionInterceptorBaseController as ge, ScrollToRangeOperation as ut, SheetSkeletonManagerService as dt, ISheetClipboardService as mt, COPY_TYPE as ht, HoverManagerService as pt } from "@univerjs/sheets-ui";
|
|
16
16
|
import { SheetsThreadCommentModel as N, UniverSheetsThreadCommentBasePlugin as lt } from "@univerjs/sheets-thread-comment-base";
|
|
17
17
|
import { SheetsThreadCommentModel as En } from "@univerjs/sheets-thread-comment-base";
|
|
18
|
-
import { useDependency as
|
|
19
|
-
import Pe, { forwardRef as Te, useRef as be, createElement as
|
|
18
|
+
import { useDependency as b } from "@wendellhu/redi/react-bindings";
|
|
19
|
+
import Pe, { forwardRef as Te, useRef as be, createElement as we, useMemo as vt, useCallback as ue, useEffect as _t } from "react";
|
|
20
20
|
import { BehaviorSubject as Ct, map as ft, debounceTime as St } from "rxjs";
|
|
21
21
|
import { IRenderManagerService as It } from "@univerjs/engine-render";
|
|
22
22
|
var I = function() {
|
|
@@ -34,12 +34,12 @@ var I = function() {
|
|
|
34
34
|
for (var o = 0, r = Object.getOwnPropertySymbols(t); o < r.length; o++)
|
|
35
35
|
e.indexOf(r[o]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[o]) && (n[r[o]] = t[r[o]]);
|
|
36
36
|
return n;
|
|
37
|
-
},
|
|
38
|
-
var n = t.icon, r = t.id, o = t.className, i = t.extend, s = gt(t, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(o || "").trim(),
|
|
39
|
-
return ye(n, "".concat(r), { defIds: n.defIds, idSuffix:
|
|
37
|
+
}, Me = Te(function(t, e) {
|
|
38
|
+
var n = t.icon, r = t.id, o = t.className, i = t.extend, s = gt(t, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(o || "").trim(), h = be("_".concat(bt()));
|
|
39
|
+
return ye(n, "".concat(r), { defIds: n.defIds, idSuffix: h.current }, I({ ref: e, className: a }, s), i);
|
|
40
40
|
});
|
|
41
41
|
function ye(t, e, n, r, o) {
|
|
42
|
-
return
|
|
42
|
+
return we(t.tag, I(I({ key: e }, Pt(t, n, o)), r), (Tt(t, n).children || []).map(function(i, s) {
|
|
43
43
|
return ye(i, "".concat(e, "-").concat(t.tag, "-").concat(s), n, void 0, o);
|
|
44
44
|
}));
|
|
45
45
|
}
|
|
@@ -61,22 +61,22 @@ function Tt(t, e) {
|
|
|
61
61
|
function bt() {
|
|
62
62
|
return Math.random().toString(36).substring(2, 8);
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
var
|
|
66
|
-
return Me
|
|
64
|
+
Me.displayName = "UniverIcon";
|
|
65
|
+
var wt = { 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" } }] }, Oe = Te(function(t, e) {
|
|
66
|
+
return we(Me, Object.assign({}, t, {
|
|
67
67
|
id: "comment-single",
|
|
68
68
|
ref: e,
|
|
69
|
-
icon:
|
|
69
|
+
icon: wt
|
|
70
70
|
}));
|
|
71
71
|
});
|
|
72
72
|
Oe.displayName = "CommentSingle";
|
|
73
73
|
const Ee = "univer.sheet.thread-comment-modal", ie = "comment-single", Ue = "SHEET_THREAD_COMMENT";
|
|
74
|
-
var
|
|
74
|
+
var Mt = Object.defineProperty, yt = Object.getOwnPropertyDescriptor, Ot = (t, e, n, r) => {
|
|
75
75
|
for (var o = r > 1 ? void 0 : r ? yt(e, n) : e, i = t.length - 1, s; i >= 0; i--)
|
|
76
76
|
(s = t[i]) && (o = (r ? s(e, n, o) : s(o)) || o);
|
|
77
|
-
return r && o &&
|
|
77
|
+
return r && o && Mt(e, n, o), o;
|
|
78
78
|
}, de = (t, e) => (n, r) => e(n, r, t);
|
|
79
|
-
let
|
|
79
|
+
let M = class extends R {
|
|
80
80
|
constructor(e, n) {
|
|
81
81
|
super();
|
|
82
82
|
U(this, "_lastPopup", null);
|
|
@@ -120,12 +120,12 @@ let y = class extends R {
|
|
|
120
120
|
);
|
|
121
121
|
if (!a)
|
|
122
122
|
throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");
|
|
123
|
-
const
|
|
124
|
-
|
|
123
|
+
const h = new Ae();
|
|
124
|
+
h.add(a), h.add({
|
|
125
125
|
dispose: () => {
|
|
126
126
|
n == null || n();
|
|
127
127
|
}
|
|
128
|
-
}), this._lastPopup =
|
|
128
|
+
}), this._lastPopup = h;
|
|
129
129
|
}
|
|
130
130
|
hidePopup() {
|
|
131
131
|
this._activePopup && (this._lastPopup && this._lastPopup.dispose(), this._lastPopup = null, this._activePopup = null, this._activePopup$.next(null));
|
|
@@ -137,22 +137,22 @@ let y = class extends R {
|
|
|
137
137
|
}, this._activePopup$.next(this._activePopup));
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
|
-
|
|
140
|
+
M = Ot([
|
|
141
141
|
de(0, p(st)),
|
|
142
142
|
de(1, ze)
|
|
143
|
-
],
|
|
143
|
+
], M);
|
|
144
144
|
const Et = () => {
|
|
145
|
-
const t =
|
|
145
|
+
const t = b($), e = b(M), n = z(e.activePopup$), r = b(N);
|
|
146
146
|
if (z(r.commentUpdate$), !n)
|
|
147
147
|
return null;
|
|
148
|
-
const { row: o, col: i, unitId: s, subUnitId: a, trigger:
|
|
148
|
+
const { row: o, col: i, unitId: s, subUnitId: a, trigger: h } = n, c = r.getByLocation(s, a, o, i), d = `${pe.chatAtABC(i)}${o + 1}`, u = () => {
|
|
149
149
|
e.hidePopup();
|
|
150
|
-
}, l = (
|
|
151
|
-
var
|
|
152
|
-
return (O = (
|
|
150
|
+
}, l = (_) => {
|
|
151
|
+
var C, y, O;
|
|
152
|
+
return (O = (y = (C = t.getCurrentUnitForType(T.UNIVER_SHEET)) == null ? void 0 : C.getSheetBySheetId(_)) == null ? void 0 : y.getName()) != null ? O : "";
|
|
153
153
|
};
|
|
154
154
|
return /* @__PURE__ */ Pe.createElement(
|
|
155
|
-
|
|
155
|
+
Be,
|
|
156
156
|
{
|
|
157
157
|
onClick: () => {
|
|
158
158
|
e.persistPopup();
|
|
@@ -161,47 +161,47 @@ const Et = () => {
|
|
|
161
161
|
id: c,
|
|
162
162
|
unitId: s,
|
|
163
163
|
subUnitId: a,
|
|
164
|
-
type:
|
|
165
|
-
refStr:
|
|
166
|
-
onClose:
|
|
164
|
+
type: T.UNIVER_SHEET,
|
|
165
|
+
refStr: d,
|
|
166
|
+
onClose: u,
|
|
167
167
|
getSubUnitName: l,
|
|
168
|
-
autoFocus:
|
|
168
|
+
autoFocus: h === "context-menu"
|
|
169
169
|
}
|
|
170
170
|
);
|
|
171
171
|
}, Q = {
|
|
172
172
|
type: je.OPERATION,
|
|
173
173
|
id: "sheets.operation.show-comment-modal",
|
|
174
174
|
handler(t) {
|
|
175
|
-
var
|
|
176
|
-
const e = t.get(Je), n = t.get($), r = t.get(
|
|
177
|
-
if (!
|
|
175
|
+
var C;
|
|
176
|
+
const e = t.get(Je), n = t.get($), r = t.get(M), o = t.get(oe), i = (C = e.getCurrentLastSelection()) == null ? void 0 : C.primary, s = t.get(N);
|
|
177
|
+
if (!i)
|
|
178
178
|
return !1;
|
|
179
|
-
const
|
|
180
|
-
if (!
|
|
179
|
+
const a = Qe(n);
|
|
180
|
+
if (!a)
|
|
181
181
|
return !1;
|
|
182
|
-
const { workbook: h, worksheet:
|
|
182
|
+
const { workbook: h, worksheet: c, unitId: d, subUnitId: u } = a, l = {
|
|
183
183
|
workbook: h,
|
|
184
|
-
worksheet:
|
|
185
|
-
unitId:
|
|
186
|
-
subUnitId:
|
|
184
|
+
worksheet: c,
|
|
185
|
+
unitId: d,
|
|
186
|
+
subUnitId: u,
|
|
187
187
|
row: i.startRow,
|
|
188
188
|
col: i.startColumn
|
|
189
189
|
};
|
|
190
|
-
r.showPopup(
|
|
191
|
-
const _ =
|
|
190
|
+
r.showPopup(l);
|
|
191
|
+
const _ = s.getByLocation(d, u, i.startRow, i.startColumn);
|
|
192
192
|
return _ && o.setActiveComment({
|
|
193
|
-
unitId:
|
|
194
|
-
subUnitId:
|
|
193
|
+
unitId: d,
|
|
194
|
+
subUnitId: u,
|
|
195
195
|
commentId: _,
|
|
196
196
|
trigger: "context-menu"
|
|
197
197
|
}), !0;
|
|
198
198
|
}
|
|
199
199
|
}, Ut = () => {
|
|
200
200
|
var f;
|
|
201
|
-
const t =
|
|
201
|
+
const t = b(at), e = b($), n = b(fe), r = b(M), o = e.getCurrentUnitForType(T.UNIVER_SHEET);
|
|
202
202
|
if (!o)
|
|
203
203
|
return null;
|
|
204
|
-
const i = o.getUnitId(), s =
|
|
204
|
+
const i = o.getUnitId(), s = b(re), a = vt(() => o.activeSheet$.pipe(ft((m) => m == null ? void 0 : m.getSheetId())), [o.activeSheet$]), h = z(a, (f = o.getActiveSheet()) == null ? void 0 : f.getSheetId()), c = be(), d = b(oe), u = z(d.activeCommentId$), l = ue((m) => {
|
|
205
205
|
const v = o.getSheets(), S = {};
|
|
206
206
|
v.forEach((E, g) => {
|
|
207
207
|
S[E.getSheetId()] = g;
|
|
@@ -212,12 +212,12 @@ const Et = () => {
|
|
|
212
212
|
return { ...g, p: Ne };
|
|
213
213
|
}).sort((g, w) => g.p[0] === w.p[0] ? g.p[1] === w.p[1] ? g.p[2] - w.p[2] : g.p[1] - w.p[1] : g.p[0] - w.p[0]);
|
|
214
214
|
return [
|
|
215
|
-
...x(
|
|
216
|
-
...x(
|
|
215
|
+
...x(m.filter((E) => !E.resolved)),
|
|
216
|
+
...x(m.filter((E) => E.resolved))
|
|
217
217
|
];
|
|
218
|
-
}, [o]),
|
|
219
|
-
if (
|
|
220
|
-
const { row: v, column: S } = G(
|
|
218
|
+
}, [o]), _ = ue((m) => {
|
|
219
|
+
if (m.unitId === i && m.subUnitId === h && !m.resolved) {
|
|
220
|
+
const { row: v, column: S } = G(m.ref);
|
|
221
221
|
if (!Number.isNaN(v) && !Number.isNaN(S))
|
|
222
222
|
return t.addShape({
|
|
223
223
|
range: {
|
|
@@ -236,36 +236,36 @@ const Et = () => {
|
|
|
236
236
|
primary: null
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
|
-
}, [t,
|
|
239
|
+
}, [t, h, i]), C = (m) => {
|
|
240
240
|
var v, S;
|
|
241
|
-
return (S = (v = o.getSheetBySheetId(
|
|
242
|
-
},
|
|
241
|
+
return (S = (v = o.getSheetBySheetId(m)) == null ? void 0 : v.getName()) != null ? S : "";
|
|
242
|
+
}, y = () => {
|
|
243
243
|
s.executeCommand(Q.id);
|
|
244
|
-
}, O = (
|
|
245
|
-
|
|
244
|
+
}, O = (m) => {
|
|
245
|
+
u && u.unitId === m.unitId && u.subUnitId === m.subUnitId && u.commentId === m.id || (c.current && (t.removeShape(c.current), c.current = null), c.current = _(m));
|
|
246
246
|
}, D = () => {
|
|
247
247
|
c.current && (t.removeShape(c.current), c.current = null);
|
|
248
|
-
}, ee = (
|
|
248
|
+
}, ee = (m, v) => {
|
|
249
249
|
v && r.hidePopup();
|
|
250
250
|
};
|
|
251
251
|
return _t(() => {
|
|
252
|
-
if (!
|
|
252
|
+
if (!u)
|
|
253
253
|
return;
|
|
254
|
-
const
|
|
255
|
-
if (!
|
|
254
|
+
const m = n.getComment(u.unitId, u.subUnitId, u.commentId);
|
|
255
|
+
if (!m)
|
|
256
256
|
return;
|
|
257
|
-
const v =
|
|
257
|
+
const v = _(m);
|
|
258
258
|
return () => {
|
|
259
259
|
v && t.removeShape(v);
|
|
260
260
|
};
|
|
261
|
-
}, [
|
|
261
|
+
}, [_, u, n, t]), /* @__PURE__ */ Pe.createElement(
|
|
262
262
|
Fe,
|
|
263
263
|
{
|
|
264
264
|
unitId: i,
|
|
265
265
|
subUnitId$: a,
|
|
266
|
-
type:
|
|
267
|
-
onAdd:
|
|
268
|
-
getSubUnitName:
|
|
266
|
+
type: T.UNIVER_SHEET,
|
|
267
|
+
onAdd: y,
|
|
268
|
+
getSubUnitName: C,
|
|
269
269
|
onResolve: ee,
|
|
270
270
|
sortComments: l,
|
|
271
271
|
onItemEnter: O,
|
|
@@ -279,7 +279,7 @@ const Et = () => {
|
|
|
279
279
|
positions: [ve.CONTEXT_MENU],
|
|
280
280
|
icon: ie,
|
|
281
281
|
title: "sheetThreadComment.menu.addComment",
|
|
282
|
-
hidden$: _e(t,
|
|
282
|
+
hidden$: _e(t, T.UNIVER_SHEET),
|
|
283
283
|
disabled$: Ie(t, {
|
|
284
284
|
workbookTypes: [q],
|
|
285
285
|
worksheetTypes: [X],
|
|
@@ -297,7 +297,7 @@ const Et = () => {
|
|
|
297
297
|
worksheetTypes: [X],
|
|
298
298
|
rangeTypes: [J]
|
|
299
299
|
}),
|
|
300
|
-
hidden$: _e(t,
|
|
300
|
+
hidden$: _e(t, T.UNIVER_SHEET)
|
|
301
301
|
}), Nt = {
|
|
302
302
|
id: Q.id,
|
|
303
303
|
binding: Ge.M | ce.CTRL_COMMAND | ce.ALT,
|
|
@@ -307,11 +307,11 @@ var Dt = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, At = (t, e
|
|
|
307
307
|
for (var o = r > 1 ? void 0 : r ? xt(e, n) : e, i = t.length - 1, s; i >= 0; i--)
|
|
308
308
|
(s = t[i]) && (o = (r ? s(e, n, o) : s(o)) || o);
|
|
309
309
|
return r && o && Dt(e, n, o), o;
|
|
310
|
-
},
|
|
310
|
+
}, P = (t, e) => (n, r) => e(n, r, t);
|
|
311
311
|
const jt = {};
|
|
312
312
|
let A = class extends R {
|
|
313
|
-
constructor(t, e, n, r, o, i, s, a,
|
|
314
|
-
super(), this._config = t, this._menuService = e, this._injector = n, this._componentManager = r, this._commandService = o, this._sheetsThreadCommentPopupService = i, this._sheetsThreadCommentModel = s, this._threadCommentPanelService = a, this._shortcutService =
|
|
313
|
+
constructor(t, e, n, r, o, i, s, a, h, c, d) {
|
|
314
|
+
super(), this._config = t, this._menuService = e, this._injector = n, this._componentManager = r, this._commandService = o, this._sheetsThreadCommentPopupService = i, this._sheetsThreadCommentModel = s, this._threadCommentPanelService = a, this._shortcutService = h, this._univerInstanceService = c, this._sheetPermissionInterceptorBaseController = d, this._initMenu(), this._initShortcut(), this._initComponent(), this._initCommandListener(), this._initPanelListener();
|
|
315
315
|
}
|
|
316
316
|
_initShortcut() {
|
|
317
317
|
this._shortcutService.registerShortcut(Nt);
|
|
@@ -326,11 +326,11 @@ let A = class extends R {
|
|
|
326
326
|
this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(ae.id);
|
|
327
327
|
return;
|
|
328
328
|
}
|
|
329
|
-
const
|
|
330
|
-
|
|
329
|
+
const h = this._sheetsThreadCommentModel.getByLocation(n, r, s, a);
|
|
330
|
+
h && this._commandService.executeCommand(ae.id, {
|
|
331
331
|
unitId: n,
|
|
332
332
|
subUnitId: r,
|
|
333
|
-
commentId:
|
|
333
|
+
commentId: h
|
|
334
334
|
});
|
|
335
335
|
}
|
|
336
336
|
}
|
|
@@ -368,33 +368,33 @@ let A = class extends R {
|
|
|
368
368
|
const { unitId: n, subUnitId: r, commentId: o, trigger: i } = t, s = this._sheetsThreadCommentModel.getComment(n, r, o);
|
|
369
369
|
if (!s || s.resolved)
|
|
370
370
|
return;
|
|
371
|
-
const a = this._univerInstanceService.getCurrentUnitForType(
|
|
371
|
+
const a = this._univerInstanceService.getCurrentUnitForType(T.UNIVER_SHEET);
|
|
372
372
|
if (!a || a.getUnitId() !== n)
|
|
373
373
|
return;
|
|
374
374
|
((e = a.getActiveSheet()) == null ? void 0 : e.getSheetId()) !== r && await this._commandService.executeCommand(nt.id, {
|
|
375
375
|
unitId: n,
|
|
376
376
|
subUnitId: r
|
|
377
377
|
});
|
|
378
|
-
const
|
|
378
|
+
const d = G(s.ref), { row: u, column: l } = d;
|
|
379
379
|
if (!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({
|
|
380
380
|
workbookTypes: [q],
|
|
381
381
|
worksheetTypes: [X],
|
|
382
382
|
rangeTypes: [J]
|
|
383
|
-
}, [{ startRow:
|
|
383
|
+
}, [{ startRow: u, startColumn: l, endRow: u, endColumn: l }]))
|
|
384
384
|
return;
|
|
385
|
-
const
|
|
385
|
+
const C = 1;
|
|
386
386
|
await this._commandService.executeCommand(ut.id, {
|
|
387
387
|
range: {
|
|
388
|
-
startRow: Math.max(
|
|
389
|
-
endRow:
|
|
390
|
-
startColumn: Math.max(
|
|
391
|
-
endColumn:
|
|
388
|
+
startRow: Math.max(d.row - C, 0),
|
|
389
|
+
endRow: d.row + C,
|
|
390
|
+
startColumn: Math.max(d.column - C, 0),
|
|
391
|
+
endColumn: d.column + C
|
|
392
392
|
}
|
|
393
393
|
}), this._sheetsThreadCommentPopupService.showPopup({
|
|
394
394
|
unitId: n,
|
|
395
395
|
subUnitId: r,
|
|
396
|
-
row:
|
|
397
|
-
col:
|
|
396
|
+
row: d.row,
|
|
397
|
+
col: d.column,
|
|
398
398
|
commentId: s.id,
|
|
399
399
|
trigger: i
|
|
400
400
|
});
|
|
@@ -405,18 +405,18 @@ let A = class extends R {
|
|
|
405
405
|
};
|
|
406
406
|
A = At([
|
|
407
407
|
j(V.Starting, A),
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
408
|
+
P(1, qe),
|
|
409
|
+
P(2, p(he)),
|
|
410
|
+
P(3, p(Ye)),
|
|
411
|
+
P(4, re),
|
|
412
|
+
P(5, p(M)),
|
|
413
|
+
P(6, p(N)),
|
|
414
|
+
P(7, p(oe)),
|
|
415
|
+
P(8, Xe),
|
|
416
|
+
P(9, $),
|
|
417
|
+
P(10, p(ge))
|
|
418
418
|
], A);
|
|
419
|
-
var Vt = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor,
|
|
419
|
+
var Vt = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, Lt = (t, e, n, r) => {
|
|
420
420
|
for (var o = r > 1 ? void 0 : r ? Ht(e, n) : e, i = t.length - 1, s; i >= 0; i--)
|
|
421
421
|
(s = t[i]) && (o = (r ? s(e, n, o) : s(o)) || o);
|
|
422
422
|
return r && o && Vt(e, n, o), o;
|
|
@@ -451,7 +451,7 @@ let F = class extends R {
|
|
|
451
451
|
_initSkeletonChange() {
|
|
452
452
|
const t = () => {
|
|
453
453
|
var s;
|
|
454
|
-
const e = this._univerInstanceService.getCurrentUnitForType(
|
|
454
|
+
const e = this._univerInstanceService.getCurrentUnitForType(T.UNIVER_SHEET);
|
|
455
455
|
if (!e) return;
|
|
456
456
|
const n = e.getUnitId(), r = (s = e.getActiveSheet()) == null ? void 0 : s.getSheetId();
|
|
457
457
|
if (!r) {
|
|
@@ -466,17 +466,17 @@ let F = class extends R {
|
|
|
466
466
|
}));
|
|
467
467
|
}
|
|
468
468
|
};
|
|
469
|
-
F =
|
|
469
|
+
F = Lt([
|
|
470
470
|
j(V.Ready, F),
|
|
471
471
|
H(0, p(Ce)),
|
|
472
472
|
H(1, p(N)),
|
|
473
473
|
H(2, $),
|
|
474
474
|
H(3, It)
|
|
475
475
|
], F);
|
|
476
|
-
var
|
|
476
|
+
var Bt = Object.defineProperty, Ft = Object.getOwnPropertyDescriptor, kt = (t, e, n, r) => {
|
|
477
477
|
for (var o = r > 1 ? void 0 : r ? Ft(e, n) : e, i = t.length - 1, s; i >= 0; i--)
|
|
478
478
|
(s = t[i]) && (o = (r ? s(e, n, o) : s(o)) || o);
|
|
479
|
-
return r && o &&
|
|
479
|
+
return r && o && Bt(e, n, o), o;
|
|
480
480
|
}, te = (t, e) => (n, r) => e(n, r, t);
|
|
481
481
|
const Wt = (t, e, n) => {
|
|
482
482
|
const r = G(t), o = n.row - e.row, i = n.column - e.column, s = {
|
|
@@ -507,31 +507,31 @@ let k = class extends R {
|
|
|
507
507
|
},
|
|
508
508
|
// eslint-disable-next-line max-lines-per-function
|
|
509
509
|
onPasteCells: (e, n, r, o) => {
|
|
510
|
-
const { unitId: i, subUnitId: s, range: a } = n,
|
|
510
|
+
const { unitId: i, subUnitId: s, range: a } = n, h = {
|
|
511
511
|
row: a.rows[0],
|
|
512
512
|
column: a.cols[0]
|
|
513
513
|
};
|
|
514
514
|
if (o.copyType === ht.CUT && this._copyInfo) {
|
|
515
|
-
const { range: c, unitId:
|
|
515
|
+
const { range: c, unitId: d, subUnitId: u } = this._copyInfo, l = {
|
|
516
516
|
row: c.startRow,
|
|
517
517
|
column: c.startColumn
|
|
518
518
|
};
|
|
519
|
-
if (!(i ===
|
|
520
|
-
const
|
|
521
|
-
Ve.foreach(c, (f,
|
|
522
|
-
const v = this._sheetsThreadCommentModel.getAllByLocation(
|
|
519
|
+
if (!(i === d && s === u)) {
|
|
520
|
+
const _ = [];
|
|
521
|
+
Ve.foreach(c, (f, m) => {
|
|
522
|
+
const v = this._sheetsThreadCommentModel.getAllByLocation(d, u, f, m);
|
|
523
523
|
this._threadCommentDataSourceService.syncUpdateMutationToColla ? v.forEach((S) => {
|
|
524
|
-
|
|
524
|
+
_.push(S);
|
|
525
525
|
}) : v.forEach(({ children: S, ...x }) => {
|
|
526
|
-
x.parentId ||
|
|
526
|
+
x.parentId || _.push(x);
|
|
527
527
|
});
|
|
528
528
|
});
|
|
529
|
-
const
|
|
530
|
-
|
|
529
|
+
const C = [], y = [], O = [], D = [], ee = (f) => {
|
|
530
|
+
C.unshift({
|
|
531
531
|
id: K.id,
|
|
532
532
|
params: {
|
|
533
|
-
unitId:
|
|
534
|
-
subUnitId:
|
|
533
|
+
unitId: d,
|
|
534
|
+
subUnitId: u,
|
|
535
535
|
commentId: f.id
|
|
536
536
|
}
|
|
537
537
|
}), O.push({
|
|
@@ -541,17 +541,17 @@ let k = class extends R {
|
|
|
541
541
|
subUnitId: s,
|
|
542
542
|
comment: {
|
|
543
543
|
...f,
|
|
544
|
-
ref: Wt(f.ref, l,
|
|
544
|
+
ref: Wt(f.ref, l, h),
|
|
545
545
|
unitId: i,
|
|
546
546
|
subUnitId: s
|
|
547
547
|
},
|
|
548
548
|
sync: !0
|
|
549
549
|
}
|
|
550
|
-
}),
|
|
550
|
+
}), y.push({
|
|
551
551
|
id: ne.id,
|
|
552
552
|
params: {
|
|
553
|
-
unitId:
|
|
554
|
-
subUnitId:
|
|
553
|
+
unitId: d,
|
|
554
|
+
subUnitId: u,
|
|
555
555
|
comment: f,
|
|
556
556
|
sync: !0
|
|
557
557
|
}
|
|
@@ -564,11 +564,11 @@ let k = class extends R {
|
|
|
564
564
|
}
|
|
565
565
|
});
|
|
566
566
|
};
|
|
567
|
-
return
|
|
567
|
+
return _.forEach((f) => {
|
|
568
568
|
ee(f);
|
|
569
569
|
}), {
|
|
570
|
-
redos: [...
|
|
571
|
-
undos: [...D, ...
|
|
570
|
+
redos: [...C, ...O],
|
|
571
|
+
undos: [...D, ...y]
|
|
572
572
|
};
|
|
573
573
|
}
|
|
574
574
|
}
|
|
@@ -591,7 +591,7 @@ var Zt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, Gt = (t, e
|
|
|
591
591
|
for (var o = r > 1 ? void 0 : r ? zt(e, n) : e, i = t.length - 1, s; i >= 0; i--)
|
|
592
592
|
(s = t[i]) && (o = (r ? s(e, n, o) : s(o)) || o);
|
|
593
593
|
return r && o && Zt(e, n, o), o;
|
|
594
|
-
},
|
|
594
|
+
}, L = (t, e) => (n, r) => e(n, r, t);
|
|
595
595
|
let W = class extends R {
|
|
596
596
|
constructor(t, e, n, r) {
|
|
597
597
|
super(), this._hoverManagerService = t, this._sheetsThreadCommentPopupService = e, this._sheetsThreadCommentModel = n, this._sheetPermissionInterceptorBaseController = r, this._initHoverEvent();
|
|
@@ -627,16 +627,16 @@ let W = class extends R {
|
|
|
627
627
|
};
|
|
628
628
|
W = Gt([
|
|
629
629
|
j(V.Rendered, W),
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
630
|
+
L(0, p(pt)),
|
|
631
|
+
L(1, p(M)),
|
|
632
|
+
L(2, p(N)),
|
|
633
|
+
L(3, p(ge))
|
|
634
634
|
], W);
|
|
635
635
|
var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, qt = (t, e, n, r) => {
|
|
636
636
|
for (var o = r > 1 ? void 0 : r ? Yt(e, n) : e, i = t.length - 1, s; i >= 0; i--)
|
|
637
637
|
(s = t[i]) && (o = (r ? s(e, n, o) : s(o)) || o);
|
|
638
638
|
return r && o && Kt(e, n, o), o;
|
|
639
|
-
},
|
|
639
|
+
}, B = (t, e) => (n, r) => e(n, r, t);
|
|
640
640
|
let Z = class extends R {
|
|
641
641
|
constructor(t, e, n, r) {
|
|
642
642
|
super(), this._sheetInterceptorService = t, this._univerInstanceService = e, this._threadCommentModel = n, this._threadCommentDataSourceService = r, this._initSheetChange();
|
|
@@ -647,32 +647,32 @@ let Z = class extends R {
|
|
|
647
647
|
getMutations: (t) => {
|
|
648
648
|
var e;
|
|
649
649
|
if (t.id === ot.id) {
|
|
650
|
-
const n = t.params, r = n.unitId ? this._univerInstanceService.getUnit(n.unitId) : this._univerInstanceService.getCurrentUnitForType(
|
|
650
|
+
const n = t.params, r = n.unitId ? this._univerInstanceService.getUnit(n.unitId) : this._univerInstanceService.getCurrentUnitForType(T.UNIVER_SHEET);
|
|
651
651
|
if (!r)
|
|
652
652
|
return { redos: [], undos: [] };
|
|
653
653
|
const o = r.getUnitId(), i = n.subUnitId || ((e = r.getActiveSheet()) == null ? void 0 : e.getSheetId());
|
|
654
654
|
if (!i)
|
|
655
655
|
return { redos: [], undos: [] };
|
|
656
|
-
const { commentMap: s } = this._threadCommentModel.ensureMap(o, i), a = Array.from(Object.values(s)).filter((l) => !l.parentId),
|
|
656
|
+
const { commentMap: s } = this._threadCommentModel.ensureMap(o, i), a = Array.from(Object.values(s)).filter((l) => !l.parentId), h = a.map((l) => l.id), c = this._threadCommentDataSourceService.syncUpdateMutationToColla, d = h.map((l) => ({
|
|
657
657
|
id: K.id,
|
|
658
658
|
params: {
|
|
659
659
|
unitId: o,
|
|
660
660
|
subUnitId: i,
|
|
661
661
|
commentId: l
|
|
662
662
|
}
|
|
663
|
-
})),
|
|
663
|
+
})), u = a.map(({ children: l, ..._ }) => ({
|
|
664
664
|
id: ne.id,
|
|
665
665
|
params: {
|
|
666
666
|
unitId: o,
|
|
667
667
|
subUnitId: i,
|
|
668
668
|
comment: {
|
|
669
|
-
...
|
|
669
|
+
..._,
|
|
670
670
|
children: c ? l : void 0
|
|
671
671
|
},
|
|
672
672
|
sync: !c
|
|
673
673
|
}
|
|
674
674
|
}));
|
|
675
|
-
return { redos:
|
|
675
|
+
return { redos: d, undos: u };
|
|
676
676
|
}
|
|
677
677
|
return { redos: [], undos: [] };
|
|
678
678
|
}
|
|
@@ -682,17 +682,17 @@ let Z = class extends R {
|
|
|
682
682
|
};
|
|
683
683
|
Z = qt([
|
|
684
684
|
j(V.Ready, Z),
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
685
|
+
B(0, p(Ce)),
|
|
686
|
+
B(1, $),
|
|
687
|
+
B(2, p(fe)),
|
|
688
|
+
B(3, Se)
|
|
689
689
|
], Z);
|
|
690
690
|
var Re = Object.defineProperty, Xt = Object.getOwnPropertyDescriptor, Jt = (t, e, n) => e in t ? Re(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, Qt = (t, e, n, r) => {
|
|
691
691
|
for (var o = r > 1 ? void 0 : r ? Xt(e, n) : e, i = t.length - 1, s; i >= 0; i--)
|
|
692
692
|
(s = t[i]) && (o = (r ? s(e, n, o) : s(o)) || o);
|
|
693
693
|
return r && o && Re(e, n, o), o;
|
|
694
694
|
}, me = (t, e) => (n, r) => e(n, r, t), $e = (t, e, n) => Jt(t, typeof e != "symbol" ? e + "" : e, n);
|
|
695
|
-
let Y = class extends
|
|
695
|
+
let Y = class extends Le {
|
|
696
696
|
constructor(e = {}, n, r) {
|
|
697
697
|
super();
|
|
698
698
|
U(this, "_pluginConfig");
|
|
@@ -710,7 +710,7 @@ let Y = class extends Be {
|
|
|
710
710
|
[k],
|
|
711
711
|
[W],
|
|
712
712
|
[Z],
|
|
713
|
-
[
|
|
713
|
+
[M]
|
|
714
714
|
].forEach((n) => {
|
|
715
715
|
e.add(n);
|
|
716
716
|
}), [Q].forEach((n) => {
|
|
@@ -719,7 +719,7 @@ let Y = class extends Be {
|
|
|
719
719
|
}
|
|
720
720
|
};
|
|
721
721
|
$e(Y, "pluginName", Ue);
|
|
722
|
-
$e(Y, "type",
|
|
722
|
+
$e(Y, "type", T.UNIVER_SHEET);
|
|
723
723
|
Y = Qt([
|
|
724
724
|
He(Ze, lt),
|
|
725
725
|
me(1, p(he)),
|
|
@@ -737,10 +737,10 @@ export {
|
|
|
737
737
|
k as SheetsThreadCommentCopyPasteController,
|
|
738
738
|
W as SheetsThreadCommentHoverController,
|
|
739
739
|
En as SheetsThreadCommentModel,
|
|
740
|
-
|
|
740
|
+
M as SheetsThreadCommentPopupService,
|
|
741
741
|
Q as ShowAddSheetCommentModalOperation,
|
|
742
742
|
Z as ThreadCommentRemoveSheetsController,
|
|
743
743
|
Pn as UniverInstanceType,
|
|
744
744
|
Y as UniverSheetsThreadCommentPlugin,
|
|
745
|
-
|
|
745
|
+
wn as UniverThreadCommentUIPlugin
|
|
746
746
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
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
|
+
declare const _default: {
|
|
17
|
+
sheetThreadComment: {
|
|
18
|
+
menu: {
|
|
19
|
+
addComment: string;
|
|
20
|
+
commentManagement: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
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
|
+
declare const _default: {
|
|
17
|
+
sheetThreadComment: {
|
|
18
|
+
menu: {
|
|
19
|
+
addComment: string;
|
|
20
|
+
commentManagement: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("@wendellhu/redi"),require("@univerjs/core"),require("@univerjs/thread-comment-ui"),require("@univerjs/ui"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment"),require("@univerjs/sheets-ui"),require("@univerjs/sheets-thread-comment-base"),require("@wendellhu/redi/react-bindings"),require("react"),require("rxjs"),require("@univerjs/engine-render")):typeof define=="function"&&define.amd?define(["exports","@wendellhu/redi","@univerjs/core","@univerjs/thread-comment-ui","@univerjs/ui","@univerjs/sheets","@univerjs/engine-formula","@univerjs/thread-comment","@univerjs/sheets-ui","@univerjs/sheets-thread-comment-base","@wendellhu/redi/react-bindings","react","rxjs","@univerjs/engine-render"],m):(a=typeof globalThis<"u"?globalThis:a||self,m(a.UniverSheetsThreadComment={},a["@wendellhu/redi"],a.UniverCore,a.UniverThreadCommentUi,a.UniverUi,a.UniverSheets,a.UniverEngineFormula,a.UniverThreadComment,a.UniverSheetsUi,a.UniverSheetsThreadCommentBase,a["@wendellhu/redi/react-bindings"],a.React,a.rxjs,a.UniverEngineRender))})(this,function(a,m,c,g,f,C,V,b,y,D,R,M,G,se){"use strict";var We=Object.defineProperty;var Fe=(a,m,c)=>m in a?We(a,m,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[m]=c;var A=(a,m,c)=>Fe(a,typeof m!="symbol"?m+"":m,c);var w=function(){return w=Object.assign||function(o){for(var r,n=1,e=arguments.length;n<e;n++){r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(o[t]=r[t])}return o},w.apply(this,arguments)},ae=function(o,r){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&r.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(o);t<e.length;t++)r.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(o,e[t])&&(n[e[t]]=o[e[t]]);return n},J=M.forwardRef(function(o,r){var n=o.icon,e=o.id,t=o.className,i=o.extend,s=ae(o,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),d=M.useRef("_".concat(me()));return Q(n,"".concat(e),{defIds:n.defIds,idSuffix:d.current},w({ref:r,className:u},s),i)});function Q(o,r,n,e,t){return M.createElement(o.tag,w(w({key:r},ce(o,n,t)),e),(ue(o,n).children||[]).map(function(i,s){return Q(i,"".concat(r,"-").concat(o.tag,"-").concat(s),n,void 0,t)}))}function ce(o,r,n){var e=w({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=r.defIds;return!t||t.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],u=i[1];typeof u=="string"&&(e[s]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function ue(o,r){var n,e=r.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?w(w({},o),{children:o.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?w(w({},t),{attrs:w(w({},t.attrs),{id:t.attrs.id+r.idSuffix})}):t})}):o}function me(){return Math.random().toString(36).substring(2,8)}J.displayName="UniverIcon";var de={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"}}]},x=M.forwardRef(function(o,r){return M.createElement(J,Object.assign({},o,{id:"comment-single",ref:r,icon:de}))});x.displayName="CommentSingle";const ee="univer.sheet.thread-comment-modal",K="comment-single",Y="SHEET_THREAD_COMMENT";var he=Object.defineProperty,le=Object.getOwnPropertyDescriptor,pe=(o,r,n,e)=>{for(var t=e>1?void 0:e?le(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&he(r,n,t),t},te=(o,r)=>(n,e)=>r(n,e,o);a.SheetsThreadCommentPopupService=class extends c.Disposable{constructor(n,e){super();A(this,"_lastPopup",null);A(this,"_activePopup");A(this,"_activePopup$",new G.BehaviorSubject(null));A(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible()}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var v;const{row:t,col:i,unitId:s,subUnitId:u}=n;if(this._activePopup&&t===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&u===((v=this.activePopup)==null?void 0:v.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const d=this._canvasPopupManagerService.attachPopupToCell(t,i,{componentKey:ee,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!d)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const p=new c.DisposableCollection;p.add(d),p.add({dispose:()=>{e==null||e()}}),this._lastPopup=p}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},a.SheetsThreadCommentPopupService=pe([te(0,m.Inject(y.SheetCanvasPopManagerService)),te(1,f.IZenZoneService)],a.SheetsThreadCommentPopupService);const ve=()=>{const o=R.useDependency(c.IUniverInstanceService),r=R.useDependency(a.SheetsThreadCommentPopupService),n=f.useObservable(r.activePopup$),e=R.useDependency(D.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!n)return null;const{row:t,col:i,unitId:s,subUnitId:u,trigger:d}=n,p=e.getByLocation(s,u,t,i),v=`${c.Tools.chatAtABC(i)}${t+1}`,l=()=>{r.hidePopup()},_=S=>{var T,I,N;return(N=(I=(T=o.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:T.getSheetBySheetId(S))==null?void 0:I.getName())!=null?N:""};return M.createElement(g.ThreadCommentTree,{onClick:()=>{r.persistPopup()},prefix:"cell",id:p,unitId:s,subUnitId:u,type:c.UniverInstanceType.UNIVER_SHEET,refStr:v,onClose:l,getSubUnitName:_,autoFocus:d==="context-menu"})},H={type:c.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var I;const r=o.get(C.SelectionManagerService),n=o.get(c.IUniverInstanceService),e=o.get(a.SheetsThreadCommentPopupService),t=o.get(g.ThreadCommentPanelService),i=(I=r.getFirst())==null?void 0:I.primary,s=r.getCurrent(),u=o.get(D.SheetsThreadCommentModel);if(!s||!i)return!1;const{unitId:d,sheetId:p}=s,v=C.getSheetCommandTarget(n,{unitId:d,subUnitId:p});if(!v)return!1;const{workbook:l,worksheet:_}=v,S={workbook:l,worksheet:_,unitId:d,subUnitId:p,row:i.startRow,col:i.startColumn};e.showPopup(S);const T=u.getByLocation(d,p,i.startRow,i.startColumn);return T&&t.setActiveComment({unitId:d,subUnitId:p,commentId:T,trigger:"context-menu"}),!0}},Ce=()=>{var z;const o=R.useDependency(y.IMarkSelectionService),r=R.useDependency(c.IUniverInstanceService),n=R.useDependency(b.ThreadCommentModel),e=R.useDependency(a.SheetsThreadCommentPopupService),t=r.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return null;const i=t.getUnitId(),s=R.useDependency(c.ICommandService),u=M.useMemo(()=>t.activeSheet$.pipe(G.map(h=>h==null?void 0:h.getSheetId())),[t.activeSheet$]),d=f.useObservable(u,(z=t.getActiveSheet())==null?void 0:z.getSheetId()),p=M.useRef(),v=R.useDependency(g.ThreadCommentPanelService),l=f.useObservable(v.activeCommentId$),_=M.useCallback(h=>{const P=t.getSheets(),O={};P.forEach((j,U)=>{O[j.getSheetId()]=U});const k=j=>j.map(U=>{var ie;const $=V.singleReferenceToGrid(U.ref),ke=[(ie=O[U.subUnitId])!=null?ie:0,$.row,$.column];return{...U,p:ke}}).sort((U,$)=>U.p[0]===$.p[0]?U.p[1]===$.p[1]?U.p[2]-$.p[2]:U.p[1]-$.p[1]:U.p[0]-$.p[0]);return[...k(h.filter(j=>!j.resolved)),...k(h.filter(j=>j.resolved))]},[t]),S=M.useCallback(h=>{if(h.unitId===i&&h.subUnitId===d&&!h.resolved){const{row:P,column:O}=V.singleReferenceToGrid(h.ref);if(!Number.isNaN(P)&&!Number.isNaN(O))return o.addShape({range:{startColumn:O,endColumn:O,startRow:P,endRow:P},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,d,i]),T=h=>{var P,O;return(O=(P=t.getSheetBySheetId(h))==null?void 0:P.getName())!=null?O:""},I=()=>{s.executeCommand(H.id)},N=h=>{l&&l.unitId===h.unitId&&l.subUnitId===h.subUnitId&&l.commentId===h.id||(p.current&&(o.removeShape(p.current),p.current=null),p.current=S(h))},L=()=>{p.current&&(o.removeShape(p.current),p.current=null)},Z=(h,P)=>{P&&e.hidePopup()};return M.useEffect(()=>{if(!l)return;const h=n.getComment(l.unitId,l.subUnitId,l.commentId);if(!h)return;const P=S(h);return()=>{P&&o.removeShape(P)}},[S,l,n,o]),M.createElement(g.ThreadCommentPanel,{unitId:i,subUnitId$:u,type:c.UniverInstanceType.UNIVER_SHEET,onAdd:I,getSubUnitName:T,onResolve:Z,sortComments:_,onItemEnter:N,onItemLeave:L,onDeleteComment:()=>(L(),!0)})},Se=o=>({id:H.id,type:f.MenuItemType.BUTTON,positions:[f.MenuPosition.CONTEXT_MENU],icon:K,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET),disabled$:y.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),fe=o=>({id:g.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:K,tooltip:"sheetThreadComment.menu.commentManagement",positions:f.MenuPosition.TOOLBAR_START,group:f.MenuGroup.TOOLBAR_OTHERS,disabled$:y.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET)}),_e={id:H.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:y.whenSheetEditorFocused};var Ie=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Te=(o,r,n,e)=>{for(var t=e>1?void 0:e?Pe(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&Ie(r,n,t),t},E=(o,r)=>(n,e)=>r(n,e,o);const ge={};a.SheetsThreadCommentController=class extends c.Disposable{constructor(r,n,e,t,i,s,u,d,p,v,l){super(),this._config=r,this._menuService=n,this._injector=e,this._componentManager=t,this._commandService=i,this._sheetsThreadCommentPopupService=s,this._sheetsThreadCommentModel=u,this._threadCommentPanelService=d,this._shortcutService=p,this._univerInstanceService=v,this._sheetPermissionInterceptorBaseController=l,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener()}_initShortcut(){this._shortcutService.registerShortcut(_e)}_initCommandListener(){this._commandService.onCommandExecuted(r=>{if(r.id===C.SetSelectionsOperation.id){const n=r.params,{unitId:e,subUnitId:t,selections:i,type:s}=n;if((s===C.SelectionMoveType.MOVE_END||s===void 0)&&i[0].primary){const u=i[0].primary.actualRow,d=i[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(e,t,u,d)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(g.SetActiveCommentOperation.id);return}const p=this._sheetsThreadCommentModel.getByLocation(e,t,u,d);p&&this._commandService.executeCommand(g.SetActiveCommentOperation.id,{unitId:e,subUnitId:t,commentId:p})}}if(r.id===b.DeleteCommentMutation.id){const n=r.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:t,subUnitId:i,commentId:s}=e;n.unitId===t&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:r={}}=this._config;[Se,fe].forEach(n=>{this._menuService.addMenuItem(n(this._injector),r)})}_initComponent(){[[ee,ve],[g.THREAD_COMMENT_PANEL,Ce],[K,x]].forEach(([r,n])=>{this._componentManager.register(r,n)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async r=>{var n;if(r){const{unitId:e,subUnitId:t,commentId:i,trigger:s}=r,u=this._sheetsThreadCommentModel.getComment(e,t,i);if(!u||u.resolved)return;const d=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!d||d.getUnitId()!==e)return;((n=d.getActiveSheet())==null?void 0:n.getSheetId())!==t&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t});const l=V.singleReferenceToGrid(u.ref),{row:_,column:S}=l;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:_,startColumn:S,endRow:_,endColumn:S}]))return;const I=1;await this._commandService.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(l.row-I,0),endRow:l.row+I,startColumn:Math.max(l.column-I,0),endColumn:l.column+I}}),this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:t,row:l.row,col:l.column,commentId:u.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}},a.SheetsThreadCommentController=Te([c.OnLifecycle(c.LifecycleStages.Starting,a.SheetsThreadCommentController),E(1,f.IMenuService),E(2,m.Inject(m.Injector)),E(3,m.Inject(f.ComponentManager)),E(4,c.ICommandService),E(5,m.Inject(a.SheetsThreadCommentPopupService)),E(6,m.Inject(D.SheetsThreadCommentModel)),E(7,m.Inject(g.ThreadCommentPanelService)),E(8,f.IShortcutService),E(9,c.IUniverInstanceService),E(10,m.Inject(y.SheetPermissionInterceptorBaseController))],a.SheetsThreadCommentController);var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Me=(o,r,n,e)=>{for(var t=e>1?void 0:e?ye(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&be(r,n,t),t},W=(o,r)=>(n,e)=>r(n,e,o);let F=class extends c.Disposable{constructor(o,r,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=r,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(o,r,n)=>{const{row:e,col:t,unitId:i,subUnitId:s}=r;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,t)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var s;const r=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!r)return;const n=r.getUnitId(),e=(s=r.getActiveSheet())==null?void 0:s.getSheetId();if(!e){console.warn("No active sheet found");return}const t=this._renderManagerService.getRenderById(n),i=t==null?void 0:t.with(y.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:e});i==null||i.makeDirty(!0),i==null||i.calculate(),t&&t.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(r=>{o()}))}};F=Me([c.OnLifecycle(c.LifecycleStages.Ready,F),W(0,m.Inject(C.SheetInterceptorService)),W(1,m.Inject(D.SheetsThreadCommentModel)),W(2,c.IUniverInstanceService),W(3,se.IRenderManagerService)],F);var we=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Ue=(o,r,n,e)=>{for(var t=e>1?void 0:e?Oe(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&we(r,n,t),t},X=(o,r)=>(n,e)=>r(n,e,o);const Ee=(o,r,n)=>{const e=V.singleReferenceToGrid(o),t=n.row-r.row,i=n.column-r.column,s={startColumn:e.column+i,startRow:e.row+t,endColumn:e.column+i,endRow:e.row+t};return V.serializeRange(s)};a.SheetsThreadCommentCopyPasteController=class extends c.Disposable{constructor(n,e,t){super();A(this,"_copyInfo");this._sheetClipboardService=n,this._sheetsThreadCommentModel=e,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Y,onBeforeCopy:(n,e,t)=>{this._copyInfo={unitId:n,subUnitId:e,range:t}},onPasteCells:(n,e,t,i)=>{const{unitId:s,subUnitId:u,range:d}=e,p={row:d.rows[0],column:d.cols[0]};if(i.copyType===y.COPY_TYPE.CUT&&this._copyInfo){const{range:v,unitId:l,subUnitId:_}=this._copyInfo,S={row:v.startRow,column:v.startColumn};if(!(s===l&&u===_)){const T=[];c.Range.foreach(v,(h,P)=>{const O=this._sheetsThreadCommentModel.getAllByLocation(l,_,h,P);this._threadCommentDataSourceService.syncUpdateMutationToColla?O.forEach(k=>{T.push(k)}):O.forEach(({children:k,...j})=>{j.parentId||T.push(j)})});const I=[],N=[],L=[],Z=[],z=h=>{I.unshift({id:b.DeleteCommentMutation.id,params:{unitId:l,subUnitId:_,commentId:h.id}}),L.push({id:b.AddCommentMutation.id,params:{unitId:s,subUnitId:u,comment:{...h,ref:Ee(h.ref,S,p),unitId:s,subUnitId:u},sync:!0}}),N.push({id:b.AddCommentMutation.id,params:{unitId:l,subUnitId:_,comment:h,sync:!0}}),Z.unshift({id:b.DeleteCommentMutation.id,params:{unitId:s,subUnitId:u,commentId:h.id}})};return T.forEach(h=>{z(h)}),{redos:[...I,...L],undos:[...Z,...N]}}}return{redos:[],undos:[]}}}))}},a.SheetsThreadCommentCopyPasteController=Ue([c.OnLifecycle(c.LifecycleStages.Rendered,a.SheetsThreadCommentCopyPasteController),X(0,m.Inject(y.ISheetClipboardService)),X(1,m.Inject(D.SheetsThreadCommentModel)),X(2,b.IThreadCommentDataSourceService)],a.SheetsThreadCommentCopyPasteController);var je=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,De=(o,r,n,e)=>{for(var t=e>1?void 0:e?Re(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&je(r,n,t),t},q=(o,r)=>(n,e)=>r(n,e,o);a.SheetsThreadCommentHoverController=class extends c.Disposable{constructor(r,n,e,t){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._sheetPermissionInterceptorBaseController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(G.debounceTime(100)).subscribe(r=>{const n=this._sheetsThreadCommentPopupService.activePopup;if(r&&(n&&n.temp||!n)){const{location:e}=r,{unitId:t,subUnitId:i,row:s,col:u}=e,d=this._sheetsThreadCommentModel.getByLocation(t,i,s,u);if(d){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:s,startColumn:u,endRow:s,endColumn:u}]))return;const v=this._sheetsThreadCommentModel.getComment(t,i,d);v&&!v.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:i,row:s,col:u,commentId:d,temp:!0})}else n&&this._sheetsThreadCommentPopupService.hidePopup()}}))}},a.SheetsThreadCommentHoverController=De([c.OnLifecycle(c.LifecycleStages.Rendered,a.SheetsThreadCommentHoverController),q(0,m.Inject(y.HoverManagerService)),q(1,m.Inject(a.SheetsThreadCommentPopupService)),q(2,m.Inject(D.SheetsThreadCommentModel)),q(3,m.Inject(y.SheetPermissionInterceptorBaseController))],a.SheetsThreadCommentHoverController);var $e=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Ae=(o,r,n,e)=>{for(var t=e>1?void 0:e?Ne(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&$e(r,n,t),t},B=(o,r)=>(n,e)=>r(n,e,o);a.ThreadCommentRemoveSheetsController=class extends c.Disposable{constructor(r,n,e,t){super(),this._sheetInterceptorService=r,this._univerInstanceService=n,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var n;if(r.id===C.RemoveSheetCommand.id){const e=r.params,t=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return{redos:[],undos:[]};const i=t.getUnitId(),s=e.subUnitId||((n=t.getActiveSheet())==null?void 0:n.getSheetId());if(!s)return{redos:[],undos:[]};const{commentMap:u}=this._threadCommentModel.ensureMap(i,s),d=Array.from(Object.values(u)).filter(S=>!S.parentId),p=d.map(S=>S.id),v=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=p.map(S=>({id:b.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:S}})),_=d.map(({children:S,...T})=>({id:b.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...T,children:v?S:void 0},sync:!v}}));return{redos:l,undos:_}}return{redos:[],undos:[]}}}))}},a.ThreadCommentRemoveSheetsController=Ae([c.OnLifecycle(c.LifecycleStages.Ready,a.ThreadCommentRemoveSheetsController),B(0,m.Inject(C.SheetInterceptorService)),B(1,c.IUniverInstanceService),B(2,m.Inject(b.ThreadCommentModel)),B(3,b.IThreadCommentDataSourceService)],a.ThreadCommentRemoveSheetsController);var ne=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,He=(o,r,n)=>r in o?ne(o,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[r]=n,Le=(o,r,n,e)=>{for(var t=e>1?void 0:e?Ve(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&ne(r,n,t),t},re=(o,r)=>(n,e)=>r(n,e,o),oe=(o,r,n)=>He(o,typeof r!="symbol"?r+"":r,n);a.UniverSheetsThreadCommentPlugin=class extends c.Plugin{constructor(n={},e,t){super();A(this,"_pluginConfig");this._injector=e,this._commandService=t,this._pluginConfig=c.Tools.deepMerge({},ge,n)}onStarting(n){[[a.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(a.SheetsThreadCommentController,this._pluginConfig)}],[F],[a.SheetsThreadCommentCopyPasteController],[a.SheetsThreadCommentHoverController],[a.ThreadCommentRemoveSheetsController],[a.SheetsThreadCommentPopupService]].forEach(e=>{n.add(e)}),[H].forEach(e=>{this._commandService.registerCommand(e)})}},oe(a.UniverSheetsThreadCommentPlugin,"pluginName",Y),oe(a.UniverSheetsThreadCommentPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),a.UniverSheetsThreadCommentPlugin=Le([c.DependentOn(g.UniverThreadCommentUIPlugin,D.UniverSheetsThreadCommentBasePlugin),re(1,m.Inject(m.Injector)),re(2,m.Inject(c.ICommandService))],a.UniverSheetsThreadCommentPlugin),Object.defineProperty(a,"Inject",{enumerable:!0,get:()=>m.Inject}),Object.defineProperty(a,"Injector",{enumerable:!0,get:()=>m.Injector}),Object.defineProperty(a,"ICommandService",{enumerable:!0,get:()=>c.ICommandService}),Object.defineProperty(a,"Plugin",{enumerable:!0,get:()=>c.Plugin}),Object.defineProperty(a,"UniverInstanceType",{enumerable:!0,get:()=>c.UniverInstanceType}),Object.defineProperty(a,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>g.IThreadCommentMentionDataService}),Object.defineProperty(a,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>g.UniverThreadCommentUIPlugin}),Object.defineProperty(a,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>b.IThreadCommentDataSourceService}),Object.defineProperty(a,"SheetsThreadCommentModel",{enumerable:!0,get:()=>D.SheetsThreadCommentModel}),a.SHEETS_THREAD_COMMENT=Y,a.ShowAddSheetCommentModalOperation=H,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(a,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("@wendellhu/redi"),require("@univerjs/core"),require("@univerjs/thread-comment-ui"),require("@univerjs/ui"),require("@univerjs/sheets"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment"),require("@univerjs/sheets-ui"),require("@univerjs/sheets-thread-comment-base"),require("@wendellhu/redi/react-bindings"),require("react"),require("rxjs"),require("@univerjs/engine-render")):typeof define=="function"&&define.amd?define(["exports","@wendellhu/redi","@univerjs/core","@univerjs/thread-comment-ui","@univerjs/ui","@univerjs/sheets","@univerjs/engine-formula","@univerjs/thread-comment","@univerjs/sheets-ui","@univerjs/sheets-thread-comment-base","@wendellhu/redi/react-bindings","react","rxjs","@univerjs/engine-render"],m):(a=typeof globalThis<"u"?globalThis:a||self,m(a.UniverSheetsThreadComment={},a["@wendellhu/redi"],a.UniverCore,a.UniverThreadCommentUi,a.UniverUi,a.UniverSheets,a.UniverEngineFormula,a.UniverThreadComment,a.UniverSheetsUi,a.UniverSheetsThreadCommentBase,a["@wendellhu/redi/react-bindings"],a.React,a.rxjs,a.UniverEngineRender))})(this,function(a,m,c,T,f,C,V,g,b,D,R,y,G,se){"use strict";var We=Object.defineProperty;var Fe=(a,m,c)=>m in a?We(a,m,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[m]=c;var A=(a,m,c)=>Fe(a,typeof m!="symbol"?m+"":m,c);var M=function(){return M=Object.assign||function(o){for(var r,n=1,e=arguments.length;n<e;n++){r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(o[t]=r[t])}return o},M.apply(this,arguments)},ae=function(o,r){var n={};for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&r.indexOf(e)<0&&(n[e]=o[e]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(o);t<e.length;t++)r.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(o,e[t])&&(n[e[t]]=o[e[t]]);return n},J=y.forwardRef(function(o,r){var n=o.icon,e=o.id,t=o.className,i=o.extend,s=ae(o,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),l=y.useRef("_".concat(me()));return Q(n,"".concat(e),{defIds:n.defIds,idSuffix:l.current},M({ref:r,className:u},s),i)});function Q(o,r,n,e,t){return y.createElement(o.tag,M(M({key:r},ce(o,n,t)),e),(ue(o,n).children||[]).map(function(i,s){return Q(i,"".concat(r,"-").concat(o.tag,"-").concat(s),n,void 0,t)}))}function ce(o,r,n){var e=M({},o.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=r.defIds;return!t||t.length===0||(o.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],u=i[1];typeof u=="string"&&(e[s]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function ue(o,r){var n,e=r.defIds;return!e||e.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?M(M({},o),{children:o.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?M(M({},t),{attrs:M(M({},t.attrs),{id:t.attrs.id+r.idSuffix})}):t})}):o}function me(){return Math.random().toString(36).substring(2,8)}J.displayName="UniverIcon";var de={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"}}]},x=y.forwardRef(function(o,r){return y.createElement(J,Object.assign({},o,{id:"comment-single",ref:r,icon:de}))});x.displayName="CommentSingle";const ee="univer.sheet.thread-comment-modal",K="comment-single",Y="SHEET_THREAD_COMMENT";var he=Object.defineProperty,le=Object.getOwnPropertyDescriptor,pe=(o,r,n,e)=>{for(var t=e>1?void 0:e?le(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&he(r,n,t),t},te=(o,r)=>(n,e)=>r(n,e,o);a.SheetsThreadCommentPopupService=class extends c.Disposable{constructor(n,e){super();A(this,"_lastPopup",null);A(this,"_activePopup");A(this,"_activePopup$",new G.BehaviorSubject(null));A(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=e,this._initZenVisible()}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,e){var v;const{row:t,col:i,unitId:s,subUnitId:u}=n;if(this._activePopup&&t===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&u===((v=this.activePopup)==null?void 0:v.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const l=this._canvasPopupManagerService.attachPopupToCell(t,i,{componentKey:ee,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!l)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const p=new c.DisposableCollection;p.add(l),p.add({dispose:()=>{e==null||e()}}),this._lastPopup=p}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},a.SheetsThreadCommentPopupService=pe([te(0,m.Inject(b.SheetCanvasPopManagerService)),te(1,f.IZenZoneService)],a.SheetsThreadCommentPopupService);const ve=()=>{const o=R.useDependency(c.IUniverInstanceService),r=R.useDependency(a.SheetsThreadCommentPopupService),n=f.useObservable(r.activePopup$),e=R.useDependency(D.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!n)return null;const{row:t,col:i,unitId:s,subUnitId:u,trigger:l}=n,p=e.getByLocation(s,u,t,i),v=`${c.Tools.chatAtABC(i)}${t+1}`,d=()=>{r.hidePopup()},_=S=>{var P,w,N;return(N=(w=(P=o.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null?void 0:P.getSheetBySheetId(S))==null?void 0:w.getName())!=null?N:""};return y.createElement(T.ThreadCommentTree,{onClick:()=>{r.persistPopup()},prefix:"cell",id:p,unitId:s,subUnitId:u,type:c.UniverInstanceType.UNIVER_SHEET,refStr:v,onClose:d,getSubUnitName:_,autoFocus:l==="context-menu"})},H={type:c.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var P;const r=o.get(C.SheetsSelectionsService),n=o.get(c.IUniverInstanceService),e=o.get(a.SheetsThreadCommentPopupService),t=o.get(T.ThreadCommentPanelService),i=(P=r.getCurrentLastSelection())==null?void 0:P.primary,s=o.get(D.SheetsThreadCommentModel);if(!i)return!1;const u=C.getSheetCommandTarget(n);if(!u)return!1;const{workbook:l,worksheet:p,unitId:v,subUnitId:d}=u,_={workbook:l,worksheet:p,unitId:v,subUnitId:d,row:i.startRow,col:i.startColumn};e.showPopup(_);const S=s.getByLocation(v,d,i.startRow,i.startColumn);return S&&t.setActiveComment({unitId:v,subUnitId:d,commentId:S,trigger:"context-menu"}),!0}},Ce=()=>{var z;const o=R.useDependency(b.IMarkSelectionService),r=R.useDependency(c.IUniverInstanceService),n=R.useDependency(g.ThreadCommentModel),e=R.useDependency(a.SheetsThreadCommentPopupService),t=r.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return null;const i=t.getUnitId(),s=R.useDependency(c.ICommandService),u=y.useMemo(()=>t.activeSheet$.pipe(G.map(h=>h==null?void 0:h.getSheetId())),[t.activeSheet$]),l=f.useObservable(u,(z=t.getActiveSheet())==null?void 0:z.getSheetId()),p=y.useRef(),v=R.useDependency(T.ThreadCommentPanelService),d=f.useObservable(v.activeCommentId$),_=y.useCallback(h=>{const I=t.getSheets(),O={};I.forEach((j,U)=>{O[j.getSheetId()]=U});const k=j=>j.map(U=>{var ie;const $=V.singleReferenceToGrid(U.ref),ke=[(ie=O[U.subUnitId])!=null?ie:0,$.row,$.column];return{...U,p:ke}}).sort((U,$)=>U.p[0]===$.p[0]?U.p[1]===$.p[1]?U.p[2]-$.p[2]:U.p[1]-$.p[1]:U.p[0]-$.p[0]);return[...k(h.filter(j=>!j.resolved)),...k(h.filter(j=>j.resolved))]},[t]),S=y.useCallback(h=>{if(h.unitId===i&&h.subUnitId===l&&!h.resolved){const{row:I,column:O}=V.singleReferenceToGrid(h.ref);if(!Number.isNaN(I)&&!Number.isNaN(O))return o.addShape({range:{startColumn:O,endColumn:O,startRow:I,endRow:I},style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,l,i]),P=h=>{var I,O;return(O=(I=t.getSheetBySheetId(h))==null?void 0:I.getName())!=null?O:""},w=()=>{s.executeCommand(H.id)},N=h=>{d&&d.unitId===h.unitId&&d.subUnitId===h.subUnitId&&d.commentId===h.id||(p.current&&(o.removeShape(p.current),p.current=null),p.current=S(h))},L=()=>{p.current&&(o.removeShape(p.current),p.current=null)},Z=(h,I)=>{I&&e.hidePopup()};return y.useEffect(()=>{if(!d)return;const h=n.getComment(d.unitId,d.subUnitId,d.commentId);if(!h)return;const I=S(h);return()=>{I&&o.removeShape(I)}},[S,d,n,o]),y.createElement(T.ThreadCommentPanel,{unitId:i,subUnitId$:u,type:c.UniverInstanceType.UNIVER_SHEET,onAdd:w,getSubUnitName:P,onResolve:Z,sortComments:_,onItemEnter:N,onItemLeave:L,onDeleteComment:()=>(L(),!0)})},Se=o=>({id:H.id,type:f.MenuItemType.BUTTON,positions:[f.MenuPosition.CONTEXT_MENU],icon:K,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET),disabled$:b.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),fe=o=>({id:T.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:K,tooltip:"sheetThreadComment.menu.commentManagement",positions:f.MenuPosition.TOOLBAR_START,group:f.MenuGroup.TOOLBAR_OTHERS,disabled$:b.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(o,c.UniverInstanceType.UNIVER_SHEET)}),_e={id:H.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:b.whenSheetEditorFocused};var Ie=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Te=(o,r,n,e)=>{for(var t=e>1?void 0:e?Pe(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&Ie(r,n,t),t},E=(o,r)=>(n,e)=>r(n,e,o);const ge={};a.SheetsThreadCommentController=class extends c.Disposable{constructor(r,n,e,t,i,s,u,l,p,v,d){super(),this._config=r,this._menuService=n,this._injector=e,this._componentManager=t,this._commandService=i,this._sheetsThreadCommentPopupService=s,this._sheetsThreadCommentModel=u,this._threadCommentPanelService=l,this._shortcutService=p,this._univerInstanceService=v,this._sheetPermissionInterceptorBaseController=d,this._initMenu(),this._initShortcut(),this._initComponent(),this._initCommandListener(),this._initPanelListener()}_initShortcut(){this._shortcutService.registerShortcut(_e)}_initCommandListener(){this._commandService.onCommandExecuted(r=>{if(r.id===C.SetSelectionsOperation.id){const n=r.params,{unitId:e,subUnitId:t,selections:i,type:s}=n;if((s===C.SelectionMoveType.MOVE_END||s===void 0)&&i[0].primary){const u=i[0].primary.actualRow,l=i[0].primary.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(e,t,u,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(T.SetActiveCommentOperation.id);return}const p=this._sheetsThreadCommentModel.getByLocation(e,t,u,l);p&&this._commandService.executeCommand(T.SetActiveCommentOperation.id,{unitId:e,subUnitId:t,commentId:p})}}if(r.id===g.DeleteCommentMutation.id){const n=r.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:t,subUnitId:i,commentId:s}=e;n.unitId===t&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initMenu(){const{menu:r={}}=this._config;[Se,fe].forEach(n=>{this._menuService.addMenuItem(n(this._injector),r)})}_initComponent(){[[ee,ve],[T.THREAD_COMMENT_PANEL,Ce],[K,x]].forEach(([r,n])=>{this._componentManager.register(r,n)})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async r=>{var n;if(r){const{unitId:e,subUnitId:t,commentId:i,trigger:s}=r,u=this._sheetsThreadCommentModel.getComment(e,t,i);if(!u||u.resolved)return;const l=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!l||l.getUnitId()!==e)return;((n=l.getActiveSheet())==null?void 0:n.getSheetId())!==t&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t});const d=V.singleReferenceToGrid(u.ref),{row:_,column:S}=d;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:_,startColumn:S,endRow:_,endColumn:S}]))return;const w=1;await this._commandService.executeCommand(b.ScrollToRangeOperation.id,{range:{startRow:Math.max(d.row-w,0),endRow:d.row+w,startColumn:Math.max(d.column-w,0),endColumn:d.column+w}}),this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:t,row:d.row,col:d.column,commentId:u.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}},a.SheetsThreadCommentController=Te([c.OnLifecycle(c.LifecycleStages.Starting,a.SheetsThreadCommentController),E(1,f.IMenuService),E(2,m.Inject(m.Injector)),E(3,m.Inject(f.ComponentManager)),E(4,c.ICommandService),E(5,m.Inject(a.SheetsThreadCommentPopupService)),E(6,m.Inject(D.SheetsThreadCommentModel)),E(7,m.Inject(T.ThreadCommentPanelService)),E(8,f.IShortcutService),E(9,c.IUniverInstanceService),E(10,m.Inject(b.SheetPermissionInterceptorBaseController))],a.SheetsThreadCommentController);var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Me=(o,r,n,e)=>{for(var t=e>1?void 0:e?ye(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&be(r,n,t),t},W=(o,r)=>(n,e)=>r(n,e,o);let F=class extends c.Disposable{constructor(o,r,n,e){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=r,this._univerInstanceService=n,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(o,r,n)=>{const{row:e,col:t,unitId:i,subUnitId:s}=r;return this._sheetsThreadCommentModel.showCommentMarker(i,s,e,t)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var s;const r=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!r)return;const n=r.getUnitId(),e=(s=r.getActiveSheet())==null?void 0:s.getSheetId();if(!e){console.warn("No active sheet found");return}const t=this._renderManagerService.getRenderById(n),i=t==null?void 0:t.with(b.SheetSkeletonManagerService).getOrCreateSkeleton({sheetId:e});i==null||i.makeDirty(!0),i==null||i.calculate(),t&&t.mainComponent.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(r=>{o()}))}};F=Me([c.OnLifecycle(c.LifecycleStages.Ready,F),W(0,m.Inject(C.SheetInterceptorService)),W(1,m.Inject(D.SheetsThreadCommentModel)),W(2,c.IUniverInstanceService),W(3,se.IRenderManagerService)],F);var we=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Ue=(o,r,n,e)=>{for(var t=e>1?void 0:e?Oe(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&we(r,n,t),t},X=(o,r)=>(n,e)=>r(n,e,o);const Ee=(o,r,n)=>{const e=V.singleReferenceToGrid(o),t=n.row-r.row,i=n.column-r.column,s={startColumn:e.column+i,startRow:e.row+t,endColumn:e.column+i,endRow:e.row+t};return V.serializeRange(s)};a.SheetsThreadCommentCopyPasteController=class extends c.Disposable{constructor(n,e,t){super();A(this,"_copyInfo");this._sheetClipboardService=n,this._sheetsThreadCommentModel=e,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Y,onBeforeCopy:(n,e,t)=>{this._copyInfo={unitId:n,subUnitId:e,range:t}},onPasteCells:(n,e,t,i)=>{const{unitId:s,subUnitId:u,range:l}=e,p={row:l.rows[0],column:l.cols[0]};if(i.copyType===b.COPY_TYPE.CUT&&this._copyInfo){const{range:v,unitId:d,subUnitId:_}=this._copyInfo,S={row:v.startRow,column:v.startColumn};if(!(s===d&&u===_)){const P=[];c.Range.foreach(v,(h,I)=>{const O=this._sheetsThreadCommentModel.getAllByLocation(d,_,h,I);this._threadCommentDataSourceService.syncUpdateMutationToColla?O.forEach(k=>{P.push(k)}):O.forEach(({children:k,...j})=>{j.parentId||P.push(j)})});const w=[],N=[],L=[],Z=[],z=h=>{w.unshift({id:g.DeleteCommentMutation.id,params:{unitId:d,subUnitId:_,commentId:h.id}}),L.push({id:g.AddCommentMutation.id,params:{unitId:s,subUnitId:u,comment:{...h,ref:Ee(h.ref,S,p),unitId:s,subUnitId:u},sync:!0}}),N.push({id:g.AddCommentMutation.id,params:{unitId:d,subUnitId:_,comment:h,sync:!0}}),Z.unshift({id:g.DeleteCommentMutation.id,params:{unitId:s,subUnitId:u,commentId:h.id}})};return P.forEach(h=>{z(h)}),{redos:[...w,...L],undos:[...Z,...N]}}}return{redos:[],undos:[]}}}))}},a.SheetsThreadCommentCopyPasteController=Ue([c.OnLifecycle(c.LifecycleStages.Rendered,a.SheetsThreadCommentCopyPasteController),X(0,m.Inject(b.ISheetClipboardService)),X(1,m.Inject(D.SheetsThreadCommentModel)),X(2,g.IThreadCommentDataSourceService)],a.SheetsThreadCommentCopyPasteController);var je=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,De=(o,r,n,e)=>{for(var t=e>1?void 0:e?Re(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&je(r,n,t),t},q=(o,r)=>(n,e)=>r(n,e,o);a.SheetsThreadCommentHoverController=class extends c.Disposable{constructor(r,n,e,t){super(),this._hoverManagerService=r,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=e,this._sheetPermissionInterceptorBaseController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(G.debounceTime(100)).subscribe(r=>{const n=this._sheetsThreadCommentPopupService.activePopup;if(r&&(n&&n.temp||!n)){const{location:e}=r,{unitId:t,subUnitId:i,row:s,col:u}=e,l=this._sheetsThreadCommentModel.getByLocation(t,i,s,u);if(l){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:s,startColumn:u,endRow:s,endColumn:u}]))return;const v=this._sheetsThreadCommentModel.getComment(t,i,l);v&&!v.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:i,row:s,col:u,commentId:l,temp:!0})}else n&&this._sheetsThreadCommentPopupService.hidePopup()}}))}},a.SheetsThreadCommentHoverController=De([c.OnLifecycle(c.LifecycleStages.Rendered,a.SheetsThreadCommentHoverController),q(0,m.Inject(b.HoverManagerService)),q(1,m.Inject(a.SheetsThreadCommentPopupService)),q(2,m.Inject(D.SheetsThreadCommentModel)),q(3,m.Inject(b.SheetPermissionInterceptorBaseController))],a.SheetsThreadCommentHoverController);var $e=Object.defineProperty,Ne=Object.getOwnPropertyDescriptor,Ae=(o,r,n,e)=>{for(var t=e>1?void 0:e?Ne(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&$e(r,n,t),t},B=(o,r)=>(n,e)=>r(n,e,o);a.ThreadCommentRemoveSheetsController=class extends c.Disposable{constructor(r,n,e,t){super(),this._sheetInterceptorService=r,this._univerInstanceService=n,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{var n;if(r.id===C.RemoveSheetCommand.id){const e=r.params,t=e.unitId?this._univerInstanceService.getUnit(e.unitId):this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return{redos:[],undos:[]};const i=t.getUnitId(),s=e.subUnitId||((n=t.getActiveSheet())==null?void 0:n.getSheetId());if(!s)return{redos:[],undos:[]};const{commentMap:u}=this._threadCommentModel.ensureMap(i,s),l=Array.from(Object.values(u)).filter(S=>!S.parentId),p=l.map(S=>S.id),v=this._threadCommentDataSourceService.syncUpdateMutationToColla,d=p.map(S=>({id:g.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:S}})),_=l.map(({children:S,...P})=>({id:g.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...P,children:v?S:void 0},sync:!v}}));return{redos:d,undos:_}}return{redos:[],undos:[]}}}))}},a.ThreadCommentRemoveSheetsController=Ae([c.OnLifecycle(c.LifecycleStages.Ready,a.ThreadCommentRemoveSheetsController),B(0,m.Inject(C.SheetInterceptorService)),B(1,c.IUniverInstanceService),B(2,m.Inject(g.ThreadCommentModel)),B(3,g.IThreadCommentDataSourceService)],a.ThreadCommentRemoveSheetsController);var ne=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,He=(o,r,n)=>r in o?ne(o,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[r]=n,Le=(o,r,n,e)=>{for(var t=e>1?void 0:e?Ve(r,n):r,i=o.length-1,s;i>=0;i--)(s=o[i])&&(t=(e?s(r,n,t):s(t))||t);return e&&t&&ne(r,n,t),t},re=(o,r)=>(n,e)=>r(n,e,o),oe=(o,r,n)=>He(o,typeof r!="symbol"?r+"":r,n);a.UniverSheetsThreadCommentPlugin=class extends c.Plugin{constructor(n={},e,t){super();A(this,"_pluginConfig");this._injector=e,this._commandService=t,this._pluginConfig=c.Tools.deepMerge({},ge,n)}onStarting(n){[[a.SheetsThreadCommentController,{useFactory:()=>this._injector.createInstance(a.SheetsThreadCommentController,this._pluginConfig)}],[F],[a.SheetsThreadCommentCopyPasteController],[a.SheetsThreadCommentHoverController],[a.ThreadCommentRemoveSheetsController],[a.SheetsThreadCommentPopupService]].forEach(e=>{n.add(e)}),[H].forEach(e=>{this._commandService.registerCommand(e)})}},oe(a.UniverSheetsThreadCommentPlugin,"pluginName",Y),oe(a.UniverSheetsThreadCommentPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),a.UniverSheetsThreadCommentPlugin=Le([c.DependentOn(T.UniverThreadCommentUIPlugin,D.UniverSheetsThreadCommentBasePlugin),re(1,m.Inject(m.Injector)),re(2,m.Inject(c.ICommandService))],a.UniverSheetsThreadCommentPlugin),Object.defineProperty(a,"Inject",{enumerable:!0,get:()=>m.Inject}),Object.defineProperty(a,"Injector",{enumerable:!0,get:()=>m.Injector}),Object.defineProperty(a,"ICommandService",{enumerable:!0,get:()=>c.ICommandService}),Object.defineProperty(a,"Plugin",{enumerable:!0,get:()=>c.Plugin}),Object.defineProperty(a,"UniverInstanceType",{enumerable:!0,get:()=>c.UniverInstanceType}),Object.defineProperty(a,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>T.IThreadCommentMentionDataService}),Object.defineProperty(a,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>T.UniverThreadCommentUIPlugin}),Object.defineProperty(a,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>g.IThreadCommentDataSourceService}),Object.defineProperty(a,"SheetsThreadCommentModel",{enumerable:!0,get:()=>D.SheetsThreadCommentModel}),a.SHEETS_THREAD_COMMENT=Y,a.ShowAddSheetCommentModalOperation=H,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-thread-comment",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer thread comment plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
"@wendellhu/redi": "0.15.5",
|
|
49
49
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
50
50
|
"rxjs": ">=7.0.0",
|
|
51
|
-
"@univerjs/core": "0.2.
|
|
52
|
-
"@univerjs/engine-formula": "0.2.
|
|
53
|
-
"@univerjs/engine-render": "0.2.
|
|
54
|
-
"@univerjs/sheets": "0.2.
|
|
55
|
-
"@univerjs/sheets-
|
|
56
|
-
"@univerjs/thread-comment": "0.2.
|
|
57
|
-
"@univerjs/sheets-
|
|
58
|
-
"@univerjs/thread-comment-ui": "0.2.
|
|
59
|
-
"@univerjs/ui": "0.2.
|
|
51
|
+
"@univerjs/core": "0.2.3",
|
|
52
|
+
"@univerjs/engine-formula": "0.2.3",
|
|
53
|
+
"@univerjs/engine-render": "0.2.3",
|
|
54
|
+
"@univerjs/sheets": "0.2.3",
|
|
55
|
+
"@univerjs/sheets-ui": "0.2.3",
|
|
56
|
+
"@univerjs/thread-comment": "0.2.3",
|
|
57
|
+
"@univerjs/sheets-thread-comment-base": "0.2.3",
|
|
58
|
+
"@univerjs/thread-comment-ui": "0.2.3",
|
|
59
|
+
"@univerjs/ui": "0.2.3"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@univerjs/icons": "^0.1.58"
|
|
@@ -69,14 +69,14 @@
|
|
|
69
69
|
"typescript": "^5.5.3",
|
|
70
70
|
"vite": "^5.3.3",
|
|
71
71
|
"vitest": "^1.6.0",
|
|
72
|
-
"@univerjs/core": "0.2.
|
|
73
|
-
"@univerjs/design": "0.2.
|
|
74
|
-
"@univerjs/engine-formula": "0.2.
|
|
75
|
-
"@univerjs/
|
|
76
|
-
"@univerjs/
|
|
77
|
-
"@univerjs/thread-comment": "0.2.
|
|
78
|
-
"@univerjs/thread-comment
|
|
79
|
-
"@univerjs/ui": "0.2.
|
|
72
|
+
"@univerjs/core": "0.2.3",
|
|
73
|
+
"@univerjs/design": "0.2.3",
|
|
74
|
+
"@univerjs/engine-formula": "0.2.3",
|
|
75
|
+
"@univerjs/sheets-thread-comment-base": "0.2.3",
|
|
76
|
+
"@univerjs/shared": "0.2.3",
|
|
77
|
+
"@univerjs/thread-comment-ui": "0.2.3",
|
|
78
|
+
"@univerjs/thread-comment": "0.2.3",
|
|
79
|
+
"@univerjs/ui": "0.2.3"
|
|
80
80
|
},
|
|
81
81
|
"univerSpace": {
|
|
82
82
|
".": {
|