@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/es/index.js CHANGED
@@ -1,25 +1,25 @@
1
- var ce = Object.defineProperty;
2
- var ae = (e, t, i) => t in e ? ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
3
- var E = (e, t, i) => ae(e, typeof t != "symbol" ? t + "" : t, i);
4
- import { CommandType as R, IUniverInstanceService as P, delayAnimationFrame as w, DOCS_ZEN_EDITOR_UNIT_ID_KEY as g, Tools as X, UniverInstanceType as x, DocumentFlavor as q, DocumentDataModel as de, createIdentifier as le, ICommandService as J, DEFAULT_EMPTY_DOCUMENT_VALUE as ue, FOCUSING_DOC as ge, FOCUSING_UNIVER_EDITOR as fe, EDITOR_ACTIVATED as he, FOCUSING_EDITOR_STANDALONE as me, Disposable as ve, RxDisposable as pe, Plugin as Se, merge as Ee, Inject as _e, Injector as Ie, IConfigService as Ce } from "@univerjs/core";
5
- import { IEditorService as k, VIEWPORT_KEY as Oe, DocBackScrollRenderController as ye } from "@univerjs/docs-ui";
6
- import { IRenderManagerService as Q } from "@univerjs/engine-render";
7
- import { IEditorBridgeService as b, EditingRenderController as Ne, getCurrentExclusiveRangeInterest$ as Te, getCurrentRangeDisable$ as be, getEditorObject as ze } from "@univerjs/sheets-ui";
8
- import { IZenZoneService as z, ISidebarService as U, useDependency as D, MenuItemType as Me, ContextMenuPosition as De, ContextMenuGroup as Re, KeyCode as ee, MetaKeys as Pe, IMenuManagerService as we, IShortcutService as xe } from "@univerjs/ui";
9
- import { jsxs as F, jsx as _ } from "react/jsx-runtime";
10
- import { clsx as W } from "@univerjs/design";
11
- import { forwardRef as Z, useRef as te, createElement as j, useEffect as ke } from "react";
12
- import { BehaviorSubject as Ue, switchMap as Ze, map as je, takeUntil as Be } from "rxjs";
13
- import { RangeProtectionPermissionEditPoint as Le, WorksheetEditPermission as Ae, WorksheetSetCellValuePermission as $e, WorksheetSetCellStylePermission as Ve, WorkbookEditablePermission as Fe } from "@univerjs/sheets";
14
- const B = {
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(z), i = e.get(k), n = e.get(b), r = e.get(P), s = e.get(U);
20
- s.visible && (s.close(), await w()), t.open();
21
- const o = i.getEditor(g);
22
- if (o == null)
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: u, drawings: v, drawingsOrder: l, tableSource: f, settings: p } = X.deepClone(a), S = {
32
- ...o.getDocumentData(),
33
- body: u,
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: l,
35
+ drawingsOrder: u,
36
36
  tableSource: f,
37
- settings: p
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 o.focus(), o.setDocumentData(S, h), o.clearUndoRedoHistory(), !0;
45
+ return s.focus(), s.setDocumentData(p, h), s.clearUndoRedoHistory(), !0;
46
46
  }
