@univerjs/thread-comment-ui 0.4.2-nightly.202411061606 → 0.4.2-nightly.202411071606
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/es/index.js +1 -2
- package/lib/umd/index.js +4 -4
- package/package.json +8 -8
package/lib/es/index.js
CHANGED
|
@@ -11,7 +11,6 @@ import React, { forwardRef, useRef, createElement, useState, useImperativeHandle
|
|
|
11
11
|
import { DocSelectionManagerService } from "@univerjs/docs";
|
|
12
12
|
import { DocSelectionRenderService } from "@univerjs/docs-ui";
|
|
13
13
|
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
14
|
-
import { IThreadCommentMentionDataService as IThreadCommentMentionDataService$1 } from "@univerjs/thread-comment-ui";
|
|
15
14
|
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
16
15
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
17
16
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -330,7 +329,7 @@ const threadCommentEditorButtons = "univer-thread-comment-editor-buttons", threa
|
|
|
330
329
|
return /* @__PURE__ */ React.createElement("div", { className: styles$2.threadCommentEditorSuggestion }, icon ? /* @__PURE__ */ React.createElement("img", { className: styles$2.threadCommentEditorSuggestionIcon, src: icon }) : null, /* @__PURE__ */ React.createElement("div", null, (_b = mention.display) != null ? _b : mention.id));
|
|
331
330
|
}, "defaultRenderSuggestion"), ThreadCommentEditor = forwardRef((props, ref) => {
|
|
332
331
|
var _a3, _b;
|
|
333
|
-
const { comment, onSave, id, onCancel, autoFocus, unitId, subUnitId } = props, mentionDataService = useDependency(IThreadCommentMentionDataService
|
|
332
|
+
const { comment, onSave, id, onCancel, autoFocus, unitId, subUnitId } = props, mentionDataService = useDependency(IThreadCommentMentionDataService), commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [localComment, setLocalComment] = useState({ ...comment }), [editing, setEditing] = useState(!1), inputRef = useRef(null), docSelectionManagerService = useDependency(DocSelectionManagerService), docSelectionRenderService = (_a3 = useDependency(IRenderManagerService).getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a3.with(DocSelectionRenderService);
|
|
334
333
|
useImperativeHandle(ref, () => ({
|
|
335
334
|
reply(text) {
|
|
336
335
|
var _a4;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(m,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/design"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/engine-render")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment","@univerjs/ui","rxjs","react","@univerjs/design","@univerjs/docs","@univerjs/docs-ui","@univerjs/engine-render"],o):(m=typeof globalThis<"u"?globalThis:m||self,o(m.UniverThreadCommentUi={},m.UniverCore,m.UniverThreadComment,m.UniverUi,m.rxjs,m.React,m.UniverDesign,m.UniverDocs,m.UniverDocsUi,m.UniverEngineRender))})(this,function(m,o,b,k,ne,h,_,Me,Oe,Re){"use strict";var ut=Object.defineProperty;var vt=(m,o,b)=>o in m?ut(m,o,{enumerable:!0,configurable:!0,writable:!0,value:b}):m[o]=b;var L=(m,o,b)=>vt(m,typeof o!="symbol"?o+"":o,b);var De=Object.defineProperty,we=Object.getOwnPropertyDescriptor,He=(n,e,t,r)=>{for(var i=r>1?void 0:r?we(e,t):e,d=n.length-1,c;d>=0;d--)(c=n[d])&&(i=(r?c(e,t,i):c(i))||i);return r&&i&&De(e,t,i),i},ce=(n,e)=>(t,r)=>e(t,r,n);m.ThreadCommentPanelService=class extends o.Disposable{constructor(t,r){super();L(this,"_panelVisible",!1);L(this,"_panelVisible$",new ne.BehaviorSubject(!1));L(this,"_activeCommentId");L(this,"_activeCommentId$",new ne.BehaviorSubject(void 0));L(this,"panelVisible$",this._panelVisible$.asObservable());L(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(ne.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}},m.ThreadCommentPanelService=He([ce(0,o.Inject(k.ISidebarService)),ce(1,o.IUniverInstanceService)],m.ThreadCommentPanelService);const he="thread-comment-panel",Ae="UNIVER_THREAD_COMMENT_UI_PLUGIN",ue={id:"thread-comment-ui.operation.toggle-panel",type:o.CommandType.OPERATION,handler(n){const e=n.get(k.ISidebarService),t=n.get(m.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:he},width:330}),t.setPanelVisible(!0)),!0}},F={id:"thread-comment-ui.operation.set-active-comment",type:o.CommandType.OPERATION,handler(n,e){return n.get(m.ThreadCommentPanelService).setActiveComment(e),!0}},Le="thread-comment-ui.config",ke={};class Ve{constructor(){L(this,"dataSource");L(this,"renderSuggestion");L(this,"trigger","@")}async getMentions(e,t,r){return this.dataSource?this.dataSource.getMentions(e,t,r):[]}}const le=o.createIdentifier("thread-comment.mention-data.service");var ve=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,Fe=(n,e,t)=>e in n?ve(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,We=(n,e,t,r)=>{for(var i=r>1?void 0:r?Be(e,t):e,d=n.length-1,c;d>=0;d--)(c=n[d])&&(i=(r?c(e,t,i):c(i))||i);return r&&i&&ve(e,t,i),i},me=(n,e)=>(t,r)=>e(t,r,n),Ce=(n,e,t)=>Fe(n,typeof e!="symbol"?e+"":e,t);m.UniverThreadCommentUIPlugin=class extends o.Plugin{constructor(e=ke,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;const{menu:d,...c}=this._config;d&&this._configService.setConfig("menu",d,{merge:!0}),this._configService.setConfig(Le,c)}onStarting(){var e;o.mergeOverrideWithDependencies([[m.ThreadCommentPanelService],[le,{useClass:Ve}]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[ue,F].forEach(t=>{this._commandService.registerCommand(t)})}},Ce(m.UniverThreadCommentUIPlugin,"pluginName",Ae),Ce(m.UniverThreadCommentUIPlugin,"type",o.UniverInstanceType.UNIVER_UNKNOWN),m.UniverThreadCommentUIPlugin=We([o.DependentOn(b.UniverThreadCommentPlugin),me(1,o.Inject(o.Injector)),me(2,o.ICommandService),me(3,o.IConfigService)],m.UniverThreadCommentUIPlugin);var fe={exports:{}},re={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
10
|
-
\r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},lt=n=>({display:n.label,id:`${n.id}`,raw:n}),
|
|
11
|
-
\r`},personId:(ae=D==null?void 0:D.userID)!=null?ae:"",ref:i!=null?i:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...($=s==null?void 0:s.children)!=null?$:[]],G=h.useRef(null),V=P=>{P.stopPropagation(),H?y.executeCommand(F.id,{unitId:t,subUnitId:r,commentId:e}):y.executeCommand(F.id),y.executeCommand(b.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!H}),O==null||O(!H)},q=P=>{P.stopPropagation(),y.executeCommand(F.id),!(s!=null&&s.root&&(S==null?void 0:S(s.root))===!1)&&(y.executeCommand(b.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),g==null||g())};h.useEffect(()=>f==null?void 0:f(),[]);const B=j((ee=s==null?void 0:s.root.subUnitId)!=null?ee:r),oe=d&&!W&&!H,Y=`${i||(s==null?void 0:s.root.ref)||""}${B?" · ":""}${B}`;return a.jsxs("div",{className:
|
|
9
|
+
*/var ze=h,Ze=Symbol.for("react.element"),Ge=Symbol.for("react.fragment"),Ke=Object.prototype.hasOwnProperty,Ye=ze.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Je={key:!0,ref:!0,__self:!0,__source:!0};function ge(n,e,t){var r,i={},d=null,c=null;t!==void 0&&(d=""+t),e.key!==void 0&&(d=""+e.key),e.ref!==void 0&&(c=e.ref);for(r in e)Ke.call(e,r)&&!Je.hasOwnProperty(r)&&(i[r]=e[r]);if(n&&n.defaultProps)for(r in e=n.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:Ze,type:n,key:d,ref:c,props:i,_owner:Ye.current}}re.Fragment=Ge,re.jsx=ge,re.jsxs=ge,fe.exports=re;var a=fe.exports,N=function(){return N=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},N.apply(this,arguments)},Qe=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},z=h.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,d=n.extend,c=Qe(n,["icon","id","className","extend"]),C="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),g=h.useRef("_".concat($e()));return pe(t,"".concat(r),{defIds:t.defIds,idSuffix:g.current},N({ref:e,className:C},c),d)});function pe(n,e,t,r,i){return h.createElement(n.tag,N(N({key:e},Xe(n,t,i)),r),(qe(n,t).children||[]).map(function(d,c){return pe(d,"".concat(e,"-").concat(n.tag,"-").concat(c),t,void 0,i)}))}function Xe(n,e,t){var r=N({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(d){var c=d[0],C=d[1];typeof C=="string"&&(r[c]=C.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function qe(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?N(N({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?N(N({},i),{attrs:N(N({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function $e(){return Math.random().toString(36).substring(2,8)}z.displayName="UniverIcon";var et={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ie=h.forwardRef(function(n,e){return h.createElement(z,Object.assign({},n,{id:"delete-single",ref:e,icon:et}))});Ie.displayName="DeleteSingle";var tt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},Se=h.forwardRef(function(n,e){return h.createElement(z,Object.assign({},n,{id:"increase-single",ref:e,icon:tt}))});Se.displayName="IncreaseSingle";var nt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},xe=h.forwardRef(function(n,e){return h.createElement(z,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:nt}))});xe.displayName="MoreHorizontalSingle";var rt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},ye=h.forwardRef(function(n,e){return h.createElement(z,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:rt}))});ye.displayName="ReplyToCommentSingle";var it={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},be=h.forwardRef(function(n,e){return h.createElement(z,Object.assign({},n,{id:"resolved-single",ref:e,icon:it}))});be.displayName="ResolvedSingle";var ot={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},Te=h.forwardRef(function(n,e){return h.createElement(z,Object.assign({},n,{id:"solve-single",ref:e,icon:ot}))});Te.displayName="SolveSingle";function je(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=je(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function at(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=je(n))&&(r&&(r+=" "),r+=e);return r}const ie={threadCommentEditorButtons:"univer-thread-comment-editor-buttons",threadCommentEditorSuggestion:"univer-thread-comment-editor-suggestion",threadCommentEditorSuggestionActive:"univer-thread-comment-editor-suggestionActive",threadCommentEditorSuggestionIcon:"univer-thread-comment-editor-suggestion-icon"},st=n=>{const e=/@\[(.*?)\]\((.*?)\)|(\w+)/g;let t,r=0;const i=[];for(;(t=e.exec(n))!==null;)t.index>r&&i.push({type:"text",content:n.substring(r,t.index)}),t[1]&&t[2]?i.push({type:"mention",content:{label:t[1],id:t[2]}}):t[3]&&i.push({type:"text",content:t[3]}),r=e.lastIndex;return r<n.length&&i.push({type:"text",content:n.substring(r)}),i},dt=n=>n.map(e=>{switch(e.type){case"mention":return`@[${e.content.label}](${e.content.id})`;default:return e.content}}).join(""),_e=n=>{const{dataStream:e,customRanges:t}=n,r=e.length-2,i=[];let d=0;return t==null||t.forEach(c=>{d<c.startIndex&&i.push({type:"text",content:e.slice(d,c.startIndex)}),i.push({type:"mention",content:{label:e.slice(c.startIndex,c.endIndex).slice(1,-1),id:c.rangeId}}),d=c.endIndex}),i.push({type:"text",content:e.slice(d,r)}),i},Ue=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const i=e.length;e+=`${r.content.label}`;const d=e.length;t.push({rangeId:r.content.id,rangeType:o.CustomRangeType.MENTION,startIndex:i,endIndex:d,properties:{}});break}}}),e+=`
|
|
10
|
+
\r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},lt=n=>({display:n.label,id:`${n.id}`,raw:n}),mt=(n,e,t,r,i)=>{var c,C;const d=(c=n.raw)==null?void 0:c.icon;return a.jsxs("div",{className:ie.threadCommentEditorSuggestion,children:[d?a.jsx("img",{className:ie.threadCommentEditorSuggestionIcon,src:d}):null,a.jsx("div",{children:(C=n.display)!=null?C:n.id})]})},Pe=h.forwardRef((n,e)=>{var x,R;const{comment:t,onSave:r,id:i,onCancel:d,autoFocus:c,unitId:C,subUnitId:g}=n,j=o.useDependency(le),w=o.useDependency(o.ICommandService),M=o.useDependency(o.LocaleService),[I,f]=h.useState({...t}),[p,S]=h.useState(!1),O=h.useRef(null),T=o.useDependency(Me.DocSelectionManagerService),u=(x=o.useDependency(Re.IRenderManagerService).getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_DOC))==null?void 0:x.with(Oe.DocSelectionRenderService);h.useImperativeHandle(e,()=>({reply(s){var y;f({...t,text:s,attachments:[]}),(y=O.current)==null||y.inputElement.focus()}}));const W=()=>{var s;I.text&&(r==null||r({...I,text:I.text}),S(!1),f({text:void 0}),(s=O.current)==null||s.inputElement.blur())};return a.jsxs("div",{className:ie.threadCommentEditor,onClick:s=>s.preventDefault(),children:[a.jsx(_.Mentions,{ref:O,autoFocus:c,style:{width:"100%"},placeholder:M.t("threadCommentUI.editor.placeholder"),value:I!=null&&I.text?dt(_e(I.text)):"",onChange:s=>{s.target.value||f({...t,text:void 0}),f==null||f({...t,text:Ue(st(s.target.value))})},onFocus:()=>{const s=T.getActiveTextRange();s&&s.collapsed&&(u==null||u.removeAllRanges()),u==null||u.blur(),S(!0)},children:a.jsx(_.Mention,{trigger:j.trigger,data:(s,y)=>j.getMentions(s,C,g).then(U=>U.map(lt)).then(y),displayTransform:(s,y)=>`@${y} `,renderSuggestion:(R=j.renderSuggestion)!=null?R:mt},j.trigger)}),p?a.jsxs("div",{className:ie.threadCommentEditorButtons,children:[a.jsx(_.Button,{style:{marginRight:12},onClick:()=>{d==null||d(),S(!1),f({text:void 0}),w.executeCommand(F.id)},children:M.t("threadCommentUI.editor.cancel")}),a.jsx(_.Button,{type:"primary",disabled:!I.text,onClick:W,children:M.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),v={threadComment:"univer-thread-comment",threadCommentActive:"univer-thread-comment-active",threadCommentContent:"univer-thread-comment-content",threadCommentHighlight:"univer-thread-comment-highlight",threadCommentIconContainer:"univer-thread-comment-icon-container",threadCommentIcon:"univer-thread-comment-icon",threadCommentTitle:"univer-thread-comment-title",threadCommentTitlePosition:"univer-thread-comment-title-position",threadCommentTitleHighlight:"univer-thread-comment-title-highlight",threadCommentTitlePositionText:"univer-thread-comment-title-position-text",threadCommentUsername:"univer-thread-comment-username",threadCommentItem:"univer-thread-comment-item",threadCommentItemHead:"univer-thread-comment-item-head",threadCommentItemTitle:"univer-thread-comment-item-title",threadCommentItemTitlePosition:"univer-thread-comment-item-title-position",threadCommentItemTitleHighlight:"univer-thread-comment-item-title-highlight",threadCommentItemTime:"univer-thread-comment-item-time",threadCommentItemContent:"univer-thread-comment-item-content",threadCommentItemAt:"univer-thread-comment-item-at"},Ee="__mock__",ct=n=>{const{item:e,unitId:t,subUnitId:r,editing:i,onEditingChange:d,onReply:c,resolved:C,isRoot:g,onClose:j,onDeleteComment:w}=n,M=o.useDependency(o.ICommandService),I=o.useDependency(o.LocaleService),f=o.useDependency(o.UserManagerService),p=f.getUser(e.personId),S=k.useObservable(f.currentUser$),O=(S==null?void 0:S.userID)===e.personId,T=e.id===Ee,[Z,u]=h.useState(!1),W=()=>{(w==null?void 0:w(e))!==!1&&(M.executeCommand(g?b.DeleteCommentTreeCommand.id:b.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),g&&(j==null||j()))};return a.jsxs("div",{className:v.threadCommentItem,onMouseLeave:()=>u(!1),onMouseEnter:()=>u(!0),children:[a.jsx("img",{className:v.threadCommentItemHead,src:p==null?void 0:p.avatar}),a.jsxs("div",{className:v.threadCommentItemTitle,children:[a.jsx("div",{className:v.threadCommentUsername,children:(p==null?void 0:p.name)||" "}),a.jsxs("div",{children:[T||C?null:Z?a.jsx("div",{className:v.threadCommentIcon,onClick:()=>c(p),children:a.jsx(ye,{})}):null,O&&!T&&!C?a.jsx(_.Dropdown,{overlay:a.jsxs(_.Menu,{children:[a.jsx(_.MenuItem,{onClick:()=>d==null?void 0:d(!0),children:I.t("threadCommentUI.item.edit")},"edit"),a.jsx(_.MenuItem,{onClick:W,children:I.t("threadCommentUI.item.delete")},"delete")]}),children:a.jsx("div",{className:v.threadCommentIcon,children:a.jsx(xe,{})})}):null]})]}),a.jsx("div",{className:v.threadCommentItemTime,children:e.dT}),i?a.jsx(Pe,{id:e.id,comment:e,onCancel:()=>d==null?void 0:d(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:x,attachments:R})=>{d==null||d(!1),M.executeCommand(b.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:x,attachments:R}})}}):a.jsx("div",{className:v.threadCommentItemContent,children:_e(e.text).map((x,R)=>{switch(x.type){case"mention":return a.jsxs("a",{className:v.threadCommentItemAt,children:["@",x.content.label," "]},R);default:return x.content}})})]})},Ne=n=>{var ae,$,ee;const{id:e,unitId:t,subUnitId:r,refStr:i,showEdit:d=!0,onClick:c,showHighlight:C,onClose:g,getSubUnitName:j,prefix:w,autoFocus:M,onMouseEnter:I,onMouseLeave:f,onAddComment:p,onDeleteComment:S,onResolve:O}=n,T=o.useDependency(b.ThreadCommentModel),[Z,u]=h.useState(!1),[W,x]=h.useState(""),R=h.useMemo(()=>T.commentUpdate$.pipe(ne.debounceTime(16)),[T]);k.useObservable(R);const s=e?T.getCommentWithChildren(t,r,e):null,y=o.useDependency(o.ICommandService),U=o.useDependency(o.UserManagerService),H=s==null?void 0:s.root.resolved,D=k.useObservable(U.currentUser$),Q=h.useRef(null),X=[...s?[s.root]:[{id:Ee,text:{dataStream:`
|
|
11
|
+
\r`},personId:(ae=D==null?void 0:D.userID)!=null?ae:"",ref:i!=null?i:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...($=s==null?void 0:s.children)!=null?$:[]],G=h.useRef(null),V=P=>{P.stopPropagation(),H?y.executeCommand(F.id,{unitId:t,subUnitId:r,commentId:e}):y.executeCommand(F.id),y.executeCommand(b.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!H}),O==null||O(!H)},q=P=>{P.stopPropagation(),y.executeCommand(F.id),!(s!=null&&s.root&&(S==null?void 0:S(s.root))===!1)&&(y.executeCommand(b.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),g==null||g())};h.useEffect(()=>f==null?void 0:f(),[]);const B=j((ee=s==null?void 0:s.root.subUnitId)!=null?ee:r),oe=d&&!W&&!H,Y=`${i||(s==null?void 0:s.root.ref)||""}${B?" · ":""}${B}`;return a.jsxs("div",{className:at(v.threadComment,{[v.threadCommentActive]:!H&&(C||Z||w==="cell")}),onClick:c,id:`${w}-${t}-${r}-${e}`,onMouseEnter:()=>{I==null||I(),u(!0)},onMouseLeave:()=>{f==null||f(),u(!1)},children:[!H&&C?a.jsx("div",{className:v.threadCommentHighlight}):null,a.jsxs("div",{className:v.threadCommentTitle,children:[a.jsxs("div",{className:v.threadCommentTitlePosition,children:[a.jsx("div",{className:v.threadCommentTitleHighlight}),a.jsx(_.Tooltip,{showIfEllipsis:!0,title:Y,children:a.jsx("div",{className:v.threadCommentTitlePositionText,children:Y})})]}),s?a.jsxs("div",{className:v.threadCommentIconContainer,children:[a.jsx("div",{onClick:V,className:v.threadCommentIcon,style:{color:H?"rgb(var(--green-500))":""},children:H?a.jsx(be,{}):a.jsx(Te,{})}),(D==null?void 0:D.userID)===s.root.personId?a.jsx("div",{className:v.threadCommentIcon,onClick:q,children:a.jsx(Ie,{})}):null]}):null]}),a.jsx("div",{className:v.threadCommentContent,ref:G,children:X.map(P=>a.jsx(ct,{onClose:g,unitId:t,subUnitId:r,item:P,isRoot:P.id===(s==null?void 0:s.root.id),editing:W===P.id,resolved:s==null?void 0:s.root.resolved,onEditingChange:A=>{x(A?P.id:"")},onReply:A=>{A&&requestAnimationFrame(()=>{var l;(l=Q.current)==null||l.reply(Ue([{type:"mention",content:{id:A.userID,label:A.name}}]))})},onAddComment:p,onDeleteComment:S},P.id))}),oe?a.jsx("div",{children:a.jsx(Pe,{ref:Q,unitId:t,subUnitId:r,onSave:async({text:P,attachments:A})=>{const l={text:P,attachments:A,dT:b.getDT(),id:o.generateRandomId(),ref:i,personId:D==null?void 0:D.userID,parentId:s==null?void 0:s.root.id,unitId:t,subUnitId:r,threadId:s==null?void 0:s.root.threadId};(p==null?void 0:p(l))!==!1&&(await y.executeCommand(b.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:l}),G.current&&(G.current.scrollTop=G.current.scrollHeight))},autoFocus:M||!s,onCancel:()=>{s||g==null||g()}},`${M}`)}):null]})},J={threadCommentPanel:"univer-thread-comment-panel",threadComment:"univer-thread-comment",threadCommentPanelForms:"univer-thread-comment-panel-forms",select:"univer-select",threadCommentPanelEmpty:"univer-thread-comment-panel-empty",threadCommentPanelAdd:"univer-thread-comment-panel-add",threadCommentPanelSolved:"univer-thread-comment-panel-solved"},ht=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:i,getSubUnitName:d,onResolve:c,sortComments:C,onItemLeave:g,onItemEnter:j,disableAdd:w,tempComment:M,onAddComment:I,onDeleteComment:f,showComments:p}=n,[S,O]=h.useState("all"),[T,Z]=h.useState("all"),u=o.useDependency(o.LocaleService),W=o.useDependency(o.UserManagerService),x=o.useDependency(b.ThreadCommentModel),[R,s]=h.useState(()=>x.getUnit(e)),y=o.useDependency(m.ThreadCommentPanelService),U=k.useObservable(y.activeCommentId$),H=k.useObservable(x.commentUpdate$),D=o.useDependency(o.ICommandService),Q=k.useObservable(t),X=h.useRef(!0),G="panel",V=k.useObservable(W.currentUser$),q=h.useMemo(()=>{var de;const l=S==="all"?R:(de=R.filter(E=>E.subUnitId===Q))!=null?de:[],te=C!=null?C:E=>E,se=l.map(E=>{var K;return{...E.root,children:(K=E.children)!=null?K:[],users:E.relativeUsers}});if(p){const E=new Map;return se.forEach(K=>{E.set(K.id,K)}),[...p,""].map(K=>E.get(K)).filter(Boolean)}else return te(se)},[p,S,R,C,Q]),B=h.useMemo(()=>[...q.filter(l=>!l.resolved),...q.filter(l=>l.resolved)],[q]),oe=h.useMemo(()=>T==="resolved"?B.filter(l=>l.resolved):T==="unsolved"?B.filter(l=>!l.resolved):T==="concern_me"&&V!=null&&V.userID?B.filter(l=>l==null?void 0:l.users.has(V.userID)):B,[B,V==null?void 0:V.userID,T]),Y=M?[M,...oe]:oe,ae=Y.filter(l=>!l.resolved),$=Y.filter(l=>l.resolved),ee=T!=="all"||S!=="all",P=()=>{Z("all"),O("all")};h.useEffect(()=>{e&&s(x.getUnit(e))},[e,x,H]),h.useEffect(()=>{var E;if(!U)return;if(!X.current){X.current=!0;return}const{unitId:l,subUnitId:te,commentId:se}=U,de=`${G}-${l}-${te}-${se}`;(E=document.getElementById(de))==null||E.scrollIntoView({block:"center"})},[U]);const A=l=>a.jsx(Ne,{prefix:G,getSubUnitName:d,id:l.id,unitId:l.unitId,subUnitId:l.subUnitId,refStr:l.ref,type:r,showEdit:(U==null?void 0:U.commentId)===l.id,showHighlight:(U==null?void 0:U.commentId)===l.id,onClick:()=>{X.current=!1,l.resolved?D.executeCommand(F.id):D.executeCommand(F.id,{unitId:l.unitId,subUnitId:l.subUnitId,commentId:l.id,temp:!1})},onMouseEnter:()=>j==null?void 0:j(l),onMouseLeave:()=>g==null?void 0:g(l),onAddComment:I,onDeleteComment:f,onResolve:te=>c==null?void 0:c(l.id,te)},l.id);return a.jsxs("div",{className:J.threadCommentPanel,children:[a.jsxs("div",{className:J.threadCommentPanelForms,children:[r===o.UniverInstanceType.UNIVER_SHEET?a.jsx(_.Select,{borderless:!0,value:S,onChange:l=>O(l),options:[{value:"current",label:u.t("threadCommentUI.filter.sheet.current")},{value:"all",label:u.t("threadCommentUI.filter.sheet.all")}]}):null,a.jsx(_.Select,{borderless:!0,value:T,onChange:l=>Z(l),options:[{value:"all",label:u.t("threadCommentUI.filter.status.all")},{value:"resolved",label:u.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:u.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:u.t("threadCommentUI.filter.status.concernMe")}]})]}),ae.map(A),$.length?a.jsx("div",{className:J.threadCommentPanelSolved,children:"已解决"}):null,$.map(A),Y.length?null:a.jsxs("div",{className:J.threadCommentPanelEmpty,children:[ee?u.t("threadCommentUI.panel.filterEmpty"):u.t("threadCommentUI.panel.empty"),ee?a.jsx(_.Button,{onClick:P,type:"link",children:u.t("threadCommentUI.panel.reset")}):a.jsxs(_.Button,{id:"thread-comment-add",className:J.threadCommentPanelAdd,type:"primary",onClick:i,disabled:w,children:[a.jsx(Se,{}),u.t("threadCommentUI.panel.addComment")]})]})]})};m.IThreadCommentMentionDataService=le,m.SetActiveCommentOperation=F,m.THREAD_COMMENT_PANEL=he,m.ThreadCommentPanel=ht,m.ThreadCommentTree=Ne,m.ToggleSheetCommentPanelOperation=ue,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/thread-comment-ui",
|
|
3
|
-
"version": "0.4.2-nightly.
|
|
3
|
+
"version": "0.4.2-nightly.202411071606",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer common thread comment UI plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
"@univerjs/protocol": "0.1.39-alpha.38",
|
|
54
54
|
"clsx": "^2.1.1",
|
|
55
55
|
"dayjs": "^1.11.13",
|
|
56
|
-
"@univerjs/core": "0.4.2-nightly.
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/docs-ui": "0.4.2-nightly.
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/thread-comment": "0.4.2-nightly.
|
|
62
|
-
"@univerjs/ui": "0.4.2-nightly.
|
|
56
|
+
"@univerjs/core": "0.4.2-nightly.202411071606",
|
|
57
|
+
"@univerjs/design": "0.4.2-nightly.202411071606",
|
|
58
|
+
"@univerjs/docs": "0.4.2-nightly.202411071606",
|
|
59
|
+
"@univerjs/docs-ui": "0.4.2-nightly.202411071606",
|
|
60
|
+
"@univerjs/engine-render": "0.4.2-nightly.202411071606",
|
|
61
|
+
"@univerjs/thread-comment": "0.4.2-nightly.202411071606",
|
|
62
|
+
"@univerjs/ui": "0.4.2-nightly.202411071606"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"less": "^4.2.0",
|