@univerjs/docs-quick-insert-ui 0.6.9-nightly.202504091607 → 0.6.10-alpha.0
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/LICENSE +176 -0
- package/lib/cjs/index.js +8 -8
- package/lib/es/index.js +446 -363
- package/lib/index.css +1 -1
- package/lib/index.js +446 -363
- package/lib/types/controllers/doc-quick-insert-menu.controller.d.ts +14 -0
- package/lib/types/plugin.d.ts +3 -1
- package/lib/types/services/doc-quick-insert-popup.service.d.ts +1 -0
- package/lib/types/views/menu/index.d.ts +23 -0
- package/lib/umd/index.js +8 -8
- package/package.json +13 -13
package/lib/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { CommandType as
|
|
5
|
-
import { UniverDocsDrawingPlugin as
|
|
6
|
-
import { InsertDocImageCommand as
|
|
7
|
-
import { UniverDrawingPlugin as
|
|
8
|
-
import { UniverDrawingUIPlugin as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { CutContentCommand as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { jsx as
|
|
15
|
-
import { clsx as
|
|
16
|
-
import { useMemo as
|
|
17
|
-
const
|
|
1
|
+
var He = Object.defineProperty;
|
|
2
|
+
var Ke = (t, e, i) => e in t ? He(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
|
|
3
|
+
var g = (t, e, i) => Ke(t, typeof e != "symbol" ? e + "" : e, i);
|
|
4
|
+
import { CommandType as w, ICommandService as T, RANGE_DIRECTION as je, LocaleService as ue, generateRandomId as Le, DisposableCollection as Ae, toDisposable as Be, Direction as A, Inject as f, IUniverInstanceService as pe, Disposable as Z, UniverInstanceType as Q, DeleteDirection as We, DependentOn as Ve, Injector as qe, Plugin as ze } from "@univerjs/core";
|
|
5
|
+
import { UniverDocsDrawingPlugin as Fe } from "@univerjs/docs-drawing";
|
|
6
|
+
import { InsertDocImageCommand as Ge, UniverDocsDrawingUIPlugin as Ze } from "@univerjs/docs-drawing-ui";
|
|
7
|
+
import { UniverDrawingPlugin as Je } from "@univerjs/drawing";
|
|
8
|
+
import { UniverDrawingUIPlugin as Xe } from "@univerjs/drawing-ui";
|
|
9
|
+
import { IRenderManagerService as le } from "@univerjs/engine-render";
|
|
10
|
+
import { useDependency as S, KeyCode as M, ComponentManager as Ie, IShortcutService as Se, useObservable as R, UniverUIPlugin as Ye } from "@univerjs/ui";
|
|
11
|
+
import { CutContentCommand as et, DocCanvasPopManagerService as Pe, DocEventManagerService as he, OrderListCommand as tt, BulletListCommand as nt, HorizontalLineCommand as it, DocCreateTableOperation as rt, InsertCommand as st, IMEInputCommand as ot, DeleteCommand as ct, MoveCursorOperation as at, DeleteLeftCommand as dt } from "@univerjs/docs-ui";
|
|
12
|
+
import { map as ut, distinctUntilChanged as pt, tap as K, combineLatest as ye, BehaviorSubject as ne, of as lt } from "rxjs";
|
|
13
|
+
import { DocSelectionManagerService as Oe, DocSkeletonManagerService as ht, RichTextEditingMutation as ft } from "@univerjs/docs";
|
|
14
|
+
import { jsx as h, jsxs as ve } from "react/jsx-runtime";
|
|
15
|
+
import { clsx as me, Menu as vt, MenuItemGroup as mt, MenuItem as gt, Tooltip as _t } from "@univerjs/design";
|
|
16
|
+
import { useMemo as se, useState as ge, useRef as L, useEffect as j, forwardRef as J, createElement as X } from "react";
|
|
17
|
+
const Me = {
|
|
18
18
|
id: "doc.command.delete-search-key",
|
|
19
|
-
type:
|
|
19
|
+
type: w.COMMAND,
|
|
20
20
|
handler: (t, e) => {
|
|
21
|
-
const i = t.get(
|
|
22
|
-
return i.syncExecuteCommand(
|
|
21
|
+
const i = t.get(T), { start: n, end: r } = e;
|
|
22
|
+
return i.syncExecuteCommand(et.id, {
|
|
23
23
|
segmentId: "",
|
|
24
24
|
textRanges: [{
|
|
25
25
|
startOffset: n,
|
|
@@ -30,176 +30,189 @@ const ve = {
|
|
|
30
30
|
startOffset: n,
|
|
31
31
|
endOffset: r,
|
|
32
32
|
collapsed: !1,
|
|
33
|
-
direction:
|
|
33
|
+
direction: je.FORWARD
|
|
34
34
|
}]
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
},
|
|
38
|
-
const t =
|
|
39
|
-
return /* @__PURE__ */
|
|
37
|
+
}, Ct = "docs.quick.insert.keyword-input-placeholder", B = () => {
|
|
38
|
+
const t = S(ue);
|
|
39
|
+
return /* @__PURE__ */ h("div", { className: "univer-translate-y-1.5 univer-text-sm univer-text-gray-500", children: t.t("docQuickInsert.keywordInputPlaceholder") });
|
|
40
40
|
};
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
B.componentKey = Ct;
|
|
42
|
+
const xe = {
|
|
43
|
+
type: w.OPERATION,
|
|
44
|
+
id: "doc.operation.show-quick-insert-popup",
|
|
45
|
+
handler(t, e) {
|
|
46
|
+
const i = t.get(C);
|
|
47
|
+
return e ? (i.showPopup(e), !0) : !1;
|
|
48
|
+
}
|
|
49
|
+
}, U = {
|
|
50
|
+
type: w.OPERATION,
|
|
51
|
+
id: "doc.operation.close-quick-insert-popup",
|
|
52
|
+
handler(t) {
|
|
53
|
+
return t.get(C).closePopup(), !0;
|
|
54
|
+
}
|
|
55
|
+
}, It = "docs.quick.insert.placeholder", W = () => {
|
|
56
|
+
const t = S(ue);
|
|
57
|
+
return /* @__PURE__ */ h(
|
|
45
58
|
"div",
|
|
46
59
|
{
|
|
47
60
|
className: `
|
|
48
61
|
univer-flex univer-h-full univer-items-center univer-justify-center univer-rounded-lg univer-bg-white
|
|
49
62
|
univer-px-12 univer-py-6 univer-text-gray-400
|
|
50
63
|
`,
|
|
51
|
-
children: /* @__PURE__ */
|
|
64
|
+
children: /* @__PURE__ */ h("span", { children: t.t("docQuickInsert.placeholder") })
|
|
52
65
|
}
|
|
53
66
|
);
|
|
54
67
|
};
|
|
55
|
-
|
|
56
|
-
function
|
|
68
|
+
W.componentKey = It;
|
|
69
|
+
function oe(t, e) {
|
|
57
70
|
return t.map((i) => ({ ...i })).filter((i) => {
|
|
58
71
|
if ("children" in i)
|
|
59
|
-
return i.children =
|
|
72
|
+
return i.children = oe(i.children, e), i.children.length > 0;
|
|
60
73
|
const n = i.keywords;
|
|
61
74
|
return n ? n.some((r) => r.includes(e)) : i.title.toLowerCase().includes(e);
|
|
62
75
|
});
|
|
63
76
|
}
|
|
64
|
-
function
|
|
77
|
+
function be(t, e) {
|
|
65
78
|
return t.map((i) => {
|
|
66
79
|
const n = { ...i };
|
|
67
|
-
return "children" in n && (n.children =
|
|
80
|
+
return "children" in n && (n.children = be(n.children, e)), n.title = e.t(n.title), "keywords" in n && (n.keywords = n.keywords.concat(n.title).map((r) => r.toLowerCase())), n;
|
|
68
81
|
});
|
|
69
82
|
}
|
|
70
|
-
const
|
|
71
|
-
const t =
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
83
|
+
const St = [M.ARROW_UP, M.ARROW_DOWN, M.ENTER], V = () => {
|
|
84
|
+
const t = S(ue), e = S(C), i = S(Ie), n = S(Se), r = S(T), s = se(() => Le(), []), [c, u] = ge(0), o = L(null), a = L(0);
|
|
85
|
+
a.current = 0;
|
|
86
|
+
const d = R(e.filterKeyword$, ""), p = R(e.editPopup$), I = R(p == null ? void 0 : p.popup.menus$, []), P = se(() => be(I, t), [I]), [H, k] = ge(() => oe(P, d.toLowerCase()));
|
|
87
|
+
j(() => {
|
|
88
|
+
const v = requestIdleCallback(() => {
|
|
89
|
+
k(oe(P, d.toLowerCase()));
|
|
77
90
|
});
|
|
78
91
|
return () => {
|
|
79
|
-
cancelIdleCallback(
|
|
92
|
+
cancelIdleCallback(v);
|
|
80
93
|
};
|
|
81
|
-
}, [
|
|
82
|
-
const
|
|
83
|
-
e.emitMenuSelected(
|
|
94
|
+
}, [P, d]);
|
|
95
|
+
const ee = (v) => {
|
|
96
|
+
e.emitMenuSelected(v), r.executeCommand(U.id);
|
|
84
97
|
};
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
n.getAllShortcuts().filter((l) => l.binding &&
|
|
88
|
-
const
|
|
89
|
-
l.preconditions = () => !1,
|
|
90
|
-
l.preconditions =
|
|
98
|
+
j(() => {
|
|
99
|
+
const v = new Ae();
|
|
100
|
+
n.getAllShortcuts().filter((l) => l.binding && St.includes(l.binding)).forEach((l) => {
|
|
101
|
+
const O = l.preconditions;
|
|
102
|
+
l.preconditions = () => !1, v.add(Be(() => {
|
|
103
|
+
l.preconditions = O;
|
|
91
104
|
}));
|
|
92
105
|
});
|
|
93
|
-
const
|
|
106
|
+
const y = {
|
|
94
107
|
id: `quick.insert.popup.enter.${s}`,
|
|
95
|
-
type:
|
|
108
|
+
type: w.OPERATION,
|
|
96
109
|
handler: () => {
|
|
97
110
|
const l = o.current;
|
|
98
|
-
l &&
|
|
111
|
+
l && ee(l);
|
|
99
112
|
}
|
|
100
|
-
},
|
|
113
|
+
}, $ = {
|
|
101
114
|
id: `quick.insert.popup.move.cursor.up.${s}`,
|
|
102
|
-
type:
|
|
115
|
+
type: w.OPERATION,
|
|
103
116
|
handler: () => {
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
return
|
|
117
|
+
u((l) => {
|
|
118
|
+
const O = l - 1;
|
|
119
|
+
return O >= 0 ? O : a.current - 1;
|
|
107
120
|
});
|
|
108
121
|
}
|
|
109
|
-
},
|
|
122
|
+
}, b = {
|
|
110
123
|
id: `quick.insert.popup.move.cursor.down.${s}`,
|
|
111
|
-
type:
|
|
124
|
+
type: w.OPERATION,
|
|
112
125
|
handler: () => {
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
return
|
|
126
|
+
u((l) => {
|
|
127
|
+
const O = l + 1;
|
|
128
|
+
return O <= a.current - 1 ? O : 0;
|
|
116
129
|
});
|
|
117
130
|
}
|
|
118
131
|
};
|
|
119
|
-
return
|
|
132
|
+
return v.add(r.registerCommand($)), v.add(r.registerCommand(b)), v.add(r.registerCommand(y)), v.add(n.registerShortcut({
|
|
120
133
|
priority: 1e3,
|
|
121
|
-
id:
|
|
122
|
-
binding:
|
|
134
|
+
id: $.id,
|
|
135
|
+
binding: M.ARROW_UP,
|
|
123
136
|
preconditions: () => !0,
|
|
124
137
|
staticParameters: {
|
|
125
|
-
direction:
|
|
138
|
+
direction: A.UP
|
|
126
139
|
}
|
|
127
|
-
})),
|
|
140
|
+
})), v.add(n.registerShortcut({
|
|
128
141
|
priority: 1e3,
|
|
129
|
-
id:
|
|
130
|
-
binding:
|
|
142
|
+
id: b.id,
|
|
143
|
+
binding: M.ARROW_DOWN,
|
|
131
144
|
preconditions: () => !0,
|
|
132
145
|
staticParameters: {
|
|
133
|
-
direction:
|
|
146
|
+
direction: A.DOWN
|
|
134
147
|
}
|
|
135
|
-
})),
|
|
148
|
+
})), v.add(n.registerShortcut({
|
|
136
149
|
priority: 1e3,
|
|
137
|
-
id:
|
|
138
|
-
binding:
|
|
150
|
+
id: y.id,
|
|
151
|
+
binding: M.ENTER,
|
|
139
152
|
preconditions: () => !0
|
|
140
153
|
})), () => {
|
|
141
|
-
|
|
154
|
+
v.dispose();
|
|
142
155
|
};
|
|
143
|
-
}, []),
|
|
144
|
-
|
|
145
|
-
}, [
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
156
|
+
}, []), j(() => {
|
|
157
|
+
u(0);
|
|
158
|
+
}, [H]);
|
|
159
|
+
const x = L(/* @__PURE__ */ new Map());
|
|
160
|
+
j(() => () => {
|
|
161
|
+
x.current.clear();
|
|
149
162
|
}, []);
|
|
150
|
-
function
|
|
151
|
-
return
|
|
152
|
-
const
|
|
163
|
+
function D(v) {
|
|
164
|
+
return v.map((m) => {
|
|
165
|
+
const te = m.icon, y = te ? i.get(te) : null;
|
|
153
166
|
if ("children" in m)
|
|
154
|
-
return /* @__PURE__ */
|
|
155
|
-
|
|
167
|
+
return /* @__PURE__ */ h(
|
|
168
|
+
mt,
|
|
156
169
|
{
|
|
157
|
-
title: /* @__PURE__ */
|
|
170
|
+
title: /* @__PURE__ */ ve(
|
|
158
171
|
"div",
|
|
159
172
|
{
|
|
160
173
|
className: `
|
|
161
174
|
univer-mb-2 univer-flex univer-items-center univer-text-xs univer-text-gray-400
|
|
162
175
|
`,
|
|
163
176
|
children: [
|
|
164
|
-
|
|
165
|
-
/* @__PURE__ */
|
|
177
|
+
y && /* @__PURE__ */ h("span", { className: "univer-mr-2 univer-inline-flex univer-text-base", children: /* @__PURE__ */ h(y, {}) }),
|
|
178
|
+
/* @__PURE__ */ h("span", { children: m.title })
|
|
166
179
|
]
|
|
167
180
|
}
|
|
168
181
|
),
|
|
169
|
-
children:
|
|
182
|
+
children: D(m.children)
|
|
170
183
|
},
|
|
171
184
|
m.id
|
|
172
185
|
);
|
|
173
|
-
const
|
|
174
|
-
if (
|
|
186
|
+
const $ = a.current, b = c === $;
|
|
187
|
+
if (b) {
|
|
175
188
|
o.current = m;
|
|
176
|
-
const l =
|
|
189
|
+
const l = x.current.get(m.id);
|
|
177
190
|
l == null || l.scrollIntoView({
|
|
178
191
|
block: "nearest"
|
|
179
192
|
});
|
|
180
193
|
}
|
|
181
|
-
return
|
|
182
|
-
|
|
194
|
+
return a.current++, /* @__PURE__ */ h(
|
|
195
|
+
gt,
|
|
183
196
|
{
|
|
184
197
|
ref: (l) => {
|
|
185
|
-
l &&
|
|
198
|
+
l && x.current.set(m.id, l);
|
|
186
199
|
},
|
|
187
|
-
onMouseEnter: () =>
|
|
188
|
-
onMouseLeave: () =>
|
|
189
|
-
className:
|
|
190
|
-
"hover:univer-bg-transparent": !
|
|
191
|
-
"univer-bg-gray-100":
|
|
200
|
+
onMouseEnter: () => u($),
|
|
201
|
+
onMouseLeave: () => u(Number.NaN),
|
|
202
|
+
className: me("univer-w-[calc(220px-var(--padding-base)*2)] univer-text-sm", {
|
|
203
|
+
"hover:univer-bg-transparent": !b,
|
|
204
|
+
"univer-bg-gray-100": b
|
|
192
205
|
}),
|
|
193
206
|
onClick: () => {
|
|
194
|
-
|
|
207
|
+
ee(m);
|
|
195
208
|
},
|
|
196
|
-
children: /* @__PURE__ */
|
|
209
|
+
children: /* @__PURE__ */ ve(
|
|
197
210
|
"div",
|
|
198
211
|
{
|
|
199
212
|
className: "univer-flex univer-w-full univer-items-center univer-px-1",
|
|
200
213
|
children: [
|
|
201
|
-
|
|
202
|
-
/* @__PURE__ */
|
|
214
|
+
y && /* @__PURE__ */ h("span", { className: "univer-mr-2 univer-inline-flex univer-text-base", children: /* @__PURE__ */ h(y, {}) }),
|
|
215
|
+
/* @__PURE__ */ h(_t, { showIfEllipsis: !0, title: m.title, placement: "right", children: /* @__PURE__ */ h("span", { className: "univer-truncate", children: m.title }) })
|
|
203
216
|
]
|
|
204
217
|
}
|
|
205
218
|
)
|
|
@@ -208,77 +221,60 @@ const mt = [O.ARROW_UP, O.ARROW_DOWN, O.ENTER], H = () => {
|
|
|
208
221
|
);
|
|
209
222
|
});
|
|
210
223
|
}
|
|
211
|
-
const
|
|
212
|
-
return /* @__PURE__ */
|
|
213
|
-
"div",
|
|
214
|
-
{
|
|
215
|
-
className: ae(`
|
|
216
|
-
univer-rounded-lg univer-border univer-border-solid univer-border-gray-100 univer-bg-white
|
|
217
|
-
univer-shadow-[0_0_10px_0_rgba(0,0,0,0.1)]
|
|
218
|
-
`),
|
|
219
|
-
children: we ? /* @__PURE__ */ f(
|
|
220
|
-
"div",
|
|
221
|
-
{
|
|
222
|
-
className: `
|
|
223
|
-
univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto univer-overflow-x-hidden
|
|
224
|
-
`,
|
|
225
|
-
children: /* @__PURE__ */ f(dt, { children: oe(W) })
|
|
226
|
-
}
|
|
227
|
-
) : se && /* @__PURE__ */ f(se, {})
|
|
228
|
-
}
|
|
229
|
-
);
|
|
224
|
+
const Qe = H.length > 0, fe = (p == null ? void 0 : p.popup.Placeholder) || i.get(W.componentKey);
|
|
225
|
+
return /* @__PURE__ */ h("div", { className: me("univer-mt-2"), children: Qe ? /* @__PURE__ */ h(vt, { wrapperClass: "univer-max-h-[360px] univer-w-[220px]", children: D(H) }) : fe && /* @__PURE__ */ h(fe, {}) });
|
|
230
226
|
};
|
|
231
|
-
|
|
232
|
-
var
|
|
233
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
234
|
-
(
|
|
227
|
+
V.componentKey = "docs.quick.insert.popup";
|
|
228
|
+
var Pt = Object.getOwnPropertyDescriptor, yt = (t, e, i, n) => {
|
|
229
|
+
for (var r = n > 1 ? void 0 : n ? Pt(e, i) : e, s = t.length - 1, c; s >= 0; s--)
|
|
230
|
+
(c = t[s]) && (r = c(r) || r);
|
|
235
231
|
return r;
|
|
236
|
-
},
|
|
237
|
-
const
|
|
232
|
+
}, N = (t, e) => (i, n) => e(i, n, t);
|
|
233
|
+
const _e = {
|
|
238
234
|
dispose: () => {
|
|
239
235
|
}
|
|
240
236
|
};
|
|
241
|
-
let C = class extends
|
|
237
|
+
let C = class extends Z {
|
|
242
238
|
constructor(e, i, n, r, s) {
|
|
243
239
|
super();
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
240
|
+
g(this, "_popups", /* @__PURE__ */ new Set());
|
|
241
|
+
g(this, "_editPopup$", new ne(void 0));
|
|
242
|
+
g(this, "editPopup$", this._editPopup$.asObservable());
|
|
243
|
+
g(this, "_isComposing$", new ne(!1));
|
|
244
|
+
g(this, "isComposing$", this._isComposing$.asObservable());
|
|
245
|
+
g(this, "_inputOffset$", new ne({ start: 0, end: 0 }));
|
|
246
|
+
g(this, "inputOffset$", this._inputOffset$.asObservable());
|
|
247
|
+
g(this, "filterKeyword$");
|
|
248
|
+
g(this, "_menuSelectedCallbacks", /* @__PURE__ */ new Set());
|
|
249
|
+
g(this, "_inputPlaceholderRenderRoot", null);
|
|
254
250
|
this._docCanvasPopupManagerService = e, this._univerInstanceService = i, this._commandService = n, this._renderManagerService = r, this._docSelectionManagerService = s, this.disposeWithMe(this._editPopup$);
|
|
255
|
-
const
|
|
256
|
-
var
|
|
257
|
-
return (p = (
|
|
251
|
+
const c = (o, a) => {
|
|
252
|
+
var d, p;
|
|
253
|
+
return (p = (d = this._univerInstanceService.getCurrentUnitOfType(Q.UNIVER_DOC)) == null ? void 0 : d.getBody()) == null ? void 0 : p.dataStream.slice(o, a);
|
|
258
254
|
};
|
|
259
|
-
let
|
|
255
|
+
let u = "";
|
|
260
256
|
this.filterKeyword$ = this._inputOffset$.pipe(
|
|
261
|
-
|
|
262
|
-
var
|
|
263
|
-
const
|
|
264
|
-
return (
|
|
257
|
+
ut((o) => {
|
|
258
|
+
var d;
|
|
259
|
+
const a = c(o.start, o.end);
|
|
260
|
+
return (d = a == null ? void 0 : a.slice(1)) != null ? d : "";
|
|
265
261
|
}),
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
262
|
+
pt(),
|
|
263
|
+
K((o) => {
|
|
264
|
+
u = o;
|
|
269
265
|
})
|
|
270
|
-
), this.disposeWithMe(
|
|
271
|
-
this.filterKeyword$.pipe(
|
|
272
|
-
var
|
|
273
|
-
o.length > 0 ? (
|
|
266
|
+
), this.disposeWithMe(ye([
|
|
267
|
+
this.filterKeyword$.pipe(K((o) => {
|
|
268
|
+
var a, d, p;
|
|
269
|
+
o.length > 0 ? (d = (a = this._inputPlaceholderRenderRoot) == null ? void 0 : a.unmount) == null || d.dispose() : (p = this._inputPlaceholderRenderRoot) == null || p.mount();
|
|
274
270
|
})),
|
|
275
|
-
this.isComposing$.pipe(
|
|
276
|
-
var
|
|
277
|
-
o ? (
|
|
271
|
+
this.isComposing$.pipe(K((o) => {
|
|
272
|
+
var a, d, p;
|
|
273
|
+
o ? (d = (a = this._inputPlaceholderRenderRoot) == null ? void 0 : a.unmount) == null || d.dispose() : u.length <= 0 && ((p = this._inputPlaceholderRenderRoot) == null || p.mount());
|
|
278
274
|
})),
|
|
279
|
-
this.editPopup$.pipe(
|
|
280
|
-
var
|
|
281
|
-
o || ((
|
|
275
|
+
this.editPopup$.pipe(K((o) => {
|
|
276
|
+
var a, d;
|
|
277
|
+
o || ((d = (a = this._inputPlaceholderRenderRoot) == null ? void 0 : a.unmount) == null || d.dispose(), this._inputPlaceholderRenderRoot = null);
|
|
282
278
|
}))
|
|
283
279
|
]).subscribe());
|
|
284
280
|
}
|
|
@@ -297,6 +293,10 @@ let C = class extends Y {
|
|
|
297
293
|
setInputOffset(e) {
|
|
298
294
|
this._inputOffset$.next(e);
|
|
299
295
|
}
|
|
296
|
+
getDocEventManagerService(e) {
|
|
297
|
+
var i;
|
|
298
|
+
return (i = this._renderManagerService.getRenderById(e)) == null ? void 0 : i.with(he);
|
|
299
|
+
}
|
|
300
300
|
resolvePopup(e) {
|
|
301
301
|
return Array.from(this._popups).find((i) => i.keyword === e);
|
|
302
302
|
}
|
|
@@ -322,32 +322,40 @@ let C = class extends Y {
|
|
|
322
322
|
};
|
|
323
323
|
}
|
|
324
324
|
showPopup(e) {
|
|
325
|
+
var a, d, p;
|
|
325
326
|
const { popup: i, index: n, unitId: r } = e;
|
|
326
|
-
this.closePopup()
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
327
|
+
this.closePopup();
|
|
328
|
+
const s = this._univerInstanceService.getUnit(r), c = (d = (a = s == null ? void 0 : s.getBody()) == null ? void 0 : a.paragraphs) == null ? void 0 : d.find((I) => I.startIndex > n);
|
|
329
|
+
if (!c)
|
|
330
|
+
return;
|
|
331
|
+
const u = (p = this.getDocEventManagerService(r)) == null ? void 0 : p.paragraphBounds.get(c.startIndex);
|
|
332
|
+
if (!u)
|
|
333
|
+
return;
|
|
334
|
+
this._inputPlaceholderRenderRoot = this._createInputPlaceholderRenderRoot(() => {
|
|
335
|
+
var D;
|
|
336
|
+
const I = (D = this._renderManagerService.getRenderById(r)) == null ? void 0 : D.with(ht), P = this._docSelectionManagerService.getActiveTextRange();
|
|
337
|
+
if (!I || !P)
|
|
338
|
+
return _e;
|
|
339
|
+
const k = I.getSkeleton().findNodeByCharIndex(P.startOffset, P.segmentId, P.segmentPage);
|
|
340
|
+
if (!((k == null ? void 0 : k.content) === "\r"))
|
|
341
|
+
return _e;
|
|
342
|
+
const x = this._docCanvasPopupManagerService.attachPopupToRange(
|
|
335
343
|
{ startOffset: n + 1, endOffset: n + 1, collapsed: !1 },
|
|
336
344
|
{
|
|
337
|
-
componentKey:
|
|
345
|
+
componentKey: B.componentKey,
|
|
338
346
|
onClickOutside: () => {
|
|
339
|
-
|
|
347
|
+
x.dispose();
|
|
340
348
|
},
|
|
341
349
|
direction: "horizontal"
|
|
342
350
|
},
|
|
343
351
|
r
|
|
344
352
|
);
|
|
345
|
-
return
|
|
353
|
+
return x;
|
|
346
354
|
}), this._inputPlaceholderRenderRoot.mount();
|
|
347
|
-
const
|
|
348
|
-
|
|
355
|
+
const o = this._docCanvasPopupManagerService.attachPopupToRect(
|
|
356
|
+
u.firstLine,
|
|
349
357
|
{
|
|
350
|
-
componentKey:
|
|
358
|
+
componentKey: V.componentKey,
|
|
351
359
|
onClickOutside: () => {
|
|
352
360
|
this.closePopup();
|
|
353
361
|
},
|
|
@@ -355,7 +363,7 @@ let C = class extends Y {
|
|
|
355
363
|
},
|
|
356
364
|
r
|
|
357
365
|
);
|
|
358
|
-
this._editPopup$.next({ disposable:
|
|
366
|
+
this._editPopup$.next({ disposable: o, popup: i, anchor: n, unitId: r });
|
|
359
367
|
}
|
|
360
368
|
closePopup() {
|
|
361
369
|
this.editPopup && (this.editPopup.disposable.dispose(), this._editPopup$.next(null));
|
|
@@ -367,7 +375,7 @@ let C = class extends Y {
|
|
|
367
375
|
}
|
|
368
376
|
emitMenuSelected(e) {
|
|
369
377
|
const { start: i, end: n } = this.inputOffset;
|
|
370
|
-
this._commandService.syncExecuteCommand(
|
|
378
|
+
this._commandService.syncExecuteCommand(Me.id, {
|
|
371
379
|
start: i,
|
|
372
380
|
end: n
|
|
373
381
|
}), setTimeout(() => {
|
|
@@ -375,86 +383,217 @@ let C = class extends Y {
|
|
|
375
383
|
}, 0);
|
|
376
384
|
}
|
|
377
385
|
};
|
|
378
|
-
C =
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
386
|
+
C = yt([
|
|
387
|
+
N(0, f(Pe)),
|
|
388
|
+
N(1, f(pe)),
|
|
389
|
+
N(2, f(T)),
|
|
390
|
+
N(3, f(le)),
|
|
391
|
+
N(4, f(Oe))
|
|
384
392
|
], C);
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
393
|
+
var _ = function() {
|
|
394
|
+
return _ = Object.assign || function(t) {
|
|
395
|
+
for (var e, i = 1, n = arguments.length; i < n; i++) {
|
|
396
|
+
e = arguments[i];
|
|
397
|
+
for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
|
|
398
|
+
}
|
|
399
|
+
return t;
|
|
400
|
+
}, _.apply(this, arguments);
|
|
401
|
+
}, Ot = function(t, e) {
|
|
402
|
+
var i = {};
|
|
403
|
+
for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (i[n] = t[n]);
|
|
404
|
+
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
405
|
+
for (var r = 0, n = Object.getOwnPropertySymbols(t); r < n.length; r++)
|
|
406
|
+
e.indexOf(n[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[r]) && (i[n[r]] = t[n[r]]);
|
|
407
|
+
return i;
|
|
408
|
+
}, Y = J(function(t, e) {
|
|
409
|
+
var i = t.icon, n = t.id, r = t.className, s = t.extend, c = Ot(t, ["icon", "id", "className", "extend"]), u = "univerjs-icon univerjs-icon-".concat(n, " ").concat(r || "").trim(), o = L("_".concat(bt()));
|
|
410
|
+
return we(i, "".concat(n), { defIds: i.defIds, idSuffix: o.current }, _({ ref: e, className: u }, c), s);
|
|
411
|
+
});
|
|
412
|
+
function we(t, e, i, n, r) {
|
|
413
|
+
return X(t.tag, _(_({ key: e }, Mt(t, i, r)), n), (xt(t, i).children || []).map(function(s, c) {
|
|
414
|
+
return we(s, "".concat(e, "-").concat(t.tag, "-").concat(c), i, void 0, r);
|
|
415
|
+
}));
|
|
416
|
+
}
|
|
417
|
+
function Mt(t, e, i) {
|
|
418
|
+
var n = _({}, t.attrs);
|
|
419
|
+
i != null && i.colorChannel1 && n.fill === "colorChannel1" && (n.fill = i.colorChannel1), t.tag === "mask" && n.id && (n.id = n.id + e.idSuffix), Object.entries(n).forEach(function(s) {
|
|
420
|
+
var c = s[0], u = s[1];
|
|
421
|
+
c === "mask" && typeof u == "string" && (n[c] = u.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
422
|
+
});
|
|
423
|
+
var r = e.defIds;
|
|
424
|
+
return !r || r.length === 0 || (t.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + e.idSuffix), Object.entries(n).forEach(function(s) {
|
|
425
|
+
var c = s[0], u = s[1];
|
|
426
|
+
typeof u == "string" && (n[c] = u.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
427
|
+
})), n;
|
|
428
|
+
}
|
|
429
|
+
function xt(t, e) {
|
|
430
|
+
var i, n = e.defIds;
|
|
431
|
+
return !n || n.length === 0 ? t : t.tag === "defs" && (!((i = t.children) === null || i === void 0) && i.length) ? _(_({}, t), { children: t.children.map(function(r) {
|
|
432
|
+
return typeof r.attrs.id == "string" && n && n.indexOf(r.attrs.id) > -1 ? _(_({}, r), { attrs: _(_({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
|
|
433
|
+
}) }) : t;
|
|
434
|
+
}
|
|
435
|
+
function bt() {
|
|
436
|
+
return Math.random().toString(36).substring(2, 8);
|
|
437
|
+
}
|
|
438
|
+
Y.displayName = "UniverIcon";
|
|
439
|
+
var wt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.01953 3.13985C1.01953 2.77258 1.31726 2.47485 1.68453 2.47485H2.73713C3.1044 2.47485 3.40213 2.77258 3.40213 3.13985 3.40213 3.50712 3.1044 3.80485 2.73713 3.80485H1.68453C1.31726 3.80485 1.01953 3.50712 1.01953 3.13985zM4.17734 3.13985C4.17734 2.77258 4.47507 2.47485 4.84234 2.47485H6.94754C7.31481 2.47485 7.61254 2.77258 7.61254 3.13985 7.61254 3.50712 7.31481 3.80485 6.94754 3.80485H4.84234C4.47507 3.80485 4.17734 3.50712 4.17734 3.13985zM8.38775 3.13985C8.38775 2.77258 8.68548 2.47485 9.05275 2.47485H11.158C11.5252 2.47485 11.823 2.77258 11.823 3.13985 11.823 3.50712 11.5252 3.80485 11.158 3.80485H9.05275C8.68548 3.80485 8.38775 3.50712 8.38775 3.13985zM12.5982 3.13985C12.5982 2.77258 12.8959 2.47485 13.2632 2.47485H14.3158C14.683 2.47485 14.9808 2.77258 14.9808 3.13985 14.9808 3.50712 14.683 3.80485 14.3158 3.80485H13.2632C12.8959 3.80485 12.5982 3.50712 12.5982 3.13985zM1.01953 7.99972C1.01953 7.63245 1.31726 7.33472 1.68453 7.33472H14.3158C14.683 7.33472 14.9808 7.63245 14.9808 7.99972 14.9808 8.36699 14.683 8.66472 14.3158 8.66472H1.68453C1.31726 8.66472 1.01953 8.36699 1.01953 7.99972zM1.68453 12.1951C1.31726 12.1951 1.01953 12.4928 1.01953 12.8601 1.01953 13.2273 1.31726 13.5251 1.68453 13.5251H2.73713C3.1044 13.5251 3.40213 13.2273 3.40213 12.8601 3.40213 12.4928 3.1044 12.1951 2.73713 12.1951H1.68453zM4.84234 12.1951C4.47507 12.1951 4.17734 12.4928 4.17734 12.8601 4.17734 13.2273 4.47507 13.5251 4.84234 13.5251H6.94754C7.31481 13.5251 7.61254 13.2273 7.61254 12.8601 7.61254 12.4928 7.31481 12.1951 6.94754 12.1951H4.84234zM9.05275 12.1951C8.68548 12.1951 8.38775 12.4928 8.38775 12.8601 8.38775 13.2273 8.68548 13.5251 9.05275 13.5251H11.158C11.5252 13.5251 11.823 13.2273 11.823 12.8601 11.823 12.4928 11.5252 12.1951 11.158 12.1951H9.05275zM13.2632 12.1951C12.8959 12.1951 12.5982 12.4928 12.5982 12.8601 12.5982 13.2273 12.8959 13.5251 13.2632 13.5251H14.3158C14.683 13.5251 14.9808 13.2273 14.9808 12.8601 14.9808 12.4928 14.683 12.1951 14.3158 12.1951H13.2632z" } }] }, ce = J(function(t, e) {
|
|
440
|
+
return X(Y, Object.assign({}, t, {
|
|
441
|
+
id: "divider-single",
|
|
442
|
+
ref: e,
|
|
443
|
+
icon: wt
|
|
444
|
+
}));
|
|
445
|
+
});
|
|
446
|
+
ce.displayName = "DividerSingle";
|
|
447
|
+
var Rt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.00033 2.66699C8.36852 2.66699 8.66699 2.96547 8.66699 3.33366V7.33366H12.667C13.0352 7.33366 13.3337 7.63214 13.3337 8.00033C13.3337 8.36852 13.0352 8.66699 12.667 8.66699H8.66699V12.667C8.66699 13.0352 8.36852 13.3337 8.00033 13.3337C7.63214 13.3337 7.33366 13.0352 7.33366 12.667V8.66699H3.33366C2.96547 8.66699 2.66699 8.36852 2.66699 8.00033C2.66699 7.63214 2.96547 7.33366 3.33366 7.33366H7.33366V3.33366C7.33366 2.96547 7.63214 2.66699 8.00033 2.66699Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Re = J(function(t, e) {
|
|
448
|
+
return X(Y, Object.assign({}, t, {
|
|
449
|
+
id: "plus-single",
|
|
450
|
+
ref: e,
|
|
451
|
+
icon: Rt
|
|
452
|
+
}));
|
|
453
|
+
});
|
|
454
|
+
Re.displayName = "PlusSingle";
|
|
455
|
+
var kt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.66695 1.33496C2.29968 1.33496 2.00195 1.63269 2.00195 1.99996V3.64439C2.00195 4.01166 2.29968 4.30939 2.66695 4.30939C3.03422 4.30939 3.33195 4.01166 3.33195 3.64439V2.66496H7.33521V13.335H5.3337C4.96643 13.335 4.6687 13.6327 4.6687 14C4.6687 14.3672 4.96643 14.665 5.3337 14.665H10.667C11.0343 14.665 11.332 14.3672 11.332 14C11.332 13.6327 11.0343 13.335 10.667 13.335H8.66521V2.66496H12.6686V3.64439C12.6686 4.01166 12.9664 4.30939 13.3336 4.30939C13.7009 4.30939 13.9986 4.01166 13.9986 3.64439V1.99996C13.9986 1.63269 13.7009 1.33496 13.3336 1.33496H2.66695Z" } }] }, ae = J(function(t, e) {
|
|
456
|
+
return X(Y, Object.assign({}, t, {
|
|
457
|
+
id: "text-single",
|
|
458
|
+
ref: e,
|
|
459
|
+
icon: kt
|
|
460
|
+
}));
|
|
461
|
+
});
|
|
462
|
+
ae.displayName = "TextSingle";
|
|
463
|
+
const q = ({
|
|
464
|
+
className: t = ""
|
|
465
|
+
}) => {
|
|
466
|
+
const e = S(C), i = S(pe), n = S(le), r = R(se(() => i.getCurrentTypeOfUnit$(Q.UNIVER_DOC), [i])), s = r && n.getRenderById(r.getUnitId()), c = s == null ? void 0 : s.with(he), u = R(c == null ? void 0 : c.hoverParagraph$), o = R(c == null ? void 0 : c.hoverParagraphLeft$), a = () => {
|
|
467
|
+
var I;
|
|
468
|
+
const d = u != null ? u : o;
|
|
469
|
+
if (!d)
|
|
470
|
+
return;
|
|
471
|
+
const p = e.resolvePopup("/");
|
|
472
|
+
p && e.showPopup({
|
|
473
|
+
popup: p,
|
|
474
|
+
index: d.startIndex - 1,
|
|
475
|
+
unitId: (I = r == null ? void 0 : r.getUnitId()) != null ? I : ""
|
|
476
|
+
});
|
|
477
|
+
};
|
|
478
|
+
return /* @__PURE__ */ h(
|
|
479
|
+
"div",
|
|
480
|
+
{
|
|
481
|
+
className: `
|
|
482
|
+
univer-mr-1 univer-flex univer-cursor-pointer univer-items-center univer-gap-2.5 univer-rounded-full
|
|
483
|
+
univer-border univer-border-gray-200 univer-bg-white univer-p-1.5 univer-shadow-sm
|
|
484
|
+
hover:univer-bg-gray-100
|
|
485
|
+
${t}
|
|
486
|
+
`,
|
|
487
|
+
onClick: a,
|
|
488
|
+
role: "button",
|
|
489
|
+
tabIndex: 0,
|
|
490
|
+
children: /* @__PURE__ */ h(Re, { className: "univer-text-gray-800" })
|
|
491
|
+
}
|
|
492
|
+
);
|
|
493
|
+
};
|
|
494
|
+
q.componentKey = "doc.quick-insert.button";
|
|
495
|
+
var Dt = Object.getOwnPropertyDescriptor, $t = (t, e, i, n) => {
|
|
496
|
+
for (var r = n > 1 ? void 0 : n ? Dt(e, i) : e, s = t.length - 1, c; s >= 0; s--)
|
|
497
|
+
(c = t[s]) && (r = c(r) || r);
|
|
498
|
+
return r;
|
|
499
|
+
}, ie = (t, e) => (i, n) => e(i, n, t);
|
|
500
|
+
let de = class extends Z {
|
|
501
|
+
constructor(e, i, n, r) {
|
|
502
|
+
super();
|
|
503
|
+
g(this, "_popup", null);
|
|
504
|
+
this._context = e, this._docEventManagerService = i, this._docQuickInsertPopupService = n, this._docCanvasPopManagerService = r, this._init();
|
|
391
505
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
506
|
+
_init() {
|
|
507
|
+
this.disposeWithMe(ye([this._docEventManagerService.hoverParagraphLeft$, this._docEventManagerService.hoverParagraph$]).subscribe(([e, i]) => {
|
|
508
|
+
var r;
|
|
509
|
+
const n = e != null ? e : i;
|
|
510
|
+
if (!n) {
|
|
511
|
+
this._hideMenu(!0);
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
if (n.paragraphStart === n.paragraphEnd && n.startIndex !== ((r = this._popup) == null ? void 0 : r.startIndex)) {
|
|
515
|
+
this._hideMenu(!0);
|
|
516
|
+
const s = this._docCanvasPopManagerService.attachPopupToRect(n.firstLine, {
|
|
517
|
+
componentKey: q.componentKey,
|
|
518
|
+
direction: "left-center"
|
|
519
|
+
}, this._context.unit.getUnitId());
|
|
520
|
+
this._popup = {
|
|
521
|
+
startIndex: n.startIndex,
|
|
522
|
+
disposable: s
|
|
523
|
+
};
|
|
524
|
+
} else
|
|
525
|
+
this._hideMenu(!0);
|
|
526
|
+
}));
|
|
527
|
+
}
|
|
528
|
+
_hideMenu(e) {
|
|
529
|
+
this._popup && (e || this._popup.disposable.canDispose()) && (this._popup.disposable.dispose(), this._popup = null);
|
|
397
530
|
}
|
|
398
|
-
}
|
|
531
|
+
};
|
|
532
|
+
de = $t([
|
|
533
|
+
ie(1, f(he)),
|
|
534
|
+
ie(2, f(C)),
|
|
535
|
+
ie(3, f(Pe))
|
|
536
|
+
], de);
|
|
537
|
+
const ke = {
|
|
399
538
|
id: "quick-insert.text.menu",
|
|
400
539
|
title: "docQuickInsert.menu.text",
|
|
401
540
|
icon: "TextSingle",
|
|
402
541
|
keywords: ["text"]
|
|
403
|
-
},
|
|
404
|
-
id:
|
|
542
|
+
}, De = {
|
|
543
|
+
id: tt.id,
|
|
405
544
|
title: "docQuickInsert.menu.numberedList",
|
|
406
545
|
icon: "OrderSingle",
|
|
407
546
|
keywords: ["numbered", "list", "ordered"]
|
|
408
|
-
},
|
|
409
|
-
id:
|
|
547
|
+
}, $e = {
|
|
548
|
+
id: nt.id,
|
|
410
549
|
title: "docQuickInsert.menu.bulletedList",
|
|
411
550
|
icon: "UnorderSingle",
|
|
412
551
|
keywords: ["bulleted", "list", "unordered"]
|
|
413
|
-
},
|
|
414
|
-
id:
|
|
552
|
+
}, Ne = {
|
|
553
|
+
id: it.id,
|
|
415
554
|
title: "docQuickInsert.menu.divider",
|
|
416
555
|
icon: "DividerSingle",
|
|
417
556
|
keywords: ["divider", "line", "separate"]
|
|
418
|
-
},
|
|
419
|
-
id:
|
|
557
|
+
}, Ee = {
|
|
558
|
+
id: rt.id,
|
|
420
559
|
title: "docQuickInsert.menu.table",
|
|
421
560
|
icon: "GridSingle",
|
|
422
561
|
keywords: ["table", "grid", "spreadsheet"]
|
|
423
|
-
},
|
|
424
|
-
id:
|
|
562
|
+
}, Ue = {
|
|
563
|
+
id: Ge.id,
|
|
425
564
|
title: "docQuickInsert.menu.image",
|
|
426
565
|
icon: "addition-and-subtraction-single",
|
|
427
566
|
keywords: ["image", "picture", "photo"]
|
|
428
|
-
},
|
|
567
|
+
}, Nt = [
|
|
429
568
|
{
|
|
430
569
|
title: "docQuickInsert.group.basics",
|
|
431
570
|
id: "quick.insert.group.basic",
|
|
432
571
|
children: [
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
572
|
+
ke,
|
|
573
|
+
De,
|
|
574
|
+
$e,
|
|
575
|
+
Ne,
|
|
576
|
+
Ee,
|
|
577
|
+
Ue
|
|
439
578
|
]
|
|
440
579
|
}
|
|
441
|
-
],
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
580
|
+
], Et = /* @__PURE__ */ new Set([
|
|
581
|
+
De.id,
|
|
582
|
+
$e.id,
|
|
583
|
+
Ne.id,
|
|
584
|
+
Ee.id,
|
|
585
|
+
Ue.id
|
|
447
586
|
]);
|
|
448
|
-
var
|
|
449
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
450
|
-
(
|
|
587
|
+
var Ut = Object.getOwnPropertyDescriptor, Tt = (t, e, i, n) => {
|
|
588
|
+
for (var r = n > 1 ? void 0 : n ? Ut(e, i) : e, s = t.length - 1, c; s >= 0; s--)
|
|
589
|
+
(c = t[s]) && (r = c(r) || r);
|
|
451
590
|
return r;
|
|
452
|
-
},
|
|
453
|
-
let
|
|
591
|
+
}, E = (t, e) => (i, n) => e(i, n, t);
|
|
592
|
+
let z = class extends Z {
|
|
454
593
|
constructor(t, e, i, n, r) {
|
|
455
594
|
super(), this._commandService = t, this._textSelectionManagerService = e, this._docQuickInsertPopupService = i, this._shortcutService = n, this._univerInstanceService = r, this.disposeWithMe(this._shortcutService.registerShortcut({
|
|
456
|
-
id:
|
|
457
|
-
binding:
|
|
595
|
+
id: U.id,
|
|
596
|
+
binding: M.ESC,
|
|
458
597
|
preconditions: () => !!this._docQuickInsertPopupService.editPopup,
|
|
459
598
|
priority: 1e3
|
|
460
599
|
})), this._initTrigger(), this._initMenuHandler();
|
|
@@ -464,10 +603,10 @@ let K = class extends Y {
|
|
|
464
603
|
this.disposeWithMe(
|
|
465
604
|
// eslint-disable-next-line complexity, max-lines-per-function
|
|
466
605
|
this._commandService.onCommandExecuted((t) => {
|
|
467
|
-
var s,
|
|
468
|
-
const { _docQuickInsertPopupService: e, _textSelectionManagerService: i, _commandService: n } = this, r = this._univerInstanceService.getCurrentUnitOfType(
|
|
606
|
+
var s, c, u;
|
|
607
|
+
const { _docQuickInsertPopupService: e, _textSelectionManagerService: i, _commandService: n } = this, r = this._univerInstanceService.getCurrentUnitOfType(Q.UNIVER_DOC);
|
|
469
608
|
if (!(r != null && r.getDisabled())) {
|
|
470
|
-
if (t.id ===
|
|
609
|
+
if (t.id === st.id) {
|
|
471
610
|
const o = t.params;
|
|
472
611
|
if (e.editPopup) {
|
|
473
612
|
e.setInputOffset({
|
|
@@ -476,47 +615,47 @@ let K = class extends Y {
|
|
|
476
615
|
});
|
|
477
616
|
return;
|
|
478
617
|
}
|
|
479
|
-
const
|
|
480
|
-
if (!
|
|
618
|
+
const a = i.getActiveTextRange();
|
|
619
|
+
if (!a)
|
|
481
620
|
return;
|
|
482
|
-
const
|
|
483
|
-
if (!
|
|
621
|
+
const d = e.resolvePopup(o.body.dataStream);
|
|
622
|
+
if (!d || !(d.preconditions ? d.preconditions(o) : !0))
|
|
484
623
|
return;
|
|
485
|
-
e.setInputOffset({ start:
|
|
486
|
-
n.executeCommand(
|
|
487
|
-
index:
|
|
624
|
+
e.setInputOffset({ start: a.startOffset - 1, end: a.startOffset }), setTimeout(() => {
|
|
625
|
+
n.executeCommand(xe.id, {
|
|
626
|
+
index: a.startOffset - 1,
|
|
488
627
|
unitId: o.unitId,
|
|
489
|
-
popup:
|
|
628
|
+
popup: d
|
|
490
629
|
});
|
|
491
630
|
}, 100);
|
|
492
631
|
}
|
|
493
|
-
if (t.id ===
|
|
632
|
+
if (t.id === ot.id) {
|
|
494
633
|
const o = t.params;
|
|
495
634
|
!e.isComposing && o.isCompositionStart && e.setIsComposing(!0), e.isComposing && o.isCompositionEnd && e.setIsComposing(!1);
|
|
496
635
|
}
|
|
497
|
-
if (t.id ===
|
|
636
|
+
if (t.id === ft.id) {
|
|
498
637
|
const o = t.params;
|
|
499
638
|
if (o.isCompositionEnd) {
|
|
500
|
-
const
|
|
501
|
-
|
|
639
|
+
const a = (c = (s = o.textRanges) == null ? void 0 : s[0]) == null ? void 0 : c.endOffset;
|
|
640
|
+
a && e.setInputOffset({ start: e.inputOffset.start, end: a });
|
|
502
641
|
}
|
|
503
642
|
}
|
|
504
|
-
if (t.id ===
|
|
643
|
+
if (t.id === ct.id) {
|
|
505
644
|
const o = t.params;
|
|
506
|
-
if (e.editPopup && o.direction ===
|
|
507
|
-
const
|
|
508
|
-
e.setInputOffset({ start: e.inputOffset.start, end: o.range.endOffset -
|
|
645
|
+
if (e.editPopup && o.direction === We.LEFT) {
|
|
646
|
+
const a = (u = o.len) != null ? u : 0;
|
|
647
|
+
e.setInputOffset({ start: e.inputOffset.start, end: o.range.endOffset - a });
|
|
509
648
|
}
|
|
510
649
|
}
|
|
511
|
-
if (t.id ===
|
|
650
|
+
if (t.id === at.id) {
|
|
512
651
|
const o = t.params;
|
|
513
|
-
(o.direction ===
|
|
652
|
+
(o.direction === A.LEFT || o.direction === A.RIGHT) && e.editPopup && n.executeCommand(U.id);
|
|
514
653
|
}
|
|
515
|
-
if (t.id ===
|
|
654
|
+
if (t.id === dt.id) {
|
|
516
655
|
const o = i.getActiveTextRange();
|
|
517
656
|
if (!e.editPopup || !o)
|
|
518
657
|
return;
|
|
519
|
-
o.endOffset <= e.editPopup.anchor && n.executeCommand(
|
|
658
|
+
o.endOffset <= e.editPopup.anchor && n.executeCommand(U.id);
|
|
520
659
|
}
|
|
521
660
|
}
|
|
522
661
|
})
|
|
@@ -524,110 +663,49 @@ let K = class extends Y {
|
|
|
524
663
|
}
|
|
525
664
|
_initMenuHandler() {
|
|
526
665
|
this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected((t) => {
|
|
527
|
-
t.id !==
|
|
666
|
+
t.id !== ke.id && Et.has(t.id) && this._commandService.executeCommand(t.id);
|
|
528
667
|
}));
|
|
529
668
|
}
|
|
530
669
|
};
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
],
|
|
538
|
-
var
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
e = arguments[i];
|
|
542
|
-
for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
|
|
543
|
-
}
|
|
544
|
-
return t;
|
|
545
|
-
}, v.apply(this, arguments);
|
|
546
|
-
}, yt = function(t, e) {
|
|
547
|
-
var i = {};
|
|
548
|
-
for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (i[n] = t[n]);
|
|
549
|
-
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
550
|
-
for (var r = 0, n = Object.getOwnPropertySymbols(t); r < n.length; r++)
|
|
551
|
-
e.indexOf(n[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[r]) && (i[n[r]] = t[n[r]]);
|
|
552
|
-
return i;
|
|
553
|
-
}, ie = te(function(t, e) {
|
|
554
|
-
var i = t.icon, n = t.id, r = t.className, s = t.extend, a = yt(t, ["icon", "id", "className", "extend"]), d = "univerjs-icon univerjs-icon-".concat(n, " ").concat(r || "").trim(), o = $("_".concat(bt()));
|
|
555
|
-
return be(i, "".concat(n), { defIds: i.defIds, idSuffix: o.current }, v({ ref: e, className: d }, a), s);
|
|
556
|
-
});
|
|
557
|
-
function be(t, e, i, n, r) {
|
|
558
|
-
return ne(t.tag, v(v({ key: e }, Ot(t, i, r)), n), (Pt(t, i).children || []).map(function(s, a) {
|
|
559
|
-
return be(s, "".concat(e, "-").concat(t.tag, "-").concat(a), i, void 0, r);
|
|
560
|
-
}));
|
|
561
|
-
}
|
|
562
|
-
function Ot(t, e, i) {
|
|
563
|
-
var n = v({}, t.attrs);
|
|
564
|
-
i != null && i.colorChannel1 && n.fill === "colorChannel1" && (n.fill = i.colorChannel1), t.tag === "mask" && n.id && (n.id = n.id + e.idSuffix), Object.entries(n).forEach(function(s) {
|
|
565
|
-
var a = s[0], d = s[1];
|
|
566
|
-
a === "mask" && typeof d == "string" && (n[a] = d.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
567
|
-
});
|
|
568
|
-
var r = e.defIds;
|
|
569
|
-
return !r || r.length === 0 || (t.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + e.idSuffix), Object.entries(n).forEach(function(s) {
|
|
570
|
-
var a = s[0], d = s[1];
|
|
571
|
-
typeof d == "string" && (n[a] = d.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
572
|
-
})), n;
|
|
573
|
-
}
|
|
574
|
-
function Pt(t, e) {
|
|
575
|
-
var i, n = e.defIds;
|
|
576
|
-
return !n || n.length === 0 ? t : t.tag === "defs" && (!((i = t.children) === null || i === void 0) && i.length) ? v(v({}, t), { children: t.children.map(function(r) {
|
|
577
|
-
return typeof r.attrs.id == "string" && n && n.indexOf(r.attrs.id) > -1 ? v(v({}, r), { attrs: v(v({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
|
|
578
|
-
}) }) : t;
|
|
579
|
-
}
|
|
580
|
-
function bt() {
|
|
581
|
-
return Math.random().toString(36).substring(2, 8);
|
|
582
|
-
}
|
|
583
|
-
ie.displayName = "UniverIcon";
|
|
584
|
-
var xt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.01953 3.13985C1.01953 2.77258 1.31726 2.47485 1.68453 2.47485H2.73713C3.1044 2.47485 3.40213 2.77258 3.40213 3.13985 3.40213 3.50712 3.1044 3.80485 2.73713 3.80485H1.68453C1.31726 3.80485 1.01953 3.50712 1.01953 3.13985zM4.17734 3.13985C4.17734 2.77258 4.47507 2.47485 4.84234 2.47485H6.94754C7.31481 2.47485 7.61254 2.77258 7.61254 3.13985 7.61254 3.50712 7.31481 3.80485 6.94754 3.80485H4.84234C4.47507 3.80485 4.17734 3.50712 4.17734 3.13985zM8.38775 3.13985C8.38775 2.77258 8.68548 2.47485 9.05275 2.47485H11.158C11.5252 2.47485 11.823 2.77258 11.823 3.13985 11.823 3.50712 11.5252 3.80485 11.158 3.80485H9.05275C8.68548 3.80485 8.38775 3.50712 8.38775 3.13985zM12.5982 3.13985C12.5982 2.77258 12.8959 2.47485 13.2632 2.47485H14.3158C14.683 2.47485 14.9808 2.77258 14.9808 3.13985 14.9808 3.50712 14.683 3.80485 14.3158 3.80485H13.2632C12.8959 3.80485 12.5982 3.50712 12.5982 3.13985zM1.01953 7.99972C1.01953 7.63245 1.31726 7.33472 1.68453 7.33472H14.3158C14.683 7.33472 14.9808 7.63245 14.9808 7.99972 14.9808 8.36699 14.683 8.66472 14.3158 8.66472H1.68453C1.31726 8.66472 1.01953 8.36699 1.01953 7.99972zM1.68453 12.1951C1.31726 12.1951 1.01953 12.4928 1.01953 12.8601 1.01953 13.2273 1.31726 13.5251 1.68453 13.5251H2.73713C3.1044 13.5251 3.40213 13.2273 3.40213 12.8601 3.40213 12.4928 3.1044 12.1951 2.73713 12.1951H1.68453zM4.84234 12.1951C4.47507 12.1951 4.17734 12.4928 4.17734 12.8601 4.17734 13.2273 4.47507 13.5251 4.84234 13.5251H6.94754C7.31481 13.5251 7.61254 13.2273 7.61254 12.8601 7.61254 12.4928 7.31481 12.1951 6.94754 12.1951H4.84234zM9.05275 12.1951C8.68548 12.1951 8.38775 12.4928 8.38775 12.8601 8.38775 13.2273 8.68548 13.5251 9.05275 13.5251H11.158C11.5252 13.5251 11.823 13.2273 11.823 12.8601 11.823 12.4928 11.5252 12.1951 11.158 12.1951H9.05275zM13.2632 12.1951C12.8959 12.1951 12.5982 12.4928 12.5982 12.8601 12.5982 13.2273 12.8959 13.5251 13.2632 13.5251H14.3158C14.683 13.5251 14.9808 13.2273 14.9808 12.8601 14.9808 12.4928 14.683 12.1951 14.3158 12.1951H13.2632z" } }] }, Z = te(function(t, e) {
|
|
585
|
-
return ne(ie, Object.assign({}, t, {
|
|
586
|
-
id: "divider-single",
|
|
587
|
-
ref: e,
|
|
588
|
-
icon: xt
|
|
589
|
-
}));
|
|
590
|
-
});
|
|
591
|
-
Z.displayName = "DividerSingle";
|
|
592
|
-
var Mt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.66695 1.33496C2.29968 1.33496 2.00195 1.63269 2.00195 1.99996V3.64439C2.00195 4.01166 2.29968 4.30939 2.66695 4.30939C3.03422 4.30939 3.33195 4.01166 3.33195 3.64439V2.66496H7.33521V13.335H5.3337C4.96643 13.335 4.6687 13.6327 4.6687 14C4.6687 14.3672 4.96643 14.665 5.3337 14.665H10.667C11.0343 14.665 11.332 14.3672 11.332 14C11.332 13.6327 11.0343 13.335 10.667 13.335H8.66521V2.66496H12.6686V3.64439C12.6686 4.01166 12.9664 4.30939 13.3336 4.30939C13.7009 4.30939 13.9986 4.01166 13.9986 3.64439V1.99996C13.9986 1.63269 13.7009 1.33496 13.3336 1.33496H2.66695Z" } }] }, J = te(function(t, e) {
|
|
593
|
-
return ne(ie, Object.assign({}, t, {
|
|
594
|
-
id: "text-single",
|
|
595
|
-
ref: e,
|
|
596
|
-
icon: Mt
|
|
597
|
-
}));
|
|
598
|
-
});
|
|
599
|
-
J.displayName = "TextSingle";
|
|
600
|
-
var wt = Object.getOwnPropertyDescriptor, Rt = (t, e, i, n) => {
|
|
601
|
-
for (var r = n > 1 ? void 0 : n ? wt(e, i) : e, s = t.length - 1, a; s >= 0; s--)
|
|
602
|
-
(a = t[s]) && (r = a(r) || r);
|
|
670
|
+
z = Tt([
|
|
671
|
+
E(0, T),
|
|
672
|
+
E(1, f(Oe)),
|
|
673
|
+
E(2, f(C)),
|
|
674
|
+
E(3, f(Se)),
|
|
675
|
+
E(4, f(pe))
|
|
676
|
+
], z);
|
|
677
|
+
var Qt = Object.getOwnPropertyDescriptor, Ht = (t, e, i, n) => {
|
|
678
|
+
for (var r = n > 1 ? void 0 : n ? Qt(e, i) : e, s = t.length - 1, c; s >= 0; s--)
|
|
679
|
+
(c = t[s]) && (r = c(r) || r);
|
|
603
680
|
return r;
|
|
604
|
-
},
|
|
605
|
-
let
|
|
681
|
+
}, re = (t, e) => (i, n) => e(i, n, t);
|
|
682
|
+
let F = class extends Z {
|
|
606
683
|
constructor(t, e, i) {
|
|
607
684
|
super(), this._commandService = t, this._docQuickInsertPopupService = e, this._componentManager = i, this._initCommands(), this._initComponents(), this._initMenus();
|
|
608
685
|
}
|
|
609
686
|
_initCommands() {
|
|
610
687
|
[
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
688
|
+
Me,
|
|
689
|
+
xe,
|
|
690
|
+
U
|
|
614
691
|
].forEach((t) => {
|
|
615
692
|
this.disposeWithMe(this._commandService.registerCommand(t));
|
|
616
693
|
});
|
|
617
694
|
}
|
|
618
695
|
_initComponents() {
|
|
619
696
|
[
|
|
620
|
-
[
|
|
621
|
-
[
|
|
622
|
-
[
|
|
623
|
-
[
|
|
624
|
-
[
|
|
697
|
+
[V.componentKey, V],
|
|
698
|
+
[B.componentKey, B],
|
|
699
|
+
[W.componentKey, W],
|
|
700
|
+
[ce.displayName, ce],
|
|
701
|
+
[ae.displayName, ae],
|
|
702
|
+
[q.componentKey, q]
|
|
625
703
|
].forEach(([e, i]) => {
|
|
626
704
|
e && this.disposeWithMe(this._componentManager.register(e, i));
|
|
627
705
|
}), [
|
|
628
706
|
{
|
|
629
707
|
keyword: "/",
|
|
630
|
-
menus$:
|
|
708
|
+
menus$: lt(Nt),
|
|
631
709
|
// only show when the cursor is at the beginning of a line
|
|
632
710
|
preconditions: (e) => {
|
|
633
711
|
var i;
|
|
@@ -641,43 +719,48 @@ let j = class extends Y {
|
|
|
641
719
|
_initMenus() {
|
|
642
720
|
}
|
|
643
721
|
};
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
],
|
|
649
|
-
var
|
|
650
|
-
for (var r = n > 1 ? void 0 : n ?
|
|
651
|
-
(
|
|
722
|
+
F = Ht([
|
|
723
|
+
re(0, T),
|
|
724
|
+
re(1, f(C)),
|
|
725
|
+
re(2, f(Ie))
|
|
726
|
+
], F);
|
|
727
|
+
var Kt = Object.defineProperty, jt = Object.getOwnPropertyDescriptor, Lt = (t, e, i) => e in t ? Kt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i, At = (t, e, i, n) => {
|
|
728
|
+
for (var r = n > 1 ? void 0 : n ? jt(e, i) : e, s = t.length - 1, c; s >= 0; s--)
|
|
729
|
+
(c = t[s]) && (r = c(r) || r);
|
|
652
730
|
return r;
|
|
653
|
-
},
|
|
654
|
-
const
|
|
655
|
-
let
|
|
656
|
-
constructor(t) {
|
|
657
|
-
super(), this._injector = t;
|
|
731
|
+
}, Ce = (t, e) => (i, n) => e(i, n, t), Te = (t, e, i) => Lt(t, typeof e != "symbol" ? e + "" : e, i);
|
|
732
|
+
const Bt = "DOC_QUICK_INSERT_UI_PLUGIN";
|
|
733
|
+
let G = class extends ze {
|
|
734
|
+
constructor(t, e) {
|
|
735
|
+
super(), this._injector = t, this._renderManagerSrv = e;
|
|
658
736
|
}
|
|
659
737
|
onStarting() {
|
|
660
738
|
[
|
|
661
|
-
[
|
|
662
|
-
[
|
|
739
|
+
[F],
|
|
740
|
+
[z],
|
|
663
741
|
[C]
|
|
664
|
-
].forEach((e) => this._injector.add(e)), this._injector.get(
|
|
742
|
+
].forEach((e) => this._injector.add(e)), this._injector.get(F);
|
|
665
743
|
}
|
|
666
744
|
onRendered() {
|
|
667
|
-
this._injector.get(
|
|
745
|
+
this._injector.get(z), this._injector.get(C), [
|
|
746
|
+
[de]
|
|
747
|
+
].forEach((t) => {
|
|
748
|
+
this._renderManagerSrv.registerRenderModule(Q.UNIVER_DOC, t);
|
|
749
|
+
});
|
|
668
750
|
}
|
|
669
751
|
};
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
752
|
+
Te(G, "type", Q.UNIVER_DOC);
|
|
753
|
+
Te(G, "pluginName", Bt);
|
|
754
|
+
G = At([
|
|
755
|
+
Ve(Xe, Je, Ze, Fe, Ye),
|
|
756
|
+
Ce(0, f(qe)),
|
|
757
|
+
Ce(1, f(le))
|
|
758
|
+
], G);
|
|
676
759
|
export {
|
|
677
760
|
C as DocQuickInsertPopupService,
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
761
|
+
z as DocQuickInsertTriggerController,
|
|
762
|
+
F as DocQuickInsertUIController,
|
|
763
|
+
Ct as KeywordInputPlaceholderComponentKey,
|
|
764
|
+
It as QuickInsertPlaceholderComponentKey,
|
|
765
|
+
G as UniverDocsQuickInsertUIPlugin
|
|
683
766
|
};
|