@univerjs/sheets-note 0.7.0-nightly.202505121607 → 0.7.0-nightly.202505141607
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 +169 -163
- package/lib/index.js +169 -163
- package/lib/types/const.d.ts +16 -0
- package/lib/types/controllers/config.schema.d.ts +20 -0
- package/lib/types/plugin.d.ts +3 -2
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var b=Object.defineProperty;var
|
|
1
|
+
"use strict";var b=Object.defineProperty;var $=(i,o,e)=>o in i?b(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e;var p=(i,o,e)=>$(i,typeof o!="symbol"?o+"":o,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@univerjs/core"),g=require("@univerjs/sheets"),m=require("rxjs"),R="SHEET_NOTE_PLUGIN",D="sheets-note.config",w={};class l extends h.Disposable{constructor(){super(...arguments);p(this,"_noteMatrix",new Map);p(this,"_change$",new m.Subject);p(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 E=Object.getOwnPropertyDescriptor,j=(i,o,e,t)=>{for(var s=t>1?void 0:t?E(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();p(this,"_disposableMap",new Map);p(this,"_watcherMap",new Map);p(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=g.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=j([_(0,h.Inject(g.RefRangeService)),_(1,h.Inject(l)),_(2,h.Inject(g.SheetsSelectionsService)),_(3,h.ICommandService)],S);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},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,T)=>{c[u]||(c[u]={}),c[u][d]=T}),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:R,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=A([C(0,h.IResourceManagerService),C(1,h.IUniverInstanceService),C(2,h.Inject(l))],exports.SheetsNoteResourceController);const y={id:"sheet.command.delete-note",type:h.CommandType.COMMAND,handler:(i,o)=>{const e=i.get(h.IUniverInstanceService),t=g.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(g.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})}},x={id:"sheet.command.toggle-note-popup",type:h.CommandType.COMMAND,handler:(i,o)=>{const e=i.get(h.IUniverInstanceService),t=g.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(g.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})}},U={id:"sheet.command.update-note",type:h.CommandType.COMMAND,handler:(i,o)=>i.get(h.ICommandService).syncExecuteCommand(M.id,o)};var W=Object.getOwnPropertyDescriptor,L=(i,o,e,t)=>{for(var s=t>1?void 0:t?W(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},J=(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,y,x,U].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}};v=L([J(0,h.ICommandService)],v);var q=Object.defineProperty,G=Object.getOwnPropertyDescriptor,H=(i,o,e)=>o in i?q(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e,z=(i,o,e,t)=>{for(var s=t>1?void 0:t?G(o,e):o,n=i.length-1,r;n>=0;n--)(r=i[n])&&(s=r(s)||s);return s},P=(i,o)=>(e,t)=>o(e,t,i),O=(i,o,e)=>H(i,typeof o!="symbol"?o+"":o,e);exports.UniverSheetsNotePlugin=class extends h.Plugin{constructor(o=w,e,t){super(),this._config=o,this._configService=e,this._injector=t;const{...s}=h.merge({},w,this._config);this._configService.setConfig(D,s)}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]])}};O(exports.UniverSheetsNotePlugin,"pluginName",R);O(exports.UniverSheetsNotePlugin,"type",h.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsNotePlugin=z([h.DependentOn(g.UniverSheetsPlugin),P(1,h.IConfigService),P(2,h.Inject(h.Injector))],exports.UniverSheetsNotePlugin);exports.RemoveNoteMutation=f;exports.SheetDeleteNoteCommand=y;exports.SheetToggleNotePopupCommand=x;exports.SheetUpdateNoteCommand=U;exports.SheetsNoteModel=l;exports.ToggleNotePopupMutation=I;exports.UpdateNoteMutation=M;exports.UpdateNotePositionMutation=N;
|
package/lib/es/index.js
CHANGED
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var d = (i,
|
|
4
|
-
import { Disposable as S, ObjectMatrix as
|
|
5
|
-
import { RefRangeService as
|
|
6
|
-
import { Subject as
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var W = (i, o, e) => o in i ? A(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
|
|
3
|
+
var d = (i, o, e) => W(i, typeof o != "symbol" ? o + "" : o, e);
|
|
4
|
+
import { Disposable as S, ObjectMatrix as L, CommandType as l, Inject as g, ICommandService as p, sequenceExecuteAsync as J, IResourceManagerService as G, IUniverInstanceService as x, UniverInstanceType as U, DependentOn as H, IConfigService as z, Injector as F, Plugin as q, merge as K, touchDependencies as O } from "@univerjs/core";
|
|
5
|
+
import { RefRangeService as Y, SheetsSelectionsService as I, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as B, getSheetCommandTarget as D, UniverSheetsPlugin as Q } from "@univerjs/sheets";
|
|
6
|
+
import { Subject as X, filter as y, map as $ } from "rxjs";
|
|
7
|
+
const T = "SHEET_NOTE_PLUGIN", Z = "sheets-note.config", b = {};
|
|
7
8
|
class u extends S {
|
|
8
9
|
constructor() {
|
|
9
10
|
super(...arguments);
|
|
10
11
|
d(this, "_noteMatrix", /* @__PURE__ */ new Map());
|
|
11
|
-
d(this, "_change$", new
|
|
12
|
+
d(this, "_change$", new X());
|
|
12
13
|
d(this, "change$", this._change$.asObservable());
|
|
13
14
|
}
|
|
14
15
|
_ensureNoteMatrix(e, n) {
|
|
15
16
|
let t = this._noteMatrix.get(e);
|
|
16
17
|
t || (t = /* @__PURE__ */ new Map(), this._noteMatrix.set(e, t));
|
|
17
18
|
let s = t.get(n);
|
|
18
|
-
return s || (s = new
|
|
19
|
+
return s || (s = new L(), t.set(n, s)), s;
|
|
19
20
|
}
|
|
20
21
|
getSheetShowNotes$(e, n) {
|
|
21
22
|
return this._change$.pipe(
|
|
22
|
-
|
|
23
|
+
y(({ unitId: t, sheetId: s }) => t === e && s === n),
|
|
23
24
|
$(() => {
|
|
24
25
|
const t = this._ensureNoteMatrix(e, n), s = [];
|
|
25
|
-
return t.forValue((
|
|
26
|
-
c.show && s.push({ loc: { row:
|
|
26
|
+
return t.forValue((r, a, c) => {
|
|
27
|
+
c.show && s.push({ loc: { row: r, col: a, unitId: e, subUnitId: n }, note: c });
|
|
27
28
|
}), s;
|
|
28
29
|
})
|
|
29
30
|
);
|
|
30
31
|
}
|
|
31
32
|
getCellNoteChange$(e, n, t, s) {
|
|
32
33
|
return this._change$.pipe(
|
|
33
|
-
|
|
34
|
-
$(({ note:
|
|
34
|
+
y(({ unitId: r, sheetId: a, row: c, col: h }) => r === e && a === n && c === t && h === s),
|
|
35
|
+
$(({ note: r }) => r)
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
|
-
updateNote(e, n, t, s,
|
|
38
|
+
updateNote(e, n, t, s, r, a) {
|
|
38
39
|
const c = this._ensureNoteMatrix(e, n), h = c.getValue(t, s);
|
|
39
|
-
c.setValue(t, s,
|
|
40
|
+
c.setValue(t, s, r), this._change$.next({ unitId: e, sheetId: n, row: t, col: s, type: "update", note: r, oldNote: h, silent: a });
|
|
40
41
|
}
|
|
41
|
-
removeNote(e, n, t, s,
|
|
42
|
+
removeNote(e, n, t, s, r) {
|
|
42
43
|
const a = this._ensureNoteMatrix(e, n), c = a.getValue(t, s);
|
|
43
|
-
a.realDeleteValue(t, s), this._change$.next({ unitId: e, sheetId: n, row: t, col: s, type: "update", note: null, oldNote: c, silent:
|
|
44
|
+
a.realDeleteValue(t, s), this._change$.next({ unitId: e, sheetId: n, row: t, col: s, type: "update", note: null, oldNote: c, silent: r });
|
|
44
45
|
}
|
|
45
|
-
toggleNotePopup(e, n, t, s,
|
|
46
|
+
toggleNotePopup(e, n, t, s, r) {
|
|
46
47
|
const a = this._ensureNoteMatrix(e, n), c = a.getValue(t, s);
|
|
47
48
|
if (c) {
|
|
48
49
|
c.show = !c.show;
|
|
@@ -55,20 +56,20 @@ class u extends S {
|
|
|
55
56
|
type: "update",
|
|
56
57
|
note: h,
|
|
57
58
|
oldNote: c,
|
|
58
|
-
silent:
|
|
59
|
+
silent: r
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
|
-
updateNotePosition(e, n, t, s,
|
|
63
|
-
const h = this._ensureNoteMatrix(e, n),
|
|
64
|
-
|
|
63
|
+
updateNotePosition(e, n, t, s, r, a, c) {
|
|
64
|
+
const h = this._ensureNoteMatrix(e, n), _ = h.getValue(t, s);
|
|
65
|
+
_ && (h.realDeleteValue(t, s), h.setValue(r, a, _), this._change$.next({
|
|
65
66
|
unitId: e,
|
|
66
67
|
sheetId: n,
|
|
67
68
|
row: t,
|
|
68
69
|
col: s,
|
|
69
70
|
type: "ref",
|
|
70
|
-
newPosition: { row:
|
|
71
|
-
note:
|
|
71
|
+
newPosition: { row: r, col: a },
|
|
72
|
+
note: _,
|
|
72
73
|
silent: c
|
|
73
74
|
}));
|
|
74
75
|
}
|
|
@@ -90,56 +91,56 @@ class u extends S {
|
|
|
90
91
|
this._noteMatrix.delete(e);
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
|
-
const
|
|
94
|
+
const R = {
|
|
94
95
|
id: "sheet.mutation.update-note",
|
|
95
96
|
type: l.MUTATION,
|
|
96
|
-
handler: (i,
|
|
97
|
-
const { unitId: e, sheetId: n, row: t, col: s, note:
|
|
98
|
-
return i.get(u).updateNote(e, n, t, s,
|
|
97
|
+
handler: (i, o) => {
|
|
98
|
+
const { unitId: e, sheetId: n, row: t, col: s, note: r, silent: a } = o;
|
|
99
|
+
return i.get(u).updateNote(e, n, t, s, r, a), !0;
|
|
99
100
|
}
|
|
100
101
|
}, P = {
|
|
101
102
|
id: "sheet.mutation.remove-note",
|
|
102
103
|
type: l.MUTATION,
|
|
103
|
-
handler: (i,
|
|
104
|
-
const { unitId: e, sheetId: n, row: t, col: s, silent:
|
|
105
|
-
return i.get(u).removeNote(e, n, t, s,
|
|
104
|
+
handler: (i, o) => {
|
|
105
|
+
const { unitId: e, sheetId: n, row: t, col: s, silent: r } = o;
|
|
106
|
+
return i.get(u).removeNote(e, n, t, s, r), !0;
|
|
106
107
|
}
|
|
107
|
-
},
|
|
108
|
+
}, V = {
|
|
108
109
|
id: "sheet.mutation.toggle-note-popup",
|
|
109
110
|
type: l.MUTATION,
|
|
110
|
-
handler: (i,
|
|
111
|
-
const { unitId: e, sheetId: n, row: t, col: s, silent:
|
|
112
|
-
return i.get(u).toggleNotePopup(e, n, t, s,
|
|
111
|
+
handler: (i, o) => {
|
|
112
|
+
const { unitId: e, sheetId: n, row: t, col: s, silent: r } = o;
|
|
113
|
+
return i.get(u).toggleNotePopup(e, n, t, s, r), !0;
|
|
113
114
|
}
|
|
114
115
|
}, C = {
|
|
115
116
|
id: "sheet.mutation.update-note-position",
|
|
116
117
|
type: l.MUTATION,
|
|
117
|
-
handler: (i,
|
|
118
|
-
const { unitId: e, sheetId: n, row: t, col: s, newPosition:
|
|
119
|
-
return i.get(u).updateNotePosition(e, n, t, s,
|
|
118
|
+
handler: (i, o) => {
|
|
119
|
+
const { unitId: e, sheetId: n, row: t, col: s, newPosition: r, silent: a } = o;
|
|
120
|
+
return i.get(u).updateNotePosition(e, n, t, s, r.row, r.col, a), !0;
|
|
120
121
|
}
|
|
121
122
|
};
|
|
122
|
-
var
|
|
123
|
-
for (var t = n > 1 ? void 0 : n ?
|
|
124
|
-
(
|
|
123
|
+
var k = Object.getOwnPropertyDescriptor, ee = (i, o, e, n) => {
|
|
124
|
+
for (var t = n > 1 ? void 0 : n ? k(o, e) : o, s = i.length - 1, r; s >= 0; s--)
|
|
125
|
+
(r = i[s]) && (t = r(t) || t);
|
|
125
126
|
return t;
|
|
126
|
-
}, m = (i,
|
|
127
|
+
}, m = (i, o) => (e, n) => o(e, n, i);
|
|
127
128
|
let N = class extends S {
|
|
128
|
-
constructor(
|
|
129
|
+
constructor(o, e, n, t) {
|
|
129
130
|
super();
|
|
130
131
|
d(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
131
132
|
d(this, "_watcherMap", /* @__PURE__ */ new Map());
|
|
132
|
-
d(this, "_handleRangeChange", (
|
|
133
|
+
d(this, "_handleRangeChange", (o, e, n, t, s, r, a) => r ? {
|
|
133
134
|
redos: [{
|
|
134
135
|
id: C.id,
|
|
135
136
|
params: {
|
|
136
|
-
unitId:
|
|
137
|
+
unitId: o,
|
|
137
138
|
sheetId: e,
|
|
138
139
|
row: t,
|
|
139
140
|
col: s,
|
|
140
141
|
newPosition: {
|
|
141
|
-
row:
|
|
142
|
-
col:
|
|
142
|
+
row: r.startRow,
|
|
143
|
+
col: r.startColumn
|
|
143
144
|
},
|
|
144
145
|
silent: a
|
|
145
146
|
}
|
|
@@ -147,10 +148,10 @@ let N = class extends S {
|
|
|
147
148
|
undos: [{
|
|
148
149
|
id: C.id,
|
|
149
150
|
params: {
|
|
150
|
-
unitId:
|
|
151
|
+
unitId: o,
|
|
151
152
|
sheetId: e,
|
|
152
|
-
row:
|
|
153
|
-
col:
|
|
153
|
+
row: r.startRow,
|
|
154
|
+
col: r.startColumn,
|
|
154
155
|
newPosition: {
|
|
155
156
|
row: t,
|
|
156
157
|
col: s
|
|
@@ -163,16 +164,16 @@ let N = class extends S {
|
|
|
163
164
|
redos: [{
|
|
164
165
|
id: P.id,
|
|
165
166
|
params: {
|
|
166
|
-
unitId:
|
|
167
|
+
unitId: o,
|
|
167
168
|
sheetId: e,
|
|
168
169
|
row: t,
|
|
169
170
|
col: s
|
|
170
171
|
}
|
|
171
172
|
}],
|
|
172
173
|
undos: [{
|
|
173
|
-
id:
|
|
174
|
+
id: R.id,
|
|
174
175
|
params: {
|
|
175
|
-
unitId:
|
|
176
|
+
unitId: o,
|
|
176
177
|
sheetId: e,
|
|
177
178
|
row: t,
|
|
178
179
|
col: s,
|
|
@@ -180,72 +181,72 @@ let N = class extends S {
|
|
|
180
181
|
}
|
|
181
182
|
}]
|
|
182
183
|
});
|
|
183
|
-
this._refRangeService =
|
|
184
|
+
this._refRangeService = o, this._sheetsNoteModel = e, this._selectionManagerService = n, this._commandService = t, this._initData(), this._initRefRange();
|
|
184
185
|
}
|
|
185
|
-
_getIdWithUnitId(
|
|
186
|
-
return `${
|
|
186
|
+
_getIdWithUnitId(o, e, n, t) {
|
|
187
|
+
return `${o}-${e}-${n}-${t}`;
|
|
187
188
|
}
|
|
188
|
-
_register(
|
|
189
|
-
const
|
|
189
|
+
_register(o, e, n, t, s) {
|
|
190
|
+
const r = {
|
|
190
191
|
startColumn: s,
|
|
191
192
|
endColumn: s,
|
|
192
193
|
startRow: t,
|
|
193
194
|
endRow: t
|
|
194
195
|
};
|
|
195
196
|
this._disposableMap.set(
|
|
196
|
-
this._getIdWithUnitId(
|
|
197
|
-
this._refRangeService.registerRefRange(
|
|
198
|
-
const c = B(
|
|
199
|
-
return h && h.startColumn ===
|
|
197
|
+
this._getIdWithUnitId(o, e, t, s),
|
|
198
|
+
this._refRangeService.registerRefRange(r, (a) => {
|
|
199
|
+
const c = B(r, a, { selectionManagerService: this._selectionManagerService }), h = Array.isArray(c) ? c[0] : c;
|
|
200
|
+
return h && h.startColumn === r.startColumn && h.startRow === r.startRow ? {
|
|
200
201
|
undos: [],
|
|
201
202
|
redos: []
|
|
202
|
-
} : this._handleRangeChange(
|
|
203
|
-
},
|
|
203
|
+
} : this._handleRangeChange(o, e, n, t, s, h, !1);
|
|
204
|
+
}, o, e)
|
|
204
205
|
);
|
|
205
206
|
}
|
|
206
|
-
_watch(
|
|
207
|
-
const
|
|
207
|
+
_watch(o, e, n, t, s) {
|
|
208
|
+
const r = {
|
|
208
209
|
startColumn: s,
|
|
209
210
|
endColumn: s,
|
|
210
211
|
startRow: t,
|
|
211
212
|
endRow: t
|
|
212
213
|
};
|
|
213
214
|
this._watcherMap.set(
|
|
214
|
-
this._getIdWithUnitId(
|
|
215
|
-
this._refRangeService.watchRange(
|
|
216
|
-
const { redos: h } = this._handleRangeChange(
|
|
217
|
-
|
|
215
|
+
this._getIdWithUnitId(o, e, t, s),
|
|
216
|
+
this._refRangeService.watchRange(o, e, r, (a, c) => {
|
|
217
|
+
const { redos: h } = this._handleRangeChange(o, e, n, a.startRow, a.startColumn, c, !0);
|
|
218
|
+
J(h, this._commandService, { onlyLocal: !0 });
|
|
218
219
|
}, !0)
|
|
219
220
|
);
|
|
220
221
|
}
|
|
221
|
-
_unwatch(
|
|
222
|
-
var
|
|
223
|
-
const s = this._getIdWithUnitId(
|
|
224
|
-
(
|
|
222
|
+
_unwatch(o, e, n, t) {
|
|
223
|
+
var r;
|
|
224
|
+
const s = this._getIdWithUnitId(o, e, n, t);
|
|
225
|
+
(r = this._watcherMap.get(s)) == null || r.dispose(), this._watcherMap.delete(s);
|
|
225
226
|
}
|
|
226
|
-
_unregister(
|
|
227
|
-
var
|
|
228
|
-
const s = this._getIdWithUnitId(
|
|
229
|
-
(
|
|
227
|
+
_unregister(o, e, n, t) {
|
|
228
|
+
var r;
|
|
229
|
+
const s = this._getIdWithUnitId(o, e, n, t);
|
|
230
|
+
(r = this._disposableMap.get(s)) == null || r.dispose(), this._disposableMap.delete(s);
|
|
230
231
|
}
|
|
231
232
|
_initData() {
|
|
232
|
-
const
|
|
233
|
-
for (const [e, n] of
|
|
233
|
+
const o = this._sheetsNoteModel.getNotes();
|
|
234
|
+
for (const [e, n] of o)
|
|
234
235
|
for (const [t, s] of n)
|
|
235
|
-
s.forValue((
|
|
236
|
+
s.forValue((r, a, c) => (c && (this._register(e, t, c, r, a), this._watch(e, t, c, r, a)), !0));
|
|
236
237
|
}
|
|
237
238
|
_initRefRange() {
|
|
238
239
|
this.disposeWithMe(
|
|
239
|
-
this._sheetsNoteModel.change$.subscribe((
|
|
240
|
-
switch (
|
|
240
|
+
this._sheetsNoteModel.change$.subscribe((o) => {
|
|
241
|
+
switch (o.type) {
|
|
241
242
|
case "update": {
|
|
242
|
-
const { unitId: e, sheetId: n, row: t, col: s, note:
|
|
243
|
-
|
|
243
|
+
const { unitId: e, sheetId: n, row: t, col: s, note: r } = o, a = this._getIdWithUnitId(e, n, t, s);
|
|
244
|
+
r ? this._disposableMap.has(a) || (this._register(e, n, r, t, s), this._watch(e, n, r, t, s)) : (this._unregister(e, n, t, s), this._unwatch(e, n, t, s));
|
|
244
245
|
break;
|
|
245
246
|
}
|
|
246
247
|
case "ref": {
|
|
247
|
-
const { unitId: e, sheetId: n, row: t, col: s, newPosition:
|
|
248
|
-
this._unregister(e, n, t, s), c || (this._unwatch(e, n, t, s), this._watch(e, n, a,
|
|
248
|
+
const { unitId: e, sheetId: n, row: t, col: s, newPosition: r, note: a, silent: c } = o;
|
|
249
|
+
this._unregister(e, n, t, s), c || (this._unwatch(e, n, t, s), this._watch(e, n, a, r.row, r.col)), this._register(e, n, a, r.row, r.col);
|
|
249
250
|
break;
|
|
250
251
|
}
|
|
251
252
|
}
|
|
@@ -253,20 +254,20 @@ let N = class extends S {
|
|
|
253
254
|
);
|
|
254
255
|
}
|
|
255
256
|
};
|
|
256
|
-
N =
|
|
257
|
-
m(0,
|
|
258
|
-
m(1,
|
|
259
|
-
m(2,
|
|
260
|
-
m(3,
|
|
257
|
+
N = ee([
|
|
258
|
+
m(0, g(Y)),
|
|
259
|
+
m(1, g(u)),
|
|
260
|
+
m(2, g(I)),
|
|
261
|
+
m(3, p)
|
|
261
262
|
], N);
|
|
262
|
-
var
|
|
263
|
-
for (var t = n > 1 ? void 0 : n ?
|
|
264
|
-
(
|
|
263
|
+
var te = Object.getOwnPropertyDescriptor, se = (i, o, e, n) => {
|
|
264
|
+
for (var t = n > 1 ? void 0 : n ? te(o, e) : o, s = i.length - 1, r; s >= 0; s--)
|
|
265
|
+
(r = i[s]) && (t = r(t) || t);
|
|
265
266
|
return t;
|
|
266
|
-
}, w = (i,
|
|
267
|
-
let
|
|
268
|
-
constructor(i,
|
|
269
|
-
super(), this._resourceManagerService = i, this._univerInstanceService =
|
|
267
|
+
}, w = (i, o) => (e, n) => o(e, n, i);
|
|
268
|
+
let f = class extends S {
|
|
269
|
+
constructor(i, o, e) {
|
|
270
|
+
super(), this._resourceManagerService = i, this._univerInstanceService = o, this._sheetsNoteModel = e, this._initSnapshot();
|
|
270
271
|
}
|
|
271
272
|
_initSnapshot() {
|
|
272
273
|
const i = (e) => {
|
|
@@ -274,13 +275,13 @@ let M = class extends S {
|
|
|
274
275
|
if (!n)
|
|
275
276
|
return "";
|
|
276
277
|
const t = {};
|
|
277
|
-
return n.forEach((s,
|
|
278
|
+
return n.forEach((s, r) => {
|
|
278
279
|
const a = {};
|
|
279
|
-
s.forValue((c, h,
|
|
280
|
-
a[c] || (a[c] = {}), a[c][h] =
|
|
281
|
-
}), Object.keys(a).length > 0 && (t[
|
|
280
|
+
s.forValue((c, h, _) => {
|
|
281
|
+
a[c] || (a[c] = {}), a[c][h] = _;
|
|
282
|
+
}), Object.keys(a).length > 0 && (t[r] = a);
|
|
282
283
|
}), JSON.stringify(t);
|
|
283
|
-
},
|
|
284
|
+
}, o = (e) => {
|
|
284
285
|
if (!e)
|
|
285
286
|
return {};
|
|
286
287
|
try {
|
|
@@ -291,21 +292,21 @@ let M = class extends S {
|
|
|
291
292
|
};
|
|
292
293
|
this.disposeWithMe(
|
|
293
294
|
this._resourceManagerService.registerPluginResource({
|
|
294
|
-
pluginName:
|
|
295
|
+
pluginName: T,
|
|
295
296
|
businesses: [U.UNIVER_SHEET],
|
|
296
297
|
toJson: (e) => i(e),
|
|
297
|
-
parseJson: (e) =>
|
|
298
|
+
parseJson: (e) => o(e),
|
|
298
299
|
onUnLoad: (e) => {
|
|
299
300
|
this._sheetsNoteModel.deleteUnitNotes(e);
|
|
300
301
|
},
|
|
301
302
|
onLoad: (e, n) => {
|
|
302
303
|
Object.entries(n).forEach(([t, s]) => {
|
|
303
|
-
Object.entries(s).forEach(([
|
|
304
|
+
Object.entries(s).forEach(([r, a]) => {
|
|
304
305
|
Object.entries(a).forEach(([c, h]) => {
|
|
305
306
|
this._sheetsNoteModel.updateNote(
|
|
306
307
|
e,
|
|
307
308
|
t,
|
|
308
|
-
Number(
|
|
309
|
+
Number(r),
|
|
309
310
|
Number(c),
|
|
310
311
|
h
|
|
311
312
|
);
|
|
@@ -317,66 +318,66 @@ let M = class extends S {
|
|
|
317
318
|
);
|
|
318
319
|
}
|
|
319
320
|
};
|
|
320
|
-
|
|
321
|
-
w(0,
|
|
321
|
+
f = se([
|
|
322
|
+
w(0, G),
|
|
322
323
|
w(1, x),
|
|
323
|
-
w(2,
|
|
324
|
-
],
|
|
325
|
-
const
|
|
324
|
+
w(2, g(u))
|
|
325
|
+
], f);
|
|
326
|
+
const ne = {
|
|
326
327
|
id: "sheet.command.delete-note",
|
|
327
328
|
type: l.COMMAND,
|
|
328
|
-
handler: (i,
|
|
329
|
+
handler: (i, o) => {
|
|
329
330
|
const e = i.get(x), n = D(e);
|
|
330
331
|
if (!n) return !1;
|
|
331
|
-
const s = i.get(
|
|
332
|
+
const s = i.get(I).getCurrentLastSelection();
|
|
332
333
|
if (!(s != null && s.primary)) return !1;
|
|
333
|
-
const { actualColumn:
|
|
334
|
-
return i.get(
|
|
334
|
+
const { actualColumn: r, actualRow: a } = s.primary;
|
|
335
|
+
return i.get(p).executeCommand(P.id, {
|
|
335
336
|
unitId: n.unitId,
|
|
336
337
|
sheetId: n.subUnitId,
|
|
337
338
|
row: a,
|
|
338
|
-
col:
|
|
339
|
+
col: r
|
|
339
340
|
});
|
|
340
341
|
}
|
|
341
|
-
},
|
|
342
|
+
}, oe = {
|
|
342
343
|
id: "sheet.command.toggle-note-popup",
|
|
343
344
|
type: l.COMMAND,
|
|
344
|
-
handler: (i,
|
|
345
|
+
handler: (i, o) => {
|
|
345
346
|
const e = i.get(x), n = D(e);
|
|
346
347
|
if (!n) return !1;
|
|
347
|
-
const s = i.get(
|
|
348
|
+
const s = i.get(I).getCurrentLastSelection();
|
|
348
349
|
if (!(s != null && s.primary)) return !1;
|
|
349
|
-
const { actualColumn:
|
|
350
|
-
return i.get(
|
|
350
|
+
const { actualColumn: r, actualRow: a } = s.primary;
|
|
351
|
+
return i.get(p).executeCommand(V.id, {
|
|
351
352
|
unitId: n.unitId,
|
|
352
353
|
sheetId: n.subUnitId,
|
|
353
354
|
row: a,
|
|
354
|
-
col:
|
|
355
|
+
col: r
|
|
355
356
|
});
|
|
356
357
|
}
|
|
357
|
-
},
|
|
358
|
+
}, re = {
|
|
358
359
|
id: "sheet.command.update-note",
|
|
359
360
|
type: l.COMMAND,
|
|
360
|
-
handler: (i,
|
|
361
|
+
handler: (i, o) => i.get(p).syncExecuteCommand(R.id, o)
|
|
361
362
|
};
|
|
362
|
-
var
|
|
363
|
-
for (var t = n > 1 ? void 0 : n ?
|
|
364
|
-
(
|
|
363
|
+
var ie = Object.getOwnPropertyDescriptor, ae = (i, o, e, n) => {
|
|
364
|
+
for (var t = n > 1 ? void 0 : n ? ie(o, e) : o, s = i.length - 1, r; s >= 0; s--)
|
|
365
|
+
(r = i[s]) && (t = r(t) || t);
|
|
365
366
|
return t;
|
|
366
|
-
},
|
|
367
|
-
let
|
|
367
|
+
}, ce = (i, o) => (e, n) => o(e, n, i);
|
|
368
|
+
let M = class extends S {
|
|
368
369
|
constructor(i) {
|
|
369
370
|
super(), this._commandService = i, this._initialize();
|
|
370
371
|
}
|
|
371
372
|
_initialize() {
|
|
372
373
|
[
|
|
373
374
|
C,
|
|
374
|
-
|
|
375
|
-
|
|
375
|
+
V,
|
|
376
|
+
R,
|
|
376
377
|
P,
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
378
|
+
ne,
|
|
379
|
+
oe,
|
|
380
|
+
re
|
|
380
381
|
].forEach((i) => {
|
|
381
382
|
this.disposeWithMe(
|
|
382
383
|
this._commandService.registerCommand(i)
|
|
@@ -384,55 +385,60 @@ let f = class extends S {
|
|
|
384
385
|
});
|
|
385
386
|
}
|
|
386
387
|
};
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
],
|
|
390
|
-
var
|
|
391
|
-
for (var t = n > 1 ? void 0 : n ?
|
|
392
|
-
(
|
|
388
|
+
M = ae([
|
|
389
|
+
ce(0, p)
|
|
390
|
+
], M);
|
|
391
|
+
var he = Object.defineProperty, ue = Object.getOwnPropertyDescriptor, de = (i, o, e) => o in i ? he(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e, le = (i, o, e, n) => {
|
|
392
|
+
for (var t = n > 1 ? void 0 : n ? ue(o, e) : o, s = i.length - 1, r; s >= 0; s--)
|
|
393
|
+
(r = i[s]) && (t = r(t) || t);
|
|
393
394
|
return t;
|
|
394
|
-
},
|
|
395
|
-
const V = "SHEET_NOTE_PLUGIN";
|
|
395
|
+
}, E = (i, o) => (e, n) => o(e, n, i), j = (i, o, e) => de(i, typeof o != "symbol" ? o + "" : o, e);
|
|
396
396
|
let v = class extends q {
|
|
397
|
-
constructor(i,
|
|
398
|
-
super(), this.
|
|
397
|
+
constructor(i = b, o, e) {
|
|
398
|
+
super(), this._config = i, this._configService = o, this._injector = e;
|
|
399
|
+
const { ...n } = K(
|
|
400
|
+
{},
|
|
401
|
+
b,
|
|
402
|
+
this._config
|
|
403
|
+
);
|
|
404
|
+
this._configService.setConfig(Z, n);
|
|
399
405
|
}
|
|
400
406
|
onStarting() {
|
|
401
407
|
[
|
|
402
408
|
[u],
|
|
403
|
-
[f],
|
|
404
409
|
[M],
|
|
410
|
+
[f],
|
|
405
411
|
[N]
|
|
406
412
|
].forEach((i) => {
|
|
407
413
|
this._injector.add(i);
|
|
408
|
-
}),
|
|
414
|
+
}), O(this._injector, [
|
|
409
415
|
[u],
|
|
410
|
-
[
|
|
411
|
-
[
|
|
416
|
+
[M],
|
|
417
|
+
[f]
|
|
412
418
|
]);
|
|
413
419
|
}
|
|
414
420
|
onReady() {
|
|
415
|
-
|
|
421
|
+
O(this._injector, [
|
|
416
422
|
[N]
|
|
417
423
|
]);
|
|
418
424
|
}
|
|
419
425
|
};
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
v =
|
|
423
|
-
H(
|
|
424
|
-
|
|
425
|
-
|
|
426
|
+
j(v, "pluginName", T);
|
|
427
|
+
j(v, "type", U.UNIVER_SHEET);
|
|
428
|
+
v = le([
|
|
429
|
+
H(Q),
|
|
430
|
+
E(1, z),
|
|
431
|
+
E(2, g(F))
|
|
426
432
|
], v);
|
|
427
433
|
export {
|
|
428
434
|
P as RemoveNoteMutation,
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
435
|
+
ne as SheetDeleteNoteCommand,
|
|
436
|
+
oe as SheetToggleNotePopupCommand,
|
|
437
|
+
re as SheetUpdateNoteCommand,
|
|
432
438
|
u as SheetsNoteModel,
|
|
433
|
-
|
|
434
|
-
|
|
439
|
+
f as SheetsNoteResourceController,
|
|
440
|
+
V as ToggleNotePopupMutation,
|
|
435
441
|
v as UniverSheetsNotePlugin,
|
|
436
|
-
|
|
442
|
+
R as UpdateNoteMutation,
|
|
437
443
|
C as UpdateNotePositionMutation
|
|
438
444
|
};
|