@univerjs/docs-thread-comment-ui 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js
CHANGED
package/lib/es/index.js
CHANGED
package/lib/index.js
CHANGED
package/lib/umd/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/docs"),require("@univerjs/docs-thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/docs-ui"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/protocol"),require("react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/docs`,`@univerjs/docs-thread-comment`,`@univerjs/thread-comment-ui`,`@univerjs/docs-ui`,`@univerjs/drawing`,`@univerjs/engine-render`,`@univerjs/thread-comment`,`@univerjs/ui`,`rxjs`,`@univerjs/protocol`,`react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsThreadCommentUi={},e.UniverCore,e.UniverDocs,e.UniverDocsThreadComment,e.UniverThreadCommentUi,e.UniverDocsUi,e.UniverDrawing,e.UniverEngineRender,e.UniverThreadComment,e.UniverUi,e.rxjs,e.UniverProtocol,e.React,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let m={id:`docs.command.add-comment`,type:t.CommandType.COMMAND,async handler(e,a){if(!a)return!1;let o=await(0,r.prepareDocTextRangeComment)(e,a);if(!o)return!1;let s={id:i.SetActiveCommentOperation.id,params:{unitId:o.comment.unitId,subUnitId:o.comment.subUnitId,commentId:o.comment.id}},c={id:n.RichTextEditingMutation.id,params:{...o.decorationMutationParams,textRanges:null,noNeedSetTextRange:!0}};return(await(0,t.sequenceExecute)([o.commentMutation,c,s],e.get(t.ICommandService))).result}},h={id:`docs.command.delete-comment`,type:t.CommandType.COMMAND,async handler(e,n){if(!n)return!1;let{commentId:r,unitId:i}=n,o=e.get(t.ICommandService),s=(0,a.deleteCustomDecorationFactory)(e,{id:r,unitId:i});return s?(await(0,t.sequenceExecute)([s],o)).result:!1}},g=`univer.doc.thread-comment-panel`,_=`DOC_THREAD_COMMENT_UI_PLUGIN`;function v(e){"@babel/helpers - typeof";return v=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},v(e)}function y(e,t){if(v(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(v(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function b(e){var t=y(e,`string`);return v(t)==`symbol`?t:t+``}function x(e,t,n){return(t=b(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function S(e,t){return function(n,r){t(n,r,e)}}function C(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let w=class extends t.Disposable{get addingComment(){return this._addingComment$.getValue()}constructor(e,t){super(),this._sidebarService=e,this._threadCommentPanelService=t,x(this,`_addingComment$`,new u.BehaviorSubject(void 0)),x(this,`addingComment$`,this._addingComment$.asObservable()),this.disposeWithMe(()=>{this._addingComment$.complete()})}startAdd(e){this._addingComment$.next(e)}endAdd(){this._addingComment$.next(void 0)}};w=C([S(0,l.ISidebarService),S(1,(0,t.Inject)(i.ThreadCommentPanelService))],w);let T={id:`docs.operation.show-comment-panel`,type:t.CommandType.OPERATION,handler(e,t){var n;let r=e.get(i.ThreadCommentPanelService),a=e.get(l.ISidebarService);return(!r.panelVisible||((n=a.options.children)==null?void 0:n.label)!==`univer.doc.thread-comment-panel`)&&(a.open({header:{title:`docs-thread-comment-ui.panel.title`},children:{label:g},width:320,onClose:()=>r.setPanelVisible(!1)}),r.setPanelVisible(!0)),t&&r.setActiveComment(t==null?void 0:t.activeComment),!0}},E={id:`docs.operation.toggle-comment-panel`,type:t.CommandType.OPERATION,handler(e){var t;let n=e.get(i.ThreadCommentPanelService),r=e.get(l.ISidebarService);return!n.panelVisible||((t=r.options.children)==null?void 0:t.label)!==`univer.doc.thread-comment-panel`?(r.open({header:{title:`docs-thread-comment-ui.panel.title`},children:{label:g},width:320,onClose:()=>n.setPanelVisible(!1)}),n.setPanelVisible(!0)):(r.close(),n.setPanelVisible(!1),n.setActiveComment(null)),!0}},D={id:`docs.operation.start-add-comment`,type:t.CommandType.OPERATION,handler(e){var o,u;let d=e.get(i.ThreadCommentPanelService),f=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),p=e.get(n.DocSelectionManagerService),m=e.get(s.IRenderManagerService),h=e.get(t.UserManagerService),g=e.get(w),_=e.get(t.ICommandService),v=e.get(l.ISidebarService),y=p.getActiveTextRange();if(!f||!y)return!1;let b=(o=m.getRenderUnitById(f.getUnitId()))==null?void 0:o.with(a.DocSelectionRenderService);if(b==null||b.setReserveRangesStatus(!0),y.collapsed)return d.panelVisible?(d.setPanelVisible(!1),v.close()):_.executeCommand(T.id),!0;_.executeCommand(T.id);let x=f.getUnitId(),S=(((u=f.getBody())==null?void 0:u.dataStream)??``).slice(y.startOffset,y.endOffset),C=t.BuildTextUtils.transform.getPlainText(S),E=r.DEFAULT_DOC_SUBUNIT_ID,D={unitId:x,subUnitId:E,id:``,ref:C,dT:(0,c.getDT)(),personId:h.getCurrentUser().userID,text:{dataStream:`\r
|
|
2
|
-
`},startOffset:y.startOffset,endOffset:y.endOffset,collapsed:!0,threadId:``};return b==null||b.blur(),g.startAdd(D),d.setActiveComment({unitId:x,subUnitId:E,commentId:``}),!0}},O={id:`docs.operation.add-drawing-comment`,type:t.CommandType.OPERATION,handler(e){let n=e.get(o.IDrawingManagerService).getFocusDrawings()[0],r=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!n||!r||n.unitId!==r.getUnitId())return!1;e.get(i.ThreadCommentDraftService).place({unitId:n.unitId,subUnitId:n.subUnitId,anchor:{kind:c.ThreadCommentAnchorKind.DOC_DRAWING,pageId:n.subUnitId,elementId:n.drawingId}});let a=e.get(i.ThreadCommentPanelService);return e.get(l.ISidebarService).open({header:{title:`docs-thread-comment-ui.panel.title`},children:{label:g},width:320,onClose:()=>a.setPanelVisible(!1)}),a.setPanelVisible(!0),!0}};function k(e){let r=e.get(t.IUniverInstanceService),i=e.get(t.IPermissionService);return(0,u.combineLatest)([r.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),i.permissionPointUpdate$.pipe((0,u.startWith)(void 0))]).pipe((0,u.map)(([e])=>!e||!(0,n.getDocumentPermissionValue)(i,e.getUnitId(),e.getUnitId(),d.UnitAction.Comment)))}function A(e){return{id:O.id,type:l.MenuItemType.BUTTON,icon:`InsertCommentDoubleIcon`,title:`docs-thread-comment-ui.panel.addComment`,tooltip:`docs-thread-comment-ui.panel.addComment`,hidden$:(0,l.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),disabled$:k(e)}}let j=e=>{var r;let i=e.get(s.IRenderManagerService),a=e.get(n.DocSelectionManagerService),o=e.get(t.IUniverInstanceService),c=e.get(t.IPermissionService),l=o.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!l||!(0,n.getDocumentPermissionValue)(c,l.getUnitId(),l.getUnitId(),d.UnitAction.Comment))return!0;let u=(r=(0,s.withCurrentTypeOfRenderer)(t.UniverInstanceType.UNIVER_DOC,n.DocSkeletonManagerService,o,i))==null?void 0:r.getSkeleton(),f=u==null?void 0:u.getViewModel().getEditArea();if(f===s.DocumentEditArea.FOOTER||f===s.DocumentEditArea.HEADER)return!0;let p=a.getActiveTextRange();return!!(p==null||p.collapsed)};function M(e){return{id:D.id,type:l.MenuItemType.BUTTON,icon:`InsertCommentDoubleIcon`,title:`docs-thread-comment-ui.panel.addComment`,tooltip:`docs-thread-comment-ui.panel.addComment`,hidden$:(0,l.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC,void 0,t.SHEET_EDITOR_UNITS),disabled$:(0,u.combineLatest)([e.get(n.DocSelectionManagerService).textSelection$.pipe((0,u.debounceTime)(16),(0,u.map)(()=>j(e)),(0,u.startWith)(j(e))),k(e)]).pipe((0,u.map)(([e,t])=>e||t))}}function N(e){return{id:E.id,type:l.MenuItemType.BUTTON,icon:`CommentIcon`,title:`docs-thread-comment-ui.panel.openComments`,tooltip:`docs-thread-comment-ui.panel.openComments`,hidden$:(0,l.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let P={[l.RibbonInsertGroup.OTHERS]:{[E.id]:{order:0,gridLayout:{row:1,column:1,showLabel:!0},menuItemFactory:N},[D.id]:{order:.1,gridLayout:{row:2,column:1,showLabel:!0},menuItemFactory:M}},[a.FLOAT_TOOLBAR_MENU_POSITION]:{[D.id]:{order:21,menuItemFactory:M}},[l.FloatingObjectToolbarPosition.DOC]:{[O.id]:{order:10,menuItemFactory:A}},[l.ContextMenuPosition.MAIN_AREA]:{[l.ContextMenuGroup.DATA]:{[D.id]:{order:1,menuItemFactory:M}}},[l.ContextMenuPosition.DRAWING]:{[l.ContextMenuGroup.DATA]:{[O.id]:{order:1,menuItemFactory:A}}}};var F=`@univerjs/docs-thread-comment-ui`,I=`1.0.0`;let L=`docs-thread-comment-ui.config`,R={};function z({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),l=`_${(0,f.useId)()}`,u=(0,f.useRef)(null);return(0,f.useImperativeHandle)(e,()=>u.current),(0,f.useLayoutEffect)(()=>{if(n&&u.current&&u.current.localName===r.tag)return U(u.current)},[n,r]),B(r,`${i}`,{defIds:r.defIds,idSuffix:l},{ref:u,className:c,...s},o)}function B(e,t,n,r,i){return(0,f.createElement)(e.tag,{key:t,...V(e,n,i),...r},(H(e,n).children||[]).map((r,a)=>B(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function V(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function H(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function U(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:W(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(G(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function W(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function G(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}z.displayName=`UniverIcon`;let ee={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 17`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.43993 3.31861H15.0381V12.5611H8.65676L5.75498 14.069V12.5611H2.43993V3.31861Z`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5.83725 7.50706V8.41159M8.73904 7.50706V8.41159M11.6408 7.50706V8.41159`,strokeLinecap:`round`,strokeWidth:1.39}}]},K=(0,f.forwardRef)(function(e,t){return(0,f.createElement)(z,Object.assign({},e,{id:`comment-icon`,ref:t,icon:ee}))});K.displayName=`CommentIcon`;let te={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.63636 1.99658C1.28491 1.99658 1 2.28149 1 2.63295V10.2693C1 10.6208 1.28491 10.9057 1.63636 10.9057H2.96368L4.05003 11.992C4.29854 12.2405 4.70146 12.2405 4.94997 11.992L6.03632 10.9057H6.72727V12.4128C6.72727 12.7643 7.01218 13.0492 7.36364 13.0492H10.6001L11.3682 13.8173C11.6167 14.0658 12.0196 14.0658 12.2682 13.8173L13.0363 13.0492H14.3636C14.7151 13.0492 15 12.7643 15 12.4128V7.32192C15 6.97047 14.7151 6.68556 14.3636 6.68556H12.4545V2.63295C12.4545 2.28149 12.1696 1.99658 11.8182 1.99658H1.63636ZM12.4545 7.95829V10.2693C12.4545 10.6208 12.1696 10.9057 11.8182 10.9057H8V11.7765H10.8636C11.0324 11.7765 11.1942 11.8435 11.3136 11.9628L11.8182 12.4674L12.3228 11.9628C12.4421 11.8435 12.604 11.7765 12.7727 11.7765H13.7273V7.95829H12.4545ZM11.1818 3.26931H2.27273V9.63295H3.22727C3.39604 9.63295 3.5579 9.70001 3.67725 9.81936L4.5 10.6421L5.32275 9.81936C5.4421 9.70001 5.60396 9.63295 5.77273 9.63295H11.1818V3.26931Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M5.13617 4.54199C4.78472 4.54199 4.49981 4.8269 4.49981 5.17836C4.49981 5.52981 4.78472 5.81472 5.13617 5.81472H8.95435C9.3058 5.81472 9.59072 5.52981 9.59072 5.17836C9.59072 4.8269 9.3058 4.54199 8.95435 4.54199H5.13617ZM4.49981 7.72381C4.49981 7.37236 4.78472 7.08744 5.13617 7.08744H7.04526C7.39671 7.08744 7.68162 7.37236 7.68162 7.72381C7.68162 8.07526 7.39671 8.36018 7.04526 8.36018H5.13617C4.78472 8.36018 4.49981 8.07526 4.49981 7.72381Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},q=(0,f.forwardRef)(function(e,t){return(0,f.createElement)(z,Object.assign({},e,{id:`insert-comment-double-icon`,ref:t,icon:te}))});q.displayName=`InsertCommentDoubleIcon`;function ne(e,t){return e&&e.unitId===t?e.subUnitId:r.DEFAULT_DOC_SUBUNIT_ID}let re=()=>{let e=(0,l.useDependency)(t.IUniverInstanceService),r=(0,l.useDependency)(t.Injector),a=(0,f.useMemo)(()=>e.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC).pipe((0,u.filter)(e=>!!e&&!(0,t.isInternalEditorID)(e.getUnitId()))),[e]),o=(0,l.useObservable)(a),s=(0,l.useDependency)(i.ThreadCommentDraftService),d=(0,l.useObservable)(s.draft$,s.draft),g=(0,f.useMemo)(()=>new u.Observable(e=>e.next(ne(d,o==null?void 0:o.getUnitId()))),[o,d]),_=(0,l.useDependency)(n.DocSelectionManagerService),v=(0,f.useMemo)(()=>_.textSelection$.pipe((0,u.debounceTime)(16)),[_.textSelection$]),y=(0,l.useDependency)(t.IPermissionService),b=(0,f.useMemo)(()=>(0,u.merge)(v,y.permissionPointUpdate$),[y.permissionPointUpdate$,v]),x=(0,l.useObservable)(()=>b.pipe((0,u.map)(()=>j(r))),j(r),!1,[b,r]),S=(0,l.useDependency)(t.ICommandService),C=(0,l.useDependency)(c.ThreadCommentModel);(0,l.useObservable)(C.commentUpdate$);let T=(0,l.useDependency)(w),E=(0,l.useObservable)(T.addingComment$),O=(0,l.useDependency)(t.UserManagerService),k=(d==null?void 0:d.anchor.kind)===c.ThreadCommentAnchorKind.DOC_DRAWING&&d.unitId===(o==null?void 0:o.getUnitId())?{id:``,threadId:``,unitId:d.unitId,subUnitId:d.subUnitId,ref:(0,c.serializeThreadCommentAnchor)(d.anchor),dT:``,personId:O.getCurrentUser().userID,text:{dataStream:`\r
|
|
2
|
+
`},startOffset:y.startOffset,endOffset:y.endOffset,collapsed:!0,threadId:``};return b==null||b.blur(),g.startAdd(D),d.setActiveComment({unitId:x,subUnitId:E,commentId:``}),!0}},O={id:`docs.operation.add-drawing-comment`,type:t.CommandType.OPERATION,handler(e){let n=e.get(o.IDrawingManagerService).getFocusDrawings()[0],r=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!n||!r||n.unitId!==r.getUnitId())return!1;e.get(i.ThreadCommentDraftService).place({unitId:n.unitId,subUnitId:n.subUnitId,anchor:{kind:c.ThreadCommentAnchorKind.DOC_DRAWING,pageId:n.subUnitId,elementId:n.drawingId}});let a=e.get(i.ThreadCommentPanelService);return e.get(l.ISidebarService).open({header:{title:`docs-thread-comment-ui.panel.title`},children:{label:g},width:320,onClose:()=>a.setPanelVisible(!1)}),a.setPanelVisible(!0),!0}};function k(e){let r=e.get(t.IUniverInstanceService),i=e.get(t.IPermissionService);return(0,u.combineLatest)([r.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),i.permissionPointUpdate$.pipe((0,u.startWith)(void 0))]).pipe((0,u.map)(([e])=>!e||!(0,n.getDocumentPermissionValue)(i,e.getUnitId(),e.getUnitId(),d.UnitAction.Comment)))}function A(e){return{id:O.id,type:l.MenuItemType.BUTTON,icon:`InsertCommentDoubleIcon`,title:`docs-thread-comment-ui.panel.addComment`,tooltip:`docs-thread-comment-ui.panel.addComment`,hidden$:(0,l.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),disabled$:k(e)}}let j=e=>{var r;let i=e.get(s.IRenderManagerService),a=e.get(n.DocSelectionManagerService),o=e.get(t.IUniverInstanceService),c=e.get(t.IPermissionService),l=o.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!l||!(0,n.getDocumentPermissionValue)(c,l.getUnitId(),l.getUnitId(),d.UnitAction.Comment))return!0;let u=(r=(0,s.withCurrentTypeOfRenderer)(t.UniverInstanceType.UNIVER_DOC,n.DocSkeletonManagerService,o,i))==null?void 0:r.getSkeleton(),f=u==null?void 0:u.getViewModel().getEditArea();if(f===s.DocumentEditArea.FOOTER||f===s.DocumentEditArea.HEADER)return!0;let p=a.getActiveTextRange();return!!(p==null||p.collapsed)};function M(e){return{id:D.id,type:l.MenuItemType.BUTTON,icon:`InsertCommentDoubleIcon`,title:`docs-thread-comment-ui.panel.addComment`,tooltip:`docs-thread-comment-ui.panel.addComment`,hidden$:(0,l.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC,void 0,t.SHEET_EDITOR_UNITS),disabled$:(0,u.combineLatest)([e.get(n.DocSelectionManagerService).textSelection$.pipe((0,u.debounceTime)(16),(0,u.map)(()=>j(e)),(0,u.startWith)(j(e))),k(e)]).pipe((0,u.map)(([e,t])=>e||t))}}function N(e){return{id:E.id,type:l.MenuItemType.BUTTON,icon:`CommentIcon`,title:`docs-thread-comment-ui.panel.openComments`,tooltip:`docs-thread-comment-ui.panel.openComments`,hidden$:(0,l.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let P={[l.RibbonInsertGroup.OTHERS]:{[E.id]:{order:0,gridLayout:{row:1,column:1,showLabel:!0},menuItemFactory:N},[D.id]:{order:.1,gridLayout:{row:2,column:1,showLabel:!0},menuItemFactory:M}},[a.FLOAT_TOOLBAR_MENU_POSITION]:{[D.id]:{order:21,menuItemFactory:M}},[l.FloatingObjectToolbarPosition.DOC]:{[O.id]:{order:10,menuItemFactory:A}},[l.ContextMenuPosition.MAIN_AREA]:{[l.ContextMenuGroup.DATA]:{[D.id]:{order:1,menuItemFactory:M}}},[l.ContextMenuPosition.DRAWING]:{[l.ContextMenuGroup.DATA]:{[O.id]:{order:1,menuItemFactory:A}}}};var F=`@univerjs/docs-thread-comment-ui`,I=`1.0.2`;let L=`docs-thread-comment-ui.config`,R={};function z({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),l=`_${(0,f.useId)()}`,u=(0,f.useRef)(null);return(0,f.useImperativeHandle)(e,()=>u.current),(0,f.useLayoutEffect)(()=>{if(n&&u.current&&u.current.localName===r.tag)return U(u.current)},[n,r]),B(r,`${i}`,{defIds:r.defIds,idSuffix:l},{ref:u,className:c,...s},o)}function B(e,t,n,r,i){return(0,f.createElement)(e.tag,{key:t,...V(e,n,i),...r},(H(e,n).children||[]).map((r,a)=>B(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function V(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function H(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function U(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:W(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(G(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function W(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function G(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}z.displayName=`UniverIcon`;let ee={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 17`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.43993 3.31861H15.0381V12.5611H8.65676L5.75498 14.069V12.5611H2.43993V3.31861Z`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5.83725 7.50706V8.41159M8.73904 7.50706V8.41159M11.6408 7.50706V8.41159`,strokeLinecap:`round`,strokeWidth:1.39}}]},K=(0,f.forwardRef)(function(e,t){return(0,f.createElement)(z,Object.assign({},e,{id:`comment-icon`,ref:t,icon:ee}))});K.displayName=`CommentIcon`;let te={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.63636 1.99658C1.28491 1.99658 1 2.28149 1 2.63295V10.2693C1 10.6208 1.28491 10.9057 1.63636 10.9057H2.96368L4.05003 11.992C4.29854 12.2405 4.70146 12.2405 4.94997 11.992L6.03632 10.9057H6.72727V12.4128C6.72727 12.7643 7.01218 13.0492 7.36364 13.0492H10.6001L11.3682 13.8173C11.6167 14.0658 12.0196 14.0658 12.2682 13.8173L13.0363 13.0492H14.3636C14.7151 13.0492 15 12.7643 15 12.4128V7.32192C15 6.97047 14.7151 6.68556 14.3636 6.68556H12.4545V2.63295C12.4545 2.28149 12.1696 1.99658 11.8182 1.99658H1.63636ZM12.4545 7.95829V10.2693C12.4545 10.6208 12.1696 10.9057 11.8182 10.9057H8V11.7765H10.8636C11.0324 11.7765 11.1942 11.8435 11.3136 11.9628L11.8182 12.4674L12.3228 11.9628C12.4421 11.8435 12.604 11.7765 12.7727 11.7765H13.7273V7.95829H12.4545ZM11.1818 3.26931H2.27273V9.63295H3.22727C3.39604 9.63295 3.5579 9.70001 3.67725 9.81936L4.5 10.6421L5.32275 9.81936C5.4421 9.70001 5.60396 9.63295 5.77273 9.63295H11.1818V3.26931Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M5.13617 4.54199C4.78472 4.54199 4.49981 4.8269 4.49981 5.17836C4.49981 5.52981 4.78472 5.81472 5.13617 5.81472H8.95435C9.3058 5.81472 9.59072 5.52981 9.59072 5.17836C9.59072 4.8269 9.3058 4.54199 8.95435 4.54199H5.13617ZM4.49981 7.72381C4.49981 7.37236 4.78472 7.08744 5.13617 7.08744H7.04526C7.39671 7.08744 7.68162 7.37236 7.68162 7.72381C7.68162 8.07526 7.39671 8.36018 7.04526 8.36018H5.13617C4.78472 8.36018 4.49981 8.07526 4.49981 7.72381Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},q=(0,f.forwardRef)(function(e,t){return(0,f.createElement)(z,Object.assign({},e,{id:`insert-comment-double-icon`,ref:t,icon:te}))});q.displayName=`InsertCommentDoubleIcon`;function ne(e,t){return e&&e.unitId===t?e.subUnitId:r.DEFAULT_DOC_SUBUNIT_ID}let re=()=>{let e=(0,l.useDependency)(t.IUniverInstanceService),r=(0,l.useDependency)(t.Injector),a=(0,f.useMemo)(()=>e.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC).pipe((0,u.filter)(e=>!!e&&!(0,t.isInternalEditorID)(e.getUnitId()))),[e]),o=(0,l.useObservable)(a),s=(0,l.useDependency)(i.ThreadCommentDraftService),d=(0,l.useObservable)(s.draft$,s.draft),g=(0,f.useMemo)(()=>new u.Observable(e=>e.next(ne(d,o==null?void 0:o.getUnitId()))),[o,d]),_=(0,l.useDependency)(n.DocSelectionManagerService),v=(0,f.useMemo)(()=>_.textSelection$.pipe((0,u.debounceTime)(16)),[_.textSelection$]),y=(0,l.useDependency)(t.IPermissionService),b=(0,f.useMemo)(()=>(0,u.merge)(v,y.permissionPointUpdate$),[y.permissionPointUpdate$,v]),x=(0,l.useObservable)(()=>b.pipe((0,u.map)(()=>j(r))),j(r),!1,[b,r]),S=(0,l.useDependency)(t.ICommandService),C=(0,l.useDependency)(c.ThreadCommentModel);(0,l.useObservable)(C.commentUpdate$);let T=(0,l.useDependency)(w),E=(0,l.useObservable)(T.addingComment$),O=(0,l.useDependency)(t.UserManagerService),k=(d==null?void 0:d.anchor.kind)===c.ThreadCommentAnchorKind.DOC_DRAWING&&d.unitId===(o==null?void 0:o.getUnitId())?{id:``,threadId:``,unitId:d.unitId,subUnitId:d.subUnitId,ref:(0,c.serializeThreadCommentAnchor)(d.anchor),dT:``,personId:O.getCurrentUser().userID,text:{dataStream:`\r
|
|
3
3
|
`}}:null,A=k??E,M=new Set(Object.keys((o==null?void 0:o.getSnapshot().drawings)??{})),N=e=>{let t=(0,c.deserializeThreadCommentAnchor)(e.ref);return(t==null?void 0:t.kind)===c.ThreadCommentAnchorKind.DOC_DRAWING||e.ref.startsWith(`#`)&&M.has(e.ref.slice(1))},P=o?C.getUnit(o.getUnitId()).filter(e=>N(e.root)).map(e=>e.root.id):[],[F,I]=(0,f.useState)([]);if((0,f.useEffect)(()=>{let e=new Set,t=o==null?void 0:o.getCustomDecorations();I((t==null?void 0:t.map(e=>e.id).filter(t=>{let n=e.has(t);return e.add(t),!n}))??[]);let r=S.onCommandExecuted(e=>{if(e.id===n.RichTextEditingMutation.id){let e=new Set,t=o==null?void 0:o.getCustomDecorations();I((t==null?void 0:t.map(e=>e.id).filter(t=>{let n=e.has(t);return e.add(t),!n}))??[])}});return()=>{r.dispose()}},[S,o]),!o)return null;let L=o.getUnitId();return(0,p.jsx)(i.ThreadCommentPanel,{unitId:L,subUnitId$:g,type:t.UniverInstanceType.UNIVER_DOC,onAdd:()=>{S.executeCommand(D.id)},getSubUnitName:()=>``,disableAdd:x,tempComment:A,onAddComment:async e=>{if(k&&!e.parentId)return!0;if(!e.parentId){let t={unitId:L,range:E,comment:e};if(!await S.executeCommand(m.id,t))throw Error(`Failed to add document comment.`);return T.endAdd(),!1}return!0},onAfterDeleteComment:async e=>{if(!e.parentId){if(N(e))return;let t={unitId:L,commentId:e.id};await S.executeCommand(h.id,t)}},showComments:[...F,...P],onTempCommentClose:()=>s.cancel(),formatRef:e=>{let t=(0,c.deserializeThreadCommentAnchor)(e.ref);return(t==null?void 0:t.kind)===c.ThreadCommentAnchorKind.DOC_DRAWING?`#${t.elementId}`:e.ref}})},J=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[g,re]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({CommentIcon:K,InsertCommentDoubleIcon:q}))}};J=C([S(0,(0,t.Inject)(l.ComponentManager)),S(1,(0,t.Inject)(l.IconManager))],J);let Y=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=n,this._docThreadCommentService=r,this._renderManagerService=i,this._threadCommentModel=a,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(a=>{if(a.id===n.SetTextSelectionsOperation.id){let{unitId:n,ranges:o}=a.params;if((0,t.isInternalEditorID)(n))return;let s=this._univerInstanceService.getUnit(n,t.UniverInstanceType.UNIVER_DOC),c=o[0];if((e==null?void 0:e.startOffset)===(c==null?void 0:c.startOffset)&&(e==null?void 0:e.endOffset)===(c==null?void 0:c.endOffset))return;if(e=c,c&&s){let{startOffset:e,endOffset:t,collapsed:i}=c,a=i?e:t-1,o=this._findActiveCommentDecoration(s,n,e,a);if(o){this._commandService.executeCommand(T.id,{activeComment:{unitId:n,subUnitId:r.DEFAULT_DOC_SUBUNIT_ID,commentId:o.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;let l=this._docThreadCommentService.addingComment,u=this._threadCommentPanelService.activeCommentId;if(l&&(u==null?void 0:u.unitId)===l.unitId&&(u==null?void 0:u.subUnitId)===r.DEFAULT_DOC_SUBUNIT_ID&&(u==null?void 0:u.commentId)===l.id)return;this._commandService.executeCommand(i.SetActiveCommentOperation.id)}}))}_findActiveCommentDecoration(e,n,i,a){var o;return[...((o=e.getBody())==null?void 0:o.customDecorations)??[]].reverse().filter(e=>e.type===t.CustomDecorationType.COMMENT&&e.startIndex<=i&&e.endIndex>=a).sort((e,t)=>e.endIndex-e.startIndex-(t.endIndex-t.startIndex)).find(e=>{let t=this._threadCommentModel.getComment(n,r.DEFAULT_DOC_SUBUNIT_ID,e.id);return t&&!t.resolved})}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t;if(e){let t=this._univerInstanceService.getUnit(e.unitId);if(t){var n,r;let i=(n=this._renderManagerService.getRenderUnitById(e.unitId))==null?void 0:n.with(a.DocBackScrollRenderController),o=(r=t.getBody())==null||(r=r.customDecorations)==null?void 0:r.find(t=>t.id===e.commentId);o&&i&&i.scrollToRange({startOffset:o.startIndex,endOffset:o.endIndex,collapsed:!1})}}(!e||e.commentId!==((t=this._docThreadCommentService.addingComment)==null?void 0:t.id))&&this._docThreadCommentService.endAdd()}))}};Y=C([S(0,(0,t.Inject)(i.ThreadCommentPanelService)),S(1,t.IUniverInstanceService),S(2,t.ICommandService),S(3,(0,t.Inject)(w)),S(4,s.IRenderManagerService),S(5,(0,t.Inject)(c.ThreadCommentModel))],Y);let X=class extends t.Disposable{constructor(e,t,n,r,a,o,s,c){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=n,this._univerInstanceService=r,this._threadCommentModel=a,this._commandService=o,this._drawingManagerService=s,this._themeService=c,x(this,`_drawingOverlay`,void 0),x(this,`_drawingCommentSubUnits`,new Map),this._drawingOverlay=new i.ThreadCommentCanvasOverlay(`doc-thread-comment-drawing-overlay`,{...this._getDrawingOverlayColors(),zoomRatio:1,markers:[],underlines:[]}),this._context.scene.addObject(this._drawingOverlay,10100),this._interceptorViewModel(),this._initReRender(),this._initSyncComments(),this._initDrawingOverlay()}_initReRender(){[this._threadCommentPanelService.activeCommentId$,this._threadCommentPanelService.hoveredCommentId$].forEach(e=>this.disposeWithMe(e.pipe((0,u.skip)(1),(0,u.startWith)(void 0),(0,u.pairwise)()).subscribe(([e,n])=>{var r;let i=(r=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC))==null?void 0:r.getUnitId();if(new Set([e==null?void 0:e.unitId,n==null?void 0:n.unitId,i]).has(this._context.unitId)){var a;(a=this._context.mainComponent)==null||a.makeDirty(!0)}}))),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{if(e.type===`resolve`&&e.unitId===this._context.unitId){var t;(t=this._context.mainComponent)==null||t.makeDirty(!0)}e.unitId===this._context.unitId&&this._syncDrawingOverlay()}))}_initDrawingOverlay(){this.disposeWithMe((0,t.toDisposable)(this._drawingOverlay.onPointerDown$.subscribeEvent((e,t)=>{let n=this._drawingOverlay.hitCommentId,r=n&&this._drawingCommentSubUnits.get(n);n&&r&&(t.stopPropagation(),this._commandService.executeCommand(T.id,{activeComment:{unitId:this._context.unitId,subUnitId:r,commentId:n,trigger:`doc-canvas`}}))}))),this.disposeWithMe((0,t.toDisposable)(this._context.engine.onTransformChange$.subscribeEvent(()=>this._syncDrawingOverlay()))),[this._threadCommentPanelService.activeCommentId$,this._threadCommentPanelService.hoveredCommentId$].forEach(e=>this.disposeWithMe(e.subscribe(()=>this._syncDrawingOverlay()))),[this._drawingManagerService.add$,this._drawingManagerService.update$,this._drawingManagerService.remove$].forEach(e=>this.disposeWithMe(e.subscribe(e=>{e.some(e=>e.unitId===this._context.unitId)&&this._syncDrawingOverlay()}))),this.disposeWithMe(this._themeService.currentTheme$.subscribe(()=>this._syncDrawingOverlay())),this._syncDrawingOverlay()}_syncDrawingOverlay(){let e=new Map;this._drawingCommentSubUnits.clear(),this._threadCommentModel.query({unitIds:[this._context.unitId],anchorKinds:[c.ThreadCommentAnchorKind.DOC_DRAWING],resolved:!1}).forEach(({root:t,subUnitId:n})=>{let r=(0,c.deserializeThreadCommentAnchor)(t.ref);if((r==null?void 0:r.kind)!==c.ThreadCommentAnchorKind.DOC_DRAWING)return;let i=this._getDrawingOutline(r.pageId??n,r.elementId);i&&(this._drawingCommentSubUnits.set(t.id,n),e.set(`${r.pageId??n}\0${r.elementId}`,{commentId:t.id,left:i.left,top:i.top+i.height+2,width:i.width}))});let t=[],n=new Map;[this._threadCommentPanelService.activeCommentId,this._threadCommentPanelService.hoveredCommentId].forEach(e=>{if(!e||e.unitId!==this._context.unitId)return;let r=this._threadCommentModel.getComment(e.unitId,e.subUnitId,e.commentId),i=r&&(0,c.deserializeThreadCommentAnchor)(r.ref);if((i==null?void 0:i.kind)!==c.ThreadCommentAnchorKind.DOC_DRAWING)return;t.push(e.commentId);let a=this._getDrawingOutline(i.pageId??e.subUnitId,i.elementId);a&&n.set(`${i.pageId??e.subUnitId}\0${i.elementId}`,a)}),this._drawingOverlay.updateState({...this._getDrawingOverlayColors(),markers:[],underlines:Array.from(e.values()),focusedCommentIds:t,focusOutlines:Array.from(n.values())})}_getDrawingOutline(e,t){var n,r;let i=(0,o.getDrawingShapeKeyByDrawingSearch)({unitId:this._context.unitId,subUnitId:e,drawingId:t}),a=((n=(r=this._context.scene).getObjectIncludeInGroup)==null?void 0:n.call(r,i))??this._context.scene.getObject(i);if(!a)return null;let s=a.getRealBound();return{left:s.left,top:s.top,width:s.width,height:s.height}}_getDrawingOverlayColors(){return{accentColor:this._themeService.getColorFromTheme(`yellow.400`),foregroundColor:this._themeService.getColorFromTheme(`gray.900`),outlineColor:this._themeService.getColorFromTheme(`white`)}}_interceptorViewModel(){this._docInterceptorService.intercept(n.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,n)=>{if(!e)return n(e);let{unitId:i}=t,a=[this._threadCommentPanelService.activeCommentId,this._threadCommentPanelService.hoveredCommentId],o=this._threadCommentModel.getComment(i,r.DEFAULT_DOC_SUBUNIT_ID,e.id);if(!o)return n({...e,show:!1});let s=a.some(t=>(t==null?void 0:t.unitId)===i&&t.subUnitId===r.DEFAULT_DOC_SUBUNIT_ID&&t.commentId===e.id);return n({...e,active:s,show:!o.resolved})}})}_initSyncComments(){var e;let i=this._context.unit.getUnitId(),a=r.DEFAULT_DOC_SUBUNIT_ID,o=((e=this._context.unit.getBody())==null||(e=e.customDecorations)==null?void 0:e.filter(e=>e.type===t.CustomDecorationType.COMMENT).map(e=>e.id))??[];o.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),r.DEFAULT_DOC_SUBUNIT_ID,o);let s=o.sort();this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===n.RichTextEditingMutation.id){var r;if(e.params.unitId!==this._context.unit.getUnitId())return;let n=((r=this._context.unit.getBody())==null||(r=r.customDecorations)==null?void 0:r.filter(e=>e.type===t.CustomDecorationType.COMMENT).map(e=>e.id))??[],o=n.sort();if(JSON.stringify(s)!==JSON.stringify(o)){let e=new Set(s),t=new Set;n.forEach(n=>{e.has(n)||t.add(n)}),s=o,this._threadCommentModel.syncThreadComments(i,a,[...t])}}}))}};X=C([S(1,(0,t.Inject)(n.DocInterceptorService)),S(2,(0,t.Inject)(i.ThreadCommentPanelService)),S(3,t.IUniverInstanceService),S(4,(0,t.Inject)(c.ThreadCommentModel)),S(5,t.ICommandService),S(6,o.IDrawingManagerService),S(7,(0,t.Inject)(t.ThemeService))],X);let Z=class extends t.Disposable{constructor(e,t){super(),this._commandService=e,this._menuManagerService=t,this._initCommands(),this._initMenus()}_initCommands(){[O,m,h,T,D,E].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.appendRootMenu({[a.FLOAT_TOOLBAR_MENU_POSITION]:{}}),this._menuManagerService.mergeMenu(P)}};Z=C([S(0,t.ICommandService),S(1,l.IMenuManagerService)],Z);let Q=class extends t.Plugin{constructor(e=R,n,r,i){super(),this._config=e,this._injector=n,this._renderManagerSrv=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},R,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(L,o)}onStarting(){[[J],[Z],[Y],[w]].forEach(e=>{this._injector.add(e)}),this._injector.get(J)}onRendered(){this._initRenderModule(),this._injector.get(Y),this._injector.get(Z)}_initRenderModule(){this._renderManagerSrv.registerRenderModule(t.UniverInstanceType.UNIVER_DOC,[X])}};x(Q,`pluginName`,_),x(Q,`packageName`,F),x(Q,`version`,I),x(Q,`type`,t.UniverInstanceType.UNIVER_DOC),Q=C([(0,t.DependentOn)(n.UniverDocsPlugin,r.UniverDocsThreadCommentPlugin,c.UniverThreadCommentPlugin,o.UniverDrawingPlugin,s.UniverRenderEnginePlugin,a.UniverDocsMobileUIPlugin,i.UniverThreadCommentMobileUIPlugin),S(1,(0,t.Inject)(t.Injector)),S(2,s.IRenderManagerService),S(3,t.IConfigService)],Q);let ie=[[Z],[Y],[w]],$=class extends t.Plugin{constructor(e=R,n,r,i){super(),this._config=e,this._injector=n,this._renderManagerSrv=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},R,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(L,o)}onStarting(){this._injector.add([J]),this._injector.get(J),ie.forEach(e=>{this._injector.add(e)})}onRendered(){this._initRenderModule(),this._injector.get(Y),this._injector.get(Z)}_initRenderModule(){this._renderManagerSrv.registerRenderModule(t.UniverInstanceType.UNIVER_DOC,[X])}};x($,`pluginName`,_),x($,`packageName`,F),x($,`version`,I),x($,`type`,t.UniverInstanceType.UNIVER_DOC),$=C([(0,t.DependentOn)(n.UniverDocsPlugin,r.UniverDocsThreadCommentPlugin,c.UniverThreadCommentPlugin,o.UniverDrawingPlugin,s.UniverRenderEnginePlugin,a.UniverDocsUIPlugin,i.UniverThreadCommentUIPlugin),S(1,(0,t.Inject)(t.Injector)),S(2,s.IRenderManagerService),S(3,t.IConfigService)],$),e.AddDocCommentComment=m,e.DeleteDocCommentComment=h,e.DocsThreadCommentUIMenuSchema=P,e.ShowCommentPanelOperation=T,e.StartAddCommentOperation=D,Object.defineProperty(e,"UniverDocsThreadCommentMobileUIPlugin",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"UniverDocsThreadCommentUIPlugin",{enumerable:!0,get:function(){return $}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-thread-comment-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Thread comment UI integration for Univer Docs.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -58,20 +58,20 @@
|
|
|
58
58
|
"rxjs": ">=7.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/core": "1.0.
|
|
62
|
-
"@univerjs/docs": "1.0.
|
|
63
|
-
"@univerjs/docs-thread-comment": "1.0.
|
|
64
|
-
"@univerjs/docs-ui": "1.0.
|
|
65
|
-
"@univerjs/drawing": "1.0.
|
|
66
|
-
"@univerjs/engine-render": "1.0.
|
|
67
|
-
"@univerjs/icons": "1.43.
|
|
68
|
-
"@univerjs/protocol": "1.0.
|
|
69
|
-
"@univerjs/thread-comment": "1.0.
|
|
70
|
-
"@univerjs/thread-comment-ui": "1.0.
|
|
71
|
-
"@univerjs/ui": "1.0.
|
|
61
|
+
"@univerjs/core": "1.0.2",
|
|
62
|
+
"@univerjs/docs": "1.0.2",
|
|
63
|
+
"@univerjs/docs-thread-comment": "1.0.2",
|
|
64
|
+
"@univerjs/docs-ui": "1.0.2",
|
|
65
|
+
"@univerjs/drawing": "1.0.2",
|
|
66
|
+
"@univerjs/engine-render": "1.0.2",
|
|
67
|
+
"@univerjs/icons": "1.43.1",
|
|
68
|
+
"@univerjs/protocol": "1.0.2",
|
|
69
|
+
"@univerjs/thread-comment": "1.0.2",
|
|
70
|
+
"@univerjs/thread-comment-ui": "1.0.2",
|
|
71
|
+
"@univerjs/ui": "1.0.2"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@univerjs-infra/shared": "1.0.
|
|
74
|
+
"@univerjs-infra/shared": "1.0.2",
|
|
75
75
|
"postcss": "^8.5.28",
|
|
76
76
|
"react": "18.3.1",
|
|
77
77
|
"rxjs": "^7.8.2",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { Disposable, ICommandService } from '@univerjs/core';
|
|
17
|
-
import { ComponentManager, IMenuManagerService } from '@univerjs/ui';
|
|
18
|
-
export declare class DocThreadCommentUIController extends Disposable {
|
|
19
|
-
private readonly _commandService;
|
|
20
|
-
private readonly _menuManagerService;
|
|
21
|
-
private readonly _componentManager;
|
|
22
|
-
constructor(_commandService: ICommandService, _menuManagerService: IMenuManagerService, _componentManager: ComponentManager);
|
|
23
|
-
private _initCommands;
|
|
24
|
-
private _initMenus;
|
|
25
|
-
private _initComponents;
|
|
26
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
export declare const DocThreadCommentPanel: () => import("react/jsx-runtime").JSX.Element | null;
|