@univerjs/sheets-note 0.7.0-nightly.202505061607 → 0.7.0-nightly.202505071607
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 +1 -2
- package/lib/index.js +1 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/plugin.d.ts +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +3 -3
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var b=Object.defineProperty;var T=(i,o,e)=>o in i?b(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e;var g=(i,o,e)=>T(i,typeof o!="symbol"?o+"":o,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@univerjs/core"),p=require("@univerjs/sheets"),m=require("rxjs");class l extends h.Disposable{constructor(){super(...arguments);g(this,"_noteMatrix",new Map);g(this,"_change$",new m.Subject);g(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(e,t){let s=this._noteMatrix.get(e);s||(s=new Map,this._noteMatrix.set(e,s));let n=s.get(t);return n||(n=new h.ObjectMatrix,s.set(t,n)),n}getSheetShowNotes$(e,t){return this._change$.pipe(m.filter(({unitId:s,sheetId:n})=>s===e&&n===t),m.map(()=>{const s=this._ensureNoteMatrix(e,t),n=[];return s.forValue((r,a,c)=>{c.show&&n.push({loc:{row:r,col:a,unitId:e,subUnitId:t},note:c})}),n}))}getCellNoteChange$(e,t,s,n){return this._change$.pipe(m.filter(({unitId:r,sheetId:a,row:c,col:u})=>r===e&&a===t&&c===s&&u===n),m.map(({note:r})=>r))}updateNote(e,t,s,n,r,a){const c=this._ensureNoteMatrix(e,t),u=c.getValue(s,n);c.setValue(s,n,r),this._change$.next({unitId:e,sheetId:t,row:s,col:n,type:"update",note:r,oldNote:u,silent:a})}removeNote(e,t,s,n,r){const a=this._ensureNoteMatrix(e,t),c=a.getValue(s,n);a.realDeleteValue(s,n),this._change$.next({unitId:e,sheetId:t,row:s,col:n,type:"update",note:null,oldNote:c,silent:r})}toggleNotePopup(e,t,s,n,r){const a=this._ensureNoteMatrix(e,t),c=a.getValue(s,n);if(c){c.show=!c.show;const u={...c,show:c.show};a.setValue(s,n,u),this._change$.next({unitId:e,sheetId:t,row:s,col:n,type:"update",note:u,oldNote:c,silent:r})}}updateNotePosition(e,t,s,n,r,a,c){const u=this._ensureNoteMatrix(e,t),d=u.getValue(s,n);d&&(u.realDeleteValue(s,n),u.setValue(r,a,d),this._change$.next({unitId:e,sheetId:t,row:s,col:n,type:"ref",newPosition:{row:r,col:a},note:d,silent:c}))}getNote(e,t,s,n){return this._ensureNoteMatrix(e,t).getValue(s,n)}getUnitNotes(e){return this._noteMatrix.get(e)}getSheetNotes(e,t){const s=this._noteMatrix.get(e);if(s)return s.get(t)}getNotes(){return this._noteMatrix}deleteUnitNotes(e){this._noteMatrix.delete(e)}}const M={id:"sheet.mutation.update-note",type:h.CommandType.MUTATION,handler:(i,o)=>{const{unitId:e,sheetId:t,row:s,col:n,note:r,silent:a}=o;return i.get(l).updateNote(e,t,s,n,r,a),!0}},f={id:"sheet.mutation.remove-note",type:h.CommandType.MUTATION,handler:(i,o)=>{const{unitId:e,sheetId:t,row:s,col:n,silent:r}=o;return i.get(l).removeNote(e,t,s,n,r),!0}},I={id:"sheet.mutation.toggle-note-popup",type:h.CommandType.MUTATION,handler:(i,o)=>{const{unitId:e,sheetId:t,row:s,col:n,silent:r}=o;return i.get(l).toggleNotePopup(e,t,s,n,r),!0}},N={id:"sheet.mutation.update-note-position",type:h.CommandType.MUTATION,handler:(i,o)=>{const{unitId:e,sheetId:t,row:s,col:n,newPosition:r,silent:a}=o;return i.get(l).updateNotePosition(e,t,s,n,r.row,r.col,a),!0}};var $=Object.getOwnPropertyDescriptor,D=(i,o,e,t)=>{for(var s=t>1?void 0:t?$(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},_=(i,o)=>(e,t)=>o(e,t,i);let S=class extends h.Disposable{constructor(o,e,t,s){super();g(this,"_disposableMap",new Map);g(this,"_watcherMap",new Map);g(this,"_handleRangeChange",(o,e,t,s,n,r,a)=>r?{redos:[{id:N.id,params:{unitId:o,sheetId:e,row:s,col:n,newPosition:{row:r.startRow,col:r.startColumn},silent:a}}],undos:[{id:N.id,params:{unitId:o,sheetId:e,row:r.startRow,col:r.startColumn,newPosition:{row:s,col:n},note:t,silent:a}}]}:{redos:[{id:f.id,params:{unitId:o,sheetId:e,row:s,col:n}}],undos:[{id:M.id,params:{unitId:o,sheetId:e,row:s,col:n,note:t}}]});this._refRangeService=o,this._sheetsNoteModel=e,this._selectionManagerService=t,this._commandService=s,this._initData(),this._initRefRange()}_getIdWithUnitId(o,e,t,s){return`${o}-${e}-${t}-${s}`}_register(o,e,t,s,n){const r={startColumn:n,endColumn:n,startRow:s,endRow:s};this._disposableMap.set(this._getIdWithUnitId(o,e,s,n),this._refRangeService.registerRefRange(r,a=>{const c=p.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(r,a,{selectionManagerService:this._selectionManagerService}),u=Array.isArray(c)?c[0]:c;return u&&u.startColumn===r.startColumn&&u.startRow===r.startRow?{undos:[],redos:[]}:this._handleRangeChange(o,e,t,s,n,u,!1)},o,e))}_watch(o,e,t,s,n){const r={startColumn:n,endColumn:n,startRow:s,endRow:s};this._watcherMap.set(this._getIdWithUnitId(o,e,s,n),this._refRangeService.watchRange(o,e,r,(a,c)=>{const{redos:u}=this._handleRangeChange(o,e,t,a.startRow,a.startColumn,c,!0);h.sequenceExecuteAsync(u,this._commandService,{onlyLocal:!0})},!0))}_unwatch(o,e,t,s){var r;const n=this._getIdWithUnitId(o,e,t,s);(r=this._watcherMap.get(n))==null||r.dispose(),this._watcherMap.delete(n)}_unregister(o,e,t,s){var r;const n=this._getIdWithUnitId(o,e,t,s);(r=this._disposableMap.get(n))==null||r.dispose(),this._disposableMap.delete(n)}_initData(){const o=this._sheetsNoteModel.getNotes();for(const[e,t]of o)for(const[s,n]of t)n.forValue((r,a,c)=>(c&&(this._register(e,s,c,r,a),this._watch(e,s,c,r,a)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(o=>{switch(o.type){case"update":{const{unitId:e,sheetId:t,row:s,col:n,note:r}=o,a=this._getIdWithUnitId(e,t,s,n);r?this._disposableMap.has(a)||(this._register(e,t,r,s,n),this._watch(e,t,r,s,n)):(this._unregister(e,t,s,n),this._unwatch(e,t,s,n));break}case"ref":{const{unitId:e,sheetId:t,row:s,col:n,newPosition:r,note:a,silent:c}=o;this._unregister(e,t,s,n),c||(this._unwatch(e,t,s,n),this._watch(e,t,a,r.row,r.col)),this._register(e,t,a,r.row,r.col);break}}}))}};S=D([_(0,h.Inject(p.RefRangeService)),_(1,h.Inject(l)),_(2,h.Inject(p.SheetsSelectionsService)),_(3,h.ICommandService)],S);var j=Object.getOwnPropertyDescriptor,E=(i,o,e,t)=>{for(var s=t>1?void 0:t?j(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},C=(i,o)=>(e,t)=>o(e,t,i);exports.SheetsNoteResourceController=class extends h.Disposable{constructor(o,e,t){super(),this._resourceManagerService=o,this._univerInstanceService=e,this._sheetsNoteModel=t,this._initSnapshot()}_initSnapshot(){const o=t=>{const s=this._sheetsNoteModel.getUnitNotes(t);if(!s)return"";const n={};return s.forEach((r,a)=>{const c={};r.forValue((u,d,O)=>{c[u]||(c[u]={}),c[u][d]=O}),Object.keys(c).length>0&&(n[a]=c)}),JSON.stringify(n)},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:U,businesses:[h.UniverInstanceType.UNIVER_SHEET],toJson:t=>o(t),parseJson:t=>e(t),onUnLoad:t=>{this._sheetsNoteModel.deleteUnitNotes(t)},onLoad:(t,s)=>{Object.entries(s).forEach(([n,r])=>{Object.entries(r).forEach(([a,c])=>{Object.entries(c).forEach(([u,d])=>{this._sheetsNoteModel.updateNote(t,n,Number(a),Number(u),d)})})})}}))}};exports.SheetsNoteResourceController=E([C(0,h.IResourceManagerService),C(1,h.IUniverInstanceService),C(2,h.Inject(l))],exports.SheetsNoteResourceController);const P={id:"sheet.command.delete-note",type:h.CommandType.COMMAND,handler:(i,o)=>{const e=i.get(h.IUniverInstanceService),t=p.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(p.SheetsSelectionsService).getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const{actualColumn:r,actualRow:a}=n.primary;return i.get(h.ICommandService).executeCommand(f.id,{unitId:t.unitId,sheetId:t.subUnitId,row:a,col:r})}},R={id:"sheet.command.toggle-note-popup",type:h.CommandType.COMMAND,handler:(i,o)=>{const e=i.get(h.IUniverInstanceService),t=p.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(p.SheetsSelectionsService).getCurrentLastSelection();if(!(n!=null&&n.primary))return!1;const{actualColumn:r,actualRow:a}=n.primary;return i.get(h.ICommandService).executeCommand(I.id,{unitId:t.unitId,sheetId:t.subUnitId,row:a,col:r})}},y={id:"sheet.command.update-note",type:h.CommandType.COMMAND,handler:(i,o)=>i.get(h.ICommandService).syncExecuteCommand(M.id,o)};var V=Object.getOwnPropertyDescriptor,A=(i,o,e,t)=>{for(var s=t>1?void 0:t?V(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},W=(i,o)=>(e,t)=>o(e,t,i);let v=class extends h.Disposable{constructor(i){super(),this._commandService=i,this._initialize()}_initialize(){[N,I,M,f,P,R,y].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}};v=A([W(0,h.ICommandService)],v);var L=Object.defineProperty,J=Object.getOwnPropertyDescriptor,q=(i,o,e)=>o in i?L(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e,H=(i,o,e,t)=>{for(var s=t>1?void 0:t?J(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},w=(i,o)=>(e,t)=>o(e,t,i),x=(i,o,e)=>q(i,typeof o!="symbol"?o+"":o,e);const U="SHEET_NOTE_PLUGIN";exports.UniverSheetsNotePlugin=class extends h.Plugin{constructor(o,e){super(),this._configService=o,this._injector=e}onStarting(){[[l],[v],[exports.SheetsNoteResourceController],[S]].forEach(o=>{this._injector.add(o)}),h.touchDependencies(this._injector,[[l],[v],[exports.SheetsNoteResourceController]])}onReady(){h.touchDependencies(this._injector,[[S]])}};x(exports.UniverSheetsNotePlugin,"pluginName",U);x(exports.UniverSheetsNotePlugin,"type",h.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNotePlugin=H([h.DependentOn(p.UniverSheetsPlugin),w(0,h.IConfigService),w(1,h.Inject(h.Injector))],exports.UniverSheetsNotePlugin);exports.RemoveNoteMutation=f;exports.SheetDeleteNoteCommand=P;exports.SheetToggleNotePopupCommand=R;exports.SheetUpdateNoteCommand=y;exports.SheetsNoteModel=l;exports.ToggleNotePopupMutation=I;exports.UpdateNoteMutation=M;exports.UpdateNotePositionMutation=N;
|
package/lib/es/index.js
CHANGED
|
@@ -425,15 +425,14 @@ v = he([
|
|
|
425
425
|
b(1, _(G))
|
|
426
426
|
], v);
|
|
427
427
|
export {
|
|
428
|
-
V as PLUGIN_NAME,
|
|
429
428
|
P as RemoveNoteMutation,
|
|
430
429
|
ee as SheetDeleteNoteCommand,
|
|
431
430
|
te as SheetToggleNotePopupCommand,
|
|
432
431
|
se as SheetUpdateNoteCommand,
|
|
433
432
|
u as SheetsNoteModel,
|
|
434
|
-
v as SheetsNotePlugin,
|
|
435
433
|
M as SheetsNoteResourceController,
|
|
436
434
|
E as ToggleNotePopupMutation,
|
|
435
|
+
v as UniverSheetsNotePlugin,
|
|
437
436
|
I as UpdateNoteMutation,
|
|
438
437
|
C as UpdateNotePositionMutation
|
|
439
438
|
};
|
package/lib/index.js
CHANGED
|
@@ -425,15 +425,14 @@ v = he([
|
|
|
425
425
|
b(1, _(G))
|
|
426
426
|
], v);
|
|
427
427
|
export {
|
|
428
|
-
V as PLUGIN_NAME,
|
|
429
428
|
P as RemoveNoteMutation,
|
|
430
429
|
ee as SheetDeleteNoteCommand,
|
|
431
430
|
te as SheetToggleNotePopupCommand,
|
|
432
431
|
se as SheetUpdateNoteCommand,
|
|
433
432
|
u as SheetsNoteModel,
|
|
434
|
-
v as SheetsNotePlugin,
|
|
435
433
|
M as SheetsNoteResourceController,
|
|
436
434
|
E as ToggleNotePopupMutation,
|
|
435
|
+
v as UniverSheetsNotePlugin,
|
|
437
436
|
I as UpdateNoteMutation,
|
|
438
437
|
C as UpdateNotePositionMutation
|
|
439
438
|
};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export { UniverSheetsNotePlugin } from './plugin';
|
|
17
17
|
export * from './models/sheets-note.model';
|
|
18
18
|
export * from './controllers/sheets-note-resource.controller';
|
|
19
19
|
export * from './commands/mutations/note.mutation';
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
2
2
|
export declare const PLUGIN_NAME = "SHEET_NOTE_PLUGIN";
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class UniverSheetsNotePlugin extends Plugin {
|
|
4
4
|
private readonly _configService;
|
|
5
5
|
protected readonly _injector: Injector;
|
|
6
6
|
static pluginName: string;
|
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,_){"use strict";var
|
|
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,_){"use strict";var H=Object.defineProperty;var z=(u,a,l)=>a in u?H(u,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[a]=l;var p=(u,a,l)=>z(u,typeof a!="symbol"?a+"":a,l);class m extends a.Disposable{constructor(){super(...arguments);p(this,"_noteMatrix",new Map);p(this,"_change$",new _.Subject);p(this,"change$",this._change$.asObservable())}_ensureNoteMatrix(e,t){let n=this._noteMatrix.get(e);n||(n=new Map,this._noteMatrix.set(e,n));let s=n.get(t);return s||(s=new a.ObjectMatrix,n.set(t,s)),s}getSheetShowNotes$(e,t){return this._change$.pipe(_.filter(({unitId:n,sheetId:s})=>n===e&&s===t),_.map(()=>{const n=this._ensureNoteMatrix(e,t),s=[];return n.forValue((i,h,c)=>{c.show&&s.push({loc:{row:i,col:h,unitId:e,subUnitId:t},note:c})}),s}))}getCellNoteChange$(e,t,n,s){return this._change$.pipe(_.filter(({unitId:i,sheetId:h,row:c,col:d})=>i===e&&h===t&&c===n&&d===s),_.map(({note:i})=>i))}updateNote(e,t,n,s,i,h){const c=this._ensureNoteMatrix(e,t),d=c.getValue(n,s);c.setValue(n,s,i),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"update",note:i,oldNote:d,silent:h})}removeNote(e,t,n,s,i){const h=this._ensureNoteMatrix(e,t),c=h.getValue(n,s);h.realDeleteValue(n,s),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"update",note:null,oldNote:c,silent:i})}toggleNotePopup(e,t,n,s,i){const h=this._ensureNoteMatrix(e,t),c=h.getValue(n,s);if(c){c.show=!c.show;const d={...c,show:c.show};h.setValue(n,s,d),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"update",note:d,oldNote:c,silent:i})}}updateNotePosition(e,t,n,s,i,h,c){const d=this._ensureNoteMatrix(e,t),g=d.getValue(n,s);g&&(d.realDeleteValue(n,s),d.setValue(i,h,g),this._change$.next({unitId:e,sheetId:t,row:n,col:s,type:"ref",newPosition:{row:i,col:h},note:g,silent:c}))}getNote(e,t,n,s){return this._ensureNoteMatrix(e,t).getValue(n,s)}getUnitNotes(e){return this._noteMatrix.get(e)}getSheetNotes(e,t){const n=this._noteMatrix.get(e);if(n)return n.get(t)}getNotes(){return this._noteMatrix}deleteUnitNotes(e){this._noteMatrix.delete(e)}}const N={id:"sheet.mutation.update-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:e,sheetId:t,row:n,col:s,note:i,silent:h}=o;return r.get(m).updateNote(e,t,n,s,i,h),!0}},v={id:"sheet.mutation.remove-note",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:e,sheetId:t,row:n,col:s,silent:i}=o;return r.get(m).removeNote(e,t,n,s,i),!0}},I={id:"sheet.mutation.toggle-note-popup",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:e,sheetId:t,row:n,col:s,silent:i}=o;return r.get(m).toggleNotePopup(e,t,n,s,i),!0}},S={id:"sheet.mutation.update-note-position",type:a.CommandType.MUTATION,handler:(r,o)=>{const{unitId:e,sheetId:t,row:n,col:s,newPosition:i,silent:h}=o;return r.get(m).updateNotePosition(e,t,n,s,i.row,i.col,h),!0}};var b=Object.getOwnPropertyDescriptor,$=(r,o,e,t)=>{for(var n=t>1?void 0:t?b(o,e):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(n=i(n)||n);return n},f=(r,o)=>(e,t)=>o(e,t,r);let M=class extends a.Disposable{constructor(o,e,t,n){super();p(this,"_disposableMap",new Map);p(this,"_watcherMap",new Map);p(this,"_handleRangeChange",(o,e,t,n,s,i,h)=>i?{redos:[{id:S.id,params:{unitId:o,sheetId:e,row:n,col:s,newPosition:{row:i.startRow,col:i.startColumn},silent:h}}],undos:[{id:S.id,params:{unitId:o,sheetId:e,row:i.startRow,col:i.startColumn,newPosition:{row:n,col:s},note:t,silent:h}}]}:{redos:[{id:v.id,params:{unitId:o,sheetId:e,row:n,col:s}}],undos:[{id:N.id,params:{unitId:o,sheetId:e,row:n,col:s,note:t}}]});this._refRangeService=o,this._sheetsNoteModel=e,this._selectionManagerService=t,this._commandService=n,this._initData(),this._initRefRange()}_getIdWithUnitId(o,e,t,n){return`${o}-${e}-${t}-${n}`}_register(o,e,t,n,s){const i={startColumn:s,endColumn:s,startRow:n,endRow:n};this._disposableMap.set(this._getIdWithUnitId(o,e,n,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,e,t,n,s,d,!1)},o,e))}_watch(o,e,t,n,s){const i={startColumn:s,endColumn:s,startRow:n,endRow:n};this._watcherMap.set(this._getIdWithUnitId(o,e,n,s),this._refRangeService.watchRange(o,e,i,(h,c)=>{const{redos:d}=this._handleRangeChange(o,e,t,h.startRow,h.startColumn,c,!0);a.sequenceExecuteAsync(d,this._commandService,{onlyLocal:!0})},!0))}_unwatch(o,e,t,n){var i;const s=this._getIdWithUnitId(o,e,t,n);(i=this._watcherMap.get(s))==null||i.dispose(),this._watcherMap.delete(s)}_unregister(o,e,t,n){var i;const s=this._getIdWithUnitId(o,e,t,n);(i=this._disposableMap.get(s))==null||i.dispose(),this._disposableMap.delete(s)}_initData(){const o=this._sheetsNoteModel.getNotes();for(const[e,t]of o)for(const[n,s]of t)s.forValue((i,h,c)=>(c&&(this._register(e,n,c,i,h),this._watch(e,n,c,i,h)),!0))}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(o=>{switch(o.type){case"update":{const{unitId:e,sheetId:t,row:n,col:s,note:i}=o,h=this._getIdWithUnitId(e,t,n,s);i?this._disposableMap.has(h)||(this._register(e,t,i,n,s),this._watch(e,t,i,n,s)):(this._unregister(e,t,n,s),this._unwatch(e,t,n,s));break}case"ref":{const{unitId:e,sheetId:t,row:n,col:s,newPosition:i,note:h,silent:c}=o;this._unregister(e,t,n,s),c||(this._unwatch(e,t,n,s),this._watch(e,t,h,i.row,i.col)),this._register(e,t,h,i.row,i.col);break}}}))}};M=$([f(0,a.Inject(l.RefRangeService)),f(1,a.Inject(m)),f(2,a.Inject(l.SheetsSelectionsService)),f(3,a.ICommandService)],M);var D=Object.getOwnPropertyDescriptor,j=(r,o,e,t)=>{for(var n=t>1?void 0:t?D(o,e):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(n=i(n)||n);return n},w=(r,o)=>(e,t)=>o(e,t,r);u.SheetsNoteResourceController=class extends a.Disposable{constructor(o,e,t){super(),this._resourceManagerService=o,this._univerInstanceService=e,this._sheetsNoteModel=t,this._initSnapshot()}_initSnapshot(){const o=t=>{const n=this._sheetsNoteModel.getUnitNotes(t);if(!n)return"";const s={};return n.forEach((i,h)=>{const c={};i.forValue((d,g,q)=>{c[d]||(c[d]={}),c[d][g]=q}),Object.keys(c).length>0&&(s[h]=c)}),JSON.stringify(s)},e=t=>{if(!t)return{};try{return JSON.parse(t)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:T,businesses:[a.UniverInstanceType.UNIVER_SHEET],toJson:t=>o(t),parseJson:t=>e(t),onUnLoad:t=>{this._sheetsNoteModel.deleteUnitNotes(t)},onLoad:(t,n)=>{Object.entries(n).forEach(([s,i])=>{Object.entries(i).forEach(([h,c])=>{Object.entries(c).forEach(([d,g])=>{this._sheetsNoteModel.updateNote(t,s,Number(h),Number(d),g)})})})}}))}},u.SheetsNoteResourceController=j([w(0,a.IResourceManagerService),w(1,a.IUniverInstanceService),w(2,a.Inject(m))],u.SheetsNoteResourceController);const y={id:"sheet.command.delete-note",type:a.CommandType.COMMAND,handler:(r,o)=>{const e=r.get(a.IUniverInstanceService),t=l.getSheetCommandTarget(e);if(!t)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(v.id,{unitId:t.unitId,sheetId:t.subUnitId,row:h,col:i})}},P={id:"sheet.command.toggle-note-popup",type:a.CommandType.COMMAND,handler:(r,o)=>{const e=r.get(a.IUniverInstanceService),t=l.getSheetCommandTarget(e);if(!t)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:t.unitId,sheetId:t.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)};var x=Object.getOwnPropertyDescriptor,E=(r,o,e,t)=>{for(var n=t>1?void 0:t?x(o,e):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(n=i(n)||n);return n},V=(r,o)=>(e,t)=>o(e,t,r);let C=class extends a.Disposable{constructor(r){super(),this._commandService=r,this._initialize()}_initialize(){[S,I,N,v,y,P,R].forEach(r=>{this.disposeWithMe(this._commandService.registerCommand(r))})}};C=E([V(0,a.ICommandService)],C);var A=Object.defineProperty,W=Object.getOwnPropertyDescriptor,L=(r,o,e)=>o in r?A(r,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[o]=e,J=(r,o,e,t)=>{for(var n=t>1?void 0:t?W(o,e):o,s=r.length-1,i;s>=0;s--)(i=r[s])&&(n=i(n)||n);return n},U=(r,o)=>(e,t)=>o(e,t,r),O=(r,o,e)=>L(r,typeof o!="symbol"?o+"":o,e);const T="SHEET_NOTE_PLUGIN";u.UniverSheetsNotePlugin=class extends a.Plugin{constructor(o,e){super(),this._configService=o,this._injector=e}onStarting(){[[m],[C],[u.SheetsNoteResourceController],[M]].forEach(o=>{this._injector.add(o)}),a.touchDependencies(this._injector,[[m],[C],[u.SheetsNoteResourceController]])}onReady(){a.touchDependencies(this._injector,[[M]])}},O(u.UniverSheetsNotePlugin,"pluginName",T),O(u.UniverSheetsNotePlugin,"type",a.UniverInstanceType.UNIVER_SHEET),u.UniverSheetsNotePlugin=J([a.DependentOn(l.UniverSheetsPlugin),U(0,a.IConfigService),U(1,a.Inject(a.Injector))],u.UniverSheetsNotePlugin),u.RemoveNoteMutation=v,u.SheetDeleteNoteCommand=y,u.SheetToggleNotePopupCommand=P,u.SheetUpdateNoteCommand=R,u.SheetsNoteModel=m,u.ToggleNotePopupMutation=I,u.UpdateNoteMutation=N,u.UpdateNotePositionMutation=S,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-note",
|
|
3
|
-
"version": "0.7.0-nightly.
|
|
3
|
+
"version": "0.7.0-nightly.202505071607",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer sheets note base plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"rxjs": ">=7.0.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@univerjs/core": "0.7.0-nightly.
|
|
60
|
-
"@univerjs/sheets": "0.7.0-nightly.
|
|
59
|
+
"@univerjs/core": "0.7.0-nightly.202505071607",
|
|
60
|
+
"@univerjs/sheets": "0.7.0-nightly.202505071607"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"rxjs": "^7.8.1",
|