@univerjs/sheets-note 0.15.4 → 0.15.5
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/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +134 -136
- package/lib/es/index.js +398 -317
- package/lib/facade.js +134 -136
- package/lib/index.js +398 -317
- package/lib/types/commands/mutations/note.mutation.d.ts +9 -6
- package/lib/types/facade/f-worksheet.d.ts +3 -7
- package/lib/types/models/sheets-note.model.d.ts +44 -23
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
package/lib/index.js
CHANGED
|
@@ -1,181 +1,260 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Disposable as
|
|
5
|
-
import { getSheetCommandTarget as
|
|
6
|
-
import { Subject as
|
|
7
|
-
class
|
|
1
|
+
var z = Object.defineProperty;
|
|
2
|
+
var F = (i, r, e) => r in i ? z(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
|
|
3
|
+
var _ = (i, r, e) => F(i, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
import { Disposable as U, generateRandomId as J, CommandType as m, IUniverInstanceService as E, ICommandService as w, IUndoRedoService as T, IResourceManagerService as q, Inject as f, UniverInstanceType as I, sequenceExecuteAsync as K, DependentOn as Y, IConfigService as Q, Injector as X, Plugin as Z, merge as k, touchDependencies as A } from "@univerjs/core";
|
|
5
|
+
import { getSheetCommandTarget as D, SheetsSelectionsService as x, SheetInterceptorService as ee, RemoveSheetCommand as te, CopySheetCommand as se, RefRangeService as oe, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as ne, UniverSheetsPlugin as re } from "@univerjs/sheets";
|
|
6
|
+
import { Subject as ie, filter as W, map as B } from "rxjs";
|
|
7
|
+
class g extends U {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
let
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
|
|
10
|
+
_(this, "_notesMap", /* @__PURE__ */ new Map());
|
|
11
|
+
_(this, "_change$", new ie());
|
|
12
|
+
_(this, "change$", this._change$.asObservable());
|
|
13
|
+
}
|
|
14
|
+
_ensureNotesMap(e, t) {
|
|
15
|
+
let s = this._notesMap.get(e);
|
|
16
|
+
s || (s = /* @__PURE__ */ new Map(), this._notesMap.set(e, s));
|
|
17
|
+
let o = s.get(t);
|
|
18
|
+
return o || (o = /* @__PURE__ */ new Map(), s.set(t, o)), o;
|
|
19
|
+
}
|
|
20
|
+
_getNoteByPosition(e, t, s, o) {
|
|
21
|
+
const n = this._ensureNotesMap(e, t);
|
|
22
|
+
for (const [a, c] of n)
|
|
23
|
+
if (c.row === s && c.col === o)
|
|
24
|
+
return c;
|
|
25
|
+
}
|
|
26
|
+
_getNoteById(e, t, s) {
|
|
27
|
+
return this._ensureNotesMap(e, t).get(s);
|
|
28
|
+
}
|
|
29
|
+
_getNoteByParams(e, t, s) {
|
|
30
|
+
const { noteId: o, row: n, col: a } = s;
|
|
31
|
+
return o ? this._getNoteById(e, t, o) : n !== void 0 && a !== void 0 ? this._getNoteByPosition(e, t, n, a) : null;
|
|
32
|
+
}
|
|
33
|
+
getSheetShowNotes$(e, t) {
|
|
21
34
|
return this._change$.pipe(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
W(({ unitId: s, subUnitId: o }) => s === e && o === t),
|
|
36
|
+
B(() => {
|
|
37
|
+
const s = this._ensureNotesMap(e, t), o = [];
|
|
38
|
+
for (const [n, a] of s)
|
|
39
|
+
a.show && o.push({ loc: { row: a.row, col: a.col, unitId: e, subUnitId: t }, note: a });
|
|
40
|
+
return o;
|
|
28
41
|
})
|
|
29
42
|
);
|
|
30
43
|
}
|
|
31
|
-
getCellNoteChange$(e,
|
|
44
|
+
getCellNoteChange$(e, t, s, o) {
|
|
32
45
|
return this._change$.pipe(
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
W(({ unitId: n, subUnitId: a, oldNote: c }) => n !== e || a !== t || !c ? !1 : c.row === s && c.col === o),
|
|
47
|
+
B((n) => n)
|
|
35
48
|
);
|
|
36
49
|
}
|
|
37
|
-
updateNote(e, s,
|
|
38
|
-
const c = this.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
50
|
+
updateNote(e, t, s, o, n, a) {
|
|
51
|
+
const c = this._getNoteByParams(e, t, { noteId: n == null ? void 0 : n.id, row: s, col: o }), d = this._ensureNotesMap(e, t), h = {
|
|
52
|
+
...n,
|
|
53
|
+
id: (c == null ? void 0 : c.id) || n.id || J(6),
|
|
54
|
+
row: s,
|
|
55
|
+
col: o
|
|
56
|
+
};
|
|
57
|
+
d.set(h.id, h), this._change$.next({ unitId: e, subUnitId: t, oldNote: c, type: "update", newNote: h, silent: a });
|
|
58
|
+
}
|
|
59
|
+
removeNote(e, t, s) {
|
|
60
|
+
const { noteId: o, row: n, col: a, silent: c } = s, d = this._getNoteByParams(e, t, { noteId: o, row: n, col: a });
|
|
61
|
+
if (!d)
|
|
62
|
+
return;
|
|
63
|
+
this._ensureNotesMap(e, t).delete(d.id), this._change$.next({ unitId: e, subUnitId: t, oldNote: d, type: "update", newNote: null, silent: c });
|
|
64
|
+
}
|
|
65
|
+
toggleNotePopup(e, t, s) {
|
|
66
|
+
const { noteId: o, row: n, col: a, silent: c } = s, d = this._getNoteByParams(e, t, { noteId: o, row: n, col: a });
|
|
67
|
+
if (!d)
|
|
68
|
+
return;
|
|
69
|
+
const h = this._ensureNotesMap(e, t), u = { ...d, show: !d.show };
|
|
70
|
+
h.set(u.id, u), this._change$.next({ unitId: e, subUnitId: t, oldNote: d, type: "update", newNote: u, silent: c });
|
|
71
|
+
}
|
|
72
|
+
updateNotePosition(e, t, s) {
|
|
73
|
+
const { noteId: o, row: n, col: a, newRow: c, newCol: d, silent: h } = s, u = this._getNoteByParams(e, t, { noteId: o, row: n, col: a });
|
|
74
|
+
if (!u)
|
|
75
|
+
return;
|
|
76
|
+
const l = this._ensureNotesMap(e, t), p = { ...u, row: c, col: d };
|
|
77
|
+
l.set(p.id, p), this._change$.next({ unitId: e, subUnitId: t, oldNote: u, type: "ref", newNote: p, silent: h });
|
|
78
|
+
}
|
|
79
|
+
getNote(e, t, s) {
|
|
80
|
+
return this._getNoteByParams(e, t, s);
|
|
61
81
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
d && (h.realDeleteValue(t, n), h.setValue(o, a, d), this._change$.next({
|
|
65
|
-
unitId: e,
|
|
66
|
-
sheetId: s,
|
|
67
|
-
row: t,
|
|
68
|
-
col: n,
|
|
69
|
-
type: "ref",
|
|
70
|
-
newPosition: { row: o, col: a },
|
|
71
|
-
note: d,
|
|
72
|
-
silent: c
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
getNote(e, s, t, n) {
|
|
76
|
-
return this._ensureNoteMatrix(e, s).getValue(t, n);
|
|
82
|
+
getNotes() {
|
|
83
|
+
return this._notesMap;
|
|
77
84
|
}
|
|
78
85
|
getUnitNotes(e) {
|
|
79
|
-
return this.
|
|
80
|
-
}
|
|
81
|
-
getSheetNotes(e, s) {
|
|
82
|
-
const t = this._noteMatrix.get(e);
|
|
83
|
-
if (t)
|
|
84
|
-
return t.get(s);
|
|
86
|
+
return this._notesMap.get(e);
|
|
85
87
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
getSheetNotes(e, t) {
|
|
89
|
+
const s = this._notesMap.get(e);
|
|
90
|
+
if (s)
|
|
91
|
+
return s.get(t);
|
|
88
92
|
}
|
|
89
93
|
deleteUnitNotes(e) {
|
|
90
|
-
this.
|
|
94
|
+
this._notesMap.delete(e);
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
|
-
const
|
|
97
|
+
const N = {
|
|
94
98
|
id: "sheet.mutation.update-note",
|
|
95
|
-
type:
|
|
99
|
+
type: m.MUTATION,
|
|
96
100
|
handler: (i, r) => {
|
|
97
|
-
const { unitId: e, sheetId:
|
|
98
|
-
return i.get(
|
|
101
|
+
const { unitId: e, sheetId: t, row: s, col: o, note: n, silent: a } = r;
|
|
102
|
+
return i.get(g).updateNote(e, t, s, o, n, a), !0;
|
|
99
103
|
}
|
|
100
|
-
},
|
|
104
|
+
}, M = {
|
|
101
105
|
id: "sheet.mutation.remove-note",
|
|
102
|
-
type:
|
|
106
|
+
type: m.MUTATION,
|
|
103
107
|
handler: (i, r) => {
|
|
104
|
-
const { unitId: e, sheetId: s, row:
|
|
105
|
-
return i.get(
|
|
108
|
+
const { unitId: e, sheetId: t, noteId: s, row: o, col: n, silent: a } = r;
|
|
109
|
+
return i.get(g).removeNote(e, t, { noteId: s, row: o, col: n, silent: a }), !0;
|
|
106
110
|
}
|
|
107
|
-
},
|
|
111
|
+
}, b = {
|
|
108
112
|
id: "sheet.mutation.toggle-note-popup",
|
|
109
|
-
type:
|
|
113
|
+
type: m.MUTATION,
|
|
110
114
|
handler: (i, r) => {
|
|
111
|
-
const { unitId: e, sheetId: s, row:
|
|
112
|
-
return i.get(
|
|
115
|
+
const { unitId: e, sheetId: t, noteId: s, row: o, col: n, silent: a } = r;
|
|
116
|
+
return i.get(g).toggleNotePopup(e, t, { noteId: s, row: o, col: n, silent: a }), !0;
|
|
113
117
|
}
|
|
114
|
-
},
|
|
118
|
+
}, $ = {
|
|
115
119
|
id: "sheet.mutation.update-note-position",
|
|
116
|
-
type:
|
|
120
|
+
type: m.MUTATION,
|
|
117
121
|
handler: (i, r) => {
|
|
118
|
-
const { unitId: e, sheetId: s, row:
|
|
119
|
-
return i.get(
|
|
122
|
+
const { unitId: e, sheetId: t, noteId: s, row: o, col: n, newPosition: a, silent: c } = r;
|
|
123
|
+
return i.get(g).updateNotePosition(e, t, { noteId: s, row: o, col: n, newRow: a.row, newCol: a.col, silent: c }), !0;
|
|
120
124
|
}
|
|
121
|
-
},
|
|
125
|
+
}, ae = {
|
|
122
126
|
id: "sheet.command.delete-note",
|
|
123
|
-
type:
|
|
124
|
-
handler: (i
|
|
125
|
-
const
|
|
126
|
-
if (!
|
|
127
|
-
const
|
|
128
|
-
if (!(
|
|
129
|
-
const {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
127
|
+
type: m.COMMAND,
|
|
128
|
+
handler: (i) => {
|
|
129
|
+
const r = D(i.get(E));
|
|
130
|
+
if (!r) return !1;
|
|
131
|
+
const t = i.get(x).getCurrentLastSelection();
|
|
132
|
+
if (!(t != null && t.primary)) return !1;
|
|
133
|
+
const s = i.get(g), { unitId: o, subUnitId: n } = r, { actualColumn: a, actualRow: c } = t.primary, d = s.getNote(o, n, { row: c, col: a });
|
|
134
|
+
if (!d) return !1;
|
|
135
|
+
const h = i.get(w), u = i.get(T), l = {
|
|
136
|
+
id: M.id,
|
|
137
|
+
params: {
|
|
138
|
+
unitId: o,
|
|
139
|
+
sheetId: n,
|
|
140
|
+
noteId: d.id
|
|
141
|
+
}
|
|
142
|
+
}, p = {
|
|
143
|
+
id: N.id,
|
|
144
|
+
params: {
|
|
145
|
+
unitId: o,
|
|
146
|
+
sheetId: n,
|
|
147
|
+
row: c,
|
|
148
|
+
col: a,
|
|
149
|
+
note: { ...d }
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
return h.syncExecuteCommand(l.id, l.params) ? (u.pushUndoRedo({
|
|
153
|
+
unitID: o,
|
|
154
|
+
redoMutations: [l],
|
|
155
|
+
undoMutations: [p]
|
|
156
|
+
}), !0) : !1;
|
|
136
157
|
}
|
|
137
|
-
},
|
|
158
|
+
}, ce = {
|
|
138
159
|
id: "sheet.command.toggle-note-popup",
|
|
139
|
-
type:
|
|
140
|
-
handler: (i
|
|
141
|
-
const
|
|
142
|
-
if (!
|
|
143
|
-
const
|
|
144
|
-
if (!(
|
|
145
|
-
const {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
160
|
+
type: m.COMMAND,
|
|
161
|
+
handler: (i) => {
|
|
162
|
+
const r = D(i.get(E));
|
|
163
|
+
if (!r) return !1;
|
|
164
|
+
const t = i.get(x).getCurrentLastSelection();
|
|
165
|
+
if (!(t != null && t.primary)) return !1;
|
|
166
|
+
const s = i.get(g), { unitId: o, subUnitId: n } = r, { actualColumn: a, actualRow: c } = t.primary, d = s.getNote(o, n, { row: c, col: a });
|
|
167
|
+
if (!d) return !1;
|
|
168
|
+
const h = i.get(w), u = i.get(T), l = {
|
|
169
|
+
id: b.id,
|
|
170
|
+
params: {
|
|
171
|
+
unitId: o,
|
|
172
|
+
sheetId: n,
|
|
173
|
+
noteId: d.id
|
|
174
|
+
}
|
|
175
|
+
}, p = {
|
|
176
|
+
id: b.id,
|
|
177
|
+
params: {
|
|
178
|
+
unitId: o,
|
|
179
|
+
sheetId: n,
|
|
180
|
+
noteId: d.id
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
return h.syncExecuteCommand(l.id, l.params) ? (u.pushUndoRedo({
|
|
184
|
+
unitID: o,
|
|
185
|
+
redoMutations: [l],
|
|
186
|
+
undoMutations: [p]
|
|
187
|
+
}), !0) : !1;
|
|
152
188
|
}
|
|
153
|
-
},
|
|
189
|
+
}, de = {
|
|
154
190
|
id: "sheet.command.update-note",
|
|
155
|
-
type:
|
|
156
|
-
handler: (i, r) =>
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
191
|
+
type: m.COMMAND,
|
|
192
|
+
handler: (i, r) => {
|
|
193
|
+
const e = D(i.get(E), r);
|
|
194
|
+
if (!e) return !1;
|
|
195
|
+
const t = i.get(w), s = i.get(T), o = i.get(g), { unitId: n, subUnitId: a } = e, { row: c, col: d, note: h } = r, u = o.getNote(n, a, { noteId: h.id, row: c, col: d }), l = {
|
|
196
|
+
id: N.id,
|
|
197
|
+
params: {
|
|
198
|
+
unitId: n,
|
|
199
|
+
sheetId: a,
|
|
200
|
+
row: c,
|
|
201
|
+
col: d,
|
|
202
|
+
note: h
|
|
203
|
+
}
|
|
204
|
+
}, p = [];
|
|
205
|
+
if (u) {
|
|
206
|
+
const O = {
|
|
207
|
+
id: N.id,
|
|
208
|
+
params: {
|
|
209
|
+
unitId: n,
|
|
210
|
+
sheetId: a,
|
|
211
|
+
row: c,
|
|
212
|
+
col: d,
|
|
213
|
+
note: { ...u }
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
p.push(O);
|
|
217
|
+
} else {
|
|
218
|
+
const O = {
|
|
219
|
+
id: M.id,
|
|
220
|
+
params: {
|
|
221
|
+
unitId: n,
|
|
222
|
+
sheetId: a,
|
|
223
|
+
row: c,
|
|
224
|
+
col: d
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
p.push(O);
|
|
228
|
+
}
|
|
229
|
+
return t.syncExecuteCommand(l.id, l.params) ? (s.pushUndoRedo({
|
|
230
|
+
unitID: n,
|
|
231
|
+
redoMutations: [l],
|
|
232
|
+
undoMutations: p
|
|
233
|
+
}), !0) : !1;
|
|
234
|
+
}
|
|
235
|
+
}, G = "SHEET_NOTE_PLUGIN";
|
|
236
|
+
var he = Object.getOwnPropertyDescriptor, ue = (i, r, e, t) => {
|
|
237
|
+
for (var s = t > 1 ? void 0 : t ? he(r, e) : r, o = i.length - 1, n; o >= 0; o--)
|
|
238
|
+
(n = i[o]) && (s = n(s) || s);
|
|
239
|
+
return s;
|
|
240
|
+
}, S = (i, r) => (e, t) => r(e, t, i);
|
|
241
|
+
let C = class extends U {
|
|
242
|
+
constructor(i, r, e, t) {
|
|
243
|
+
super(), this._resourceManagerService = i, this._univerInstanceService = r, this._sheetInterceptorService = e, this._sheetsNoteModel = t, this._initSnapshot(), this._initSheetChange();
|
|
166
244
|
}
|
|
167
245
|
_initSnapshot() {
|
|
168
246
|
const i = (e) => {
|
|
169
|
-
const
|
|
170
|
-
if (!
|
|
247
|
+
const t = this._sheetsNoteModel.getUnitNotes(e);
|
|
248
|
+
if (!t)
|
|
171
249
|
return "";
|
|
172
|
-
const
|
|
173
|
-
return
|
|
250
|
+
const s = {};
|
|
251
|
+
return t.forEach((o, n) => {
|
|
174
252
|
const a = {};
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
253
|
+
o.forEach((c) => {
|
|
254
|
+
const { row: d, col: h } = c;
|
|
255
|
+
a[d] || (a[d] = {}), a[d][h] = c;
|
|
256
|
+
}), Object.keys(a).length > 0 && (s[n] = a);
|
|
257
|
+
}), JSON.stringify(s);
|
|
179
258
|
}, r = (e) => {
|
|
180
259
|
if (!e)
|
|
181
260
|
return {};
|
|
@@ -187,23 +266,23 @@ let M = class extends x {
|
|
|
187
266
|
};
|
|
188
267
|
this.disposeWithMe(
|
|
189
268
|
this._resourceManagerService.registerPluginResource({
|
|
190
|
-
pluginName:
|
|
191
|
-
businesses: [
|
|
269
|
+
pluginName: G,
|
|
270
|
+
businesses: [I.UNIVER_SHEET],
|
|
192
271
|
toJson: (e) => i(e),
|
|
193
272
|
parseJson: (e) => r(e),
|
|
194
273
|
onUnLoad: (e) => {
|
|
195
274
|
this._sheetsNoteModel.deleteUnitNotes(e);
|
|
196
275
|
},
|
|
197
|
-
onLoad: (e,
|
|
198
|
-
Object.entries(
|
|
199
|
-
Object.entries(
|
|
200
|
-
Object.entries(a).forEach(([c,
|
|
276
|
+
onLoad: (e, t) => {
|
|
277
|
+
Object.entries(t).forEach(([s, o]) => {
|
|
278
|
+
Object.entries(o).forEach(([n, a]) => {
|
|
279
|
+
Object.entries(a).forEach(([c, d]) => {
|
|
201
280
|
this._sheetsNoteModel.updateNote(
|
|
202
281
|
e,
|
|
203
|
-
|
|
204
|
-
Number(
|
|
282
|
+
s,
|
|
283
|
+
Number(n),
|
|
205
284
|
Number(c),
|
|
206
|
-
|
|
285
|
+
d
|
|
207
286
|
);
|
|
208
287
|
});
|
|
209
288
|
});
|
|
@@ -219,59 +298,62 @@ let M = class extends x {
|
|
|
219
298
|
// eslint-disable-next-line max-lines-per-function
|
|
220
299
|
getMutations: (i) => {
|
|
221
300
|
var r;
|
|
222
|
-
if (i.id ===
|
|
223
|
-
const e = i.params,
|
|
224
|
-
if (!
|
|
301
|
+
if (i.id === te.id) {
|
|
302
|
+
const e = i.params, t = e.unitId || this._univerInstanceService.getCurrentUnitOfType(I.UNIVER_SHEET).getUnitId(), s = e.subUnitId || ((r = this._univerInstanceService.getCurrentUnitOfType(I.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : r.getSheetId());
|
|
303
|
+
if (!t || !s)
|
|
225
304
|
return { redos: [], undos: [] };
|
|
226
|
-
const
|
|
227
|
-
if (!
|
|
305
|
+
const o = this._sheetsNoteModel.getSheetNotes(t, s);
|
|
306
|
+
if (!o)
|
|
228
307
|
return { redos: [], undos: [] };
|
|
229
|
-
const
|
|
230
|
-
return
|
|
231
|
-
|
|
232
|
-
id:
|
|
308
|
+
const n = [], a = [];
|
|
309
|
+
return o.forEach((c) => {
|
|
310
|
+
n.push({
|
|
311
|
+
id: M.id,
|
|
233
312
|
params: {
|
|
234
|
-
unitId:
|
|
235
|
-
sheetId:
|
|
236
|
-
|
|
237
|
-
|
|
313
|
+
unitId: t,
|
|
314
|
+
sheetId: s,
|
|
315
|
+
noteId: c.id,
|
|
316
|
+
row: c.row,
|
|
317
|
+
col: c.col
|
|
238
318
|
}
|
|
239
319
|
}), a.push({
|
|
240
|
-
id:
|
|
320
|
+
id: N.id,
|
|
241
321
|
params: {
|
|
242
|
-
unitId:
|
|
243
|
-
sheetId:
|
|
244
|
-
row: c,
|
|
245
|
-
col:
|
|
246
|
-
note:
|
|
322
|
+
unitId: t,
|
|
323
|
+
sheetId: s,
|
|
324
|
+
row: c.row,
|
|
325
|
+
col: c.col,
|
|
326
|
+
note: c
|
|
247
327
|
}
|
|
248
328
|
});
|
|
249
|
-
}), { redos:
|
|
250
|
-
} else if (i.id ===
|
|
251
|
-
const e = i.params, { unitId:
|
|
252
|
-
if (!
|
|
329
|
+
}), { redos: n, undos: a };
|
|
330
|
+
} else if (i.id === se.id) {
|
|
331
|
+
const e = i.params, { unitId: t, subUnitId: s, targetSubUnitId: o } = e;
|
|
332
|
+
if (!t || !s || !o)
|
|
253
333
|
return { redos: [], undos: [] };
|
|
254
|
-
const
|
|
255
|
-
if (!
|
|
334
|
+
const n = this._sheetsNoteModel.getSheetNotes(t, s);
|
|
335
|
+
if (!n)
|
|
256
336
|
return { redos: [], undos: [] };
|
|
257
337
|
const a = [], c = [];
|
|
258
|
-
return
|
|
338
|
+
return n.forEach((d) => {
|
|
339
|
+
const h = { ...d, id: J(6) };
|
|
259
340
|
a.push({
|
|
260
|
-
id:
|
|
341
|
+
id: N.id,
|
|
261
342
|
params: {
|
|
262
|
-
unitId:
|
|
263
|
-
sheetId:
|
|
264
|
-
row: h,
|
|
265
|
-
col:
|
|
266
|
-
note:
|
|
343
|
+
unitId: t,
|
|
344
|
+
sheetId: o,
|
|
345
|
+
row: h.row,
|
|
346
|
+
col: h.col,
|
|
347
|
+
note: h
|
|
267
348
|
}
|
|
268
349
|
}), c.push({
|
|
269
|
-
id:
|
|
350
|
+
id: M.id,
|
|
270
351
|
params: {
|
|
271
|
-
unitId:
|
|
272
|
-
sheetId:
|
|
273
|
-
|
|
274
|
-
|
|
352
|
+
unitId: t,
|
|
353
|
+
sheetId: o,
|
|
354
|
+
noteId: h.id,
|
|
355
|
+
row: h.row,
|
|
356
|
+
col: h.col
|
|
275
357
|
}
|
|
276
358
|
});
|
|
277
359
|
}), { redos: a, undos: c };
|
|
@@ -282,140 +364,139 @@ let M = class extends x {
|
|
|
282
364
|
);
|
|
283
365
|
}
|
|
284
366
|
};
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
],
|
|
291
|
-
const
|
|
292
|
-
var
|
|
293
|
-
for (var
|
|
294
|
-
(
|
|
295
|
-
return
|
|
296
|
-
},
|
|
297
|
-
let
|
|
298
|
-
constructor(r, e,
|
|
367
|
+
C = ue([
|
|
368
|
+
S(0, q),
|
|
369
|
+
S(1, E),
|
|
370
|
+
S(2, f(ee)),
|
|
371
|
+
S(3, f(g))
|
|
372
|
+
], C);
|
|
373
|
+
const le = "sheets-note.config", L = {};
|
|
374
|
+
var pe = Object.getOwnPropertyDescriptor, ge = (i, r, e, t) => {
|
|
375
|
+
for (var s = t > 1 ? void 0 : t ? pe(r, e) : r, o = i.length - 1, n; o >= 0; o--)
|
|
376
|
+
(n = i[o]) && (s = n(s) || s);
|
|
377
|
+
return s;
|
|
378
|
+
}, v = (i, r) => (e, t) => r(e, t, i);
|
|
379
|
+
let R = class extends U {
|
|
380
|
+
constructor(r, e, t, s) {
|
|
299
381
|
super();
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
382
|
+
_(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
383
|
+
_(this, "_watcherMap", /* @__PURE__ */ new Map());
|
|
384
|
+
_(this, "_handleRangeChange", (r, e, t, s, o, n, a) => n ? {
|
|
303
385
|
redos: [{
|
|
304
|
-
id:
|
|
386
|
+
id: $.id,
|
|
305
387
|
params: {
|
|
306
388
|
unitId: r,
|
|
307
389
|
sheetId: e,
|
|
308
|
-
|
|
309
|
-
col: n,
|
|
390
|
+
noteId: t.id,
|
|
310
391
|
newPosition: {
|
|
311
|
-
row:
|
|
312
|
-
col:
|
|
392
|
+
row: n.startRow,
|
|
393
|
+
col: n.startColumn
|
|
313
394
|
},
|
|
314
395
|
silent: a
|
|
315
396
|
}
|
|
316
397
|
}],
|
|
317
398
|
undos: [{
|
|
318
|
-
id:
|
|
399
|
+
id: $.id,
|
|
319
400
|
params: {
|
|
320
401
|
unitId: r,
|
|
321
402
|
sheetId: e,
|
|
322
|
-
|
|
323
|
-
col: o.startColumn,
|
|
403
|
+
noteId: t.id,
|
|
324
404
|
newPosition: {
|
|
325
|
-
row:
|
|
326
|
-
col:
|
|
405
|
+
row: s,
|
|
406
|
+
col: o
|
|
327
407
|
},
|
|
328
|
-
note:
|
|
408
|
+
note: t,
|
|
329
409
|
silent: a
|
|
330
410
|
}
|
|
331
411
|
}]
|
|
332
412
|
} : {
|
|
333
413
|
redos: [{
|
|
334
|
-
id:
|
|
414
|
+
id: M.id,
|
|
335
415
|
params: {
|
|
336
416
|
unitId: r,
|
|
337
417
|
sheetId: e,
|
|
338
|
-
|
|
339
|
-
col: n
|
|
418
|
+
noteId: t.id
|
|
340
419
|
}
|
|
341
420
|
}],
|
|
342
421
|
undos: [{
|
|
343
|
-
id:
|
|
422
|
+
id: N.id,
|
|
344
423
|
params: {
|
|
345
424
|
unitId: r,
|
|
346
425
|
sheetId: e,
|
|
347
|
-
row:
|
|
348
|
-
col:
|
|
349
|
-
note:
|
|
426
|
+
row: s,
|
|
427
|
+
col: o,
|
|
428
|
+
note: t
|
|
350
429
|
}
|
|
351
430
|
}]
|
|
352
431
|
});
|
|
353
|
-
this._refRangeService = r, this._sheetsNoteModel = e, this._selectionManagerService =
|
|
432
|
+
this._refRangeService = r, this._sheetsNoteModel = e, this._selectionManagerService = t, this._commandService = s, this._initData(), this._initRefRange();
|
|
354
433
|
}
|
|
355
|
-
_getIdWithUnitId(r, e,
|
|
356
|
-
return `${r}-${e}-${
|
|
434
|
+
_getIdWithUnitId(r, e, t, s) {
|
|
435
|
+
return `${r}-${e}-${t}-${s}`;
|
|
357
436
|
}
|
|
358
|
-
_register(r, e,
|
|
359
|
-
const
|
|
360
|
-
startColumn:
|
|
361
|
-
endColumn:
|
|
362
|
-
startRow:
|
|
363
|
-
endRow:
|
|
437
|
+
_register(r, e, t, s, o) {
|
|
438
|
+
const n = {
|
|
439
|
+
startColumn: o,
|
|
440
|
+
endColumn: o,
|
|
441
|
+
startRow: s,
|
|
442
|
+
endRow: s
|
|
364
443
|
};
|
|
365
444
|
this._disposableMap.set(
|
|
366
|
-
this._getIdWithUnitId(r, e,
|
|
367
|
-
this._refRangeService.registerRefRange(
|
|
368
|
-
const c =
|
|
369
|
-
return
|
|
445
|
+
this._getIdWithUnitId(r, e, s, o),
|
|
446
|
+
this._refRangeService.registerRefRange(n, (a) => {
|
|
447
|
+
const c = ne(n, a, { selectionManagerService: this._selectionManagerService }), d = Array.isArray(c) ? c[0] : c;
|
|
448
|
+
return d && d.startColumn === n.startColumn && d.startRow === n.startRow ? {
|
|
370
449
|
undos: [],
|
|
371
450
|
redos: []
|
|
372
|
-
} : this._handleRangeChange(r, e,
|
|
451
|
+
} : this._handleRangeChange(r, e, t, s, o, d, !1);
|
|
373
452
|
}, r, e)
|
|
374
453
|
);
|
|
375
454
|
}
|
|
376
|
-
_watch(r, e,
|
|
377
|
-
const
|
|
378
|
-
startColumn:
|
|
379
|
-
endColumn:
|
|
380
|
-
startRow:
|
|
381
|
-
endRow:
|
|
455
|
+
_watch(r, e, t, s, o) {
|
|
456
|
+
const n = {
|
|
457
|
+
startColumn: o,
|
|
458
|
+
endColumn: o,
|
|
459
|
+
startRow: s,
|
|
460
|
+
endRow: s
|
|
382
461
|
};
|
|
383
462
|
this._watcherMap.set(
|
|
384
|
-
this._getIdWithUnitId(r, e,
|
|
385
|
-
this._refRangeService.watchRange(r, e,
|
|
386
|
-
const { redos:
|
|
387
|
-
|
|
463
|
+
this._getIdWithUnitId(r, e, s, o),
|
|
464
|
+
this._refRangeService.watchRange(r, e, n, (a, c) => {
|
|
465
|
+
const { redos: d } = this._handleRangeChange(r, e, t, a.startRow, a.startColumn, c, !0);
|
|
466
|
+
K(d, this._commandService, { onlyLocal: !0 });
|
|
388
467
|
}, !0)
|
|
389
468
|
);
|
|
390
469
|
}
|
|
391
|
-
_unwatch(r, e,
|
|
392
|
-
var
|
|
393
|
-
const
|
|
394
|
-
(
|
|
470
|
+
_unwatch(r, e, t, s) {
|
|
471
|
+
var n;
|
|
472
|
+
const o = this._getIdWithUnitId(r, e, t, s);
|
|
473
|
+
(n = this._watcherMap.get(o)) == null || n.dispose(), this._watcherMap.delete(o);
|
|
395
474
|
}
|
|
396
|
-
_unregister(r, e,
|
|
397
|
-
var
|
|
398
|
-
const
|
|
399
|
-
(
|
|
475
|
+
_unregister(r, e, t, s) {
|
|
476
|
+
var n;
|
|
477
|
+
const o = this._getIdWithUnitId(r, e, t, s);
|
|
478
|
+
(n = this._disposableMap.get(o)) == null || n.dispose(), this._disposableMap.delete(o);
|
|
400
479
|
}
|
|
401
480
|
_initData() {
|
|
402
481
|
const r = this._sheetsNoteModel.getNotes();
|
|
403
|
-
for (const [e,
|
|
404
|
-
for (const [
|
|
405
|
-
|
|
482
|
+
for (const [e, t] of r)
|
|
483
|
+
for (const [s, o] of t)
|
|
484
|
+
o.forEach((n) => {
|
|
485
|
+
this._register(e, s, n, n.row, n.col), this._watch(e, s, n, n.row, n.col);
|
|
486
|
+
});
|
|
406
487
|
}
|
|
407
488
|
_initRefRange() {
|
|
408
489
|
this.disposeWithMe(
|
|
409
490
|
this._sheetsNoteModel.change$.subscribe((r) => {
|
|
410
491
|
switch (r.type) {
|
|
411
492
|
case "update": {
|
|
412
|
-
const { unitId: e,
|
|
413
|
-
o ? this._disposableMap.has(
|
|
493
|
+
const { unitId: e, subUnitId: t, oldNote: s, newNote: o } = r, n = o ? o.row : s.row, a = o ? o.col : s.col, c = this._getIdWithUnitId(e, t, n, a);
|
|
494
|
+
o ? this._disposableMap.has(c) || (this._register(e, t, o, n, a), this._watch(e, t, o, n, a)) : (this._unregister(e, t, n, a), this._unwatch(e, t, n, a));
|
|
414
495
|
break;
|
|
415
496
|
}
|
|
416
497
|
case "ref": {
|
|
417
|
-
const { unitId: e,
|
|
418
|
-
this._unregister(e,
|
|
498
|
+
const { unitId: e, subUnitId: t, oldNote: s, newNote: o, silent: n } = r, { row: a, col: c } = s, { row: d, col: h } = o;
|
|
499
|
+
this._unregister(e, t, a, c), n || (this._unwatch(e, t, a, c), this._watch(e, t, o, d, h)), this._register(e, t, o, d, h);
|
|
419
500
|
break;
|
|
420
501
|
}
|
|
421
502
|
}
|
|
@@ -423,30 +504,30 @@ let I = class extends x {
|
|
|
423
504
|
);
|
|
424
505
|
}
|
|
425
506
|
};
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
],
|
|
432
|
-
var
|
|
433
|
-
for (var
|
|
434
|
-
(
|
|
435
|
-
return
|
|
436
|
-
},
|
|
437
|
-
let
|
|
507
|
+
R = ge([
|
|
508
|
+
v(0, f(oe)),
|
|
509
|
+
v(1, f(g)),
|
|
510
|
+
v(2, f(x)),
|
|
511
|
+
v(3, w)
|
|
512
|
+
], R);
|
|
513
|
+
var _e = Object.getOwnPropertyDescriptor, Ne = (i, r, e, t) => {
|
|
514
|
+
for (var s = t > 1 ? void 0 : t ? _e(r, e) : r, o = i.length - 1, n; o >= 0; o--)
|
|
515
|
+
(n = i[o]) && (s = n(s) || s);
|
|
516
|
+
return s;
|
|
517
|
+
}, me = (i, r) => (e, t) => r(e, t, i);
|
|
518
|
+
let y = class extends U {
|
|
438
519
|
constructor(i) {
|
|
439
520
|
super(), this._commandService = i, this._initialize();
|
|
440
521
|
}
|
|
441
522
|
_initialize() {
|
|
442
523
|
[
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
524
|
+
$,
|
|
525
|
+
b,
|
|
526
|
+
N,
|
|
527
|
+
M,
|
|
528
|
+
ae,
|
|
529
|
+
ce,
|
|
530
|
+
de
|
|
450
531
|
].forEach((i) => {
|
|
451
532
|
this.disposeWithMe(
|
|
452
533
|
this._commandService.registerCommand(i)
|
|
@@ -454,60 +535,60 @@ let C = class extends x {
|
|
|
454
535
|
});
|
|
455
536
|
}
|
|
456
537
|
};
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
],
|
|
460
|
-
var
|
|
461
|
-
for (var
|
|
462
|
-
(
|
|
463
|
-
return
|
|
464
|
-
},
|
|
465
|
-
let
|
|
466
|
-
constructor(i =
|
|
538
|
+
y = Ne([
|
|
539
|
+
me(0, w)
|
|
540
|
+
], y);
|
|
541
|
+
var fe = Object.defineProperty, Me = Object.getOwnPropertyDescriptor, we = (i, r, e) => r in i ? fe(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e, Se = (i, r, e, t) => {
|
|
542
|
+
for (var s = t > 1 ? void 0 : t ? Me(r, e) : r, o = i.length - 1, n; o >= 0; o--)
|
|
543
|
+
(n = i[o]) && (s = n(s) || s);
|
|
544
|
+
return s;
|
|
545
|
+
}, H = (i, r) => (e, t) => r(e, t, i), V = (i, r, e) => we(i, typeof r != "symbol" ? r + "" : r, e);
|
|
546
|
+
let P = class extends Z {
|
|
547
|
+
constructor(i = L, r, e) {
|
|
467
548
|
super(), this._config = i, this._configService = r, this._injector = e;
|
|
468
|
-
const { ...
|
|
549
|
+
const { ...t } = k(
|
|
469
550
|
{},
|
|
470
|
-
|
|
551
|
+
L,
|
|
471
552
|
this._config
|
|
472
553
|
);
|
|
473
|
-
this._configService.setConfig(
|
|
554
|
+
this._configService.setConfig(le, t);
|
|
474
555
|
}
|
|
475
556
|
onStarting() {
|
|
476
557
|
[
|
|
477
|
-
[
|
|
558
|
+
[g],
|
|
559
|
+
[y],
|
|
478
560
|
[C],
|
|
479
|
-
[
|
|
480
|
-
[I]
|
|
561
|
+
[R]
|
|
481
562
|
].forEach((i) => {
|
|
482
563
|
this._injector.add(i);
|
|
483
|
-
}),
|
|
484
|
-
[
|
|
485
|
-
[
|
|
486
|
-
[
|
|
564
|
+
}), A(this._injector, [
|
|
565
|
+
[g],
|
|
566
|
+
[y],
|
|
567
|
+
[C]
|
|
487
568
|
]);
|
|
488
569
|
}
|
|
489
570
|
onReady() {
|
|
490
|
-
|
|
491
|
-
[
|
|
571
|
+
A(this._injector, [
|
|
572
|
+
[R]
|
|
492
573
|
]);
|
|
493
574
|
}
|
|
494
575
|
};
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
],
|
|
576
|
+
V(P, "pluginName", G);
|
|
577
|
+
V(P, "type", I.UNIVER_SHEET);
|
|
578
|
+
P = Se([
|
|
579
|
+
Y(re),
|
|
580
|
+
H(1, Q),
|
|
581
|
+
H(2, f(X))
|
|
582
|
+
], P);
|
|
502
583
|
export {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
584
|
+
M as RemoveNoteMutation,
|
|
585
|
+
ae as SheetDeleteNoteCommand,
|
|
586
|
+
ce as SheetToggleNotePopupCommand,
|
|
587
|
+
de as SheetUpdateNoteCommand,
|
|
588
|
+
g as SheetsNoteModel,
|
|
589
|
+
C as SheetsNoteResourceController,
|
|
590
|
+
b as ToggleNotePopupMutation,
|
|
591
|
+
P as UniverSheetsNotePlugin,
|
|
592
|
+
N as UpdateNoteMutation,
|
|
593
|
+
$ as UpdateNotePositionMutation
|
|
513
594
|
};
|