@univerjs/thread-comment 0.4.2 → 0.5.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +675 -392
- package/lib/types/common/utils.d.ts +16 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +11 -10
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export declare function getDT(): string;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export { ThreadCommentResourceController } from './controllers/tc-resource.contr
|
|
|
18
18
|
export { TC_PLUGIN_NAME } from './types/const';
|
|
19
19
|
export type { IBaseComment, IThreadComment, IThreadCommentMention } from './types/interfaces/i-thread-comment';
|
|
20
20
|
export { UniverThreadCommentPlugin } from './plugin';
|
|
21
|
+
export { getDT } from './common/utils';
|
|
21
22
|
export { type IThreadCommentDataSource, IThreadCommentDataSourceService, ThreadCommentDataSourceService, type ThreadCommentJSON, } from './services/tc-datasource.service';
|
|
22
23
|
export { AddCommentMutation, DeleteCommentMutation, ResolveCommentMutation, UpdateCommentMutation, UpdateCommentRefMutation, } from './commands/mutations/comment.mutation';
|
|
23
24
|
export type { IAddCommentMutationParams, IDeleteCommentMutationParams, IResolveCommentMutationParams, IUpdateCommentMutationParams, IUpdateCommentPayload, IUpdateCommentRefMutationParams, } from './commands/mutations/comment.mutation';
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverThreadComment={},global.UniverCore,global.rxjs))})(this,function(exports2,core,rxjs){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c;const _ThreadCommentDataSourceService=class _ThreadCommentDataSourceService extends core.Disposable{constructor(){super();__publicField(this,"_dataSource",null);__publicField(this,"syncUpdateMutationToColla",!0)}set dataSource(dataSource){this._dataSource=dataSource}get dataSource(){return this._dataSource}async getThreadComment(unitId,subUnitId,threadId){return this._dataSource?(await this._dataSource.listComments(unitId,subUnitId,[threadId]))[0]:null}async addComment(comment){var _a2;return this._dataSource?this._dataSource.addComment(comment):{...comment,threadId:(_a2=comment.threadId)!=null?_a2:comment.id}}async updateComment(comment){return this._dataSource?this._dataSource.updateComment(comment):!0}async resolveComment(comment){return this._dataSource?this._dataSource.resolveComment(comment):!0}async deleteComment(unitId,subUnitId,threadId,commentId){return this._dataSource?this._dataSource.deleteComment(unitId,subUnitId,threadId,commentId):!0}async listThreadComments(unitId,subUnitId,threadIds){return this.dataSource?this.dataSource.listComments(unitId,subUnitId,threadIds):!1}saveToSnapshot(unitComments,unitId){if(this._dataSource){const map={};return Object.keys(unitComments).forEach(subUnitId=>{const comments=unitComments[subUnitId];map[subUnitId]=comments.map(this.dataSource.saveCommentToSnapshot)}),map}return unitComments}};__name(_ThreadCommentDataSourceService,"ThreadCommentDataSourceService");let ThreadCommentDataSourceService=_ThreadCommentDataSourceService;const IThreadCommentDataSourceService=core.createIdentifier("univer.thread-comment.data-source-service");var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");exports2.ThreadCommentModel=(_a=class extends core.Disposable{constructor(_dataSourceService,_lifecycleService){super();__publicField(this,"_commentsMap",new Map);__publicField(this,"_threadMap",new Map);__publicField(this,"_commentUpdate$",new rxjs.Subject);__publicField(this,"commentUpdate$",this._commentUpdate$.asObservable());__publicField(this,"_tasks",[]);this._dataSourceService=_dataSourceService,this._lifecycleService=_lifecycleService,this.disposeWithMe(()=>{this._commentUpdate$.complete()}),this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe(stage=>{const taskMap=new Map;stage===core.LifecycleStages.Rendered&&(this._tasks.forEach(({unitId,subUnitId,threadIds})=>{let unitMap=taskMap.get(unitId);unitMap||(unitMap=new Map,taskMap.set(unitId,unitMap));let subUnitMap=unitMap.get(subUnitId);subUnitMap||(subUnitMap=new Set,unitMap.set(subUnitId,subUnitMap));for(const threadId of threadIds)subUnitMap.add(threadId)}),this._tasks=[],taskMap.forEach((subUnitMap,unitId)=>{subUnitMap.forEach((threadIds,subUnitId)=>{this.syncThreadComments(unitId,subUnitId,Array.from(threadIds))})}))}))}_ensureCommentMap(unitId,subUnitId){let unitMap=this._commentsMap.get(unitId);unitMap||(unitMap=new Map,this._commentsMap.set(unitId,unitMap));let subUnitMap=unitMap.get(subUnitId);return subUnitMap||(subUnitMap=new Map,unitMap.set(subUnitId,subUnitMap)),subUnitMap}ensureMap(unitId,subUnitId){return this._ensureCommentMap(unitId,subUnitId)}_ensureThreadMap(unitId,subUnitId){let unitMap=this._threadMap.get(unitId);unitMap||(unitMap=new Map,this._threadMap.set(unitId,unitMap));let subUnitMap=unitMap.get(subUnitId);return subUnitMap||(subUnitMap=new Map,unitMap.set(subUnitId,subUnitMap)),subUnitMap}_replaceComment(unitId,subUnitId,comment){const commentMap=this._ensureCommentMap(unitId,subUnitId),currentComment=commentMap.get(comment.id);if(currentComment){const{children,...rest}=comment,newComment={...rest,ref:currentComment.ref};commentMap.set(comment.id,newComment),children==null||children.forEach(child=>{commentMap.set(child.id,{...child,ref:""})}),this._commentUpdate$.next({unitId,subUnitId,type:"syncUpdate",payload:newComment}),!!comment.resolved!=!!currentComment.resolved&&this._commentUpdate$.next({unitId,subUnitId,type:"resolve",payload:{commentId:comment.id,resolved:!!comment.resolved}})}}async syncThreadComments(unitId,subUnitId,threadIds){if(this._lifecycleService.stage<core.LifecycleStages.Rendered){this._tasks.push({unitId,subUnitId,threadIds});return}const threadMap=this._ensureThreadMap(unitId,subUnitId),commentMap=this._ensureCommentMap(unitId,subUnitId),comments=await this._dataSourceService.listThreadComments(unitId,subUnitId,threadIds);if(!comments)return;const deleteThreads=new Set(threadIds);comments.forEach(comment=>{this._replaceComment(unitId,subUnitId,comment),deleteThreads.delete(comment.threadId)}),deleteThreads.forEach(id=>{threadMap.delete(id),commentMap.forEach((comment,commentId)=>{comment.threadId===id&&commentMap.delete(commentId)})})}addComment(unitId,subUnitId,origin,shouldSync){const commentMap=this._ensureCommentMap(unitId,subUnitId),{parentId,children=[],...rest}=origin,comment={...rest,parentId:parentId===origin.id?void 0:parentId},addCommentItem=__name(item=>{commentMap.set(item.id,item),this._commentUpdate$.next({unitId,subUnitId,type:"add",payload:item,isRoot:!item.parentId})},"addCommentItem");addCommentItem(comment);const threadMap=this._ensureThreadMap(unitId,subUnitId);if(!comment.parentId){threadMap.set(comment.threadId,comment);for(const child of children)addCommentItem(child)}return shouldSync&&this.syncThreadComments(unitId,subUnitId,[comment.threadId]),!0}updateComment(unitId,subUnitId,payload,silent){const oldComment=this._ensureCommentMap(unitId,subUnitId).get(payload.commentId);return oldComment&&(oldComment.updated=!0,oldComment.text=payload.text,oldComment.attachments=payload.attachments,oldComment.updateT=payload.updateT,this._commentUpdate$.next({unitId,subUnitId,type:"update",payload,silent})),!0}updateCommentRef(unitId,subUnitId,payload,silent){const oldComment=this._ensureCommentMap(unitId,subUnitId).get(payload.commentId);return oldComment?(oldComment.ref=payload.ref,this._commentUpdate$.next({unitId,subUnitId,type:"updateRef",payload,silent,threadId:oldComment.threadId}),!0):!1}resolveComment(unitId,subUnitId,commentId,resolved){const oldComment=this._ensureCommentMap(unitId,subUnitId).get(commentId);return oldComment?(oldComment.resolved=resolved,this._commentUpdate$.next({unitId,subUnitId,type:"resolve",payload:{commentId,resolved}}),!0):!1}getComment(unitId,subUnitId,commentId){return this._ensureCommentMap(unitId,subUnitId).get(commentId)}getRootComment(unitId,subUnitId,threadId){return this._ensureThreadMap(unitId,subUnitId).get(threadId)}getThread(unitId,subUnitId,threadId){const commentMap=this._ensureCommentMap(unitId,subUnitId),comments=Array.from(commentMap.values()).filter(comment=>comment.threadId===threadId);let root;const children=[],relativeUsers=new Set;for(const comment of comments)comment.parentId?children.push(comment):root=comment,relativeUsers.add(comment.personId);if(root)return{root,children,relativeUsers,unitId,subUnitId,threadId}}getCommentWithChildren(unitId,subUnitId,commentId){const comment=this.getComment(unitId,subUnitId,commentId);if(comment)return this.getThread(unitId,subUnitId,comment.threadId)}_deleteComment(unitId,subUnitId,commentId){const commentMap=this._ensureCommentMap(unitId,subUnitId),current=commentMap.get(commentId);current&&(commentMap.delete(commentId),this._commentUpdate$.next({unitId,subUnitId,type:"delete",payload:{commentId,isRoot:!current.parentId,comment:current}}))}deleteThread(unitId,subUnitId,threadId){this._ensureThreadMap(unitId,subUnitId).delete(threadId),this._ensureCommentMap(unitId,subUnitId).forEach(comment=>{comment.threadId===threadId&&this._deleteComment(unitId,subUnitId,comment.id)})}deleteComment(unitId,subUnitId,commentId){const current=this._ensureCommentMap(unitId,subUnitId).get(commentId);return current&&(current.parentId?this._deleteComment(unitId,subUnitId,commentId):this.deleteThread(unitId,subUnitId,current.threadId)),!0}deleteUnit(unitId){const unitMap=this._commentsMap.get(unitId);unitMap&&unitMap.forEach((subUnitMap,subUnitId)=>{subUnitMap.forEach(comment=>{this.deleteComment(unitId,subUnitId,comment.id)})})}getUnit(unitId){const unitMap=this._threadMap.get(unitId);if(!unitMap)return[];const threads=[];return unitMap.forEach((subUnitSet,subUnitId)=>{subUnitSet.forEach((threadComment,threadId)=>{const thread=this.getThread(unitId,subUnitId,threadId);thread&&threads.push(thread)})}),threads}getAll(){const all=[];return this._commentsMap.forEach((unitMap,unitId)=>{all.push({unitId,threads:this.getUnit(unitId)})}),all}},__name(_a,"ThreadCommentModel"),_a),exports2.ThreadCommentModel=__decorateClass$2([__decorateParam$2(0,core.Inject(IThreadCommentDataSourceService)),__decorateParam$2(1,core.Inject(core.LifecycleService))],exports2.ThreadCommentModel);var _=(E=>(E[E.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",E[E.UNIVER_DOC=1]="UNIVER_DOC",E[E.UNIVER_SHEET=2]="UNIVER_SHEET",E[E.UNIVER_SLIDE=3]="UNIVER_SLIDE",E[E.UNIVER_PROJECT=4]="UNIVER_PROJECT",E[E.UNRECOGNIZED=-1]="UNRECOGNIZED",E))(_||{});const TC_PLUGIN_NAME="UNIVER_THREAD_COMMENT_PLUGIN";var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");exports2.ThreadCommentResourceController=(_b=class extends core.Disposable{constructor(_resourceManagerService,_threadCommentModel,_threadCommentDataSourceService){super(),this._resourceManagerService=_resourceManagerService,this._threadCommentModel=_threadCommentModel,this._threadCommentDataSourceService=_threadCommentDataSourceService,this._initSnapshot()}_initSnapshot(){const toJson=__name(unitID=>{const map=this._threadCommentModel.getUnit(unitID),resultMap={};return map?(map.forEach(info=>{var _a2;const subUnitComments=(_a2=resultMap[info.subUnitId])!=null?_a2:[];subUnitComments.push({...info.root,children:info.children}),resultMap[info.unitId]=subUnitComments}),JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(resultMap,unitID))):""},"toJson"),parseJson=__name(json=>{if(!json)return{};try{return JSON.parse(json)}catch{return{}}},"parseJson");this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:`SHEET_${TC_PLUGIN_NAME}`,businesses:[_.UNIVER_SHEET,_.UNIVER_DOC],toJson:__name(unitID=>toJson(unitID),"toJson"),parseJson:__name(json=>parseJson(json),"parseJson"),onUnLoad:__name(unitID=>{this._threadCommentModel.deleteUnit(unitID)},"onUnLoad"),onLoad:__name(async(unitID,value)=>{Object.keys(value).forEach(subunitId=>{const commentList=value[subunitId];commentList.forEach(comment=>{this._threadCommentModel.addComment(unitID,subunitId,comment)}),this._threadCommentModel.syncThreadComments(unitID,subunitId,commentList.map(i=>i.threadId))})},"onLoad")}))}},__name(_b,"ThreadCommentResourceController"),_b),exports2.ThreadCommentResourceController=__decorateClass$1([__decorateParam$1(0,core.IResourceManagerService),__decorateParam$1(1,core.Inject(exports2.ThreadCommentModel)),__decorateParam$1(2,IThreadCommentDataSourceService)],exports2.ThreadCommentResourceController);const AddCommentMutation={id:"thread-comment.mutation.add-comment",type:core.CommandType.MUTATION,handler(accessor,params,options){if(!params)return!1;const threadCommentModel=accessor.get(exports2.ThreadCommentModel),{unitId,subUnitId,comment,sync}=params,shouldSync=sync||(options==null?void 0:options.fromChangeset)&&!comment.parentId;return threadCommentModel.addComment(unitId,subUnitId,comment,shouldSync)}},UpdateCommentMutation={id:"thread-comment.mutation.update-comment",type:core.CommandType.MUTATION,handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports2.ThreadCommentModel),{unitId,subUnitId,payload,silent}=params;return threadCommentModel.updateComment(unitId,subUnitId,payload,silent)}},UpdateCommentRefMutation={id:"thread-comment.mutation.update-comment-ref",type:core.CommandType.MUTATION,handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports2.ThreadCommentModel),{unitId,subUnitId,payload,silent}=params;return threadCommentModel.updateCommentRef(unitId,subUnitId,payload,silent)}},ResolveCommentMutation={id:"thread-comment.mutation.resolve-comment",type:core.CommandType.MUTATION,handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports2.ThreadCommentModel),{unitId,subUnitId,resolved,commentId}=params;return threadCommentModel.resolveComment(unitId,subUnitId,commentId,resolved)}},DeleteCommentMutation={id:"thread-comment.mutation.delete-comment",type:core.CommandType.MUTATION,handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports2.ThreadCommentModel),{unitId,subUnitId,commentId}=params;return threadCommentModel.deleteComment(unitId,subUnitId,commentId)}},AddCommentCommand={id:"thread-comment.command.add-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const commandService=accessor.get(core.ICommandService),dataSourceService=accessor.get(IThreadCommentDataSourceService),{comment:originComment}=params,comment=await dataSourceService.addComment(originComment),syncUpdateMutationToColla=dataSourceService.syncUpdateMutationToColla,isRoot=!originComment.parentId,redo={id:AddCommentMutation.id,params:{...params,comment}};return isRoot?await commandService.executeCommand(redo.id,redo.params):commandService.executeCommand(redo.id,redo.params,{onlyLocal:!syncUpdateMutationToColla})}},UpdateCommentCommand={id:"thread-comment.command.update-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const{unitId,subUnitId,payload}=params,commandService=accessor.get(core.ICommandService),threadCommentModel=accessor.get(exports2.ThreadCommentModel),dataSourceService=accessor.get(IThreadCommentDataSourceService),syncUpdateMutationToColla=dataSourceService.syncUpdateMutationToColla,current=threadCommentModel.getComment(unitId,subUnitId,payload.commentId);if(!current)return!1;const{children,...currentComment}=current;if(!await dataSourceService.updateComment({...currentComment,...payload}))return!1;const redo={id:UpdateCommentMutation.id,params};return commandService.executeCommand(redo.id,redo.params,{onlyLocal:!syncUpdateMutationToColla}),!0}},ResolveCommentCommand={id:"thread-comment.command.resolve-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const{unitId,subUnitId,resolved,commentId}=params,dataSourceService=accessor.get(IThreadCommentDataSourceService),currentComment=accessor.get(exports2.ThreadCommentModel).getComment(unitId,subUnitId,commentId),syncUpdateMutationToColla=dataSourceService.syncUpdateMutationToColla;return!currentComment||!await dataSourceService.resolveComment({...currentComment,resolved})?!1:accessor.get(core.ICommandService).executeCommand(ResolveCommentMutation.id,params,{onlyLocal:!syncUpdateMutationToColla})}},DeleteCommentCommand={id:"thread-comment.command.delete-comment",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports2.ThreadCommentModel),dataSourceService=accessor.get(IThreadCommentDataSourceService),commandService=accessor.get(core.ICommandService),{unitId,subUnitId,commentId}=params,syncUpdateMutationToColla=dataSourceService.syncUpdateMutationToColla,comment=threadCommentModel.getComment(unitId,subUnitId,commentId);if(!comment||!await dataSourceService.deleteComment(unitId,subUnitId,comment.threadId,commentId))return!1;const redo={id:DeleteCommentMutation.id,params};return commandService.executeCommand(redo.id,redo.params,{onlyLocal:!syncUpdateMutationToColla})}},DeleteCommentTreeCommand={id:"thread-comment.command.delete-comment-tree",type:core.CommandType.COMMAND,async handler(accessor,params){if(!params)return!1;const threadCommentModel=accessor.get(exports2.ThreadCommentModel),commandService=accessor.get(core.ICommandService),dataSourceService=accessor.get(IThreadCommentDataSourceService),{unitId,subUnitId,commentId}=params,commentWithChildren=threadCommentModel.getCommentWithChildren(unitId,subUnitId,commentId);return!commentWithChildren||!await dataSourceService.deleteComment(unitId,subUnitId,commentWithChildren.root.threadId,commentId)?!1:await commandService.executeCommand(DeleteCommentMutation.id,{unitId,subUnitId,commentId:commentWithChildren.root.id})}},PLUGIN_CONFIG_KEY="thread-comment.config",defaultPluginConfig={};var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam");exports2.UniverThreadCommentPlugin=(_c=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_commandService,_configService){super(),this._config=_config,this._injector=_injector,this._commandService=_commandService,this._configService=_configService;const{...rest}=this._config;this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){var _a2;core.mergeOverrideWithDependencies([[IThreadCommentDataSourceService,{useClass:ThreadCommentDataSourceService}],[exports2.ThreadCommentModel],[exports2.ThreadCommentResourceController]],(_a2=this._config)==null?void 0:_a2.overrides).forEach(d=>{this._injector.add(d)}),[AddCommentCommand,UpdateCommentCommand,DeleteCommentCommand,ResolveCommentCommand,DeleteCommentTreeCommand,AddCommentMutation,UpdateCommentMutation,UpdateCommentRefMutation,DeleteCommentMutation,ResolveCommentMutation].forEach(command=>{this._commandService.registerCommand(command)}),this._injector.get(exports2.ThreadCommentResourceController)}},__name(_c,"UniverThreadCommentPlugin"),__publicField(_c,"pluginName",TC_PLUGIN_NAME),__publicField(_c,"type",core.UniverInstanceType.UNIVER_UNKNOWN),_c),exports2.UniverThreadCommentPlugin=__decorateClass([__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.ICommandService),__decorateParam(3,core.IConfigService)],exports2.UniverThreadCommentPlugin),exports2.AddCommentCommand=AddCommentCommand,exports2.AddCommentMutation=AddCommentMutation,exports2.DeleteCommentCommand=DeleteCommentCommand,exports2.DeleteCommentMutation=DeleteCommentMutation,exports2.DeleteCommentTreeCommand=DeleteCommentTreeCommand,exports2.IThreadCommentDataSourceService=IThreadCommentDataSourceService,exports2.ResolveCommentCommand=ResolveCommentCommand,exports2.ResolveCommentMutation=ResolveCommentMutation,exports2.TC_PLUGIN_NAME=TC_PLUGIN_NAME,exports2.ThreadCommentDataSourceService=ThreadCommentDataSourceService,exports2.UpdateCommentCommand=UpdateCommentCommand,exports2.UpdateCommentMutation=UpdateCommentMutation,exports2.UpdateCommentRefMutation=UpdateCommentRefMutation,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(h,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],l):(h=typeof globalThis<"u"?globalThis:h||self,l(h.UniverThreadComment={},h.UniverCore,h.rxjs))})(this,function(h,l,A){"use strict";var Pe=Object.defineProperty;var Ae=(h,l,A)=>l in h?Pe(h,l,{enumerable:!0,configurable:!0,writable:!0,value:A}):h[l]=A;var I=(h,l,A)=>Ae(h,typeof l!="symbol"?l+"":l,A);var k;class re extends l.Disposable{constructor(){super();I(this,"_dataSource",null);I(this,"syncUpdateMutationToColla",!0)}set dataSource(e){this._dataSource=e}get dataSource(){return this._dataSource}async getThreadComment(e,t,n){return this._dataSource?(await this._dataSource.listComments(e,t,[n]))[0]:null}async addComment(e){var t;return this._dataSource?this._dataSource.addComment(e):{...e,threadId:(t=e.threadId)!=null?t:e.id}}async updateComment(e){return this._dataSource?this._dataSource.updateComment(e):!0}async resolveComment(e){return this._dataSource?this._dataSource.resolveComment(e):!0}async deleteComment(e,t,n,r){return this._dataSource?this._dataSource.deleteComment(e,t,n,r):!0}async listThreadComments(e,t,n){return this.dataSource?this.dataSource.listComments(e,t,n):!1}saveToSnapshot(e,t){if(this._dataSource){const n={};return Object.keys(e).forEach(r=>{const a=e[r];n[r]=a.map(this.dataSource.saveCommentToSnapshot)}),n}return e}}const E=l.createIdentifier("univer.thread-comment.data-source-service");var Ce=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,Me=(s,i,e,t)=>{for(var n=t>1?void 0:t?pe(i,e):i,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(t?a(i,e,n):a(n))||n);return t&&n&&Ce(i,e,n),n},ae=(s,i)=>(e,t)=>i(e,t,s);h.ThreadCommentModel=class extends l.Disposable{constructor(e,t){super();I(this,"_commentsMap",new Map);I(this,"_threadMap",new Map);I(this,"_commentUpdate$",new A.Subject);I(this,"commentUpdate$",this._commentUpdate$.asObservable());I(this,"_tasks",[]);this._dataSourceService=e,this._lifecycleService=t,this.disposeWithMe(()=>{this._commentUpdate$.complete()}),this.disposeWithMe(this._lifecycleService.lifecycle$.subscribe(n=>{const r=new Map;n===l.LifecycleStages.Rendered&&(this._tasks.forEach(({unitId:a,subUnitId:d,threadIds:C})=>{let p=r.get(a);p||(p=new Map,r.set(a,p));let v=p.get(d);v||(v=new Set,p.set(d,v));for(const S of C)v.add(S)}),this._tasks=[],r.forEach((a,d)=>{a.forEach((C,p)=>{this.syncThreadComments(d,p,Array.from(C))})}))}))}_ensureCommentMap(e,t){let n=this._commentsMap.get(e);n||(n=new Map,this._commentsMap.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}ensureMap(e,t){return this._ensureCommentMap(e,t)}_ensureThreadMap(e,t){let n=this._threadMap.get(e);n||(n=new Map,this._threadMap.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}_replaceComment(e,t,n){const r=this._ensureCommentMap(e,t),a=r.get(n.id);if(a){const{children:d,...C}=n,p={...C,ref:a.ref};r.set(n.id,p),d==null||d.forEach(v=>{r.set(v.id,{...v,ref:""})}),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"syncUpdate",payload:p}),!!n.resolved!=!!a.resolved&&this._commentUpdate$.next({unitId:e,subUnitId:t,type:"resolve",payload:{commentId:n.id,resolved:!!n.resolved}})}}async syncThreadComments(e,t,n){if(this._lifecycleService.stage<l.LifecycleStages.Rendered){this._tasks.push({unitId:e,subUnitId:t,threadIds:n});return}const r=this._ensureThreadMap(e,t),a=this._ensureCommentMap(e,t),d=await this._dataSourceService.listThreadComments(e,t,n);if(!d)return;const C=new Set(n);d.forEach(p=>{this._replaceComment(e,t,p),C.delete(p.threadId)}),C.forEach(p=>{r.delete(p),a.forEach((v,S)=>{v.threadId===p&&a.delete(S)})})}addComment(e,t,n,r){const a=this._ensureCommentMap(e,t),{parentId:d,children:C=[],...p}=n,v={...p,parentId:d===n.id?void 0:d},S=$=>{a.set($.id,$),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"add",payload:$,isRoot:!$.parentId})};S(v);const W=this._ensureThreadMap(e,t);if(!v.parentId){W.set(v.threadId,v);for(const $ of C)S($)}return r&&this.syncThreadComments(e,t,[v.threadId]),!0}updateComment(e,t,n,r){const d=this._ensureCommentMap(e,t).get(n.commentId);return d&&(d.updated=!0,d.text=n.text,d.attachments=n.attachments,d.updateT=n.updateT,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"update",payload:n,silent:r})),!0}updateCommentRef(e,t,n,r){const d=this._ensureCommentMap(e,t).get(n.commentId);return d?(d.ref=n.ref,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"updateRef",payload:n,silent:r,threadId:d.threadId}),!0):!1}resolveComment(e,t,n,r){const d=this._ensureCommentMap(e,t).get(n);return d?(d.resolved=r,this._commentUpdate$.next({unitId:e,subUnitId:t,type:"resolve",payload:{commentId:n,resolved:r}}),!0):!1}getComment(e,t,n){return this._ensureCommentMap(e,t).get(n)}getRootComment(e,t,n){return this._ensureThreadMap(e,t).get(n)}getThread(e,t,n){const r=this._ensureCommentMap(e,t),a=Array.from(r.values()).filter(v=>v.threadId===n);let d;const C=[],p=new Set;for(const v of a)v.parentId?C.push(v):d=v,p.add(v.personId);if(d)return{root:d,children:C,relativeUsers:p,unitId:e,subUnitId:t,threadId:n}}getCommentWithChildren(e,t,n){const r=this.getComment(e,t,n);if(r)return this.getThread(e,t,r.threadId)}_deleteComment(e,t,n){const r=this._ensureCommentMap(e,t),a=r.get(n);a&&(r.delete(n),this._commentUpdate$.next({unitId:e,subUnitId:t,type:"delete",payload:{commentId:n,isRoot:!a.parentId,comment:a}}))}deleteThread(e,t,n){this._ensureThreadMap(e,t).delete(n),this._ensureCommentMap(e,t).forEach(d=>{d.threadId===n&&this._deleteComment(e,t,d.id)})}deleteComment(e,t,n){const a=this._ensureCommentMap(e,t).get(n);return a&&(a.parentId?this._deleteComment(e,t,n):this.deleteThread(e,t,a.threadId)),!0}deleteUnit(e){const t=this._commentsMap.get(e);t&&t.forEach((n,r)=>{n.forEach(a=>{this.deleteComment(e,r,a.id)})})}getUnit(e){const t=this._threadMap.get(e);if(!t)return[];const n=[];return t.forEach((r,a)=>{r.forEach((d,C)=>{const p=this.getThread(e,a,C);p&&n.push(p)})}),n}getAll(){const e=[];return this._commentsMap.forEach((t,n)=>{e.push({unitId:n,threads:this.getUnit(n)})}),e}},h.ThreadCommentModel=Me([ae(0,l.Inject(E)),ae(1,l.Inject(l.LifecycleService))],h.ThreadCommentModel);var K=(s=>(s[s.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",s[s.UNIVER_DOC=1]="UNIVER_DOC",s[s.UNIVER_SHEET=2]="UNIVER_SHEET",s[s.UNIVER_SLIDE=3]="UNIVER_SLIDE",s[s.UNIVER_PROJECT=4]="UNIVER_PROJECT",s[s.UNRECOGNIZED=-1]="UNRECOGNIZED",s))(K||{});const q="UNIVER_THREAD_COMMENT_PLUGIN";var _e=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,ye=(s,i,e,t)=>{for(var n=t>1?void 0:t?ve(i,e):i,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(t?a(i,e,n):a(n))||n);return t&&n&&_e(i,e,n),n},z=(s,i)=>(e,t)=>i(e,t,s);h.ThreadCommentResourceController=class extends l.Disposable{constructor(i,e,t){super(),this._resourceManagerService=i,this._threadCommentModel=e,this._threadCommentDataSourceService=t,this._initSnapshot()}_initSnapshot(){const i=t=>{const n=this._threadCommentModel.getUnit(t),r={};return n?(n.forEach(a=>{var C;const d=(C=r[a.subUnitId])!=null?C:[];d.push({...a.root,children:a.children}),r[a.unitId]=d}),JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(r,t))):""},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:`SHEET_${q}`,businesses:[K.UNIVER_SHEET,K.UNIVER_DOC],toJson:t=>i(t),parseJson:t=>e(t),onUnLoad:t=>{this._threadCommentModel.deleteUnit(t)},onLoad:async(t,n)=>{Object.keys(n).forEach(r=>{const a=n[r];a.forEach(d=>{this._threadCommentModel.addComment(t,r,d)}),this._threadCommentModel.syncThreadComments(t,r,a.map(d=>d.threadId))})}}))}},h.ThreadCommentResourceController=ye([z(0,l.IResourceManagerService),z(1,l.Inject(h.ThreadCommentModel)),z(2,E)],h.ThreadCommentResourceController);const Q={id:"thread-comment.mutation.add-comment",type:l.CommandType.MUTATION,handler(s,i,e){if(!i)return!1;const t=s.get(h.ThreadCommentModel),{unitId:n,subUnitId:r,comment:a,sync:d}=i,C=d||(e==null?void 0:e.fromChangeset)&&!a.parentId;return t.addComment(n,r,a,C)}},X={id:"thread-comment.mutation.update-comment",type:l.CommandType.MUTATION,handler(s,i){if(!i)return!1;const e=s.get(h.ThreadCommentModel),{unitId:t,subUnitId:n,payload:r,silent:a}=i;return e.updateComment(t,n,r,a)}},oe={id:"thread-comment.mutation.update-comment-ref",type:l.CommandType.MUTATION,handler(s,i){if(!i)return!1;const e=s.get(h.ThreadCommentModel),{unitId:t,subUnitId:n,payload:r,silent:a}=i;return e.updateCommentRef(t,n,r,a)}},x={id:"thread-comment.mutation.resolve-comment",type:l.CommandType.MUTATION,handler(s,i){if(!i)return!1;const e=s.get(h.ThreadCommentModel),{unitId:t,subUnitId:n,resolved:r,commentId:a}=i;return e.resolveComment(t,n,a,r)}},G={id:"thread-comment.mutation.delete-comment",type:l.CommandType.MUTATION,handler(s,i){if(!i)return!1;const e=s.get(h.ThreadCommentModel),{unitId:t,subUnitId:n,commentId:r}=i;return e.deleteComment(t,n,r)}},se={id:"thread-comment.command.add-comment",type:l.CommandType.COMMAND,async handler(s,i){if(!i)return!1;const e=s.get(l.ICommandService),t=s.get(E),{comment:n}=i,r=await t.addComment(n),a=t.syncUpdateMutationToColla,d=!n.parentId,C={id:Q.id,params:{...i,comment:r}};return d?await e.executeCommand(C.id,C.params):e.executeCommand(C.id,C.params,{onlyLocal:!a})}},ie={id:"thread-comment.command.update-comment",type:l.CommandType.COMMAND,async handler(s,i){if(!i)return!1;const{unitId:e,subUnitId:t,payload:n}=i,r=s.get(l.ICommandService),a=s.get(h.ThreadCommentModel),d=s.get(E),C=d.syncUpdateMutationToColla,p=a.getComment(e,t,n.commentId);if(!p)return!1;const{children:v,...S}=p;if(!await d.updateComment({...S,...n}))return!1;const $={id:X.id,params:i};return r.executeCommand($.id,$.params,{onlyLocal:!C}),!0}},me={id:"thread-comment.command.resolve-comment",type:l.CommandType.COMMAND,async handler(s,i){if(!i)return!1;const{unitId:e,subUnitId:t,resolved:n,commentId:r}=i,a=s.get(E),C=s.get(h.ThreadCommentModel).getComment(e,t,r),p=a.syncUpdateMutationToColla;return!C||!await a.resolveComment({...C,resolved:n})?!1:s.get(l.ICommandService).executeCommand(x.id,i,{onlyLocal:!p})}},ce={id:"thread-comment.command.delete-comment",type:l.CommandType.COMMAND,async handler(s,i){if(!i)return!1;const e=s.get(h.ThreadCommentModel),t=s.get(E),n=s.get(l.ICommandService),{unitId:r,subUnitId:a,commentId:d}=i,C=t.syncUpdateMutationToColla,p=e.getComment(r,a,d);if(!p||!await t.deleteComment(r,a,p.threadId,d))return!1;const v={id:G.id,params:i};return n.executeCommand(v.id,v.params,{onlyLocal:!C})}},de={id:"thread-comment.command.delete-comment-tree",type:l.CommandType.COMMAND,async handler(s,i){if(!i)return!1;const e=s.get(h.ThreadCommentModel),t=s.get(l.ICommandService),n=s.get(E),{unitId:r,subUnitId:a,commentId:d}=i,C=e.getCommentWithChildren(r,a,d);return!C||!await n.deleteComment(r,a,C.root.threadId,d)?!1:await t.executeCommand(G.id,{unitId:r,subUnitId:a,commentId:C.root.id})}},ge="thread-comment.config",Se={};var Te=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,De=(s,i,e,t)=>{for(var n=t>1?void 0:t?$e(i,e):i,r=s.length-1,a;r>=0;r--)(a=s[r])&&(n=(t?a(i,e,n):a(n))||n);return t&&n&&Te(i,e,n),n},ee=(s,i)=>(e,t)=>i(e,t,s);h.UniverThreadCommentPlugin=(k=class extends l.Plugin{constructor(i=Se,e,t,n){super(),this._config=i,this._injector=e,this._commandService=t,this._configService=n;const{...r}=this._config;this._configService.setConfig(ge,r)}onStarting(){var i;l.mergeOverrideWithDependencies([[E,{useClass:re}],[h.ThreadCommentModel],[h.ThreadCommentResourceController]],(i=this._config)==null?void 0:i.overrides).forEach(e=>{this._injector.add(e)}),[se,ie,ce,me,de,Q,X,oe,G,x].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(h.ThreadCommentResourceController)}},I(k,"pluginName",q),I(k,"type",l.UniverInstanceType.UNIVER_UNKNOWN),k),h.UniverThreadCommentPlugin=De([ee(1,l.Inject(l.Injector)),ee(2,l.ICommandService),ee(3,l.IConfigService)],h.UniverThreadCommentPlugin);var Oe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ue(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var ue={exports:{}};(function(s,i){(function(e,t){s.exports=t()})(Oe,function(){var e=1e3,t=6e4,n=36e5,r="millisecond",a="second",d="minute",C="hour",p="day",v="week",S="month",W="quarter",$="year",L="date",he="Invalid Date",Ee=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,Re=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,je={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(f){var c=["th","st","nd","rd"],o=f%100;return"["+f+(c[(o-20)%10]||c[o]||c[0])+"]"}},te=function(f,c,o){var u=String(f);return!u||u.length>=c?f:""+Array(c+1-u.length).join(o)+f},be={s:te,z:function(f){var c=-f.utcOffset(),o=Math.abs(c),u=Math.floor(o/60),m=o%60;return(c<=0?"+":"-")+te(u,2,"0")+":"+te(m,2,"0")},m:function f(c,o){if(c.date()<o.date())return-f(o,c);var u=12*(o.year()-c.year())+(o.month()-c.month()),m=c.clone().add(u,S),M=o-m<0,_=c.clone().add(u+(M?-1:1),S);return+(-(u+(o-m)/(M?m-_:_-m))||0)},a:function(f){return f<0?Math.ceil(f)||0:Math.floor(f)},p:function(f){return{M:S,y:$,w:v,d:p,D:L,h:C,m:d,s:a,ms:r,Q:W}[f]||String(f||"").toLowerCase().replace(/s$/,"")},u:function(f){return f===void 0}},Y="en",j={};j[Y]=je;var le="$isDayjsObject",ne=function(f){return f instanceof Z||!(!f||!f[le])},F=function f(c,o,u){var m;if(!c)return Y;if(typeof c=="string"){var M=c.toLowerCase();j[M]&&(m=M),o&&(j[M]=o,m=M);var _=c.split("-");if(!m&&_.length>1)return f(_[0])}else{var g=c.name;j[g]=c,m=g}return!u&&m&&(Y=m),m||!u&&Y},D=function(f,c){if(ne(f))return f.clone();var o=typeof c=="object"?c:{};return o.date=f,o.args=arguments,new Z(o)},y=be;y.l=F,y.i=ne,y.w=function(f,c){return D(f,{locale:c.$L,utc:c.$u,x:c.$x,$offset:c.$offset})};var Z=function(){function f(o){this.$L=F(o.locale,null,!0),this.parse(o),this.$x=this.$x||o.x||{},this[le]=!0}var c=f.prototype;return c.parse=function(o){this.$d=function(u){var m=u.date,M=u.utc;if(m===null)return new Date(NaN);if(y.u(m))return new Date;if(m instanceof Date)return new Date(m);if(typeof m=="string"&&!/Z$/i.test(m)){var _=m.match(Ee);if(_){var g=_[2]-1||0,T=(_[7]||"0").substring(0,3);return M?new Date(Date.UTC(_[1],g,_[3]||1,_[4]||0,_[5]||0,_[6]||0,T)):new Date(_[1],g,_[3]||1,_[4]||0,_[5]||0,_[6]||0,T)}}return new Date(m)}(o),this.init()},c.init=function(){var o=this.$d;this.$y=o.getFullYear(),this.$M=o.getMonth(),this.$D=o.getDate(),this.$W=o.getDay(),this.$H=o.getHours(),this.$m=o.getMinutes(),this.$s=o.getSeconds(),this.$ms=o.getMilliseconds()},c.$utils=function(){return y},c.isValid=function(){return this.$d.toString()!==he},c.isSame=function(o,u){var m=D(o);return this.startOf(u)<=m&&m<=this.endOf(u)},c.isAfter=function(o,u){return D(o)<this.startOf(u)},c.isBefore=function(o,u){return this.endOf(u)<D(o)},c.$g=function(o,u,m){return y.u(o)?this[u]:this.set(m,o)},c.unix=function(){return Math.floor(this.valueOf()/1e3)},c.valueOf=function(){return this.$d.getTime()},c.startOf=function(o,u){var m=this,M=!!y.u(u)||u,_=y.p(o),g=function(P,w){var R=y.w(m.$u?Date.UTC(m.$y,w,P):new Date(m.$y,w,P),m);return M?R:R.endOf(p)},T=function(P,w){return y.w(m.toDate()[P].apply(m.toDate("s"),(M?[0,0,0,0]:[23,59,59,999]).slice(w)),m)},O=this.$W,U=this.$M,N=this.$D,H="set"+(this.$u?"UTC":"");switch(_){case $:return M?g(1,0):g(31,11);case S:return M?g(1,U):g(0,U+1);case v:var b=this.$locale().weekStart||0,V=(O<b?O+7:O)-b;return g(M?N-V:N+(6-V),U);case p:case L:return T(H+"Hours",0);case C:return T(H+"Minutes",1);case d:return T(H+"Seconds",2);case a:return T(H+"Milliseconds",3);default:return this.clone()}},c.endOf=function(o){return this.startOf(o,!1)},c.$set=function(o,u){var m,M=y.p(o),_="set"+(this.$u?"UTC":""),g=(m={},m[p]=_+"Date",m[L]=_+"Date",m[S]=_+"Month",m[$]=_+"FullYear",m[C]=_+"Hours",m[d]=_+"Minutes",m[a]=_+"Seconds",m[r]=_+"Milliseconds",m)[M],T=M===p?this.$D+(u-this.$W):u;if(M===S||M===$){var O=this.clone().set(L,1);O.$d[g](T),O.init(),this.$d=O.set(L,Math.min(this.$D,O.daysInMonth())).$d}else g&&this.$d[g](T);return this.init(),this},c.set=function(o,u){return this.clone().$set(o,u)},c.get=function(o){return this[y.p(o)]()},c.add=function(o,u){var m,M=this;o=Number(o);var _=y.p(u),g=function(U){var N=D(M);return y.w(N.date(N.date()+Math.round(U*o)),M)};if(_===S)return this.set(S,this.$M+o);if(_===$)return this.set($,this.$y+o);if(_===p)return g(1);if(_===v)return g(7);var T=(m={},m[d]=t,m[C]=n,m[a]=e,m)[_]||1,O=this.$d.getTime()+o*T;return y.w(O,this)},c.subtract=function(o,u){return this.add(-1*o,u)},c.format=function(o){var u=this,m=this.$locale();if(!this.isValid())return m.invalidDate||he;var M=o||"YYYY-MM-DDTHH:mm:ssZ",_=y.z(this),g=this.$H,T=this.$m,O=this.$M,U=m.weekdays,N=m.months,H=m.meridiem,b=function(w,R,J,B){return w&&(w[R]||w(u,M))||J[R].slice(0,B)},V=function(w){return y.s(g%12||12,w,"0")},P=H||function(w,R,J){var B=w<12?"AM":"PM";return J?B.toLowerCase():B};return M.replace(Re,function(w,R){return R||function(J){switch(J){case"YY":return String(u.$y).slice(-2);case"YYYY":return y.s(u.$y,4,"0");case"M":return O+1;case"MM":return y.s(O+1,2,"0");case"MMM":return b(m.monthsShort,O,N,3);case"MMMM":return b(N,O);case"D":return u.$D;case"DD":return y.s(u.$D,2,"0");case"d":return String(u.$W);case"dd":return b(m.weekdaysMin,u.$W,U,2);case"ddd":return b(m.weekdaysShort,u.$W,U,3);case"dddd":return U[u.$W];case"H":return String(g);case"HH":return y.s(g,2,"0");case"h":return V(1);case"hh":return V(2);case"a":return P(g,T,!0);case"A":return P(g,T,!1);case"m":return String(T);case"mm":return y.s(T,2,"0");case"s":return String(u.$s);case"ss":return y.s(u.$s,2,"0");case"SSS":return y.s(u.$ms,3,"0");case"Z":return _}return null}(w)||_.replace(":","")})},c.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},c.diff=function(o,u,m){var M,_=this,g=y.p(u),T=D(o),O=(T.utcOffset()-this.utcOffset())*t,U=this-T,N=function(){return y.m(_,T)};switch(g){case $:M=N()/12;break;case S:M=N();break;case W:M=N()/3;break;case v:M=(U-O)/6048e5;break;case p:M=(U-O)/864e5;break;case C:M=U/n;break;case d:M=U/t;break;case a:M=U/e;break;default:M=U}return m?M:y.a(M)},c.daysInMonth=function(){return this.endOf(S).$D},c.$locale=function(){return j[this.$L]},c.locale=function(o,u){if(!o)return this.$L;var m=this.clone(),M=F(o,u,!0);return M&&(m.$L=M),m},c.clone=function(){return y.w(this.$d,this)},c.toDate=function(){return new Date(this.valueOf())},c.toJSON=function(){return this.isValid()?this.toISOString():null},c.toISOString=function(){return this.$d.toISOString()},c.toString=function(){return this.$d.toUTCString()},f}(),fe=Z.prototype;return D.prototype=fe,[["$ms",r],["$s",a],["$m",d],["$H",C],["$W",p],["$M",S],["$y",$],["$D",L]].forEach(function(f){fe[f[1]]=function(c){return this.$g(c,f[0],f[1])}}),D.extend=function(f,c){return f.$i||(f(c,Z,D),f.$i=!0),D},D.locale=F,D.isDayjs=ne,D.unix=function(f){return D(1e3*f)},D.en=j[Y],D.Ls=j,D.p={},D})})(ue);var we=ue.exports;const Ne=Ue(we);function Ie(){return Ne().format("YYYY/MM/DD HH:mm")}h.AddCommentCommand=se,h.AddCommentMutation=Q,h.DeleteCommentCommand=ce,h.DeleteCommentMutation=G,h.DeleteCommentTreeCommand=de,h.IThreadCommentDataSourceService=E,h.ResolveCommentCommand=me,h.ResolveCommentMutation=x,h.TC_PLUGIN_NAME=q,h.ThreadCommentDataSourceService=re,h.UpdateCommentCommand=ie,h.UpdateCommentMutation=X,h.UpdateCommentRefMutation=oe,h.getDT=Ie,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/thread-comment",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-alpha.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer thread comment core plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -31,8 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"./lib/*": "./lib/*"
|
|
33
33
|
},
|
|
34
|
-
"main": "./lib/
|
|
35
|
-
"module": "./lib/es/index.js",
|
|
34
|
+
"main": "./lib/es/index.js",
|
|
36
35
|
"types": "./lib/types/index.d.ts",
|
|
37
36
|
"publishConfig": {
|
|
38
37
|
"access": "public"
|
|
@@ -48,16 +47,17 @@
|
|
|
48
47
|
},
|
|
49
48
|
"dependencies": {
|
|
50
49
|
"@univerjs/protocol": "0.1.39-alpha.38",
|
|
51
|
-
"
|
|
50
|
+
"dayjs": "^1.11.13",
|
|
51
|
+
"@univerjs/core": "0.5.0-alpha.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"rxjs": "^7.8.1",
|
|
55
55
|
"typescript": "^5.6.3",
|
|
56
|
-
"vite": "^5.4.
|
|
57
|
-
"vitest": "^2.1.
|
|
58
|
-
"@univerjs-infra/shared": "0.
|
|
56
|
+
"vite": "^5.4.10",
|
|
57
|
+
"vitest": "^2.1.4",
|
|
58
|
+
"@univerjs-infra/shared": "0.5.0-alpha.0"
|
|
59
59
|
},
|
|
60
|
-
"
|
|
60
|
+
"space": {
|
|
61
61
|
".": {
|
|
62
62
|
"import": "./lib/es/index.js",
|
|
63
63
|
"require": "./lib/cjs/index.js",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"test:watch": "vitest",
|
|
76
76
|
"coverage": "vitest run --coverage",
|
|
77
77
|
"lint:types": "tsc --noEmit",
|
|
78
|
-
"build": "
|
|
79
|
-
}
|
|
78
|
+
"build": "tsx build.ts"
|
|
79
|
+
},
|
|
80
|
+
"module": "./lib/es/index.js"
|
|
80
81
|
}
|