@univerjs/sheets-note 0.10.12 → 0.10.13
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 +304 -234
- package/lib/index.js +304 -234
- package/lib/types/controllers/sheets-note-resource.controller.d.ts +4 -1
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Disposable, IResourceManagerService, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
+
import { SheetInterceptorService } from '@univerjs/sheets';
|
|
2
3
|
import { SheetsNoteModel } from '../models/sheets-note.model';
|
|
3
4
|
export declare class SheetsNoteResourceController extends Disposable {
|
|
4
5
|
private readonly _resourceManagerService;
|
|
5
6
|
private readonly _univerInstanceService;
|
|
7
|
+
private _sheetInterceptorService;
|
|
6
8
|
private readonly _sheetsNoteModel;
|
|
7
|
-
constructor(_resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService, _sheetsNoteModel: SheetsNoteModel);
|
|
9
|
+
constructor(_resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService, _sheetInterceptorService: SheetInterceptorService, _sheetsNoteModel: SheetsNoteModel);
|
|
8
10
|
private _initSnapshot;
|
|
11
|
+
private _initSheetChange;
|
|
9
12
|
}
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","rxjs"],a):(u=typeof globalThis<"u"?globalThis:u||self,a(u.UniverSheetsNote={},u.UniverCore,u.UniverSheets,u.rxjs))})(this,(function(u,a,l,p){"use strict";var z=Object.defineProperty;var F=(u,a,l)=>a in u?z(u,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[a]=l;var _=(u,a,l)=>F(u,typeof a!="symbol"?a+"":a,l);class g extends a.Disposable{constructor(){super(...arguments);_(this,"_noteMatrix",new Map);_(this,"_change$",new p.Subject);_(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(n,e){let t=this._noteMatrix.get(n);t||(t=new Map,this._noteMatrix.set(n,t));let s=t.get(e);return s||(s=new a.ObjectMatrix,t.set(e,s)),s}getSheetShowNotes$(n,e){return this._change$.pipe(p.filter(({unitId:t,sheetId:s})=>t===n&&s===e),p.map(()=>{const t=this._ensureNoteMatrix(n,e),s=[];return t.forValue((i,h,c)=>{c.show&&s.push({loc:{row:i,col:h,unitId:n,subUnitId:e},note:c})}),s}))}getCellNoteChange$(n,e,t,s){return this._change$.pipe(p.filter(({unitId:i,sheetId:h,row:c,col:d})=>i===n&&h===e&&c===t&&d===s),p.map(({note:i})=>i))}updateNote(n,e,t,s,i,h){const c=this._ensureNoteMatrix(n,e),d=c.getValue(t,s);c.setValue(t,s,i),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:i,oldNote:d,silent:h})}removeNote(n,e,t,s,i){const h=this._ensureNoteMatrix(n,e),c=h.getValue(t,s);h.realDeleteValue(t,s),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:null,oldNote:c,silent:i})}toggleNotePopup(n,e,t,s,i){const h=this._ensureNoteMatrix(n,e),c=h.getValue(t,s);if(c){c.show=!c.show;const d={...c,show:c.show};h.setValue(t,s,d),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"update",note:d,oldNote:c,silent:i})}}updateNotePosition(n,e,t,s,i,h,c){const d=this._ensureNoteMatrix(n,e),m=d.getValue(t,s);m&&(d.realDeleteValue(t,s),d.setValue(i,h,m),this._change$.next({unitId:n,sheetId:e,row:t,col:s,type:"ref",newPosition:{row:i,col:h},note:m,silent:c}))}getNote(n,e,t,s){return this._ensureNoteMatrix(n,e).getValue(t,s)}getUnitNotes(n){return this._noteMatrix.get(n)}getSheetNotes(n,e){const t=this._noteMatrix.get(n);if(t)return t.get(e)}getNotes(){return this._noteMatrix}deleteUnitNotes(n){this._noteMatrix.delete(n)}}const N={id:"sheet.mutation.update-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,note:i,silent:h}=o;return r.get(g).updateNote(n,e,t,s,i,h),!0}},S={id:"sheet.mutation.remove-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,silent:i}=o;return r.get(g).removeNote(n,e,t,s,i),!0}},I={id:"sheet.mutation.toggle-note-popup",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,silent:i}=o;return r.get(g).toggleNotePopup(n,e,t,s,i),!0}},v={id:"sheet.mutation.update-note-position",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:n,sheetId:e,row:t,col:s,newPosition:i,silent:h}=o;return r.get(g).updateNotePosition(n,e,t,s,i.row,i.col,h),!0}},P={id:"sheet.command.delete-note",type:a.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(a.IUniverInstanceService),e=l.getSheetCommandTarget(n);if(!e)return!1;const s=r.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(s!=null&&s.primary))return!1;const{actualColumn:i,actualRow:h}=s.primary;return r.get(a.ICommandService).executeCommand(S.id,{unitId:e.unitId,sheetId:e.subUnitId,row:h,col:i})}},y={id:"sheet.command.toggle-note-popup",type:a.CommandType.COMMAND,handler:(r,o)=>{const n=r.get(a.IUniverInstanceService),e=l.getSheetCommandTarget(n);if(!e)return!1;const s=r.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(s!=null&&s.primary))return!1;const{actualColumn:i,actualRow:h}=s.primary;return r.get(a.ICommandService).executeCommand(I.id,{unitId:e.unitId,sheetId:e.subUnitId,row:h,col:i})}},R={id:"sheet.command.update-note",type:a.CommandType.COMMAND,handler:(r,o)=>r.get(a.ICommandService).syncExecuteCommand(N.id,o)},U="SHEET_NOTE_PLUGIN";var $=Object.getOwnPropertyDescriptor,D=(r,o,n,e)=>{for(var t=e>1?void 0:e?$(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},w=(r,o)=>(n,e)=>o(n,e,r);u.SheetsNoteResourceController=class extends a.Disposable{constructor(o,n,e){super(),this._resourceManagerService=o,this._univerInstanceService=n,this._sheetsNoteModel=e,this._initSnapshot()}_initSnapshot(){const o=e=>{const t=this._sheetsNoteModel.getUnitNotes(e);if(!t)return"";const s={};return t.forEach((i,h)=>{const c={};i.forValue((d,m,H)=>{c[d]||(c[d]={}),c[d][m]=H}),Object.keys(c).length>0&&(s[h]=c)}),JSON.stringify(s)},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:U,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:e=>o(e),parseJson:e=>n(e),onUnLoad:e=>{this._sheetsNoteModel.deleteUnitNotes(e)},onLoad:(e,t)=>{Object.entries(t).forEach(([s,i])=>{Object.entries(i).forEach(([h,c])=>{Object.entries(c).forEach(([d,m])=>{this._sheetsNoteModel.updateNote(e,s,Number(h),Number(d),m)})})})}}))}},u.SheetsNoteResourceController=D([w(0,a.IResourceManagerService),w(1,a.IUniverInstanceService),w(2,a.Inject(g))],u.SheetsNoteResourceController);const j="sheets-note.config",O={};var E=Object.getOwnPropertyDescriptor,x=(r,o,n,e)=>{for(var t=e>1?void 0:e?E(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},f=(r,o)=>(n,e)=>o(n,e,r);let M=class extends a.Disposable{constructor(o,n,e,t){super();_(this,"_disposableMap",new Map);_(this,"_watcherMap",new Map);_(this,"_handleRangeChange",(o,n,e,t,s,i,h)=>i?{redos:[{id:v.id,params:{unitId:o,sheetId:n,row:t,col:s,newPosition:{row:i.startRow,col:i.startColumn},silent:h}}],undos:[{id:v.id,params:{unitId:o,sheetId:n,row:i.startRow,col:i.startColumn,newPosition:{row:t,col:s},note:e,silent:h}}]}:{redos:[{id:S.id,params:{unitId:o,sheetId:n,row:t,col:s}}],undos:[{id:N.id,params:{unitId:o,sheetId:n,row:t,col:s,note:e}}]});this._refRangeService=o,this._sheetsNoteModel=n,this._selectionManagerService=e,this._commandService=t,this._initData(),this._initRefRange()}_getIdWithUnitId(o,n,e,t){return`${o}-${n}-${e}-${t}`}_register(o,n,e,t,s){const i={startColumn:s,endColumn:s,startRow:t,endRow:t};this._disposableMap.set(this._getIdWithUnitId(o,n,t,s),this._refRangeService.registerRefRange(i,h=>{const c=l.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(i,h,{selectionManagerService:this._selectionManagerService}),d=Array.isArray(c)?c[0]:c;return d&&d.startColumn===i.startColumn&&d.startRow===i.startRow?{undos:[],redos:[]}:this._handleRangeChange(o,n,e,t,s,d,!1)},o,n))}_watch(o,n,e,t,s){const i={startColumn:s,endColumn:s,startRow:t,endRow:t};this._watcherMap.set(this._getIdWithUnitId(o,n,t,s),this._refRangeService.watchRange(o,n,i,(h,c)=>{const{redos:d}=this._handleRangeChange(o,n,e,h.startRow,h.startColumn,c,!0);a.sequenceExecuteAsync(d,this._commandService,{onlyLocal:!0})},!0))}_unwatch(o,n,e,t){var i;const s=this._getIdWithUnitId(o,n,e,t);(i=this._watcherMap.get(s))==null||i.dispose(),this._watcherMap.delete(s)}_unregister(o,n,e,t){var i;const s=this._getIdWithUnitId(o,n,e,t);(i=this._disposableMap.get(s))==null||i.dispose(),this._disposableMap.delete(s)}_initData(){const o=this._sheetsNoteModel.getNotes();for(const[n,e]of o)for(const[t,s]of e)s.forValue((i,h,c)=>(c&&(this._register(n,t,c,i,h),this._watch(n,t,c,i,h)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(o=>{switch(o.type){case"update":{const{unitId:n,sheetId:e,row:t,col:s,note:i}=o,h=this._getIdWithUnitId(n,e,t,s);i?this._disposableMap.has(h)||(this._register(n,e,i,t,s),this._watch(n,e,i,t,s)):(this._unregister(n,e,t,s),this._unwatch(n,e,t,s));break}case"ref":{const{unitId:n,sheetId:e,row:t,col:s,newPosition:i,note:h,silent:c}=o;this._unregister(n,e,t,s),c||(this._unwatch(n,e,t,s),this._watch(n,e,h,i.row,i.col)),this._register(n,e,h,i.row,i.col);break}}}))}};M=x([f(0,a.Inject(l.RefRangeService)),f(1,a.Inject(g)),f(2,a.Inject(l.SheetsSelectionsService)),f(3,a.ICommandService)],M);var V=Object.getOwnPropertyDescriptor,A=(r,o,n,e)=>{for(var t=e>1?void 0:e?V(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},W=(r,o)=>(n,e)=>o(n,e,r);let C=class extends a.Disposable{constructor(r){super(),this._commandService=r,this._initialize()}_initialize(){[v,I,N,S,P,y,R].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))})}};C=A([W(0,a.ICommandService)],C);var L=Object.defineProperty,J=Object.getOwnPropertyDescriptor,q=(r,o,n)=>o in r?L(r,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[o]=n,G=(r,o,n,e)=>{for(var t=e>1?void 0:e?J(o,n):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(t=i(t)||t);return t},T=(r,o)=>(n,e)=>o(n,e,r),b=(r,o,n)=>q(r,typeof o!="symbol"?o+"":o,n);u.UniverSheetsNotePlugin=class extends a.Plugin{constructor(o=O,n,e){super(),this._config=o,this._configService=n,this._injector=e;const{...t}=a.merge({},O,this._config);this._configService.setConfig(j,t)}onStarting(){[[g],[C],[u.SheetsNoteResourceController],[M]].forEach(o=>{this._injector.add(o)}),a.touchDependencies(this._injector,[[g],[C],[u.SheetsNoteResourceController]])}onReady(){a.touchDependencies(this._injector,[[M]])}},b(u.UniverSheetsNotePlugin,"pluginName",U),b(u.UniverSheetsNotePlugin,"type",a.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNotePlugin=G([a.DependentOn(l.UniverSheetsPlugin),T(1,a.IConfigService),T(2,a.Inject(a.Injector))],u.UniverSheetsNotePlugin),u.RemoveNoteMutation=S,u.SheetDeleteNoteCommand=P,u.SheetToggleNotePopupCommand=y,u.SheetUpdateNoteCommand=R,u.SheetsNoteModel=g,u.ToggleNotePopupMutation=I,u.UpdateNoteMutation=N,u.UpdateNotePositionMutation=v,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(d,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","rxjs"],r):(d=typeof globalThis<"u"?globalThis:d||self,r(d.UniverSheetsNote={},d.UniverCore,d.UniverSheets,d.rxjs))})(this,(function(d,r,l,v){"use strict";var F=Object.defineProperty;var K=(d,r,l)=>r in d?F(d,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):d[r]=l;var m=(d,r,l)=>K(d,typeof r!="symbol"?r+"":r,l);class p extends r.Disposable{constructor(){super(...arguments);m(this,"_noteMatrix",new Map);m(this,"_change$",new v.Subject);m(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(s,t){let e=this._noteMatrix.get(s);e||(e=new Map,this._noteMatrix.set(s,e));let n=e.get(t);return n||(n=new r.ObjectMatrix,e.set(t,n)),n}getSheetShowNotes$(s,t){return this._change$.pipe(v.filter(({unitId:e,sheetId:n})=>e===s&&n===t),v.map(()=>{const e=this._ensureNoteMatrix(s,t),n=[];return e.forValue((i,h,c)=>{c.show&&n.push({loc:{row:i,col:h,unitId:s,subUnitId:t},note:c})}),n}))}getCellNoteChange$(s,t,e,n){return this._change$.pipe(v.filter(({unitId:i,sheetId:h,row:c,col:u})=>i===s&&h===t&&c===e&&u===n),v.map(({note:i})=>i))}updateNote(s,t,e,n,i,h){const c=this._ensureNoteMatrix(s,t),u=c.getValue(e,n);c.setValue(e,n,i),this._change$.next({unitId:s,sheetId:t,row:e,col:n,type:"update",note:i,oldNote:u,silent:h})}removeNote(s,t,e,n,i){const h=this._ensureNoteMatrix(s,t),c=h.getValue(e,n);h.realDeleteValue(e,n),this._change$.next({unitId:s,sheetId:t,row:e,col:n,type:"update",note:null,oldNote:c,silent:i})}toggleNotePopup(s,t,e,n,i){const h=this._ensureNoteMatrix(s,t),c=h.getValue(e,n);if(c){c.show=!c.show;const u={...c,show:c.show};h.setValue(e,n,u),this._change$.next({unitId:s,sheetId:t,row:e,col:n,type:"update",note:u,oldNote:c,silent:i})}}updateNotePosition(s,t,e,n,i,h,c){const u=this._ensureNoteMatrix(s,t),g=u.getValue(e,n);g&&(u.realDeleteValue(e,n),u.setValue(i,h,g),this._change$.next({unitId:s,sheetId:t,row:e,col:n,type:"ref",newPosition:{row:i,col:h},note:g,silent:c}))}getNote(s,t,e,n){return this._ensureNoteMatrix(s,t).getValue(e,n)}getUnitNotes(s){return this._noteMatrix.get(s)}getSheetNotes(s,t){const e=this._noteMatrix.get(s);if(e)return e.get(t)}getNotes(){return this._noteMatrix}deleteUnitNotes(s){this._noteMatrix.delete(s)}}const _={id:"sheet.mutation.update-note",type:r.CommandType.MUTATION,handler:(a,o)=>{const{unitId:s,sheetId:t,row:e,col:n,note:i,silent:h}=o;return a.get(p).updateNote(s,t,e,n,i,h),!0}},S={id:"sheet.mutation.remove-note",type:r.CommandType.MUTATION,handler:(a,o)=>{const{unitId:s,sheetId:t,row:e,col:n,silent:i}=o;return a.get(p).removeNote(s,t,e,n,i),!0}},y={id:"sheet.mutation.toggle-note-popup",type:r.CommandType.MUTATION,handler:(a,o)=>{const{unitId:s,sheetId:t,row:e,col:n,silent:i}=o;return a.get(p).toggleNotePopup(s,t,e,n,i),!0}},f={id:"sheet.mutation.update-note-position",type:r.CommandType.MUTATION,handler:(a,o)=>{const{unitId:s,sheetId:t,row:e,col:n,newPosition:i,silent:h}=o;return a.get(p).updateNotePosition(s,t,e,n,i.row,i.col,h),!0}},R={id:"sheet.command.delete-note",type:r.CommandType.COMMAND,handler:(a,o)=>{const s=a.get(r.IUniverInstanceService),t=l.getSheetCommandTarget(s);if(!t)return!1;const n=a.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const{actualColumn:i,actualRow:h}=n.primary;return a.get(r.ICommandService).executeCommand(S.id,{unitId:t.unitId,sheetId:t.subUnitId,row:h,col:i})}},P={id:"sheet.command.toggle-note-popup",type:r.CommandType.COMMAND,handler:(a,o)=>{const s=a.get(r.IUniverInstanceService),t=l.getSheetCommandTarget(s);if(!t)return!1;const n=a.get(l.SheetsSelectionsService).getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const{actualColumn:i,actualRow:h}=n.primary;return a.get(r.ICommandService).executeCommand(y.id,{unitId:t.unitId,sheetId:t.subUnitId,row:h,col:i})}},w={id:"sheet.command.update-note",type:r.CommandType.COMMAND,handler:(a,o)=>a.get(r.ICommandService).syncExecuteCommand(_.id,o)},T="SHEET_NOTE_PLUGIN";var $=Object.getOwnPropertyDescriptor,j=(a,o,s,t)=>{for(var e=t>1?void 0:t?$(o,s):o,n=a.length-1,i;n>=0;n--)(i=a[n])&&(e=i(e)||e);return e},M=(a,o)=>(s,t)=>o(s,t,a);d.SheetsNoteResourceController=class extends r.Disposable{constructor(o,s,t,e){super(),this._resourceManagerService=o,this._univerInstanceService=s,this._sheetInterceptorService=t,this._sheetsNoteModel=e,this._initSnapshot(),this._initSheetChange()}_initSnapshot(){const o=t=>{const e=this._sheetsNoteModel.getUnitNotes(t);if(!e)return"";const n={};return e.forEach((i,h)=>{const c={};i.forValue((u,g,N)=>{c[u]||(c[u]={}),c[u][g]=N}),Object.keys(c).length>0&&(n[h]=c)}),JSON.stringify(n)},s=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:T,businesses:[r.UniverInstanceType.UNIVER_SHEET],toJson:t=>o(t),parseJson:t=>s(t),onUnLoad:t=>{this._sheetsNoteModel.deleteUnitNotes(t)},onLoad:(t,e)=>{Object.entries(e).forEach(([n,i])=>{Object.entries(i).forEach(([h,c])=>{Object.entries(c).forEach(([u,g])=>{this._sheetsNoteModel.updateNote(t,n,Number(h),Number(u),g)})})})}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var s;if(o.id===l.RemoveSheetCommand.id){const t=o.params,e=t.unitId||this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET).getUnitId(),n=t.subUnitId||((s=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:s.getSheetId());if(!e||!n)return{redos:[],undos:[]};const i=this._sheetsNoteModel.getSheetNotes(e,n);if(!i)return{redos:[],undos:[]};const h=[],c=[];return i.forValue((u,g,N)=>{h.push({id:S.id,params:{unitId:e,sheetId:n,row:u,col:g}}),c.push({id:_.id,params:{unitId:e,sheetId:n,row:u,col:g,note:N}})}),{redos:h,undos:c}}else if(o.id===l.CopySheetCommand.id){const t=o.params,{unitId:e,subUnitId:n,targetSubUnitId:i}=t;if(!e||!n||!i)return{redos:[],undos:[]};const h=this._sheetsNoteModel.getSheetNotes(e,n);if(!h)return{redos:[],undos:[]};const c=[],u=[];return h.forValue((g,N,z)=>{c.push({id:_.id,params:{unitId:e,sheetId:i,row:g,col:N,note:z}}),u.push({id:S.id,params:{unitId:e,sheetId:i,row:g,col:N}})}),{redos:c,undos:u}}return{redos:[],undos:[]}}}))}},d.SheetsNoteResourceController=j([M(0,r.IResourceManagerService),M(1,r.IUniverInstanceService),M(2,r.Inject(l.SheetInterceptorService)),M(3,r.Inject(p))],d.SheetsNoteResourceController);const D="sheets-note.config",O={};var x=Object.getOwnPropertyDescriptor,V=(a,o,s,t)=>{for(var e=t>1?void 0:t?x(o,s):o,n=a.length-1,i;n>=0;n--)(i=a[n])&&(e=i(e)||e);return e},C=(a,o)=>(s,t)=>o(s,t,a);let I=class extends r.Disposable{constructor(o,s,t,e){super();m(this,"_disposableMap",new Map);m(this,"_watcherMap",new Map);m(this,"_handleRangeChange",(o,s,t,e,n,i,h)=>i?{redos:[{id:f.id,params:{unitId:o,sheetId:s,row:e,col:n,newPosition:{row:i.startRow,col:i.startColumn},silent:h}}],undos:[{id:f.id,params:{unitId:o,sheetId:s,row:i.startRow,col:i.startColumn,newPosition:{row:e,col:n},note:t,silent:h}}]}:{redos:[{id:S.id,params:{unitId:o,sheetId:s,row:e,col:n}}],undos:[{id:_.id,params:{unitId:o,sheetId:s,row:e,col:n,note:t}}]});this._refRangeService=o,this._sheetsNoteModel=s,this._selectionManagerService=t,this._commandService=e,this._initData(),this._initRefRange()}_getIdWithUnitId(o,s,t,e){return`${o}-${s}-${t}-${e}`}_register(o,s,t,e,n){const i={startColumn:n,endColumn:n,startRow:e,endRow:e};this._disposableMap.set(this._getIdWithUnitId(o,s,e,n),this._refRangeService.registerRefRange(i,h=>{const c=l.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(i,h,{selectionManagerService:this._selectionManagerService}),u=Array.isArray(c)?c[0]:c;return u&&u.startColumn===i.startColumn&&u.startRow===i.startRow?{undos:[],redos:[]}:this._handleRangeChange(o,s,t,e,n,u,!1)},o,s))}_watch(o,s,t,e,n){const i={startColumn:n,endColumn:n,startRow:e,endRow:e};this._watcherMap.set(this._getIdWithUnitId(o,s,e,n),this._refRangeService.watchRange(o,s,i,(h,c)=>{const{redos:u}=this._handleRangeChange(o,s,t,h.startRow,h.startColumn,c,!0);r.sequenceExecuteAsync(u,this._commandService,{onlyLocal:!0})},!0))}_unwatch(o,s,t,e){var i;const n=this._getIdWithUnitId(o,s,t,e);(i=this._watcherMap.get(n))==null||i.dispose(),this._watcherMap.delete(n)}_unregister(o,s,t,e){var i;const n=this._getIdWithUnitId(o,s,t,e);(i=this._disposableMap.get(n))==null||i.dispose(),this._disposableMap.delete(n)}_initData(){const o=this._sheetsNoteModel.getNotes();for(const[s,t]of o)for(const[e,n]of t)n.forValue((i,h,c)=>(c&&(this._register(s,e,c,i,h),this._watch(s,e,c,i,h)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(o=>{switch(o.type){case"update":{const{unitId:s,sheetId:t,row:e,col:n,note:i}=o,h=this._getIdWithUnitId(s,t,e,n);i?this._disposableMap.has(h)||(this._register(s,t,i,e,n),this._watch(s,t,i,e,n)):(this._unregister(s,t,e,n),this._unwatch(s,t,e,n));break}case"ref":{const{unitId:s,sheetId:t,row:e,col:n,newPosition:i,note:h,silent:c}=o;this._unregister(s,t,e,n),c||(this._unwatch(s,t,e,n),this._watch(s,t,h,i.row,i.col)),this._register(s,t,h,i.row,i.col);break}}}))}};I=V([C(0,r.Inject(l.RefRangeService)),C(1,r.Inject(p)),C(2,r.Inject(l.SheetsSelectionsService)),C(3,r.ICommandService)],I);var A=Object.getOwnPropertyDescriptor,W=(a,o,s,t)=>{for(var e=t>1?void 0:t?A(o,s):o,n=a.length-1,i;n>=0;n--)(i=a[n])&&(e=i(e)||e);return e},L=(a,o)=>(s,t)=>o(s,t,a);let U=class extends r.Disposable{constructor(a){super(),this._commandService=a,this._initialize()}_initialize(){[f,y,_,S,R,P,w].forEach(a=>{this.disposeWithMe(this._commandService.registerCommand(a))})}};U=W([L(0,r.ICommandService)],U);var H=Object.defineProperty,J=Object.getOwnPropertyDescriptor,q=(a,o,s)=>o in a?H(a,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[o]=s,G=(a,o,s,t)=>{for(var e=t>1?void 0:t?J(o,s):o,n=a.length-1,i;n>=0;n--)(i=a[n])&&(e=i(e)||e);return e},b=(a,o)=>(s,t)=>o(s,t,a),E=(a,o,s)=>q(a,typeof o!="symbol"?o+"":o,s);d.UniverSheetsNotePlugin=class extends r.Plugin{constructor(o=O,s,t){super(),this._config=o,this._configService=s,this._injector=t;const{...e}=r.merge({},O,this._config);this._configService.setConfig(D,e)}onStarting(){[[p],[U],[d.SheetsNoteResourceController],[I]].forEach(o=>{this._injector.add(o)}),r.touchDependencies(this._injector,[[p],[U],[d.SheetsNoteResourceController]])}onReady(){r.touchDependencies(this._injector,[[I]])}},E(d.UniverSheetsNotePlugin,"pluginName",T),E(d.UniverSheetsNotePlugin,"type",r.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsNotePlugin=G([r.DependentOn(l.UniverSheetsPlugin),b(1,r.IConfigService),b(2,r.Inject(r.Injector))],d.UniverSheetsNotePlugin),d.RemoveNoteMutation=S,d.SheetDeleteNoteCommand=R,d.SheetToggleNotePopupCommand=P,d.SheetUpdateNoteCommand=w,d.SheetsNoteModel=p,d.ToggleNotePopupMutation=y,d.UpdateNoteMutation=_,d.UpdateNotePositionMutation=f,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-note",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer sheets note base plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -56,15 +56,15 @@
|
|
|
56
56
|
"rxjs": ">=7.0.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@univerjs/core": "0.10.
|
|
60
|
-
"@univerjs/sheets": "0.10.
|
|
59
|
+
"@univerjs/core": "0.10.13",
|
|
60
|
+
"@univerjs/sheets": "0.10.13"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"rxjs": "^7.8.2",
|
|
64
64
|
"typescript": "^5.9.3",
|
|
65
65
|
"vite": "^7.1.10",
|
|
66
66
|
"vitest": "^3.2.4",
|
|
67
|
-
"@univerjs-infra/shared": "0.10.
|
|
67
|
+
"@univerjs-infra/shared": "0.10.13"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"test": "vitest run",
|