@univerjs/sheets-crosshair-highlight 0.6.7 → 0.6.9
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/facade.js +63 -0
- package/lib/index.js +447 -0
- package/lib/locale/en-US.js +10 -0
- package/lib/locale/fa-IR.js +10 -0
- package/lib/locale/fr-FR.js +10 -0
- package/lib/locale/ru-RU.js +10 -0
- package/lib/locale/vi-VN.js +10 -0
- package/lib/locale/zh-CN.js +10 -0
- package/lib/locale/zh-TW.js +10 -0
- package/package.json +10 -10
package/lib/facade.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ICommandService as l } from "@univerjs/core";
|
|
2
|
+
import { FEventName as C, FUniver as n } from "@univerjs/core/facade";
|
|
3
|
+
import { EnableCrosshairHighlightOperation as h, DisableCrosshairHighlightOperation as s, ToggleCrosshairHighlightOperation as d, SetCrosshairHighlightColorOperation as g, SheetsCrosshairHighlightService as o, CROSSHAIR_HIGHLIGHT_COLORS as c } from "@univerjs/sheets-crosshair-highlight";
|
|
4
|
+
class H {
|
|
5
|
+
get CrosshairHighlightEnabledChanged() {
|
|
6
|
+
return "CrosshairHighlightEnabledChanged";
|
|
7
|
+
}
|
|
8
|
+
get CrosshairHighlightColorChanged() {
|
|
9
|
+
return "CrosshairHighlightColorChanged";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
class v extends n {
|
|
13
|
+
/**
|
|
14
|
+
* @ignore
|
|
15
|
+
*/
|
|
16
|
+
_initialize(i) {
|
|
17
|
+
const r = i.get(l);
|
|
18
|
+
this.registerEventHandler(
|
|
19
|
+
this.Event.CrosshairHighlightEnabledChanged,
|
|
20
|
+
() => r.onCommandExecuted((e) => {
|
|
21
|
+
if (e.id === h.id || e.id === s.id || e.id === d.id) {
|
|
22
|
+
const t = this.getActiveSheet();
|
|
23
|
+
if (!t) return;
|
|
24
|
+
this.fireEvent(this.Event.CrosshairHighlightEnabledChanged, {
|
|
25
|
+
enabled: this.getCrosshairHighlightEnabled(),
|
|
26
|
+
...t
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
), this.registerEventHandler(
|
|
31
|
+
this.Event.CrosshairHighlightColorChanged,
|
|
32
|
+
() => r.onCommandExecuted((e) => {
|
|
33
|
+
if (e.id === g.id) {
|
|
34
|
+
const t = this.getActiveSheet();
|
|
35
|
+
if (!t) return;
|
|
36
|
+
this.fireEvent(this.Event.CrosshairHighlightColorChanged, {
|
|
37
|
+
color: this.getCrosshairHighlightColor(),
|
|
38
|
+
...t
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
setCrosshairHighlightEnabled(i) {
|
|
45
|
+
return i ? this._commandService.syncExecuteCommand(h.id) : this._commandService.syncExecuteCommand(s.id), this;
|
|
46
|
+
}
|
|
47
|
+
setCrosshairHighlightColor(i) {
|
|
48
|
+
return this._commandService.syncExecuteCommand(g.id, {
|
|
49
|
+
value: i
|
|
50
|
+
}), this;
|
|
51
|
+
}
|
|
52
|
+
getCrosshairHighlightEnabled() {
|
|
53
|
+
return this._injector.get(o).enabled;
|
|
54
|
+
}
|
|
55
|
+
getCrosshairHighlightColor() {
|
|
56
|
+
return this._injector.get(o).color;
|
|
57
|
+
}
|
|
58
|
+
get CROSSHAIR_HIGHLIGHT_COLORS() {
|
|
59
|
+
return c;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
C.extend(H);
|
|
63
|
+
n.extend(v);
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
var K = Object.defineProperty;
|
|
2
|
+
var q = (n, e, t) => e in n ? K(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var c = (n, e, t) => q(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Disposable as y, CommandType as H, UniverInstanceType as E, Inject as u, ICommandService as J, RANGE_TYPE as f, Rectangle as $, IContextService as Q, ColorKit as ee, Plugin as te, merge as re, Injector as ne, IConfigService as ie } from "@univerjs/core";
|
|
5
|
+
import { Shape as se, Rect as oe, IRenderManagerService as ae } from "@univerjs/engine-render";
|
|
6
|
+
import { useDependency as ce, useObservable as le, getMenuHiddenObservable as he, MenuItemType as ge, ContextMenuPosition as de, ContextMenuGroup as ue, ComponentManager as fe, IMenuManagerService as _e } from "@univerjs/ui";
|
|
7
|
+
import { BehaviorSubject as x, combineLatest as ve, merge as T, startWith as Se, tap as pe, map as V } from "rxjs";
|
|
8
|
+
import { jsx as N } from "react/jsx-runtime";
|
|
9
|
+
import { clsx as Ce } from "@univerjs/design";
|
|
10
|
+
import { forwardRef as k, useRef as me, createElement as A, useCallback as be } from "react";
|
|
11
|
+
import { SheetsSelectionsService as Re, IRefSelectionsService as He, REF_SELECTIONS_ENABLED as Oe } from "@univerjs/sheets";
|
|
12
|
+
import { SheetSkeletonManagerService as Ie, getCoordByCell as P } from "@univerjs/sheets-ui";
|
|
13
|
+
const Ee = "sheets-crosshair-highlight.config", j = {};
|
|
14
|
+
var l = function() {
|
|
15
|
+
return l = Object.assign || function(n) {
|
|
16
|
+
for (var e, t = 1, r = arguments.length; t < r; t++) {
|
|
17
|
+
e = arguments[t];
|
|
18
|
+
for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (n[i] = e[i]);
|
|
19
|
+
}
|
|
20
|
+
return n;
|
|
21
|
+
}, l.apply(this, arguments);
|
|
22
|
+
}, ye = function(n, e) {
|
|
23
|
+
var t = {};
|
|
24
|
+
for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && e.indexOf(r) < 0 && (t[r] = n[r]);
|
|
25
|
+
if (n != null && typeof Object.getOwnPropertySymbols == "function")
|
|
26
|
+
for (var i = 0, r = Object.getOwnPropertySymbols(n); i < r.length; i++)
|
|
27
|
+
e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[i]) && (t[r[i]] = n[r[i]]);
|
|
28
|
+
return t;
|
|
29
|
+
}, G = k(function(n, e) {
|
|
30
|
+
var t = n.icon, r = n.id, i = n.className, s = n.extend, o = ye(n, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(i || "").trim(), h = me("_".concat($e()));
|
|
31
|
+
return U(t, "".concat(r), { defIds: t.defIds, idSuffix: h.current }, l({ ref: e, className: a }, o), s);
|
|
32
|
+
});
|
|
33
|
+
function U(n, e, t, r, i) {
|
|
34
|
+
return A(n.tag, l(l({ key: e }, we(n, t, i)), r), (Me(n, t).children || []).map(function(s, o) {
|
|
35
|
+
return U(s, "".concat(e, "-").concat(n.tag, "-").concat(o), t, void 0, i);
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
function we(n, e, t) {
|
|
39
|
+
var r = l({}, n.attrs);
|
|
40
|
+
t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1), n.tag === "mask" && r.id && (r.id = r.id + e.idSuffix), Object.entries(r).forEach(function(s) {
|
|
41
|
+
var o = s[0], a = s[1];
|
|
42
|
+
o === "mask" && typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
43
|
+
});
|
|
44
|
+
var i = e.defIds;
|
|
45
|
+
return !i || i.length === 0 || (n.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(s) {
|
|
46
|
+
var o = s[0], a = s[1];
|
|
47
|
+
typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
48
|
+
})), r;
|
|
49
|
+
}
|
|
50
|
+
function Me(n, e) {
|
|
51
|
+
var t, r = e.defIds;
|
|
52
|
+
return !r || r.length === 0 ? n : n.tag === "defs" && (!((t = n.children) === null || t === void 0) && t.length) ? l(l({}, n), { children: n.children.map(function(i) {
|
|
53
|
+
return typeof i.attrs.id == "string" && r && r.indexOf(i.attrs.id) > -1 ? l(l({}, i), { attrs: l(l({}, i.attrs), { id: i.attrs.id + e.idSuffix }) }) : i;
|
|
54
|
+
}) }) : n;
|
|
55
|
+
}
|
|
56
|
+
function $e() {
|
|
57
|
+
return Math.random().toString(36).substring(2, 8);
|
|
58
|
+
}
|
|
59
|
+
G.displayName = "UniverIcon";
|
|
60
|
+
var xe = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "#E5E5E5", d: "M1.6499 3.65002C1.6499 2.54545 2.54533 1.65002 3.6499 1.65002H12.3499C13.4545 1.65002 14.3499 2.54545 14.3499 3.65002V12.35C14.3499 13.4546 13.4545 14.35 12.3499 14.35H3.6499C2.54533 14.35 1.6499 13.4546 1.6499 12.35V3.65002Z" } }, { tag: "path", attrs: { fill: "#fff", d: "M9.9998 1.65002H5.9998V6H1.6499V10H5.9998V14.35H9.9998V10H14.3499V6H9.9998V1.65002Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, D = k(function(n, e) {
|
|
61
|
+
return A(G, Object.assign({}, n, {
|
|
62
|
+
id: "cross-highlighting-single",
|
|
63
|
+
ref: e,
|
|
64
|
+
icon: xe
|
|
65
|
+
}));
|
|
66
|
+
});
|
|
67
|
+
D.displayName = "CrossHighlightingSingle";
|
|
68
|
+
const Z = [
|
|
69
|
+
"rgba(158, 109, 227, 0.3)",
|
|
70
|
+
"rgba(254, 75, 75, 0.3)",
|
|
71
|
+
"rgba(255, 140, 81, 0.3)",
|
|
72
|
+
"rgba(164, 220, 22, 0.3)",
|
|
73
|
+
"rgba(45, 174, 255, 0.3)",
|
|
74
|
+
"rgba(58, 96, 247, 0.3)",
|
|
75
|
+
"rgba(242, 72, 166, 0.3)",
|
|
76
|
+
"rgba(153, 153, 153, 0.3)",
|
|
77
|
+
"rgba(158, 109, 227, 0.15)",
|
|
78
|
+
"rgba(254, 75, 75, 0.15)",
|
|
79
|
+
"rgba(255, 140, 81, 0.15)",
|
|
80
|
+
"rgba(164, 220, 22, 0.15)",
|
|
81
|
+
"rgba(45, 174, 255, 0.15)",
|
|
82
|
+
"rgba(58, 96, 247, 0.15)",
|
|
83
|
+
"rgba(242, 72, 166, 0.15)",
|
|
84
|
+
"rgba(153, 153, 153, 0.15)"
|
|
85
|
+
];
|
|
86
|
+
class g extends y {
|
|
87
|
+
constructor() {
|
|
88
|
+
super(...arguments);
|
|
89
|
+
c(this, "_enabled$", new x(!1));
|
|
90
|
+
c(this, "enabled$", this._enabled$.asObservable());
|
|
91
|
+
c(this, "_color$", new x(Z[0]));
|
|
92
|
+
c(this, "color$", this._color$.asObservable());
|
|
93
|
+
}
|
|
94
|
+
get enabled() {
|
|
95
|
+
return this._enabled$.getValue();
|
|
96
|
+
}
|
|
97
|
+
get color() {
|
|
98
|
+
return this._color$.getValue();
|
|
99
|
+
}
|
|
100
|
+
dispose() {
|
|
101
|
+
this._enabled$.complete();
|
|
102
|
+
}
|
|
103
|
+
setEnabled(t) {
|
|
104
|
+
this._enabled$.next(t);
|
|
105
|
+
}
|
|
106
|
+
setColor(t) {
|
|
107
|
+
this._color$.next(t);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const w = {
|
|
111
|
+
id: "sheet.operation.toggle-crosshair-highlight",
|
|
112
|
+
type: H.OPERATION,
|
|
113
|
+
handler(n) {
|
|
114
|
+
const e = n.get(g), t = e.enabled;
|
|
115
|
+
return e.setEnabled(!t), !0;
|
|
116
|
+
}
|
|
117
|
+
}, B = {
|
|
118
|
+
id: "sheet.operation.set-crosshair-highlight-color",
|
|
119
|
+
type: H.OPERATION,
|
|
120
|
+
handler(n, { value: e }) {
|
|
121
|
+
const t = n.get(g);
|
|
122
|
+
return t.enabled || t.setEnabled(!0), t.setColor(e), !0;
|
|
123
|
+
}
|
|
124
|
+
}, Te = {
|
|
125
|
+
id: "sheet.operation.enable-crosshair-highlight",
|
|
126
|
+
type: H.OPERATION,
|
|
127
|
+
handler(n) {
|
|
128
|
+
const e = n.get(g);
|
|
129
|
+
return e.enabled ? !1 : (e.setEnabled(!0), !0);
|
|
130
|
+
}
|
|
131
|
+
}, Ve = {
|
|
132
|
+
id: "sheet.operation.disable-crosshair-highlight",
|
|
133
|
+
type: H.OPERATION,
|
|
134
|
+
handler(n) {
|
|
135
|
+
const e = n.get(g);
|
|
136
|
+
return e.enabled ? (e.setEnabled(!1), !0) : !1;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
function Ne(n) {
|
|
140
|
+
const { onChange: e } = n, t = ce(g), r = le(t.color$), i = be((s) => {
|
|
141
|
+
e == null || e(s);
|
|
142
|
+
}, [e]);
|
|
143
|
+
return /* @__PURE__ */ N("div", { className: "univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3", children: Z.map((s) => /* @__PURE__ */ N(
|
|
144
|
+
"div",
|
|
145
|
+
{
|
|
146
|
+
className: Ce(`
|
|
147
|
+
univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-border
|
|
148
|
+
univer-border-solid univer-border-gray-200 univer-ring-offset-1 univer-transition-shadow
|
|
149
|
+
hover:univer-ring-[1.5px] hover:univer-ring-primary-600/40
|
|
150
|
+
`, {
|
|
151
|
+
"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600": s === r
|
|
152
|
+
}),
|
|
153
|
+
style: { backgroundColor: s },
|
|
154
|
+
onClick: () => i(s)
|
|
155
|
+
},
|
|
156
|
+
s
|
|
157
|
+
)) });
|
|
158
|
+
}
|
|
159
|
+
const W = "CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";
|
|
160
|
+
function Pe(n) {
|
|
161
|
+
const e = n.get(g);
|
|
162
|
+
return {
|
|
163
|
+
id: w.id,
|
|
164
|
+
tooltip: "crosshair.button.tooltip",
|
|
165
|
+
type: ge.BUTTON_SELECTOR,
|
|
166
|
+
icon: "CrossHighlightingSingle",
|
|
167
|
+
selections: [
|
|
168
|
+
{
|
|
169
|
+
label: {
|
|
170
|
+
name: W,
|
|
171
|
+
hoverable: !1,
|
|
172
|
+
selectable: !1
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
selectionsCommandId: B.id,
|
|
177
|
+
activated$: e.enabled$,
|
|
178
|
+
hidden$: he(n, E.UNIVER_SHEET)
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
const je = {
|
|
182
|
+
[de.FOOTER_MENU]: {
|
|
183
|
+
[ue.OTHERS]: {
|
|
184
|
+
[w.id]: {
|
|
185
|
+
order: 0,
|
|
186
|
+
menuItemFactory: Pe
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
var Le = Object.getOwnPropertyDescriptor, ke = (n, e, t, r) => {
|
|
192
|
+
for (var i = r > 1 ? void 0 : r ? Le(e, t) : e, s = n.length - 1, o; s >= 0; s--)
|
|
193
|
+
(o = n[s]) && (i = o(i) || i);
|
|
194
|
+
return i;
|
|
195
|
+
}, O = (n, e) => (t, r) => e(t, r, n);
|
|
196
|
+
let b = class extends y {
|
|
197
|
+
constructor(n, e, t) {
|
|
198
|
+
super(), this._componentMgr = n, this._menuManagerService = e, this._cmdSrv = t, this._initCommands(), this._initMenus(), this._initComponents();
|
|
199
|
+
}
|
|
200
|
+
_initCommands() {
|
|
201
|
+
[
|
|
202
|
+
w,
|
|
203
|
+
B,
|
|
204
|
+
Te,
|
|
205
|
+
Ve
|
|
206
|
+
].forEach((n) => this._cmdSrv.registerCommand(n));
|
|
207
|
+
}
|
|
208
|
+
_initMenus() {
|
|
209
|
+
this._menuManagerService.mergeMenu(je);
|
|
210
|
+
}
|
|
211
|
+
_initComponents() {
|
|
212
|
+
this._componentMgr.register(W, Ne), this._componentMgr.register("CrossHighlightingSingle", D);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
b = ke([
|
|
216
|
+
O(0, u(fe)),
|
|
217
|
+
O(1, _e),
|
|
218
|
+
O(2, J)
|
|
219
|
+
], b);
|
|
220
|
+
const Ae = 1;
|
|
221
|
+
class Ge {
|
|
222
|
+
constructor() {
|
|
223
|
+
c(this, "_selectedRanges", []);
|
|
224
|
+
c(this, "_ranges", []);
|
|
225
|
+
}
|
|
226
|
+
addRange(e) {
|
|
227
|
+
if (e.rangeType === f.COLUMN || e.rangeType === f.ROW || e.rangeType === f.ALL)
|
|
228
|
+
return;
|
|
229
|
+
const t = this._getIntersects(e), r = this._getSplitRanges(e, t);
|
|
230
|
+
r.length > 0 && this._ranges.push(...r);
|
|
231
|
+
}
|
|
232
|
+
setSelectedRanges(e) {
|
|
233
|
+
this._selectedRanges = e;
|
|
234
|
+
}
|
|
235
|
+
_getSplitRanges(e, t) {
|
|
236
|
+
let r = [e];
|
|
237
|
+
for (const i of t.concat(this._selectedRanges)) {
|
|
238
|
+
const s = [];
|
|
239
|
+
for (const o of r) {
|
|
240
|
+
const a = $.subtract(o, i);
|
|
241
|
+
a && a.length > 0 && s.push(...a);
|
|
242
|
+
}
|
|
243
|
+
r = s;
|
|
244
|
+
}
|
|
245
|
+
return r.filter((i) => i.startRow <= i.endRow && i.startColumn <= i.endColumn);
|
|
246
|
+
}
|
|
247
|
+
_getIntersects(e) {
|
|
248
|
+
const t = [];
|
|
249
|
+
for (const r of this._ranges) {
|
|
250
|
+
const i = $.getIntersects(r, e);
|
|
251
|
+
i && t.push(i);
|
|
252
|
+
}
|
|
253
|
+
return t;
|
|
254
|
+
}
|
|
255
|
+
getRanges() {
|
|
256
|
+
return this._ranges;
|
|
257
|
+
}
|
|
258
|
+
reset() {
|
|
259
|
+
this._ranges = [], this._selectedRanges = [];
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
class Ue extends se {
|
|
263
|
+
constructor(t, r) {
|
|
264
|
+
super(t, r);
|
|
265
|
+
// protected _showHighLight = false;
|
|
266
|
+
c(this, "_color");
|
|
267
|
+
r && this.setShapeProps(r);
|
|
268
|
+
}
|
|
269
|
+
setShapeProps(t) {
|
|
270
|
+
typeof t.color < "u" && (this._color = t.color), this.transformByState({
|
|
271
|
+
width: t.width,
|
|
272
|
+
height: t.height
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
_draw(t) {
|
|
276
|
+
var i, s;
|
|
277
|
+
const r = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(s = (i = this._color) == null ? void 0 : i.a) != null ? s : 0.5})`;
|
|
278
|
+
oe.drawWith(t, {
|
|
279
|
+
width: this.width,
|
|
280
|
+
height: this.height,
|
|
281
|
+
fill: r,
|
|
282
|
+
stroke: void 0,
|
|
283
|
+
strokeWidth: 0,
|
|
284
|
+
evented: !1
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
var De = Object.getOwnPropertyDescriptor, Ze = (n, e, t, r) => {
|
|
289
|
+
for (var i = r > 1 ? void 0 : r ? De(e, t) : e, s = n.length - 1, o; s >= 0; s--)
|
|
290
|
+
(o = n[s]) && (i = o(i) || i);
|
|
291
|
+
return i;
|
|
292
|
+
}, S = (n, e) => (t, r) => e(t, r, n);
|
|
293
|
+
let R = class extends y {
|
|
294
|
+
constructor(e, t, r, i, s, o) {
|
|
295
|
+
super();
|
|
296
|
+
c(this, "_shapes", []);
|
|
297
|
+
c(this, "_rangeCollection", new Ge());
|
|
298
|
+
c(this, "_color", "rgba(255,0,0,0.5)");
|
|
299
|
+
this._context = e, this._sheetSkeletonManagerService = t, this._sheetsSelectionsService = r, this._sheetsCrosshairHighlightService = i, this._contextService = s, this._refSelectionsService = o, this._initRenderListener();
|
|
300
|
+
}
|
|
301
|
+
_transformSelection(e, t) {
|
|
302
|
+
if (!e)
|
|
303
|
+
return;
|
|
304
|
+
const r = t.getRowCount(), i = t.getColumnCount(), s = [];
|
|
305
|
+
for (const o of e) {
|
|
306
|
+
const { startRow: a, endRow: h, startColumn: _, endColumn: v } = o.range;
|
|
307
|
+
h - a + 1 === r || v - _ + 1 === i || s.push(o.range);
|
|
308
|
+
}
|
|
309
|
+
this._rangeCollection.setSelectedRanges(s);
|
|
310
|
+
for (const o of s)
|
|
311
|
+
this.addSelection(o, t);
|
|
312
|
+
}
|
|
313
|
+
_initRenderListener() {
|
|
314
|
+
const e = this._context.unit;
|
|
315
|
+
this.disposeWithMe(ve([
|
|
316
|
+
this._contextService.subscribeContextValue$(Oe).pipe(Se(!1)),
|
|
317
|
+
this._sheetSkeletonManagerService.currentSkeleton$,
|
|
318
|
+
this._sheetsCrosshairHighlightService.enabled$,
|
|
319
|
+
this._sheetsCrosshairHighlightService.color$.pipe(pe((t) => this._color = t)),
|
|
320
|
+
T(
|
|
321
|
+
this._sheetsSelectionsService.selectionMoveStart$,
|
|
322
|
+
this._sheetsSelectionsService.selectionMoving$,
|
|
323
|
+
this._sheetsSelectionsService.selectionMoveEnd$,
|
|
324
|
+
this._sheetsSelectionsService.selectionSet$,
|
|
325
|
+
e.activeSheet$.pipe(V(() => this._sheetsSelectionsService.getCurrentSelections()))
|
|
326
|
+
),
|
|
327
|
+
T(
|
|
328
|
+
this._refSelectionsService.selectionMoveStart$,
|
|
329
|
+
this._refSelectionsService.selectionMoving$,
|
|
330
|
+
this._refSelectionsService.selectionMoveEnd$,
|
|
331
|
+
this._sheetsSelectionsService.selectionSet$,
|
|
332
|
+
e.activeSheet$.pipe(V(() => this._refSelectionsService.getCurrentSelections()))
|
|
333
|
+
)
|
|
334
|
+
]).subscribe(([t, r, i, s, o, a]) => {
|
|
335
|
+
if (this._clear(), !i) return;
|
|
336
|
+
const h = t ? a : o;
|
|
337
|
+
this._rangeCollection.reset(), this._transformSelection(h, e.getActiveSheet()), this.render(this._rangeCollection.getRanges());
|
|
338
|
+
}));
|
|
339
|
+
}
|
|
340
|
+
addSelection(e, t) {
|
|
341
|
+
if (e.rangeType === f.COLUMN || e.rangeType === f.ROW || e.rangeType === f.ALL)
|
|
342
|
+
return;
|
|
343
|
+
const r = t.getRowCount(), i = t.getColumnCount(), { startRow: s, endRow: o, startColumn: a, endColumn: h } = e, _ = {
|
|
344
|
+
startRow: s,
|
|
345
|
+
endRow: o,
|
|
346
|
+
startColumn: 0,
|
|
347
|
+
endColumn: a - 1
|
|
348
|
+
}, v = {
|
|
349
|
+
startRow: s,
|
|
350
|
+
endRow: o,
|
|
351
|
+
startColumn: h + 1,
|
|
352
|
+
endColumn: i
|
|
353
|
+
}, p = {
|
|
354
|
+
startRow: 0,
|
|
355
|
+
endRow: s - 1,
|
|
356
|
+
startColumn: a,
|
|
357
|
+
endColumn: h
|
|
358
|
+
}, C = {
|
|
359
|
+
startRow: o + 1,
|
|
360
|
+
endRow: r,
|
|
361
|
+
startColumn: a,
|
|
362
|
+
endColumn: h
|
|
363
|
+
};
|
|
364
|
+
for (const d of [_, v, p, C])
|
|
365
|
+
d.startRow <= d.endRow && d.startColumn <= d.endColumn && this._rangeCollection.addRange(d);
|
|
366
|
+
}
|
|
367
|
+
_clear() {
|
|
368
|
+
this._shapes.forEach((e) => {
|
|
369
|
+
e.dispose();
|
|
370
|
+
}), this._shapes = [];
|
|
371
|
+
}
|
|
372
|
+
_addShapes(e, t, r, i) {
|
|
373
|
+
const { startRow: s, endRow: o, startColumn: a, endColumn: h } = e, _ = P(s, a, r, i), v = P(o, h, r, i), { startX: p, startY: C } = _, { endX: d, endY: Y } = v, F = d - p, X = Y - C, z = {
|
|
374
|
+
left: p,
|
|
375
|
+
top: C,
|
|
376
|
+
color: new ee(this._color).toRgb(),
|
|
377
|
+
width: F,
|
|
378
|
+
height: X,
|
|
379
|
+
zIndex: Ae,
|
|
380
|
+
evented: !1
|
|
381
|
+
}, M = new Ue(`crosshair-${t}`, z);
|
|
382
|
+
this._shapes.push(M), r.addObject(M);
|
|
383
|
+
}
|
|
384
|
+
render(e) {
|
|
385
|
+
const t = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
386
|
+
if (!t)
|
|
387
|
+
return;
|
|
388
|
+
const { scene: r } = this._context;
|
|
389
|
+
this._clear();
|
|
390
|
+
for (let i = 0; i < e.length; i++) {
|
|
391
|
+
const s = e[i];
|
|
392
|
+
this._addShapes(s, i, r, t);
|
|
393
|
+
}
|
|
394
|
+
r.makeDirty(!0);
|
|
395
|
+
}
|
|
396
|
+
async dispose() {
|
|
397
|
+
super.dispose();
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
R = Ze([
|
|
401
|
+
S(1, u(Ie)),
|
|
402
|
+
S(2, u(Re)),
|
|
403
|
+
S(3, u(g)),
|
|
404
|
+
S(4, u(Q)),
|
|
405
|
+
S(5, He)
|
|
406
|
+
], R);
|
|
407
|
+
var Be = Object.getOwnPropertyDescriptor, We = (n, e, t, r) => {
|
|
408
|
+
for (var i = r > 1 ? void 0 : r ? Be(e, t) : e, s = n.length - 1, o; s >= 0; s--)
|
|
409
|
+
(o = n[s]) && (i = o(i) || i);
|
|
410
|
+
return i;
|
|
411
|
+
}, I = (n, e) => (t, r) => e(t, r, n), m;
|
|
412
|
+
let L = (m = class extends te {
|
|
413
|
+
constructor(n = j, e, t, r) {
|
|
414
|
+
super(), this._config = n, this._injector = e, this._renderManagerService = t, this._configService = r;
|
|
415
|
+
const { ...i } = re(
|
|
416
|
+
{},
|
|
417
|
+
j,
|
|
418
|
+
this._config
|
|
419
|
+
);
|
|
420
|
+
this._configService.setConfig(Ee, i);
|
|
421
|
+
}
|
|
422
|
+
onStarting() {
|
|
423
|
+
[
|
|
424
|
+
[g],
|
|
425
|
+
[b]
|
|
426
|
+
].forEach((n) => this._injector.add(n));
|
|
427
|
+
}
|
|
428
|
+
onReady() {
|
|
429
|
+
[
|
|
430
|
+
[R]
|
|
431
|
+
].forEach((n) => this._injector.add(n)), this._injector.get(b), this._renderManagerService.registerRenderModule(E.UNIVER_SHEET, [R]);
|
|
432
|
+
}
|
|
433
|
+
}, c(m, "pluginName", "SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"), c(m, "type", E.UNIVER_SHEET), m);
|
|
434
|
+
L = We([
|
|
435
|
+
I(1, u(ne)),
|
|
436
|
+
I(2, ae),
|
|
437
|
+
I(3, ie)
|
|
438
|
+
], L);
|
|
439
|
+
export {
|
|
440
|
+
Z as CROSSHAIR_HIGHLIGHT_COLORS,
|
|
441
|
+
Ve as DisableCrosshairHighlightOperation,
|
|
442
|
+
Te as EnableCrosshairHighlightOperation,
|
|
443
|
+
B as SetCrosshairHighlightColorOperation,
|
|
444
|
+
g as SheetsCrosshairHighlightService,
|
|
445
|
+
w as ToggleCrosshairHighlightOperation,
|
|
446
|
+
L as UniverSheetsCrosshairHighlightPlugin
|
|
447
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-crosshair-highlight",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -53,17 +53,17 @@
|
|
|
53
53
|
"lib"
|
|
54
54
|
],
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"react": "
|
|
56
|
+
"react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
|
|
57
57
|
"rxjs": ">=7.0.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@univerjs/icons": "^0.2.
|
|
61
|
-
"@univerjs/core": "0.6.
|
|
62
|
-
"@univerjs/design": "0.6.
|
|
63
|
-
"@univerjs/engine-render": "0.6.
|
|
64
|
-
"@univerjs/sheets
|
|
65
|
-
"@univerjs/sheets": "0.6.
|
|
66
|
-
"@univerjs/ui": "0.6.
|
|
60
|
+
"@univerjs/icons": "^0.2.31",
|
|
61
|
+
"@univerjs/core": "0.6.9",
|
|
62
|
+
"@univerjs/design": "0.6.9",
|
|
63
|
+
"@univerjs/engine-render": "0.6.9",
|
|
64
|
+
"@univerjs/sheets": "0.6.9",
|
|
65
|
+
"@univerjs/sheets-ui": "0.6.9",
|
|
66
|
+
"@univerjs/ui": "0.6.9"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"postcss": "^8.5.3",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"typescript": "^5.8.2",
|
|
74
74
|
"vite": "^6.2.3",
|
|
75
75
|
"vitest": "^3.0.9",
|
|
76
|
-
"@univerjs-infra/shared": "0.6.
|
|
76
|
+
"@univerjs-infra/shared": "0.6.9"
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|
|
79
79
|
"test": "vitest run",
|