47
- }, L = {
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(z), i = e.get(b), n = e.get(P), r = e.get(U);
52
- r.visible && (r.close(), await w()), t.close();
53
- const s = n.getCurrentUnitForType(x.UNIVER_SHEET);
54
- return s ? (n.focusUnit(s.getUnitId()), i.refreshEditCellState(), !0) : !1;
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
- }, A = {
56
+ }, L = {
57
57
  id: "zen-editor.command.confirm-zen-edit",
58
58
  type: R.COMMAND,
59
59
  handler: async (e) => {
60
- var u;
61
- const t = e.get(z), i = e.get(b), n = e.get(P), r = e.get(k), s = e.get(U);
62
- s.visible && (s.close(), await w()), t.close();
63
- const o = r.getEditor(g);
64
- if (o == null)
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(Q), a = n.getCurrentUnitForType(x.UNIVER_SHEET);
66
+ const c = e.get(J), a = n.getCurrentUnitForType(w.UNIVER_SHEET);
67
67
  if (a) {
68
- const v = a.getUnitId(), l = (u = c.getRenderById(v)) == null ? void 0 : u.with(Ne);
69
- if (l) {
70
- const f = X.deepClone(o.getDocumentData());
71
- f.documentStyle.documentFlavor = q.UNSPECIFIED, l.submitCellData(new de(f));
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
- }, We = "sheets-zen-editor.config", H = {};
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
- }, He = function(e, t) {
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
- }, $ = Z(function(e, t) {
94
- var i = e.icon, n = e.id, r = e.className, s = e.extend, o = He(e, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(n, " ").concat(r || "").trim(), a = te("_".concat(Ke()));
95
- return ne(i, "".concat(n), { defIds: i.defIds, idSuffix: a.current }, d({ ref: t, className: c }, o), s);
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 ne(e, t, i, n, r) {
98
- return j(e.tag, d(d({ key: t }, Ye(e, i, r)), n), (Ge(e, i).children || []).map(function(s, o) {
99
- return ne(s, "".concat(t, "-").concat(e.tag, "-").concat(o), i, void 0, r);
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 Ye(e, t, i) {
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(s) {
105
- var o = s[0], c = s[1];
106
- o === "mask" && typeof c == "string" && (n[o] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
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(s) {
110
- var o = s[0], c = s[1];
111
- typeof c == "string" && (n[o] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
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 Ge(e, t) {
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 Ke() {
120
+ function Ge() {
121
121
  return Math.random().toString(36).substring(2, 8);
122
122
  }
123
- $.displayName = "UniverIcon";
124
- var Xe = { 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" } }] }, ie = Z(function(e, t) {
125
- return j($, Object.assign({}, e, {
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: Xe
128
+ icon: Ke
129
129
  }));
130
130
  });
131
- ie.displayName = "CheckMarkSingle";
132
- var qe = { 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" } }] }, re = Z(function(e, t) {
133
- return j($, Object.assign({}, e, {
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: qe
136
+ icon: Xe
137
137
  }));
138
138
  });
139
- re.displayName = "CloseSingle";
140
- class Je {
139
+ ie.displayName = "CloseSingle";
140
+ class qe {
141
141
  constructor() {
142
- E(this, "_position", null);
143
- E(this, "_position$", new Ue(null));
144
- E(this, "position$", this._position$.asObservable());
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 V = le(
159
+ const $ = le(
160
160
  "univer.sheet-zen-editor-manager.service"
161
- ), Qe = "univer-zen-editor", et = "univer-zen-editor-icon-wrapper", tt = "univer-zen-editor-icon-container", nt = "univer-zen-editor-icon-success", it = "univer-zen-editor-icon-error", rt = "univer-zen-editor-canvas-container", m = {
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: `${ue}`,
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: q.MODERN,
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 at() {
204
- const e = te(null), t = D(V), i = D(k), n = D(J);
205
- ke(() => {
206
- const o = e.current;
207
- if (!o)
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 c = i.register({
202
+ const a = i.register({
210
203
  editorUnitId: g,
211
- initialSnapshot: ct,
204
+ initialSnapshot: et,
212
205
  scrollBar: !0,
213
206
  backScrollOffset: 100
214
- }, o), a = new ResizeObserver(() => {
215
- t.setPosition(o.getBoundingClientRect());
207
+ }, c), l = new ResizeObserver(() => {
208
+ t.setPosition(c.getBoundingClientRect());
216
209
  });
217
- return a.observe(o), () => {
218
- c.dispose(), a.unobserve(o);
210
+ return l.observe(c), () => {
211
+ a.dispose(), l.unobserve(c);
219
212
  };
220
213
  }, []);
221
214
  function r() {
222
- const o = i.getEditor(g);
223
- o == null || o.blur(), n.executeCommand(L.id);
215
+ const c = i.getEditor(g);
216
+ c == null || c.blur(), n.executeCommand(B.id);
224
217
  }
225
- function s() {
226
- const o = i.getEditor(g);
227
- o == null || o.blur(), n.executeCommand(A.id);
218
+ function o() {
219
+ const c = i.getEditor(g);
220
+ c == null || c.blur(), n.executeCommand(L.id);
228
221
  }
229
- return /* @__PURE__ */ F("div", { className: m.zenEditor, children: [
230
- /* @__PURE__ */ F("div", { className: m.zenEditorIconWrapper, children: [
231
- /* @__PURE__ */ _(
232
- "span",
233
- {
234
- className: W(m.zenEditorIconContainer, m.zenEditorIconError),
235
- onClick: r,
236
- children: /* @__PURE__ */ _(re, { style: { fontSize: "22px" } })
237
- }
238
- ),
239
- /* @__PURE__ */ _(
240
- "span",
241
- {
242
- className: W(m.zenEditorIconContainer, m.zenEditorIconSuccess),
243
- onClick: s,
244
- children: /* @__PURE__ */ _(ie, { style: { fontSize: "22px" } })
245
- }
246
- )
247
- ] }),
248
- /* @__PURE__ */ _("div", { className: m.zenEditorCanvasContainer, ref: e })
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 dt(e) {
260
+ function nt(e) {
252
261
  const t = e.get(b);
253
262
  return {
254
- id: B.id,
263
+ id: Z.id,
255
264
  type: Me.BUTTON,
256
265
  title: "rightClick.zenEditor",
257
266
  icon: "AmplifySingle",
258
- hidden$: Te(e),
267
+ hidden$: ye(e),
259
268
  disabled$: t.currentEditCell$.pipe(
260
- Ze((i) => be(e, { workbookTypes: [Fe], worksheetTypes: [Ae, $e, Ve], rangeTypes: [Le] }).pipe(je((n) => {
261
- var r, s, o, c;
262
- return n || ((c = (o = (s = (r = i == null ? void 0 : i.documentLayoutObject.documentModel) == null ? void 0 : r.getBody()) == null ? void 0 : s.customBlocks) == null ? void 0 : o.length) != null ? c : 0) > 0;
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 lt = {
276
+ const it = {
268
277
  [De.MAIN_AREA]: {
269
278
  [Re.OTHERS]: {
270
- [B.id]: {
279
+ [Z.id]: {
271
280
  order: 2,
272
- menuItemFactory: dt
281
+ menuItemFactory: nt
273
282
  }
274
283
  }
275
284
  }
276
- }, ut = {
277
- id: A.id,
285
+ }, rt = {
286
+ id: L.id,
278
287
  description: "shortcut.sheet.zen-edit-confirm",
279
288
  group: "4_sheet-edit",
280
- preconditions: (e) => oe(e),
281
- binding: ee.ENTER | Pe.ALT
282
- }, gt = {
283
- id: L.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) => oe(e),
287
- binding: ee.ESC
295
+ preconditions: (e) => re(e),
296
+ binding: Q.ESC
288
297
  };
289
- function oe(e) {
290
- return e.getContextValue(ge) && e.getContextValue(fe) && e.getContextValue(he) && !e.getContextValue(me);
298
+ function re(e) {
299
+ return e.getContextValue(ue) && e.getContextValue(ge) && e.getContextValue(fe) && !e.getContextValue(he);
291
300
  }
292
- var ft = Object.getOwnPropertyDescriptor, ht = (e, t, i, n) => {
293
- for (var r = n > 1 ? void 0 : n ? ft(t, i) : t, s = e.length - 1, o; s >= 0; s--)
294
- (o = e[s]) && (r = o(r) || r);
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
- }, O = (e, t) => (i, n) => t(i, n, e);
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(st, at));
314
+ this.disposeWithMe(this._zenZoneService.set(Qe, tt));
306
315
  }
307
316
  _initCommands() {
308
- [B, L, A].forEach((e) => {
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(lt);
322
+ this._menuManagerService.mergeMenu(it);
314
323
  }
315
324
  _initShortcuts() {
316
- [ut, gt].forEach((e) => {
325
+ [rt, ot].forEach((e) => {
317
326
  this.disposeWithMe(this._shortcutService.registerShortcut(e));
318
327
  });
319
328
  }
320
329
  };
321
- N = ht([
322
- O(0, z),
323
- O(1, J),
324
- O(2, we),
325
- O(3, xe)
330
+ N = ct([
331
+ E(0, T),
332
+ E(1, q),
333
+ E(2, Pe),
334
+ E(3, we)
326
335
  ], N);
327
- var mt = Object.getOwnPropertyDescriptor, vt = (e, t, i, n) => {
328
- for (var r = n > 1 ? void 0 : n ? mt(t, i) : t, s = e.length - 1, o; s >= 0; s--)
329
- (o = e[s]) && (r = o(r) || r);
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
- }, Y = (e, t) => (i, n) => t(i, n, e);
332
- let T = class extends pe {
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(Be(this.dispose$)).subscribe((e) => {
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 = ze(g, this._renderManagerService);
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: s, height: o, pageMarginLeft: c, pageMarginTop: a } = t;
352
- if (r == null || s === Number.POSITIVE_INFINITY || o === Number.POSITIVE_INFINITY)
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: u, height: v } = r;
355
- let l = 0;
363
+ const { width: l, height: v } = r;
364
+ let u = 0;
356
365
  const f = a;
357
- let p = 0, I = 0, S = Number.POSITIVE_INFINITY;
366
+ let m = 0, I = 0, p = Number.POSITIVE_INFINITY;
358
367
  const { scaleX: h, scaleY: C } = i.getAncestorScale();
359
- u > (s + c * 2) * h ? (l = u / 2 - s * h / 2, l /= h, p = (u - c * 2) / h, S = 0) : (l = c, p = s + c * 2, S = (p - u / h) / 2), v > o ? I = (v - a * 2) / C : I = o + a * 2, i.resize(p, I), t.translate(l, f), n.translate(l, f);
360
- const M = i.getViewport(Oe.VIEW_MAIN);
361
- if (S !== Number.POSITIVE_INFINITY && M != null) {
362
- const se = M.transScroll2ViewportScrollValue(S, 0).x;
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: se
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(ye), t = {
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
- T = vt([
379
- Y(0, V),
380
- Y(1, Q)
381
- ], T);
382
- var pt = Object.getOwnPropertyDescriptor, St = (e, t, i, n) => {
383
- for (var r = n > 1 ? void 0 : n ? pt(t, i) : t, s = e.length - 1, o; s >= 0; s--)
384
- (o = e[s]) && (r = o(r) || r);
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
- }, G = (e, t) => (i, n) => t(i, n, e), y;
387
- let K = (y = class extends Se {
388
- constructor(e = H, t, i) {
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 } = Ee(
399
+ const { menu: n, ...r } = _e(
391
400
  {},
392
- H,
401
+ W,
393
402
  this._config
394
403
  );
395
- n && this._configService.setConfig("menu", n, { merge: !0 }), this._configService.setConfig(We, r), this._initializeDependencies(this._injector);
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
- [T],
401
- [V, { useClass: Je }]
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(T);
417
+ this._injector.get(y);
409
418
  }
410
- }, E(y, "pluginName", "SHEET_ZEN_EDITOR_PLUGIN"), E(y, "type", x.UNIVER_SHEET), y);
411
- K = St([
412
- G(1, _e(Ie)),
413
- G(2, Ce)
414
- ], K);
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
- L as CancelZenEditCommand,
417
- A as ConfirmZenEditCommand,
418
- B as OpenZenEditorCommand,
419
- K as UniverSheetsZenEditorPlugin
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-zen-editor{position:absolute;top:0;left:0;width:100%;height:100%;background-color:rgb(var(--color-white))}.univer-zen-editor-icon-wrapper{position:absolute;z-index:10;top:0;right:20px;display:flex;align-items:center;justify-content:space-around;width:60px;height:30px}.univer-zen-editor-icon-container{cursor:pointer;display:flex;align-items:center;justify-content:center;width:30px;height:30px}.univer-zen-editor-icon-success{color:rgb(var(--success-color))}.univer-zen-editor-icon-error{color:rgb(var(--error-color))}.univer-zen-editor-canvas-container{position:absolute;top:0;left:0;width:100%;height:100%}
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)}