@univerjs/docs-quick-insert-ui 0.6.6-experimental.20250317-28d180b
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/README.md +27 -0
- package/lib/cjs/index.js +9 -0
- package/lib/cjs/locale/en-US.js +1 -0
- package/lib/cjs/locale/fa-IR.js +1 -0
- package/lib/cjs/locale/fr-FR.js +1 -0
- package/lib/cjs/locale/ru-RU.js +1 -0
- package/lib/cjs/locale/vi-VN.js +1 -0
- package/lib/cjs/locale/zh-CN.js +1 -0
- package/lib/cjs/locale/zh-TW.js +1 -0
- package/lib/es/index.js +582 -0
- package/lib/es/locale/en-US.js +18 -0
- package/lib/es/locale/fa-IR.js +18 -0
- package/lib/es/locale/fr-FR.js +18 -0
- package/lib/es/locale/ru-RU.js +18 -0
- package/lib/es/locale/vi-VN.js +18 -0
- package/lib/es/locale/zh-CN.js +18 -0
- package/lib/es/locale/zh-TW.js +18 -0
- package/lib/index.css +1 -0
- package/lib/types/commands/commands/doc-quick-insert.command.d.ts +7 -0
- package/lib/types/commands/operations/quick-insert-popup.operation.d.ts +9 -0
- package/lib/types/controllers/built-in-menus.d.ts +11 -0
- package/lib/types/controllers/doc-quick-insert-trigger.controller.d.ts +13 -0
- package/lib/types/controllers/doc-quick-insert-ui.controller.d.ts +12 -0
- package/lib/types/index.d.ts +21 -0
- package/lib/types/locale/en-US.d.ts +3 -0
- package/lib/types/locale/fa-IR.d.ts +3 -0
- package/lib/types/locale/fr-FR.d.ts +3 -0
- package/lib/types/locale/ru-RU.d.ts +3 -0
- package/lib/types/locale/vi-VN.d.ts +3 -0
- package/lib/types/locale/zh-CN.d.ts +31 -0
- package/lib/types/locale/zh-TW.d.ts +3 -0
- package/lib/types/plugin.d.ts +9 -0
- package/lib/types/services/doc-quick-insert-popup.service.d.ts +69 -0
- package/lib/types/views/KeywordInputPlaceholder.d.ts +20 -0
- package/lib/types/views/QuickInsertPlaceholder.d.ts +16 -0
- package/lib/types/views/QuickInsertPopup.d.ts +20 -0
- package/lib/umd/index.js +9 -0
- package/lib/umd/locale/en-US.js +1 -0
- package/lib/umd/locale/fa-IR.js +1 -0
- package/lib/umd/locale/fr-FR.js +1 -0
- package/lib/umd/locale/ru-RU.js +1 -0
- package/lib/umd/locale/vi-VN.js +1 -0
- package/lib/umd/locale/zh-CN.js +1 -0
- package/lib/umd/locale/zh-TW.js +1 -0
- package/package.json +84 -0
package/lib/es/index.js
ADDED
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
var Ie = Object.defineProperty;
|
|
2
|
+
var Pe = (t, e, r) => e in t ? Ie(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var m = (t, e, r) => Pe(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { CommandType as y, ICommandService as M, RANGE_DIRECTION as ye, LocaleService as L, generateRandomId as xe, DisposableCollection as be, toDisposable as Me, Direction as R, Inject as v, IUniverInstanceService as we, Disposable as z, UniverInstanceType as ie, DeleteDirection as Re, DependentOn as ke, Injector as De, Plugin as Ne } from "@univerjs/core";
|
|
5
|
+
import { UniverDocsDrawingPlugin as $e } from "@univerjs/docs-drawing";
|
|
6
|
+
import { UniverDrawingPlugin as Ee } from "@univerjs/drawing";
|
|
7
|
+
import { UniverDrawingUIPlugin as Te } from "@univerjs/drawing-ui";
|
|
8
|
+
import { useDependency as O, KeyCode as S, ComponentManager as oe, IShortcutService as se, useObservable as Q, UniverUIPlugin as He } from "@univerjs/ui";
|
|
9
|
+
import { DocSelectionManagerService as je, RichTextEditingMutation as Qe } from "@univerjs/docs";
|
|
10
|
+
import { CutContentCommand as Ue, DocCanvasPopManagerService as Ke, OrderListCommand as Ae, BulletListCommand as We, HorizontalLineCommand as Le, InsertCommand as ze, DeleteCommand as qe, MoveCursorOperation as Be, DeleteLeftCommand as Ve } from "@univerjs/docs-ui";
|
|
11
|
+
import { map as Fe, distinctUntilChanged as Ge, combineLatest as Ze, tap as X, BehaviorSubject as Y, of as Je } from "rxjs";
|
|
12
|
+
import { jsx as a, jsxs as ee } from "react/jsx-runtime";
|
|
13
|
+
import { clsx as te, Menu as Xe, MenuItemGroup as Ye, MenuItem as et } from "@univerjs/design";
|
|
14
|
+
import { useMemo as ne, useState as re, useRef as W, useEffect as U, forwardRef as q, createElement as B } from "react";
|
|
15
|
+
const ce = {
|
|
16
|
+
id: "doc.command.delete-search-key",
|
|
17
|
+
type: y.COMMAND,
|
|
18
|
+
handler: (t, e) => {
|
|
19
|
+
const r = t.get(M), { start: n, end: i } = e;
|
|
20
|
+
return r.syncExecuteCommand(Ue.id, {
|
|
21
|
+
segmentId: "",
|
|
22
|
+
textRanges: [{
|
|
23
|
+
startOffset: n,
|
|
24
|
+
endOffset: n,
|
|
25
|
+
collapsed: !0
|
|
26
|
+
}],
|
|
27
|
+
selections: [{
|
|
28
|
+
startOffset: n,
|
|
29
|
+
endOffset: i,
|
|
30
|
+
collapsed: !1,
|
|
31
|
+
direction: ye.FORWARD
|
|
32
|
+
}]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}, k = () => {
|
|
36
|
+
const t = O(L);
|
|
37
|
+
return /* @__PURE__ */ a("div", { className: "univer-translate-y-1.5 univer-text-sm univer-text-gray-500", children: t.t("docQuickInsert.keywordInputPlaceholder") });
|
|
38
|
+
};
|
|
39
|
+
k.componentKey = "KeywordInputPlaceholder";
|
|
40
|
+
const tt = () => {
|
|
41
|
+
const t = O(L);
|
|
42
|
+
return /* @__PURE__ */ a(
|
|
43
|
+
"div",
|
|
44
|
+
{
|
|
45
|
+
className: `
|
|
46
|
+
univer-flex univer-h-full univer-items-center univer-justify-center univer-rounded-lg univer-bg-white
|
|
47
|
+
univer-px-12 univer-py-6 univer-text-gray-400
|
|
48
|
+
`,
|
|
49
|
+
children: /* @__PURE__ */ a("span", { children: t.t("docQuickInsert.placeholder") })
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
function de(t, e) {
|
|
54
|
+
return t.map((r) => ({ ...r })).filter((r) => {
|
|
55
|
+
if ("children" in r)
|
|
56
|
+
return r.children = de(r.children, e), r.children.length > 0;
|
|
57
|
+
const n = r.keywords;
|
|
58
|
+
return n ? n.some((i) => i.includes(e)) : r.title.toLowerCase().includes(e);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function ae(t, e) {
|
|
62
|
+
return t.map((r) => {
|
|
63
|
+
const n = { ...r };
|
|
64
|
+
return "children" in n && (n.children = ae(n.children, e)), n.title = e.t(n.title), "keywords" in n && (n.keywords = n.keywords.concat(n.title).map((i) => i.toLowerCase())), n;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const nt = [S.ARROW_UP, S.ARROW_DOWN, S.ENTER], D = () => {
|
|
68
|
+
const t = O(L), e = O(g), r = O(oe), n = O(se), i = O(M), o = ne(() => xe(), []), [c, s] = re(0), d = W(null), f = W(0);
|
|
69
|
+
f.current = 0;
|
|
70
|
+
const T = Q(e.filterKeyword$, ""), I = Q(e.editPopup$), F = Q(I == null ? void 0 : I.popup.menus$, []), [H, Ce] = re([]), G = ne(() => ae(F, t), [F]);
|
|
71
|
+
U(() => {
|
|
72
|
+
const u = requestIdleCallback(() => {
|
|
73
|
+
Ce(de(G, T.toLowerCase()));
|
|
74
|
+
});
|
|
75
|
+
return () => {
|
|
76
|
+
cancelIdleCallback(u);
|
|
77
|
+
};
|
|
78
|
+
}, [G, T]);
|
|
79
|
+
const Z = (u) => {
|
|
80
|
+
e.emitMenuSelected(u), i.executeCommand(b.id);
|
|
81
|
+
};
|
|
82
|
+
U(() => {
|
|
83
|
+
const u = new be();
|
|
84
|
+
n.getAllShortcuts().filter((l) => l.binding && nt.includes(l.binding)).forEach((l) => {
|
|
85
|
+
const C = l.preconditions;
|
|
86
|
+
l.preconditions = () => !1, u.add(Me(() => {
|
|
87
|
+
l.preconditions = C;
|
|
88
|
+
}));
|
|
89
|
+
});
|
|
90
|
+
const _ = {
|
|
91
|
+
id: `quick.insert.popup.enter.${o}`,
|
|
92
|
+
type: y.OPERATION,
|
|
93
|
+
handler: () => {
|
|
94
|
+
const l = d.current;
|
|
95
|
+
l && Z(l);
|
|
96
|
+
}
|
|
97
|
+
}, x = {
|
|
98
|
+
id: `quick.insert.popup.move.cursor.up.${o}`,
|
|
99
|
+
type: y.OPERATION,
|
|
100
|
+
handler: () => {
|
|
101
|
+
s((l) => {
|
|
102
|
+
const C = l - 1;
|
|
103
|
+
return C >= 0 ? C : f.current - 1;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}, P = {
|
|
107
|
+
id: `quick.insert.popup.move.cursor.down.${o}`,
|
|
108
|
+
type: y.OPERATION,
|
|
109
|
+
handler: () => {
|
|
110
|
+
s((l) => {
|
|
111
|
+
const C = l + 1;
|
|
112
|
+
return C <= f.current - 1 ? C : 0;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
return u.add(i.registerCommand(x)), u.add(i.registerCommand(P)), u.add(i.registerCommand(_)), u.add(n.registerShortcut({
|
|
117
|
+
priority: 1e3,
|
|
118
|
+
id: x.id,
|
|
119
|
+
binding: S.ARROW_UP,
|
|
120
|
+
preconditions: () => !0,
|
|
121
|
+
staticParameters: {
|
|
122
|
+
direction: R.UP
|
|
123
|
+
}
|
|
124
|
+
})), u.add(n.registerShortcut({
|
|
125
|
+
priority: 1e3,
|
|
126
|
+
id: P.id,
|
|
127
|
+
binding: S.ARROW_DOWN,
|
|
128
|
+
preconditions: () => !0,
|
|
129
|
+
staticParameters: {
|
|
130
|
+
direction: R.DOWN
|
|
131
|
+
}
|
|
132
|
+
})), u.add(n.registerShortcut({
|
|
133
|
+
priority: 1e3,
|
|
134
|
+
id: _.id,
|
|
135
|
+
binding: S.ENTER,
|
|
136
|
+
preconditions: () => !0
|
|
137
|
+
})), () => {
|
|
138
|
+
u.dispose();
|
|
139
|
+
};
|
|
140
|
+
}, []), U(() => {
|
|
141
|
+
s(0);
|
|
142
|
+
}, [H]);
|
|
143
|
+
function J(u) {
|
|
144
|
+
return u.map((h) => {
|
|
145
|
+
const j = h.icon, _ = j ? r.get(j) : null;
|
|
146
|
+
if ("children" in h)
|
|
147
|
+
return /* @__PURE__ */ a(
|
|
148
|
+
Ye,
|
|
149
|
+
{
|
|
150
|
+
title: /* @__PURE__ */ ee(
|
|
151
|
+
"div",
|
|
152
|
+
{
|
|
153
|
+
className: `
|
|
154
|
+
univer-mb-2 univer-flex univer-items-center univer-text-xs univer-text-gray-400
|
|
155
|
+
`,
|
|
156
|
+
children: [
|
|
157
|
+
_ && /* @__PURE__ */ a("span", { className: "univer-mr-2 univer-inline-flex univer-text-base", children: /* @__PURE__ */ a(_, {}) }),
|
|
158
|
+
/* @__PURE__ */ a("span", { children: h.title })
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
children: J(h.children)
|
|
163
|
+
},
|
|
164
|
+
h.id
|
|
165
|
+
);
|
|
166
|
+
const x = f.current, P = c === x;
|
|
167
|
+
return P && (d.current = h), f.current++, /* @__PURE__ */ a(
|
|
168
|
+
et,
|
|
169
|
+
{
|
|
170
|
+
onMouseEnter: () => s(x),
|
|
171
|
+
onMouseLeave: () => s(Number.NaN),
|
|
172
|
+
className: te("univer-text-sm", {
|
|
173
|
+
"hover:univer-bg-transparent": !P,
|
|
174
|
+
"univer-bg-gray-100": P
|
|
175
|
+
}),
|
|
176
|
+
onClick: () => {
|
|
177
|
+
Z(h);
|
|
178
|
+
},
|
|
179
|
+
children: /* @__PURE__ */ ee("div", { className: "univer-flex univer-items-center univer-px-1", children: [
|
|
180
|
+
_ && /* @__PURE__ */ a("span", { className: "univer-mr-2 univer-inline-flex univer-text-base", children: /* @__PURE__ */ a(_, {}) }),
|
|
181
|
+
/* @__PURE__ */ a("span", { children: h.title })
|
|
182
|
+
] })
|
|
183
|
+
},
|
|
184
|
+
h.id
|
|
185
|
+
);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const Oe = H.length > 0, Se = (I == null ? void 0 : I.popup.Placeholder) || tt;
|
|
189
|
+
return /* @__PURE__ */ a(
|
|
190
|
+
"div",
|
|
191
|
+
{
|
|
192
|
+
className: te(`
|
|
193
|
+
univer-rounded-lg univer-border univer-border-solid univer-border-gray-100
|
|
194
|
+
univer-shadow-[0_0_10px_0_rgba(0,0,0,0.1)]
|
|
195
|
+
`),
|
|
196
|
+
children: Oe ? /* @__PURE__ */ a("div", { className: "univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto", children: /* @__PURE__ */ a(Xe, { children: J(H) }) }) : /* @__PURE__ */ a(Se, {})
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
};
|
|
200
|
+
D.componentKey = "doc.quick-insert-popup";
|
|
201
|
+
var rt = Object.getOwnPropertyDescriptor, it = (t, e, r, n) => {
|
|
202
|
+
for (var i = n > 1 ? void 0 : n ? rt(e, r) : e, o = t.length - 1, c; o >= 0; o--)
|
|
203
|
+
(c = t[o]) && (i = c(i) || i);
|
|
204
|
+
return i;
|
|
205
|
+
}, K = (t, e) => (r, n) => e(r, n, t);
|
|
206
|
+
let g = class extends z {
|
|
207
|
+
constructor(e, r, n) {
|
|
208
|
+
super();
|
|
209
|
+
m(this, "_popups", /* @__PURE__ */ new Set());
|
|
210
|
+
m(this, "_editPopup$", new Y(void 0));
|
|
211
|
+
m(this, "editPopup$", this._editPopup$.asObservable());
|
|
212
|
+
m(this, "_inputOffset$", new Y({ start: 0, end: 0 }));
|
|
213
|
+
m(this, "inputOffset$", this._inputOffset$.asObservable());
|
|
214
|
+
m(this, "filterKeyword$");
|
|
215
|
+
m(this, "_menuSelectedCallbacks", /* @__PURE__ */ new Set());
|
|
216
|
+
m(this, "_inputPlaceholderRenderRoot", null);
|
|
217
|
+
this._docCanvasPopupManagerService = e, this._univerInstanceService = r, this._commandService = n, this.disposeWithMe(this._editPopup$);
|
|
218
|
+
const i = (o, c) => {
|
|
219
|
+
var s, d;
|
|
220
|
+
return (d = (s = this._univerInstanceService.getCurrentUnitOfType(ie.UNIVER_DOC)) == null ? void 0 : s.getBody()) == null ? void 0 : d.dataStream.slice(o, c);
|
|
221
|
+
};
|
|
222
|
+
this.filterKeyword$ = this._inputOffset$.pipe(
|
|
223
|
+
Fe((o) => {
|
|
224
|
+
var s;
|
|
225
|
+
const c = i(o.start, o.end);
|
|
226
|
+
return (s = c == null ? void 0 : c.slice(1)) != null ? s : "";
|
|
227
|
+
}),
|
|
228
|
+
Ge()
|
|
229
|
+
), this.disposeWithMe(Ze([
|
|
230
|
+
this.filterKeyword$.pipe(X((o) => {
|
|
231
|
+
var c, s, d;
|
|
232
|
+
o.length > 0 ? (s = (c = this._inputPlaceholderRenderRoot) == null ? void 0 : c.unmount) == null || s.dispose() : (d = this._inputPlaceholderRenderRoot) == null || d.mount();
|
|
233
|
+
})),
|
|
234
|
+
this.editPopup$.pipe(X((o) => {
|
|
235
|
+
var c, s;
|
|
236
|
+
o || (s = (c = this._inputPlaceholderRenderRoot) == null ? void 0 : c.unmount) == null || s.dispose();
|
|
237
|
+
}))
|
|
238
|
+
]).subscribe());
|
|
239
|
+
}
|
|
240
|
+
get editPopup() {
|
|
241
|
+
return this._editPopup$.value;
|
|
242
|
+
}
|
|
243
|
+
get inputOffset() {
|
|
244
|
+
return this._inputOffset$.value;
|
|
245
|
+
}
|
|
246
|
+
setInputOffset(e) {
|
|
247
|
+
this._inputOffset$.next(e);
|
|
248
|
+
}
|
|
249
|
+
resolvePopup(e) {
|
|
250
|
+
return Array.from(this._popups).find((r) => r.keyword === e);
|
|
251
|
+
}
|
|
252
|
+
registerPopup(e) {
|
|
253
|
+
return this._popups.add(e), () => {
|
|
254
|
+
this._popups.delete(e);
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
_createInputPlaceholderRenderRoot(e) {
|
|
258
|
+
return {
|
|
259
|
+
mount() {
|
|
260
|
+
this.unmount = e();
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
showPopup(e) {
|
|
265
|
+
const { popup: r, index: n, unitId: i } = e;
|
|
266
|
+
this.closePopup();
|
|
267
|
+
const o = this._docCanvasPopupManagerService.attachPopupToRange(
|
|
268
|
+
{ startOffset: n, endOffset: n, collapsed: !0 },
|
|
269
|
+
{
|
|
270
|
+
componentKey: D.componentKey,
|
|
271
|
+
onClickOutside: () => {
|
|
272
|
+
this.closePopup();
|
|
273
|
+
},
|
|
274
|
+
direction: "bottom"
|
|
275
|
+
},
|
|
276
|
+
i
|
|
277
|
+
);
|
|
278
|
+
this._inputPlaceholderRenderRoot = this._createInputPlaceholderRenderRoot(() => {
|
|
279
|
+
const c = this._docCanvasPopupManagerService.attachPopupToRange(
|
|
280
|
+
{ startOffset: n + 1, endOffset: n + 1, collapsed: !1 },
|
|
281
|
+
{
|
|
282
|
+
componentKey: k.componentKey,
|
|
283
|
+
onClickOutside: () => {
|
|
284
|
+
c.dispose();
|
|
285
|
+
},
|
|
286
|
+
direction: "horizontal"
|
|
287
|
+
},
|
|
288
|
+
i
|
|
289
|
+
);
|
|
290
|
+
return c;
|
|
291
|
+
}), this._inputPlaceholderRenderRoot.mount(), this._editPopup$.next({ disposable: o, popup: r, anchor: n, unitId: i });
|
|
292
|
+
}
|
|
293
|
+
closePopup() {
|
|
294
|
+
this.editPopup && (this.editPopup.disposable.dispose(), this._editPopup$.next(null));
|
|
295
|
+
}
|
|
296
|
+
onMenuSelected(e) {
|
|
297
|
+
return this._menuSelectedCallbacks.add(e), () => {
|
|
298
|
+
this._menuSelectedCallbacks.delete(e);
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
emitMenuSelected(e) {
|
|
302
|
+
const { start: r, end: n } = this.inputOffset;
|
|
303
|
+
this._commandService.syncExecuteCommand(ce.id, {
|
|
304
|
+
start: r,
|
|
305
|
+
end: n
|
|
306
|
+
}), setTimeout(() => {
|
|
307
|
+
this._menuSelectedCallbacks.forEach((i) => i(e));
|
|
308
|
+
}, 0);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
g = it([
|
|
312
|
+
K(0, v(Ke)),
|
|
313
|
+
K(1, v(we)),
|
|
314
|
+
K(2, v(M))
|
|
315
|
+
], g);
|
|
316
|
+
const ue = {
|
|
317
|
+
type: y.OPERATION,
|
|
318
|
+
id: "doc.operation.show-quick-insert-popup",
|
|
319
|
+
handler(t, e) {
|
|
320
|
+
const r = t.get(g);
|
|
321
|
+
return e ? (r.showPopup(e), !0) : !1;
|
|
322
|
+
}
|
|
323
|
+
}, b = {
|
|
324
|
+
type: y.OPERATION,
|
|
325
|
+
id: "doc.operation.close-quick-insert-popup",
|
|
326
|
+
handler(t) {
|
|
327
|
+
return t.get(g).closePopup(), !0;
|
|
328
|
+
}
|
|
329
|
+
}, le = {
|
|
330
|
+
id: "quick-insert.text.menu",
|
|
331
|
+
title: "docQuickInsert.menu.text",
|
|
332
|
+
icon: "TextSingle",
|
|
333
|
+
keywords: ["text"]
|
|
334
|
+
}, pe = {
|
|
335
|
+
id: Ae.id,
|
|
336
|
+
title: "docQuickInsert.menu.numberedList",
|
|
337
|
+
icon: "OrderSingle",
|
|
338
|
+
keywords: ["numbered", "list", "ordered"]
|
|
339
|
+
}, fe = {
|
|
340
|
+
id: We.id,
|
|
341
|
+
title: "docQuickInsert.menu.bulletedList",
|
|
342
|
+
icon: "UnorderSingle",
|
|
343
|
+
keywords: ["bulleted", "list", "unordered"]
|
|
344
|
+
}, he = {
|
|
345
|
+
id: Le.id,
|
|
346
|
+
title: "docQuickInsert.menu.divider",
|
|
347
|
+
icon: "DividerSingle",
|
|
348
|
+
keywords: ["divider", "line", "separate"]
|
|
349
|
+
}, ot = [
|
|
350
|
+
{
|
|
351
|
+
title: "docQuickInsert.group.basics",
|
|
352
|
+
id: "quick.insert.group.basic",
|
|
353
|
+
children: [
|
|
354
|
+
le,
|
|
355
|
+
pe,
|
|
356
|
+
fe,
|
|
357
|
+
he
|
|
358
|
+
]
|
|
359
|
+
}
|
|
360
|
+
], st = /* @__PURE__ */ new Set([
|
|
361
|
+
pe.id,
|
|
362
|
+
fe.id,
|
|
363
|
+
he.id
|
|
364
|
+
]);
|
|
365
|
+
var ct = Object.getOwnPropertyDescriptor, dt = (t, e, r, n) => {
|
|
366
|
+
for (var i = n > 1 ? void 0 : n ? ct(e, r) : e, o = t.length - 1, c; o >= 0; o--)
|
|
367
|
+
(c = t[o]) && (i = c(i) || i);
|
|
368
|
+
return i;
|
|
369
|
+
}, w = (t, e) => (r, n) => e(r, n, t);
|
|
370
|
+
let N = class extends z {
|
|
371
|
+
constructor(t, e, r, n) {
|
|
372
|
+
super(), this._commandService = t, this._textSelectionManagerService = e, this._docQuickInsertPopupService = r, this._shortcutService = n, this.disposeWithMe(this._shortcutService.registerShortcut({
|
|
373
|
+
id: b.id,
|
|
374
|
+
binding: S.ESC,
|
|
375
|
+
preconditions: () => !!this._docQuickInsertPopupService.editPopup,
|
|
376
|
+
priority: 1e3
|
|
377
|
+
})), this._initTrigger(), this._initMenuHandler();
|
|
378
|
+
}
|
|
379
|
+
_initTrigger() {
|
|
380
|
+
this.disposeWithMe(
|
|
381
|
+
// eslint-disable-next-line complexity
|
|
382
|
+
this._commandService.onCommandExecuted((t) => {
|
|
383
|
+
var i, o, c;
|
|
384
|
+
const { _docQuickInsertPopupService: e, _textSelectionManagerService: r, _commandService: n } = this;
|
|
385
|
+
if (t.id === ze.id) {
|
|
386
|
+
const s = t.params;
|
|
387
|
+
if (e.editPopup) {
|
|
388
|
+
e.setInputOffset({
|
|
389
|
+
start: e.inputOffset.start,
|
|
390
|
+
end: s.range.endOffset + 1
|
|
391
|
+
});
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
const d = r.getActiveTextRange();
|
|
395
|
+
if (!d)
|
|
396
|
+
return;
|
|
397
|
+
const f = e.resolvePopup(s.body.dataStream);
|
|
398
|
+
if (!f || !(f.preconditions ? f.preconditions(s) : !0))
|
|
399
|
+
return;
|
|
400
|
+
e.setInputOffset({ start: d.startOffset - 1, end: d.startOffset }), setTimeout(() => {
|
|
401
|
+
n.executeCommand(ue.id, {
|
|
402
|
+
index: d.startOffset - 1,
|
|
403
|
+
unitId: s.unitId,
|
|
404
|
+
popup: f
|
|
405
|
+
});
|
|
406
|
+
}, 100);
|
|
407
|
+
}
|
|
408
|
+
if (t.id === Qe.id) {
|
|
409
|
+
const s = t.params;
|
|
410
|
+
if (s.isCompositionEnd) {
|
|
411
|
+
const d = (o = (i = s.textRanges) == null ? void 0 : i[0]) == null ? void 0 : o.endOffset;
|
|
412
|
+
d && e.setInputOffset({ start: e.inputOffset.start, end: d });
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (t.id === qe.id) {
|
|
416
|
+
const s = t.params;
|
|
417
|
+
if (e.editPopup && s.direction === Re.LEFT) {
|
|
418
|
+
const d = (c = s.len) != null ? c : 0;
|
|
419
|
+
e.setInputOffset({ start: e.inputOffset.start, end: s.range.endOffset - d });
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
if (t.id === Be.id) {
|
|
423
|
+
const s = t.params;
|
|
424
|
+
(s.direction === R.LEFT || s.direction === R.RIGHT) && e.editPopup && n.executeCommand(b.id);
|
|
425
|
+
}
|
|
426
|
+
if (t.id === Ve.id) {
|
|
427
|
+
const s = r.getActiveTextRange();
|
|
428
|
+
if (!e.editPopup || !s)
|
|
429
|
+
return;
|
|
430
|
+
s.endOffset <= e.editPopup.anchor && n.executeCommand(b.id);
|
|
431
|
+
}
|
|
432
|
+
})
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
_initMenuHandler() {
|
|
436
|
+
this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected((t) => {
|
|
437
|
+
t.id !== le.id && st.has(t.id) && this._commandService.executeCommand(t.id);
|
|
438
|
+
}));
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
N = dt([
|
|
442
|
+
w(0, M),
|
|
443
|
+
w(1, v(je)),
|
|
444
|
+
w(2, v(g)),
|
|
445
|
+
w(3, v(se))
|
|
446
|
+
], N);
|
|
447
|
+
var p = function() {
|
|
448
|
+
return p = Object.assign || function(t) {
|
|
449
|
+
for (var e, r = 1, n = arguments.length; r < n; r++) {
|
|
450
|
+
e = arguments[r];
|
|
451
|
+
for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
|
|
452
|
+
}
|
|
453
|
+
return t;
|
|
454
|
+
}, p.apply(this, arguments);
|
|
455
|
+
}, at = function(t, e) {
|
|
456
|
+
var r = {};
|
|
457
|
+
for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]);
|
|
458
|
+
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
459
|
+
for (var i = 0, n = Object.getOwnPropertySymbols(t); i < n.length; i++)
|
|
460
|
+
e.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[i]) && (r[n[i]] = t[n[i]]);
|
|
461
|
+
return r;
|
|
462
|
+
}, V = q(function(t, e) {
|
|
463
|
+
var r = t.icon, n = t.id, i = t.className, o = t.extend, c = at(t, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(n, " ").concat(i || "").trim(), d = W("_".concat(pt()));
|
|
464
|
+
return me(r, "".concat(n), { defIds: r.defIds, idSuffix: d.current }, p({ ref: e, className: s }, c), o);
|
|
465
|
+
});
|
|
466
|
+
function me(t, e, r, n, i) {
|
|
467
|
+
return B(t.tag, p(p({ key: e }, ut(t, r, i)), n), (lt(t, r).children || []).map(function(o, c) {
|
|
468
|
+
return me(o, "".concat(e, "-").concat(t.tag, "-").concat(c), r, void 0, i);
|
|
469
|
+
}));
|
|
470
|
+
}
|
|
471
|
+
function ut(t, e, r) {
|
|
472
|
+
var n = p({}, t.attrs);
|
|
473
|
+
r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1), t.tag === "mask" && n.id && (n.id = n.id + e.idSuffix), Object.entries(n).forEach(function(o) {
|
|
474
|
+
var c = o[0], s = o[1];
|
|
475
|
+
c === "mask" && typeof s == "string" && (n[c] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
476
|
+
});
|
|
477
|
+
var i = e.defIds;
|
|
478
|
+
return !i || i.length === 0 || (t.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + e.idSuffix), Object.entries(n).forEach(function(o) {
|
|
479
|
+
var c = o[0], s = o[1];
|
|
480
|
+
typeof s == "string" && (n[c] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
481
|
+
})), n;
|
|
482
|
+
}
|
|
483
|
+
function lt(t, e) {
|
|
484
|
+
var r, n = e.defIds;
|
|
485
|
+
return !n || n.length === 0 ? t : t.tag === "defs" && (!((r = t.children) === null || r === void 0) && r.length) ? p(p({}, t), { children: t.children.map(function(i) {
|
|
486
|
+
return typeof i.attrs.id == "string" && n && n.indexOf(i.attrs.id) > -1 ? p(p({}, i), { attrs: p(p({}, i.attrs), { id: i.attrs.id + e.idSuffix }) }) : i;
|
|
487
|
+
}) }) : t;
|
|
488
|
+
}
|
|
489
|
+
function pt() {
|
|
490
|
+
return Math.random().toString(36).substring(2, 8);
|
|
491
|
+
}
|
|
492
|
+
V.displayName = "UniverIcon";
|
|
493
|
+
var ft = { 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" } }] }, ve = q(function(t, e) {
|
|
494
|
+
return B(V, Object.assign({}, t, {
|
|
495
|
+
id: "divider-single",
|
|
496
|
+
ref: e,
|
|
497
|
+
icon: ft
|
|
498
|
+
}));
|
|
499
|
+
});
|
|
500
|
+
ve.displayName = "DividerSingle";
|
|
501
|
+
var ht = { 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" } }] }, ge = q(function(t, e) {
|
|
502
|
+
return B(V, Object.assign({}, t, {
|
|
503
|
+
id: "text-single",
|
|
504
|
+
ref: e,
|
|
505
|
+
icon: ht
|
|
506
|
+
}));
|
|
507
|
+
});
|
|
508
|
+
ge.displayName = "TextSingle";
|
|
509
|
+
var mt = Object.getOwnPropertyDescriptor, vt = (t, e, r, n) => {
|
|
510
|
+
for (var i = n > 1 ? void 0 : n ? mt(e, r) : e, o = t.length - 1, c; o >= 0; o--)
|
|
511
|
+
(c = t[o]) && (i = c(i) || i);
|
|
512
|
+
return i;
|
|
513
|
+
}, A = (t, e) => (r, n) => e(r, n, t);
|
|
514
|
+
let $ = class extends z {
|
|
515
|
+
constructor(t, e, r) {
|
|
516
|
+
super(), this._commandService = t, this._docQuickInsertPopupService = e, this._componentManager = r, this._initCommands(), this._initComponents(), this._initMenus();
|
|
517
|
+
}
|
|
518
|
+
_initCommands() {
|
|
519
|
+
[
|
|
520
|
+
ce,
|
|
521
|
+
ue,
|
|
522
|
+
b
|
|
523
|
+
].forEach((t) => {
|
|
524
|
+
this.disposeWithMe(this._commandService.registerCommand(t));
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
_initComponents() {
|
|
528
|
+
this.disposeWithMe(this._componentManager.register(D.componentKey, D)), this.disposeWithMe(this._componentManager.register(k.componentKey, k)), this.disposeWithMe(this._componentManager.register("DividerSingle", ve)), this.disposeWithMe(this._componentManager.register("TextSingle", ge)), [
|
|
529
|
+
{
|
|
530
|
+
keyword: "/",
|
|
531
|
+
menus$: Je(ot),
|
|
532
|
+
// only show when the cursor is at the beginning of a line
|
|
533
|
+
preconditions: (e) => {
|
|
534
|
+
var r;
|
|
535
|
+
return ((r = e.range.startNodePosition) == null ? void 0 : r.glyph) === 0;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
].forEach((e) => {
|
|
539
|
+
this.disposeWithMe(this._docQuickInsertPopupService.registerPopup(e));
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
_initMenus() {
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
$ = vt([
|
|
546
|
+
A(0, M),
|
|
547
|
+
A(1, v(g)),
|
|
548
|
+
A(2, v(oe))
|
|
549
|
+
], $);
|
|
550
|
+
var gt = Object.defineProperty, _t = Object.getOwnPropertyDescriptor, Ct = (t, e, r) => e in t ? gt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Ot = (t, e, r, n) => {
|
|
551
|
+
for (var i = n > 1 ? void 0 : n ? _t(e, r) : e, o = t.length - 1, c; o >= 0; o--)
|
|
552
|
+
(c = t[o]) && (i = c(i) || i);
|
|
553
|
+
return i;
|
|
554
|
+
}, St = (t, e) => (r, n) => e(r, n, t), _e = (t, e, r) => Ct(t, typeof e != "symbol" ? e + "" : e, r);
|
|
555
|
+
const It = "DOC_QUICK_INSERT_UI_PLUGIN";
|
|
556
|
+
let E = class extends Ne {
|
|
557
|
+
constructor(t) {
|
|
558
|
+
super(), this._injector = t;
|
|
559
|
+
}
|
|
560
|
+
onStarting() {
|
|
561
|
+
[
|
|
562
|
+
[$],
|
|
563
|
+
[N],
|
|
564
|
+
[g]
|
|
565
|
+
].forEach((e) => this._injector.add(e)), this._injector.get($);
|
|
566
|
+
}
|
|
567
|
+
onRendered() {
|
|
568
|
+
this._injector.get(N), this._injector.get(g);
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
_e(E, "type", ie.UNIVER_DOC);
|
|
572
|
+
_e(E, "pluginName", It);
|
|
573
|
+
E = Ot([
|
|
574
|
+
ke(Te, Ee, $e, He),
|
|
575
|
+
St(0, v(De))
|
|
576
|
+
], E);
|
|
577
|
+
export {
|
|
578
|
+
g as DocQuickInsertPopupService,
|
|
579
|
+
N as DocQuickInsertTriggerController,
|
|
580
|
+
$ as DocQuickInsertUIController,
|
|
581
|
+
E as UniverDocsQuickInsertUIPlugin
|
|
582
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
docQuickInsert: {
|
|
3
|
+
menu: {
|
|
4
|
+
numberedList: "Numbered List",
|
|
5
|
+
bulletedList: "Bulleted List",
|
|
6
|
+
divider: "Divider",
|
|
7
|
+
text: "Text"
|
|
8
|
+
},
|
|
9
|
+
group: {
|
|
10
|
+
basics: "Basics"
|
|
11
|
+
},
|
|
12
|
+
placeholder: "No results found",
|
|
13
|
+
keywordInputPlaceholder: "Enter keywords"
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
e as default
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
docQuickInsert: {
|
|
3
|
+
menu: {
|
|
4
|
+
numberedList: "لیست شمارهدار",
|
|
5
|
+
bulletedList: "لیست نقطهدار",
|
|
6
|
+
divider: "خط تقسیم",
|
|
7
|
+
text: "متن"
|
|
8
|
+
},
|
|
9
|
+
group: {
|
|
10
|
+
basics: "بنیادی"
|
|
11
|
+
},
|
|
12
|
+
placeholder: "هیچ نتیجهای یافت نشد",
|
|
13
|
+
keywordInputPlaceholder: "وارد کلمات کلیدی"
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
e as default
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
docQuickInsert: {
|
|
3
|
+
menu: {
|
|
4
|
+
numberedList: "Liste numérotée",
|
|
5
|
+
bulletedList: "Liste à puces",
|
|
6
|
+
divider: "Ligne de séparation",
|
|
7
|
+
text: "Texte"
|
|
8
|
+
},
|
|
9
|
+
group: {
|
|
10
|
+
basics: "Basiques"
|
|
11
|
+
},
|
|
12
|
+
placeholder: "Aucun résultat",
|
|
13
|
+
keywordInputPlaceholder: "Entrez des mots clés"
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
e as default
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
docQuickInsert: {
|
|
3
|
+
menu: {
|
|
4
|
+
numberedList: "Список с нумерацией",
|
|
5
|
+
bulletedList: "Маркированный список",
|
|
6
|
+
divider: "Разделительная линия",
|
|
7
|
+
text: "Текст"
|
|
8
|
+
},
|
|
9
|
+
group: {
|
|
10
|
+
basics: "Основные"
|
|
11
|
+
},
|
|
12
|
+
placeholder: "Нет результатов",
|
|
13
|
+
keywordInputPlaceholder: "Введите ключевые слова"
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
e as default
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
docQuickInsert: {
|
|
3
|
+
menu: {
|
|
4
|
+
numberedList: "Danh sách được đánh số",
|
|
5
|
+
bulletedList: "Danh sách không được đánh số",
|
|
6
|
+
divider: "Đường phân cách",
|
|
7
|
+
text: "Văn bản"
|
|
8
|
+
},
|
|
9
|
+
group: {
|
|
10
|
+
basics: "Cơ bản"
|
|
11
|
+
},
|
|
12
|
+
placeholder: "Không có kết quả",
|
|
13
|
+
keywordInputPlaceholder: "Nhập từ khóa"
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
e as default
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
docQuickInsert: {
|
|
3
|
+
menu: {
|
|
4
|
+
numberedList: "有序列表",
|
|
5
|
+
bulletedList: "无序列表",
|
|
6
|
+
divider: "分隔线",
|
|
7
|
+
text: "文本"
|
|
8
|
+
},
|
|
9
|
+
group: {
|
|
10
|
+
basics: "基础"
|
|
11
|
+
},
|
|
12
|
+
placeholder: "暂无结果",
|
|
13
|
+
keywordInputPlaceholder: "输入关键词"
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
e as default
|
|
18
|
+
};
|