@univerjs/sheets-zen-editor 0.6.10 → 0.7.0-beta.1
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 +10 -1
- package/lib/es/index.js +201 -192
- package/lib/index.css +1 -1
- package/lib/index.js +201 -192
- package/lib/umd/index.js +10 -1
- package/package.json +13 -14
package/lib/es/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { CommandType as R, IUniverInstanceService as
|
|
5
|
-
import { IEditorService as
|
|
6
|
-
import { IRenderManagerService as
|
|
7
|
-
import { IEditorBridgeService as b, EditingRenderController as Ne, getCurrentExclusiveRangeInterest$ as
|
|
8
|
-
import { IZenZoneService as
|
|
9
|
-
import { jsxs as
|
|
10
|
-
import { clsx as
|
|
11
|
-
import { forwardRef as
|
|
12
|
-
import { BehaviorSubject as
|
|
13
|
-
import { RangeProtectionPermissionEditPoint as
|
|
14
|
-
const
|
|
1
|
+
var se = Object.defineProperty;
|
|
2
|
+
var ce = (e, t, i) => t in e ? se(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
3
|
+
var _ = (e, t, i) => ce(e, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
+
import { CommandType as R, IUniverInstanceService as x, delayAnimationFrame as P, DOCS_ZEN_EDITOR_UNIT_ID_KEY as g, Tools as K, UniverInstanceType as w, DocumentFlavor as X, DocumentDataModel as ae, createIdentifier as le, ICommandService as q, DEFAULT_EMPTY_DOCUMENT_VALUE as de, FOCUSING_DOC as ue, FOCUSING_UNIVER_EDITOR as ge, EDITOR_ACTIVATED as fe, FOCUSING_EDITOR_STANDALONE as he, Disposable as ve, RxDisposable as me, Plugin as pe, merge as _e, Inject as Se, Injector as Ie, IConfigService as Ce } from "@univerjs/core";
|
|
5
|
+
import { IEditorService as z, VIEWPORT_KEY as Ee, DocBackScrollRenderController as Oe } from "@univerjs/docs-ui";
|
|
6
|
+
import { IRenderManagerService as J } from "@univerjs/engine-render";
|
|
7
|
+
import { IEditorBridgeService as b, EditingRenderController as Ne, getCurrentExclusiveRangeInterest$ as ye, getCurrentRangeDisable$ as be, getEditorObject as Te } from "@univerjs/sheets-ui";
|
|
8
|
+
import { IZenZoneService as T, ISidebarService as k, useDependency as D, MenuItemType as Me, ContextMenuPosition as De, ContextMenuGroup as Re, KeyCode as Q, MetaKeys as xe, IMenuManagerService as Pe, IShortcutService as we } from "@univerjs/ui";
|
|
9
|
+
import { jsxs as V, jsx as S } from "react/jsx-runtime";
|
|
10
|
+
import { clsx as F } from "@univerjs/design";
|
|
11
|
+
import { forwardRef as U, useRef as ee, createElement as j, useEffect as ze } from "react";
|
|
12
|
+
import { BehaviorSubject as ke, switchMap as Ue, map as je, takeUntil as Ze } from "rxjs";
|
|
13
|
+
import { RangeProtectionPermissionEditPoint as Be, WorksheetEditPermission as Le, WorksheetSetCellValuePermission as Ae, WorksheetSetCellStylePermission as $e, WorkbookEditablePermission as Ve } from "@univerjs/sheets";
|
|
14
|
+
const Z = {
|
|
15
15
|
id: "zen-editor.command.open-zen-editor",
|
|
16
16
|
type: R.COMMAND,
|
|
17
17
|
handler: async (e) => {
|
|
18
18
|
var C;
|
|
19
|
-
const t = e.get(
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
19
|
+
const t = e.get(T), i = e.get(z), n = e.get(b), r = e.get(x), o = e.get(k);
|
|
20
|
+
o.visible && (o.close(), await P()), t.open();
|
|
21
|
+
const s = i.getEditor(g);
|
|
22
|
+
if (s == null)
|
|
23
23
|
return !1;
|
|
24
24
|
const c = n.getLatestEditCellState();
|
|
25
25
|
if (c == null)
|
|
@@ -28,13 +28,13 @@ const B = {
|
|
|
28
28
|
if (a == null)
|
|
29
29
|
return !1;
|
|
30
30
|
r.focusUnit(g);
|
|
31
|
-
const { body:
|
|
32
|
-
...
|
|
33
|
-
body:
|
|
31
|
+
const { body: l, drawings: v, drawingsOrder: u, tableSource: f, settings: m } = K.deepClone(a), p = {
|
|
32
|
+
...s.getDocumentData(),
|
|
33
|
+
body: l,
|
|
34
34
|
drawings: v,
|
|
35
|
-
drawingsOrder:
|
|
35
|
+
drawingsOrder: u,
|
|
36
36
|
tableSource: f,
|
|
37
|
-
settings:
|
|
37
|
+
settings: m
|
|
38
38
|
}, h = [
|
|
39
39
|
{
|
|
40
40
|
startOffset: 0,
|
|
@@ -42,39 +42,39 @@ const B = {
|
|
|
42
42
|
collapsed: !0
|
|
43
43
|
}
|
|
44
44
|
];
|
|
45
|
-
return
|
|
45
|
+
return s.focus(), s.setDocumentData(p, h), s.clearUndoRedoHistory(), !0;
|
|
46
46
|
}
|
|
47
|
-
},
|
|
47
|
+
}, B = {
|
|
48
48
|
id: "zen-editor.command.cancel-zen-edit",
|
|
49
49
|
type: R.COMMAND,
|
|
50
50
|
handler: async (e) => {
|
|
51
|
-
const t = e.get(
|
|
52
|
-
r.visible && (r.close(), await
|
|
53
|
-
const
|
|
54
|
-
return
|
|
51
|
+
const t = e.get(T), i = e.get(b), n = e.get(x), r = e.get(k);
|
|
52
|
+
r.visible && (r.close(), await P()), t.close();
|
|
53
|
+
const o = n.getCurrentUnitForType(w.UNIVER_SHEET);
|
|
54
|
+
return o ? (n.focusUnit(o.getUnitId()), i.refreshEditCellState(), !0) : !1;
|
|
55
55
|
}
|
|
56
|
-
},
|
|
56
|
+
}, L = {
|
|
57
57
|
id: "zen-editor.command.confirm-zen-edit",
|
|
58
58
|
type: R.COMMAND,
|
|
59
59
|
handler: async (e) => {
|
|
60
|
-
var
|
|
61
|
-
const t = e.get(
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
60
|
+
var l;
|
|
61
|
+
const t = e.get(T), i = e.get(b), n = e.get(x), r = e.get(z), o = e.get(k);
|
|
62
|
+
o.visible && (o.close(), await P()), t.close();
|
|
63
|
+
const s = r.getEditor(g);
|
|
64
|
+
if (s == null)
|
|
65
65
|
return !1;
|
|
66
|
-
const c = e.get(
|
|
66
|
+
const c = e.get(J), a = n.getCurrentUnitForType(w.UNIVER_SHEET);
|
|
67
67
|
if (a) {
|
|
68
|
-
const v = a.getUnitId(),
|
|
69
|
-
if (
|
|
70
|
-
const f =
|
|
71
|
-
f.documentStyle.documentFlavor =
|
|
68
|
+
const v = a.getUnitId(), u = (l = c.getRenderById(v)) == null ? void 0 : l.with(Ne);
|
|
69
|
+
if (u) {
|
|
70
|
+
const f = K.deepClone(s.getDocumentData());
|
|
71
|
+
f.documentStyle.documentFlavor = X.UNSPECIFIED, u.submitCellData(new ae(f));
|
|
72
72
|
}
|
|
73
73
|
return n.focusUnit(a.getUnitId()), i.refreshEditCellState(), !0;
|
|
74
74
|
}
|
|
75
75
|
return !1;
|
|
76
76
|
}
|
|
77
|
-
},
|
|
77
|
+
}, Fe = "sheets-zen-editor.config", W = {};
|
|
78
78
|
var d = function() {
|
|
79
79
|
return d = Object.assign || function(e) {
|
|
80
80
|
for (var t, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -83,65 +83,65 @@ var d = function() {
|
|
|
83
83
|
}
|
|
84
84
|
return e;
|
|
85
85
|
}, d.apply(this, arguments);
|
|
86
|
-
},
|
|
86
|
+
}, We = function(e, t) {
|
|
87
87
|
var i = {};
|
|
88
88
|
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (i[n] = e[n]);
|
|
89
89
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
90
90
|
for (var r = 0, n = Object.getOwnPropertySymbols(e); r < n.length; r++)
|
|
91
91
|
t.indexOf(n[r]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[r]) && (i[n[r]] = e[n[r]]);
|
|
92
92
|
return i;
|
|
93
|
-
},
|
|
94
|
-
var i = e.icon, n = e.id, r = e.className,
|
|
95
|
-
return
|
|
93
|
+
}, A = U(function(e, t) {
|
|
94
|
+
var i = e.icon, n = e.id, r = e.className, o = e.extend, s = We(e, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(n, " ").concat(r || "").trim(), a = ee("_".concat(Ge()));
|
|
95
|
+
return te(i, "".concat(n), { defIds: i.defIds, idSuffix: a.current }, d({ ref: t, className: c }, s), o);
|
|
96
96
|
});
|
|
97
|
-
function
|
|
98
|
-
return j(e.tag, d(d({ key: t },
|
|
99
|
-
return
|
|
97
|
+
function te(e, t, i, n, r) {
|
|
98
|
+
return j(e.tag, d(d({ key: t }, He(e, i, r)), n), (Ye(e, i).children || []).map(function(o, s) {
|
|
99
|
+
return te(o, "".concat(t, "-").concat(e.tag, "-").concat(s), i, void 0, r);
|
|
100
100
|
}));
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function He(e, t, i) {
|
|
103
103
|
var n = d({}, e.attrs);
|
|
104
|
-
i != null && i.colorChannel1 && n.fill === "colorChannel1" && (n.fill = i.colorChannel1), e.tag === "mask" && n.id && (n.id = n.id + t.idSuffix), Object.entries(n).forEach(function(
|
|
105
|
-
var
|
|
106
|
-
|
|
104
|
+
i != null && i.colorChannel1 && n.fill === "colorChannel1" && (n.fill = i.colorChannel1), e.tag === "mask" && n.id && (n.id = n.id + t.idSuffix), Object.entries(n).forEach(function(o) {
|
|
105
|
+
var s = o[0], c = o[1];
|
|
106
|
+
s === "mask" && typeof c == "string" && (n[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
|
|
107
107
|
});
|
|
108
108
|
var r = t.defIds;
|
|
109
|
-
return !r || r.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + t.idSuffix), Object.entries(n).forEach(function(
|
|
110
|
-
var
|
|
111
|
-
typeof c == "string" && (n[
|
|
109
|
+
return !r || r.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + t.idSuffix), Object.entries(n).forEach(function(o) {
|
|
110
|
+
var s = o[0], c = o[1];
|
|
111
|
+
typeof c == "string" && (n[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
|
|
112
112
|
})), n;
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function Ye(e, t) {
|
|
115
115
|
var i, n = t.defIds;
|
|
116
116
|
return !n || n.length === 0 ? e : e.tag === "defs" && (!((i = e.children) === null || i === void 0) && i.length) ? d(d({}, e), { children: e.children.map(function(r) {
|
|
117
117
|
return typeof r.attrs.id == "string" && n && n.indexOf(r.attrs.id) > -1 ? d(d({}, r), { attrs: d(d({}, r.attrs), { id: r.attrs.id + t.idSuffix }) }) : r;
|
|
118
118
|
}) }) : e;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function Ge() {
|
|
121
121
|
return Math.random().toString(36).substring(2, 8);
|
|
122
122
|
}
|
|
123
|
-
|
|
124
|
-
var
|
|
125
|
-
return j(
|
|
123
|
+
A.displayName = "UniverIcon";
|
|
124
|
+
var Ke = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, ne = U(function(e, t) {
|
|
125
|
+
return j(A, Object.assign({}, e, {
|
|
126
126
|
id: "check-mark-single",
|
|
127
127
|
ref: t,
|
|
128
|
-
icon:
|
|
128
|
+
icon: Ke
|
|
129
129
|
}));
|
|
130
130
|
});
|
|
131
|
-
|
|
132
|
-
var
|
|
133
|
-
return j(
|
|
131
|
+
ne.displayName = "CheckMarkSingle";
|
|
132
|
+
var Xe = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z" } }] }, ie = U(function(e, t) {
|
|
133
|
+
return j(A, Object.assign({}, e, {
|
|
134
134
|
id: "close-single",
|
|
135
135
|
ref: t,
|
|
136
|
-
icon:
|
|
136
|
+
icon: Xe
|
|
137
137
|
}));
|
|
138
138
|
});
|
|
139
|
-
|
|
140
|
-
class
|
|
139
|
+
ie.displayName = "CloseSingle";
|
|
140
|
+
class qe {
|
|
141
141
|
constructor() {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
_(this, "_position", null);
|
|
143
|
+
_(this, "_position$", new ke(null));
|
|
144
|
+
_(this, "position$", this._position$.asObservable());
|
|
145
145
|
}
|
|
146
146
|
dispose() {
|
|
147
147
|
this._position$.complete(), this._position = null;
|
|
@@ -156,19 +156,12 @@ class Je {
|
|
|
156
156
|
this._position$.next(t);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
const
|
|
159
|
+
const $ = le(
|
|
160
160
|
"univer.sheet-zen-editor-manager.service"
|
|
161
|
-
),
|
|
162
|
-
zenEditor: Qe,
|
|
163
|
-
zenEditorIconWrapper: et,
|
|
164
|
-
zenEditorIconContainer: tt,
|
|
165
|
-
zenEditorIconSuccess: nt,
|
|
166
|
-
zenEditorIconError: it,
|
|
167
|
-
zenEditorCanvasContainer: rt
|
|
168
|
-
}, ot = "ZEN_EDITOR_PLUGIN_", st = `${ot}ZEN_EDITOR_COMPONENT`, ct = {
|
|
161
|
+
), Je = "ZEN_EDITOR_PLUGIN_", Qe = `${Je}ZEN_EDITOR_COMPONENT`, et = {
|
|
169
162
|
id: g,
|
|
170
163
|
body: {
|
|
171
|
-
dataStream: `${
|
|
164
|
+
dataStream: `${de}`,
|
|
172
165
|
textRuns: [],
|
|
173
166
|
tables: [],
|
|
174
167
|
customBlocks: [],
|
|
@@ -187,7 +180,7 @@ const V = le(
|
|
|
187
180
|
width: 595,
|
|
188
181
|
height: Number.POSITIVE_INFINITY
|
|
189
182
|
},
|
|
190
|
-
documentFlavor:
|
|
183
|
+
documentFlavor: X.MODERN,
|
|
191
184
|
marginTop: 0,
|
|
192
185
|
marginBottom: 0,
|
|
193
186
|
marginRight: 0,
|
|
@@ -200,100 +193,116 @@ const V = le(
|
|
|
200
193
|
drawings: {},
|
|
201
194
|
drawingsOrder: []
|
|
202
195
|
};
|
|
203
|
-
function
|
|
204
|
-
const e =
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
if (!
|
|
196
|
+
function tt() {
|
|
197
|
+
const e = ee(null), t = D($), i = D(z), n = D(q);
|
|
198
|
+
ze(() => {
|
|
199
|
+
const c = e.current;
|
|
200
|
+
if (!c)
|
|
208
201
|
return;
|
|
209
|
-
const
|
|
202
|
+
const a = i.register({
|
|
210
203
|
editorUnitId: g,
|
|
211
|
-
initialSnapshot:
|
|
204
|
+
initialSnapshot: et,
|
|
212
205
|
scrollBar: !0,
|
|
213
206
|
backScrollOffset: 100
|
|
214
|
-
},
|
|
215
|
-
t.setPosition(
|
|
207
|
+
}, c), l = new ResizeObserver(() => {
|
|
208
|
+
t.setPosition(c.getBoundingClientRect());
|
|
216
209
|
});
|
|
217
|
-
return
|
|
218
|
-
|
|
210
|
+
return l.observe(c), () => {
|
|
211
|
+
a.dispose(), l.unobserve(c);
|
|
219
212
|
};
|
|
220
213
|
}, []);
|
|
221
214
|
function r() {
|
|
222
|
-
const
|
|
223
|
-
|
|
215
|
+
const c = i.getEditor(g);
|
|
216
|
+
c == null || c.blur(), n.executeCommand(B.id);
|
|
224
217
|
}
|
|
225
|
-
function
|
|
226
|
-
const
|
|
227
|
-
|
|
218
|
+
function o() {
|
|
219
|
+
const c = i.getEditor(g);
|
|
220
|
+
c == null || c.blur(), n.executeCommand(L.id);
|
|
228
221
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
222
|
+
const s = "univer-flex univer-w-7 univer-cursor-pointer univer-items-center univer-justify-center univer-transition-colors";
|
|
223
|
+
return /* @__PURE__ */ V("div", { className: "univer-absolute univer-inset-0 univer-size-full univer-bg-white", children: [
|
|
224
|
+
/* @__PURE__ */ V(
|
|
225
|
+
"div",
|
|
226
|
+
{
|
|
227
|
+
className: `
|
|
228
|
+
univer-absolute univer-right-6 univer-top-2 univer-z-10 univer-flex univer-items-center
|
|
229
|
+
univer-justify-center
|
|
230
|
+
`,
|
|
231
|
+
children: [
|
|
232
|
+
/* @__PURE__ */ S(
|
|
233
|
+
"span",
|
|
234
|
+
{
|
|
235
|
+
className: F(s, `
|
|
236
|
+
univer-text-red-500
|
|
237
|
+
hover:univer-text-red-600
|
|
238
|
+
`),
|
|
239
|
+
onClick: r,
|
|
240
|
+
children: /* @__PURE__ */ S(ie, { className: "univer-size-5" })
|
|
241
|
+
}
|
|
242
|
+
),
|
|
243
|
+
/* @__PURE__ */ S(
|
|
244
|
+
"span",
|
|
245
|
+
{
|
|
246
|
+
className: F(s, `
|
|
247
|
+
univer-text-green-500
|
|
248
|
+
hover:univer-text-green-600
|
|
249
|
+
`),
|
|
250
|
+
onClick: o,
|
|
251
|
+
children: /* @__PURE__ */ S(ne, { className: "univer-size-5" })
|
|
252
|
+
}
|
|
253
|
+
)
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
),
|
|
257
|
+
/* @__PURE__ */ S("div", { ref: e, className: "univer-absolute univer-inset-0 univer-size-full" })
|
|
249
258
|
] });
|
|
250
259
|
}
|
|
251
|
-
function
|
|
260
|
+
function nt(e) {
|
|
252
261
|
const t = e.get(b);
|
|
253
262
|
return {
|
|
254
|
-
id:
|
|
263
|
+
id: Z.id,
|
|
255
264
|
type: Me.BUTTON,
|
|
256
265
|
title: "rightClick.zenEditor",
|
|
257
266
|
icon: "AmplifySingle",
|
|
258
|
-
hidden$:
|
|
267
|
+
hidden$: ye(e),
|
|
259
268
|
disabled$: t.currentEditCell$.pipe(
|
|
260
|
-
|
|
261
|
-
var r,
|
|
262
|
-
return n || ((c = (
|
|
269
|
+
Ue((i) => be(e, { workbookTypes: [Ve], worksheetTypes: [Le, Ae, $e], rangeTypes: [Be] }).pipe(je((n) => {
|
|
270
|
+
var r, o, s, c;
|
|
271
|
+
return n || ((c = (s = (o = (r = i == null ? void 0 : i.documentLayoutObject.documentModel) == null ? void 0 : r.getBody()) == null ? void 0 : o.customBlocks) == null ? void 0 : s.length) != null ? c : 0) > 0;
|
|
263
272
|
})))
|
|
264
273
|
)
|
|
265
274
|
};
|
|
266
275
|
}
|
|
267
|
-
const
|
|
276
|
+
const it = {
|
|
268
277
|
[De.MAIN_AREA]: {
|
|
269
278
|
[Re.OTHERS]: {
|
|
270
|
-
[
|
|
279
|
+
[Z.id]: {
|
|
271
280
|
order: 2,
|
|
272
|
-
menuItemFactory:
|
|
281
|
+
menuItemFactory: nt
|
|
273
282
|
}
|
|
274
283
|
}
|
|
275
284
|
}
|
|
276
|
-
},
|
|
277
|
-
id:
|
|
285
|
+
}, rt = {
|
|
286
|
+
id: L.id,
|
|
278
287
|
description: "shortcut.sheet.zen-edit-confirm",
|
|
279
288
|
group: "4_sheet-edit",
|
|
280
|
-
preconditions: (e) =>
|
|
281
|
-
binding:
|
|
282
|
-
},
|
|
283
|
-
id:
|
|
289
|
+
preconditions: (e) => re(e),
|
|
290
|
+
binding: Q.ENTER | xe.ALT
|
|
291
|
+
}, ot = {
|
|
292
|
+
id: B.id,
|
|
284
293
|
description: "shortcut.sheet.zen-edit-cancel",
|
|
285
294
|
group: "4_sheet-edit",
|
|
286
|
-
preconditions: (e) =>
|
|
287
|
-
binding:
|
|
295
|
+
preconditions: (e) => re(e),
|
|
296
|
+
binding: Q.ESC
|
|
288
297
|
};
|
|
289
|
-
function
|
|
290
|
-
return e.getContextValue(
|
|
298
|
+
function re(e) {
|
|
299
|
+
return e.getContextValue(ue) && e.getContextValue(ge) && e.getContextValue(fe) && !e.getContextValue(he);
|
|
291
300
|
}
|
|
292
|
-
var
|
|
293
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
294
|
-
(
|
|
301
|
+
var st = Object.getOwnPropertyDescriptor, ct = (e, t, i, n) => {
|
|
302
|
+
for (var r = n > 1 ? void 0 : n ? st(t, i) : t, o = e.length - 1, s; o >= 0; o--)
|
|
303
|
+
(s = e[o]) && (r = s(r) || r);
|
|
295
304
|
return r;
|
|
296
|
-
},
|
|
305
|
+
}, E = (e, t) => (i, n) => t(i, n, e);
|
|
297
306
|
let N = class extends ve {
|
|
298
307
|
constructor(e, t, i, n) {
|
|
299
308
|
super(), this._zenZoneService = e, this._commandService = t, this._menuManagerService = i, this._shortcutService = n, this._initialize();
|
|
@@ -302,34 +311,34 @@ let N = class extends ve {
|
|
|
302
311
|
this._initCustomComponents(), this._initCommands(), this._initMenus(), this._initShortcuts();
|
|
303
312
|
}
|
|
304
313
|
_initCustomComponents() {
|
|
305
|
-
this.disposeWithMe(this._zenZoneService.set(
|
|
314
|
+
this.disposeWithMe(this._zenZoneService.set(Qe, tt));
|
|
306
315
|
}
|
|
307
316
|
_initCommands() {
|
|
308
|
-
[B, L
|
|
317
|
+
[Z, B, L].forEach((e) => {
|
|
309
318
|
this.disposeWithMe(this._commandService.registerCommand(e));
|
|
310
319
|
});
|
|
311
320
|
}
|
|
312
321
|
_initMenus() {
|
|
313
|
-
this._menuManagerService.mergeMenu(
|
|
322
|
+
this._menuManagerService.mergeMenu(it);
|
|
314
323
|
}
|
|
315
324
|
_initShortcuts() {
|
|
316
|
-
[
|
|
325
|
+
[rt, ot].forEach((e) => {
|
|
317
326
|
this.disposeWithMe(this._shortcutService.registerShortcut(e));
|
|
318
327
|
});
|
|
319
328
|
}
|
|
320
329
|
};
|
|
321
|
-
N =
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
330
|
+
N = ct([
|
|
331
|
+
E(0, T),
|
|
332
|
+
E(1, q),
|
|
333
|
+
E(2, Pe),
|
|
334
|
+
E(3, we)
|
|
326
335
|
], N);
|
|
327
|
-
var
|
|
328
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
329
|
-
(
|
|
336
|
+
var at = Object.getOwnPropertyDescriptor, lt = (e, t, i, n) => {
|
|
337
|
+
for (var r = n > 1 ? void 0 : n ? at(t, i) : t, o = e.length - 1, s; o >= 0; o--)
|
|
338
|
+
(s = e[o]) && (r = s(r) || r);
|
|
330
339
|
return r;
|
|
331
|
-
},
|
|
332
|
-
let
|
|
340
|
+
}, H = (e, t) => (i, n) => t(i, n, e);
|
|
341
|
+
let y = class extends me {
|
|
333
342
|
constructor(e, t) {
|
|
334
343
|
super(), this._zenEditorManagerService = e, this._renderManagerService = t, this._initialize();
|
|
335
344
|
}
|
|
@@ -338,83 +347,83 @@ let T = class extends pe {
|
|
|
338
347
|
}
|
|
339
348
|
// Listen to changes in the size of the zen editor container to set the size of the editor.
|
|
340
349
|
_syncZenEditorSize() {
|
|
341
|
-
this._zenEditorManagerService.position$.pipe(
|
|
350
|
+
this._zenEditorManagerService.position$.pipe(Ze(this.dispose$)).subscribe((e) => {
|
|
342
351
|
if (e == null)
|
|
343
352
|
return;
|
|
344
|
-
const { width: t, height: i } = e, n =
|
|
353
|
+
const { width: t, height: i } = e, n = Te(g, this._renderManagerService);
|
|
345
354
|
n != null && requestIdleCallback(() => {
|
|
346
355
|
n.engine.resizeBySize(t, i), this._calculatePagePosition(n), this._scrollToTop();
|
|
347
356
|
});
|
|
348
357
|
});
|
|
349
358
|
}
|
|
350
359
|
_calculatePagePosition(e) {
|
|
351
|
-
const { document: t, scene: i, docBackground: n } = e, r = i == null ? void 0 : i.getParent(), { width:
|
|
352
|
-
if (r == null ||
|
|
360
|
+
const { document: t, scene: i, docBackground: n } = e, r = i == null ? void 0 : i.getParent(), { width: o, height: s, pageMarginLeft: c, pageMarginTop: a } = t;
|
|
361
|
+
if (r == null || o === Number.POSITIVE_INFINITY || s === Number.POSITIVE_INFINITY)
|
|
353
362
|
return;
|
|
354
|
-
const { width:
|
|
355
|
-
let
|
|
363
|
+
const { width: l, height: v } = r;
|
|
364
|
+
let u = 0;
|
|
356
365
|
const f = a;
|
|
357
|
-
let
|
|
366
|
+
let m = 0, I = 0, p = Number.POSITIVE_INFINITY;
|
|
358
367
|
const { scaleX: h, scaleY: C } = i.getAncestorScale();
|
|
359
|
-
|
|
360
|
-
const M = i.getViewport(
|
|
361
|
-
if (
|
|
362
|
-
const
|
|
368
|
+
l > (o + c * 2) * h ? (u = l / 2 - o * h / 2, u /= h, m = (l - c * 2) / h, p = 0) : (u = c, m = o + c * 2, p = (m - l / h) / 2), v > s ? I = (v - a * 2) / C : I = s + a * 2, i.resize(m, I), t.translate(u, f), n.translate(u, f);
|
|
369
|
+
const M = i.getViewport(Ee.VIEW_MAIN);
|
|
370
|
+
if (p !== Number.POSITIVE_INFINITY && M != null) {
|
|
371
|
+
const oe = M.transScroll2ViewportScrollValue(p, 0).x;
|
|
363
372
|
M.scrollToBarPos({
|
|
364
|
-
x:
|
|
373
|
+
x: oe
|
|
365
374
|
});
|
|
366
375
|
}
|
|
367
376
|
return this;
|
|
368
377
|
}
|
|
369
378
|
_scrollToTop() {
|
|
370
379
|
var i;
|
|
371
|
-
const e = (i = this._renderManagerService.getRenderById(g)) == null ? void 0 : i.with(
|
|
380
|
+
const e = (i = this._renderManagerService.getRenderById(g)) == null ? void 0 : i.with(Oe), t = {
|
|
372
381
|
startOffset: 0,
|
|
373
382
|
endOffset: 0
|
|
374
383
|
};
|
|
375
384
|
e && e.scrollToRange(t);
|
|
376
385
|
}
|
|
377
386
|
};
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
],
|
|
382
|
-
var
|
|
383
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
384
|
-
(
|
|
387
|
+
y = lt([
|
|
388
|
+
H(0, $),
|
|
389
|
+
H(1, J)
|
|
390
|
+
], y);
|
|
391
|
+
var dt = Object.getOwnPropertyDescriptor, ut = (e, t, i, n) => {
|
|
392
|
+
for (var r = n > 1 ? void 0 : n ? dt(t, i) : t, o = e.length - 1, s; o >= 0; o--)
|
|
393
|
+
(s = e[o]) && (r = s(r) || r);
|
|
385
394
|
return r;
|
|
386
|
-
},
|
|
387
|
-
let
|
|
388
|
-
constructor(e =
|
|
395
|
+
}, Y = (e, t) => (i, n) => t(i, n, e), O;
|
|
396
|
+
let G = (O = class extends pe {
|
|
397
|
+
constructor(e = W, t, i) {
|
|
389
398
|
super(), this._config = e, this._injector = t, this._configService = i;
|
|
390
|
-
const { menu: n, ...r } =
|
|
399
|
+
const { menu: n, ...r } = _e(
|
|
391
400
|
{},
|
|
392
|
-
|
|
401
|
+
W,
|
|
393
402
|
this._config
|
|
394
403
|
);
|
|
395
|
-
n && this._configService.setConfig("menu", n, { merge: !0 }), this._configService.setConfig(
|
|
404
|
+
n && this._configService.setConfig("menu", n, { merge: !0 }), this._configService.setConfig(Fe, r), this._initializeDependencies(this._injector);
|
|
396
405
|
}
|
|
397
406
|
_initializeDependencies(e) {
|
|
398
407
|
[
|
|
399
408
|
[N],
|
|
400
|
-
[
|
|
401
|
-
[
|
|
409
|
+
[y],
|
|
410
|
+
[$, { useClass: qe }]
|
|
402
411
|
].forEach((i) => e.add(i));
|
|
403
412
|
}
|
|
404
413
|
onReady() {
|
|
405
414
|
this._injector.get(N);
|
|
406
415
|
}
|
|
407
416
|
onSteady() {
|
|
408
|
-
this._injector.get(
|
|
417
|
+
this._injector.get(y);
|
|
409
418
|
}
|
|
410
|
-
},
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
],
|
|
419
|
+
}, _(O, "pluginName", "SHEET_ZEN_EDITOR_PLUGIN"), _(O, "type", w.UNIVER_SHEET), O);
|
|
420
|
+
G = ut([
|
|
421
|
+
Y(1, Se(Ie)),
|
|
422
|
+
Y(2, Ce)
|
|
423
|
+
], G);
|
|
415
424
|
export {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
425
|
+
B as CancelZenEditCommand,
|
|
426
|
+
L as ConfirmZenEditCommand,
|
|
427
|
+
Z as OpenZenEditorCommand,
|
|
428
|
+
G as UniverSheetsZenEditorPlugin
|
|
420
429
|
};
|
package/lib/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.univer-
|
|
1
|
+
.univer-absolute{position:absolute}.univer-inset-0{top:0;right:0;bottom:0;left:0}.univer-right-6{right:24px}.univer-top-2{top:8px}.univer-z-10{z-index:10}.univer-flex{display:flex}.univer-size-5{width:20px;height:20px}.univer-size-full{width:100%;height:100%}.univer-w-7{width:28px}.univer-cursor-pointer{cursor:pointer}.univer-items-center{align-items:center}.univer-justify-center{justify-content:center}.univer-bg-white{background-color:var(--univer-white)}.univer-text-green-500{color:var(--univer-green-500)}.univer-text-red-500{color:var(--univer-red-500)}.univer-transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover\:univer-text-green-600:hover{color:var(--univer-green-600)}.hover\:univer-text-red-600:hover{color:var(--univer-red-600)}
|