@univerjs/docs-quick-insert-ui 0.16.1 → 0.17.0-insiders.20260318-d69dc16

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.
Files changed (82) hide show
  1. package/lib/cjs/index.js +33 -1
  2. package/lib/cjs/locale/ca-ES.js +1 -1
  3. package/lib/cjs/locale/en-US.js +1 -1
  4. package/lib/cjs/locale/es-ES.js +1 -1
  5. package/lib/cjs/locale/fa-IR.js +1 -1
  6. package/lib/cjs/locale/fr-FR.js +1 -1
  7. package/lib/cjs/locale/ja-JP.js +1 -1
  8. package/lib/cjs/locale/ko-KR.js +1 -1
  9. package/lib/cjs/locale/ru-RU.js +1 -1
  10. package/lib/cjs/locale/sk-SK.js +1 -1
  11. package/lib/cjs/locale/vi-VN.js +1 -1
  12. package/lib/cjs/locale/zh-CN.js +1 -1
  13. package/lib/cjs/locale/zh-TW.js +1 -1
  14. package/lib/es/index.js +33 -924
  15. package/lib/es/locale/ca-ES.js +1 -20
  16. package/lib/es/locale/en-US.js +1 -20
  17. package/lib/es/locale/es-ES.js +1 -20
  18. package/lib/es/locale/fa-IR.js +1 -20
  19. package/lib/es/locale/fr-FR.js +1 -20
  20. package/lib/es/locale/ja-JP.js +1 -20
  21. package/lib/es/locale/ko-KR.js +1 -20
  22. package/lib/es/locale/ru-RU.js +1 -20
  23. package/lib/es/locale/sk-SK.js +1 -20
  24. package/lib/es/locale/vi-VN.js +1 -20
  25. package/lib/es/locale/zh-CN.js +1 -20
  26. package/lib/es/locale/zh-TW.js +1 -20
  27. package/lib/index.css +292 -1
  28. package/lib/index.js +33 -924
  29. package/lib/locale/ca-ES.js +1 -20
  30. package/lib/locale/en-US.js +1 -20
  31. package/lib/locale/es-ES.js +1 -20
  32. package/lib/locale/fa-IR.js +1 -20
  33. package/lib/locale/fr-FR.js +1 -20
  34. package/lib/locale/ja-JP.js +1 -20
  35. package/lib/locale/ko-KR.js +1 -20
  36. package/lib/locale/ru-RU.js +1 -20
  37. package/lib/locale/sk-SK.js +1 -20
  38. package/lib/locale/vi-VN.js +1 -20
  39. package/lib/locale/zh-CN.js +1 -20
  40. package/lib/locale/zh-TW.js +1 -20
  41. package/lib/types/commands/commands/doc-quick-insert.command.d.ts +16 -1
  42. package/lib/types/commands/operations/quick-insert-popup.operation.d.ts +17 -2
  43. package/lib/types/config/config.d.ts +22 -0
  44. package/lib/types/controllers/doc-quick-insert-trigger.controller.d.ts +15 -0
  45. package/lib/types/controllers/doc-quick-insert-ui.controller.d.ts +15 -0
  46. package/lib/types/index.d.ts +1 -1
  47. package/lib/types/locale/ca-ES.d.ts +16 -1
  48. package/lib/types/locale/es-ES.d.ts +16 -1
  49. package/lib/types/locale/fa-IR.d.ts +16 -1
  50. package/lib/types/locale/fr-FR.d.ts +16 -1
  51. package/lib/types/locale/ja-JP.d.ts +16 -1
  52. package/lib/types/locale/ko-KR.d.ts +16 -1
  53. package/lib/types/locale/ru-RU.d.ts +16 -1
  54. package/lib/types/locale/sk-SK.d.ts +16 -1
  55. package/lib/types/locale/vi-VN.d.ts +16 -1
  56. package/lib/types/locale/zh-CN.d.ts +16 -1
  57. package/lib/types/locale/zh-TW.d.ts +16 -1
  58. package/lib/types/menu/built-in-menus.d.ts +28 -0
  59. package/lib/types/{controllers → menu}/doc-quick-insert-menu.controller.d.ts +19 -3
  60. package/lib/types/plugin.d.ts +18 -1
  61. package/lib/types/services/doc-quick-insert-popup.service.d.ts +24 -3
  62. package/lib/types/views/KeywordInputPlaceholder.d.ts +14 -1
  63. package/lib/types/views/QuickInsertMenu.d.ts +30 -0
  64. package/lib/umd/index.js +33 -1
  65. package/lib/umd/locale/ca-ES.js +1 -1
  66. package/lib/umd/locale/en-US.js +1 -1
  67. package/lib/umd/locale/es-ES.js +1 -1
  68. package/lib/umd/locale/fa-IR.js +1 -1
  69. package/lib/umd/locale/fr-FR.js +1 -1
  70. package/lib/umd/locale/ja-JP.js +1 -1
  71. package/lib/umd/locale/ko-KR.js +1 -1
  72. package/lib/umd/locale/ru-RU.js +1 -1
  73. package/lib/umd/locale/sk-SK.js +1 -1
  74. package/lib/umd/locale/vi-VN.js +1 -1
  75. package/lib/umd/locale/zh-CN.js +1 -1
  76. package/lib/umd/locale/zh-TW.js +1 -1
  77. package/package.json +17 -16
  78. package/LICENSE +0 -176
  79. package/lib/types/controllers/built-in-menus.d.ts +0 -13
  80. package/lib/types/controllers/config.schema.d.ts +0 -7
  81. /package/lib/types/{views/menu → menu}/const.d.ts +0 -0
  82. /package/lib/types/{views/menu → menu}/index.d.ts +0 -0
package/lib/es/index.js CHANGED
@@ -1,924 +1,33 @@
1
- var Le = Object.defineProperty;
2
- var Ae = (t, e, n) => e in t ? Le(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var C = (t, e, n) => Ae(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { CommandType as k, ICommandService as Q, RANGE_DIRECTION as je, LocaleService as ue, generateRandomId as Be, DisposableCollection as We, toDisposable as qe, Direction as B, Inject as f, IUniverInstanceService as pe, Disposable as Y, UniverInstanceType as H, DeleteDirection as Ze, DependentOn as Ve, Injector as Fe, IConfigService as Ge, Plugin as ze, merge as Ye } from "@univerjs/core";
5
- import { DocSelectionManagerService as le, DocSkeletonManagerService as Je, RichTextEditingMutation as Xe } from "@univerjs/docs";
6
- import { CutContentCommand as et, DocCanvasPopManagerService as Se, DocEventManagerService as Pe, 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";
7
- import { useDependency as _, KeyCode as O, ComponentManager as ye, IShortcutService as xe, useObservable as T, ILayoutService as ut, useEvent as pt, UniverUIPlugin as lt } from "@univerjs/ui";
8
- import { IRenderManagerService as he } from "@univerjs/engine-render";
9
- import { map as Me, distinctUntilChanged as ht, tap as K, combineLatest as fe, BehaviorSubject as A, of as ft } from "rxjs";
10
- import { jsx as h, jsxs as ve } from "react/jsx-runtime";
11
- import { Menu as gt, clsx as re, scrollbarClassName as mt, MenuItemGroup as vt, MenuItem as Ct, Tooltip as _t, borderClassName as It } from "@univerjs/design";
12
- import { useMemo as se, useState as Ce, useRef as j, useEffect as L, createElement as J, forwardRef as ge } from "react";
13
- import { InsertDocImageCommand as St, UniverDocsDrawingUIPlugin as Pt } from "@univerjs/docs-drawing-ui";
14
- import { UniverDocsDrawingPlugin as yt } from "@univerjs/docs-drawing";
15
- import { UniverDrawingPlugin as xt } from "@univerjs/drawing";
16
- import { UniverDrawingUIPlugin as Mt } from "@univerjs/drawing-ui";
17
- const Oe = {
18
- id: "doc.command.delete-search-key",
19
- type: k.COMMAND,
20
- handler: (t, e) => {
21
- const n = t.get(Q), { start: i, end: r } = e;
22
- return n.syncExecuteCommand(et.id, {
23
- segmentId: "",
24
- textRanges: [{
25
- startOffset: i,
26
- endOffset: i,
27
- collapsed: !0
28
- }],
29
- selections: [{
30
- startOffset: i,
31
- endOffset: r,
32
- collapsed: !1,
33
- direction: je.FORWARD
34
- }]
35
- });
36
- }
37
- }, Ot = "docs.quick.insert.keyword-input-placeholder", W = () => {
38
- const t = _(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
- };
41
- W.componentKey = Ot;
42
- const bt = "docs.quick.insert.placeholder", q = () => {
43
- const t = _(ue);
44
- return /* @__PURE__ */ h(
45
- "div",
46
- {
47
- className: "univer-flex univer-h-full univer-items-center univer-justify-center univer-rounded-lg univer-bg-white univer-px-12 univer-py-6 univer-text-gray-400 univer-shadow-lg",
48
- children: /* @__PURE__ */ h("span", { children: t.t("docQuickInsert.placeholder") })
49
- }
50
- );
51
- };
52
- q.componentKey = bt;
53
- function oe(t, e) {
54
- return t.map((n) => ({ ...n })).filter((n) => {
55
- if ("children" in n)
56
- return n.children = oe(n.children, e), n.children.length > 0;
57
- const i = n.keywords;
58
- return i ? i.some((r) => r.includes(e)) : n.title.toLowerCase().includes(e);
59
- });
60
- }
61
- function be(t, e) {
62
- return t.map((n) => {
63
- const i = { ...n };
64
- return "children" in i && (i.children = be(i.children, e)), i.title = e.t(i.title), "keywords" in i && (i.keywords = i.keywords.concat(i.title).map((r) => r.toLowerCase())), i;
65
- });
66
- }
67
- const wt = [O.ARROW_UP, O.ARROW_DOWN, O.ENTER], Z = () => {
68
- const t = _(ue), e = _(I), n = _(ye), i = _(xe), r = _(Q), s = se(() => Be(), []), [c, l] = Ce(0), o = j(null), a = j(0);
69
- a.current = 0;
70
- const d = T(e.filterKeyword$, ""), u = T(e.editPopup$), g = T(u == null ? void 0 : u.popup.menus$, []), S = se(() => be(g, t), [g]), [b, P] = Ce(() => oe(S, d.toLowerCase()));
71
- L(() => {
72
- const m = requestIdleCallback(() => {
73
- P(oe(S, d.toLowerCase()));
74
- });
75
- return () => {
76
- cancelIdleCallback(m);
77
- };
78
- }, [S, d]);
79
- const y = (m) => {
80
- e.emitMenuSelected(m), r.executeCommand(U.id);
81
- };
82
- L(() => {
83
- const m = new We();
84
- i.getAllShortcuts().filter((p) => p.binding && wt.includes(p.binding)).forEach((p) => {
85
- const M = p.preconditions;
86
- p.preconditions = () => !1, m.add(qe(() => {
87
- p.preconditions = M;
88
- }));
89
- });
90
- const x = {
91
- id: `quick.insert.popup.enter.${s}`,
92
- type: k.OPERATION,
93
- handler: () => {
94
- const p = o.current;
95
- p && y(p);
96
- }
97
- }, D = {
98
- id: `quick.insert.popup.move.cursor.up.${s}`,
99
- type: k.OPERATION,
100
- handler: () => {
101
- l((p) => {
102
- const M = p - 1;
103
- return M >= 0 ? M : a.current - 1;
104
- });
105
- }
106
- }, R = {
107
- id: `quick.insert.popup.move.cursor.down.${s}`,
108
- type: k.OPERATION,
109
- handler: () => {
110
- l((p) => {
111
- const M = p + 1;
112
- return M <= a.current - 1 ? M : 0;
113
- });
114
- }
115
- };
116
- return m.add(r.registerCommand(D)), m.add(r.registerCommand(R)), m.add(r.registerCommand(x)), m.add(i.registerShortcut({
117
- priority: 1e3,
118
- id: D.id,
119
- binding: O.ARROW_UP,
120
- preconditions: () => !0,
121
- staticParameters: {
122
- direction: B.UP
123
- }
124
- })), m.add(i.registerShortcut({
125
- priority: 1e3,
126
- id: R.id,
127
- binding: O.ARROW_DOWN,
128
- preconditions: () => !0,
129
- staticParameters: {
130
- direction: B.DOWN
131
- }
132
- })), m.add(i.registerShortcut({
133
- priority: 1e3,
134
- id: x.id,
135
- binding: O.ENTER,
136
- preconditions: () => !0
137
- })), () => {
138
- m.dispose();
139
- };
140
- }, []), L(() => {
141
- l(0);
142
- }, [b]);
143
- const w = j(/* @__PURE__ */ new Map());
144
- L(() => () => {
145
- w.current.clear();
146
- }, []);
147
- function $(m) {
148
- return m.map((v) => {
149
- const ee = v.icon, x = ee ? n.get(ee) : null;
150
- if ("children" in v)
151
- return /* @__PURE__ */ h(
152
- vt,
153
- {
154
- title: /* @__PURE__ */ ve(
155
- "div",
156
- {
157
- className: "univer-mb-2 univer-flex univer-items-center univer-text-xs univer-text-gray-400",
158
- children: [
159
- x && /* @__PURE__ */ h("span", { className: "univer-mr-2 univer-inline-flex univer-text-base", children: /* @__PURE__ */ h(x, {}) }),
160
- /* @__PURE__ */ h("span", { children: v.title })
161
- ]
162
- }
163
- ),
164
- children: $(v.children)
165
- },
166
- v.id
167
- );
168
- const D = a.current, R = c === D;
169
- if (R) {
170
- o.current = v;
171
- const p = w.current.get(v.id);
172
- p == null || p.scrollIntoView({
173
- block: "nearest"
174
- });
175
- }
176
- return a.current++, /* @__PURE__ */ h(
177
- Ct,
178
- {
179
- ref: (p) => {
180
- p && w.current.set(v.id, p);
181
- },
182
- onMouseEnter: () => l(D),
183
- onMouseLeave: () => l(Number.NaN),
184
- className: re("univer-w-[calc(220px-var(--padding-base)*2)] univer-text-sm", {
185
- "hover:univer-bg-transparent": !R,
186
- "univer-bg-gray-100 dark:!univer-bg-gray-500": R
187
- }),
188
- onClick: () => {
189
- y(v);
190
- },
191
- children: /* @__PURE__ */ ve(
192
- "div",
193
- {
194
- className: "univer-flex univer-w-full univer-items-center univer-px-1",
195
- children: [
196
- x && /* @__PURE__ */ h("span", { className: "univer-mr-2 univer-inline-flex univer-text-base", children: /* @__PURE__ */ h(x, {}) }),
197
- /* @__PURE__ */ h(_t, { showIfEllipsis: !0, title: v.title, placement: "right", children: /* @__PURE__ */ h("span", { className: "univer-truncate", children: v.title }) })
198
- ]
199
- }
200
- )
201
- },
202
- v.id
203
- );
204
- });
205
- }
206
- const Ke = b.length > 0, me = (u == null ? void 0 : u.popup.Placeholder) || n.get(q.componentKey);
207
- return /* @__PURE__ */ h("div", { className: "univer-mt-2", children: Ke ? /* @__PURE__ */ h(
208
- gt,
209
- {
210
- wrapperClass: re("univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto univer-overflow-x-hidden", mt),
211
- children: $(b)
212
- }
213
- ) : me && /* @__PURE__ */ h(me, {}) });
214
- };
215
- Z.componentKey = "docs.quick.insert.popup";
216
- var Rt = Object.getOwnPropertyDescriptor, kt = (t, e, n, i) => {
217
- for (var r = i > 1 ? void 0 : i ? Rt(e, n) : e, s = t.length - 1, c; s >= 0; s--)
218
- (c = t[s]) && (r = c(r) || r);
219
- return r;
220
- }, N = (t, e) => (n, i) => e(n, i, t);
221
- const _e = {
222
- dispose: () => {
223
- }
224
- };
225
- let I = class extends Y {
226
- constructor(e, n, i, r, s) {
227
- super();
228
- C(this, "_popups", /* @__PURE__ */ new Set());
229
- C(this, "_editPopup$", new A(void 0));
230
- C(this, "editPopup$", this._editPopup$.asObservable());
231
- C(this, "_isComposing$", new A(!1));
232
- C(this, "isComposing$", this._isComposing$.asObservable());
233
- C(this, "_inputOffset$", new A({ start: 0, end: 0 }));
234
- C(this, "inputOffset$", this._inputOffset$.asObservable());
235
- C(this, "filterKeyword$");
236
- C(this, "_menuSelectedCallbacks", /* @__PURE__ */ new Set());
237
- C(this, "_inputPlaceholderRenderRoot", null);
238
- this._docCanvasPopupManagerService = e, this._univerInstanceService = n, this._commandService = i, this._renderManagerService = r, this._docSelectionManagerService = s, this.disposeWithMe(this._editPopup$);
239
- const c = (o, a) => {
240
- var d, u;
241
- return (u = (d = this._univerInstanceService.getCurrentUnitOfType(H.UNIVER_DOC)) == null ? void 0 : d.getBody()) == null ? void 0 : u.dataStream.slice(o, a);
242
- };
243
- let l = "";
244
- this.filterKeyword$ = this._inputOffset$.pipe(
245
- Me((o) => {
246
- var d;
247
- const a = c(o.start, o.end);
248
- return (d = a == null ? void 0 : a.slice(1)) != null ? d : "";
249
- }),
250
- ht(),
251
- K((o) => {
252
- l = o;
253
- })
254
- ), this.disposeWithMe(fe([
255
- this.filterKeyword$.pipe(K((o) => {
256
- var a, d, u;
257
- o.length > 0 ? (d = (a = this._inputPlaceholderRenderRoot) == null ? void 0 : a.unmount) == null || d.dispose() : (u = this._inputPlaceholderRenderRoot) == null || u.mount();
258
- })),
259
- this.isComposing$.pipe(K((o) => {
260
- var a, d, u;
261
- o ? (d = (a = this._inputPlaceholderRenderRoot) == null ? void 0 : a.unmount) == null || d.dispose() : l.length <= 0 && ((u = this._inputPlaceholderRenderRoot) == null || u.mount());
262
- })),
263
- this.editPopup$.pipe(K((o) => {
264
- var a, d;
265
- o || ((d = (a = this._inputPlaceholderRenderRoot) == null ? void 0 : a.unmount) == null || d.dispose(), this._inputPlaceholderRenderRoot = null);
266
- }))
267
- ]).subscribe());
268
- }
269
- get popups() {
270
- return Array.from(this._popups);
271
- }
272
- get editPopup() {
273
- return this._editPopup$.value;
274
- }
275
- get isComposing() {
276
- return this._isComposing$.value;
277
- }
278
- setIsComposing(e) {
279
- this._isComposing$.next(e);
280
- }
281
- get inputOffset() {
282
- return this._inputOffset$.value;
283
- }
284
- setInputOffset(e) {
285
- this._inputOffset$.next(e);
286
- }
287
- getDocEventManagerService(e) {
288
- var n;
289
- return (n = this._renderManagerService.getRenderById(e)) == null ? void 0 : n.with(Pe);
290
- }
291
- resolvePopup(e) {
292
- return Array.from(this._popups).find((n) => n.keyword === e);
293
- }
294
- registerPopup(e) {
295
- return this._popups.add(e), () => {
296
- this._popups.delete(e);
297
- };
298
- }
299
- _createInputPlaceholderRenderRoot(e) {
300
- return {
301
- isMounted: !1,
302
- mount() {
303
- if (this.isMounted)
304
- return;
305
- this.isMounted = !0;
306
- const i = e();
307
- this.unmount = {
308
- dispose: () => {
309
- i.dispose(), this.isMounted = !1;
310
- }
311
- };
312
- }
313
- };
314
- }
315
- showPopup(e) {
316
- var d, u;
317
- const { popup: n, index: i, unitId: r } = e;
318
- this.closePopup();
319
- const s = this._univerInstanceService.getUnit(r), c = (u = (d = s == null ? void 0 : s.getBody()) == null ? void 0 : d.paragraphs) == null ? void 0 : u.find((g) => g.startIndex > i);
320
- if (!c)
321
- return;
322
- const l = this.getDocEventManagerService(r), o = l == null ? void 0 : l.findParagraphBoundByIndex(c.startIndex);
323
- if (!o)
324
- return;
325
- this._inputPlaceholderRenderRoot = this._createInputPlaceholderRenderRoot(() => {
326
- var $;
327
- const g = ($ = this._renderManagerService.getRenderById(r)) == null ? void 0 : $.with(Je), S = this._docSelectionManagerService.getActiveTextRange();
328
- if (!g || !S)
329
- return _e;
330
- const P = g.getSkeleton().findNodeByCharIndex(S.startOffset, S.segmentId, S.segmentPage);
331
- if (!((P == null ? void 0 : P.content) === "\r"))
332
- return _e;
333
- const w = this._docCanvasPopupManagerService.attachPopupToRange(
334
- { startOffset: i + 1, endOffset: i + 1, collapsed: !1 },
335
- {
336
- componentKey: W.componentKey,
337
- onClickOutside: () => {
338
- w.dispose();
339
- },
340
- direction: "horizontal"
341
- },
342
- r
343
- );
344
- return w;
345
- }), this._inputPlaceholderRenderRoot.mount();
346
- const a = this._docCanvasPopupManagerService.attachPopupToRect(
347
- o.firstLine,
348
- {
349
- componentKey: Z.componentKey,
350
- onClickOutside: () => {
351
- this.closePopup();
352
- },
353
- direction: "bottom"
354
- },
355
- r
356
- );
357
- this._editPopup$.next({ disposable: a, popup: n, anchor: i, unitId: r });
358
- }
359
- closePopup() {
360
- this.editPopup && (this.editPopup.disposable.dispose(), this._editPopup$.next(null));
361
- }
362
- onMenuSelected(e) {
363
- return this._menuSelectedCallbacks.add(e), () => {
364
- this._menuSelectedCallbacks.delete(e);
365
- };
366
- }
367
- emitMenuSelected(e) {
368
- const { start: n, end: i } = this.inputOffset;
369
- this._commandService.syncExecuteCommand(Oe.id, {
370
- start: n,
371
- end: i
372
- }), setTimeout(() => {
373
- this._menuSelectedCallbacks.forEach((r) => r(e));
374
- }, 0);
375
- }
376
- };
377
- I = kt([
378
- N(0, f(Se)),
379
- N(1, f(pe)),
380
- N(2, f(Q)),
381
- N(3, f(he)),
382
- N(4, f(le))
383
- ], I);
384
- const we = {
385
- type: k.OPERATION,
386
- id: "doc.operation.show-quick-insert-popup",
387
- handler(t, e) {
388
- const n = t.get(I);
389
- return e ? (n.showPopup(e), !0) : !1;
390
- }
391
- }, U = {
392
- type: k.OPERATION,
393
- id: "doc.operation.close-quick-insert-popup",
394
- handler(t) {
395
- return t.get(I).closePopup(), !0;
396
- }
397
- }, Re = {
398
- id: "quick-insert.text.menu",
399
- title: "docQuickInsert.menu.text",
400
- icon: "TextIcon",
401
- keywords: ["text"]
402
- }, ke = {
403
- id: tt.id,
404
- title: "docQuickInsert.menu.numberedList",
405
- icon: "OrderIcon",
406
- keywords: ["numbered", "list", "ordered"]
407
- }, $e = {
408
- id: nt.id,
409
- title: "docQuickInsert.menu.bulletedList",
410
- icon: "UnorderIcon",
411
- keywords: ["bulleted", "list", "unordered"]
412
- }, De = {
413
- id: it.id,
414
- title: "docQuickInsert.menu.divider",
415
- icon: "DividerIcon",
416
- keywords: ["divider", "line", "separate"]
417
- }, Ne = {
418
- id: rt.id,
419
- title: "docQuickInsert.menu.table",
420
- icon: "GridIcon",
421
- keywords: ["table", "grid", "spreadsheet"]
422
- }, Ee = {
423
- id: St.id,
424
- title: "docQuickInsert.menu.image",
425
- icon: "AdditionAndSubtractionIcon",
426
- keywords: ["image", "picture", "photo"]
427
- }, $t = [
428
- {
429
- title: "docQuickInsert.group.basics",
430
- id: "quick.insert.group.basic",
431
- children: [
432
- Re,
433
- ke,
434
- $e,
435
- De,
436
- Ne,
437
- Ee
438
- ]
439
- }
440
- ], Dt = /* @__PURE__ */ new Set([
441
- ke.id,
442
- $e.id,
443
- De.id,
444
- Ne.id,
445
- Ee.id
446
- ]);
447
- var Nt = Object.getOwnPropertyDescriptor, Et = (t, e, n, i) => {
448
- for (var r = i > 1 ? void 0 : i ? Nt(e, n) : e, s = t.length - 1, c; s >= 0; s--)
449
- (c = t[s]) && (r = c(r) || r);
450
- return r;
451
- }, E = (t, e) => (n, i) => e(n, i, t);
452
- let V = class extends Y {
453
- constructor(t, e, n, i, r) {
454
- super(), this._commandService = t, this._textSelectionManagerService = e, this._docQuickInsertPopupService = n, this._shortcutService = i, this._univerInstanceService = r, this.disposeWithMe(this._shortcutService.registerShortcut({
455
- id: U.id,
456
- binding: O.ESC,
457
- preconditions: () => !!this._docQuickInsertPopupService.editPopup,
458
- priority: 1e3
459
- })), this._initTrigger(), this._initMenuHandler();
460
- }
461
- // eslint-disable-next-line max-lines-per-function
462
- _initTrigger() {
463
- this.disposeWithMe(
464
- // eslint-disable-next-line complexity, max-lines-per-function
465
- this._commandService.onCommandExecuted((t) => {
466
- var s, c, l;
467
- const { _docQuickInsertPopupService: e, _textSelectionManagerService: n, _commandService: i } = this, r = this._univerInstanceService.getCurrentUnitOfType(H.UNIVER_DOC);
468
- if (!(r != null && r.getDisabled())) {
469
- if (t.id === st.id) {
470
- const o = t.params;
471
- if (e.editPopup) {
472
- e.setInputOffset({
473
- start: e.inputOffset.start,
474
- end: o.range.endOffset + 1
475
- });
476
- return;
477
- }
478
- const a = n.getActiveTextRange();
479
- if (!a)
480
- return;
481
- const d = e.resolvePopup(o.body.dataStream);
482
- if (!d || !(d.preconditions ? d.preconditions(o) : !0))
483
- return;
484
- e.setInputOffset({ start: a.startOffset - 1, end: a.startOffset }), setTimeout(() => {
485
- i.executeCommand(we.id, {
486
- index: a.startOffset - 1,
487
- unitId: o.unitId,
488
- popup: d
489
- });
490
- }, 100);
491
- }
492
- if (t.id === ot.id) {
493
- const o = t.params;
494
- !e.isComposing && o.isCompositionStart && e.setIsComposing(!0), e.isComposing && o.isCompositionEnd && e.setIsComposing(!1);
495
- }
496
- if (t.id === Xe.id) {
497
- const o = t.params;
498
- if (o.isCompositionEnd) {
499
- const a = (c = (s = o.textRanges) == null ? void 0 : s[0]) == null ? void 0 : c.endOffset;
500
- a && e.setInputOffset({ start: e.inputOffset.start, end: a });
501
- }
502
- }
503
- if (t.id === ct.id) {
504
- const o = t.params;
505
- if (e.editPopup && o.direction === Ze.LEFT) {
506
- const a = (l = o.len) != null ? l : 0;
507
- e.setInputOffset({ start: e.inputOffset.start, end: o.range.endOffset - a });
508
- }
509
- }
510
- if (t.id === at.id) {
511
- const o = t.params;
512
- (o.direction === B.LEFT || o.direction === B.RIGHT) && e.editPopup && i.executeCommand(U.id);
513
- }
514
- if (t.id === dt.id) {
515
- const o = n.getActiveTextRange();
516
- if (!e.editPopup || !o)
517
- return;
518
- o.endOffset <= e.editPopup.anchor && i.executeCommand(U.id);
519
- }
520
- }
521
- })
522
- );
523
- }
524
- _initMenuHandler() {
525
- this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected((t) => {
526
- t.id !== Re.id && Dt.has(t.id) && this._commandService.executeCommand(t.id);
527
- }));
528
- }
529
- };
530
- V = Et([
531
- E(0, Q),
532
- E(1, f(le)),
533
- E(2, f(I)),
534
- E(3, f(xe)),
535
- E(4, f(pe))
536
- ], V);
537
- function X({ ref: t, ...e }) {
538
- const { icon: n, id: i, className: r, extend: s, ...c } = e, l = `univerjs-icon univerjs-icon-${i} ${r || ""}`.trim(), o = j(`_${Qt()}`);
539
- return Te(n, `${i}`, {
540
- defIds: n.defIds,
541
- idSuffix: o.current
542
- }, {
543
- ref: t,
544
- className: l,
545
- ...c
546
- }, s);
547
- }
548
- function Te(t, e, n, i, r) {
549
- return J(t.tag, {
550
- key: e,
551
- ...Tt(t, n, r),
552
- ...i
553
- }, (Ut(t, n).children || []).map((s, c) => Te(s, `${e}-${t.tag}-${c}`, n, void 0, r)));
554
- }
555
- function Tt(t, e, n) {
556
- const i = { ...t.attrs };
557
- n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1), t.tag === "mask" && i.id && (i.id = i.id + e.idSuffix), Object.entries(i).forEach(([s, c]) => {
558
- s === "mask" && typeof c == "string" && (i[s] = c.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
559
- });
560
- const { defIds: r } = e;
561
- return !r || r.length === 0 || (t.tag === "use" && i["xlink:href"] && (i["xlink:href"] = i["xlink:href"] + e.idSuffix), Object.entries(i).forEach(([s, c]) => {
562
- typeof c == "string" && (i[s] = c.replace(/url\(#(.*)\)/, `url(#$1${e.idSuffix})`));
563
- })), i;
564
- }
565
- function Ut(t, e) {
566
- var i;
567
- const { defIds: n } = e;
568
- return !n || n.length === 0 ? t : t.tag === "defs" && ((i = t.children) != null && i.length) ? {
569
- ...t,
570
- children: t.children.map((r) => typeof r.attrs.id == "string" && n && n.includes(r.attrs.id) ? {
571
- ...r,
572
- attrs: {
573
- ...r.attrs,
574
- id: r.attrs.id + e.idSuffix
575
- }
576
- } : r)
577
- } : t;
578
- }
579
- function Qt() {
580
- return Math.random().toString(36).substring(2, 8);
581
- }
582
- X.displayName = "UniverIcon";
583
- const Ht = {
584
- tag: "svg",
585
- attrs: {
586
- xmlns: "http://www.w3.org/2000/svg",
587
- fill: "none",
588
- viewBox: "0 0 16 16",
589
- width: "1em",
590
- height: "1em"
591
- },
592
- children: [
593
- {
594
- tag: "path",
595
- attrs: {
596
- fill: "currentColor",
597
- 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.13985C3.40213 3.50712 3.1044 3.80485 2.73713 3.80485H1.68453C1.31726 3.80485 1.01953 3.50712 1.01953 3.13985Z"
598
- }
599
- },
600
- {
601
- tag: "path",
602
- attrs: {
603
- fill: "currentColor",
604
- d: "M4.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.13985C7.61254 3.50712 7.31481 3.80485 6.94754 3.80485H4.84234C4.47507 3.80485 4.17734 3.50712 4.17734 3.13985Z"
605
- }
606
- },
607
- {
608
- tag: "path",
609
- attrs: {
610
- fill: "currentColor",
611
- d: "M8.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.13985C11.823 3.50712 11.5252 3.80485 11.158 3.80485H9.05275C8.68548 3.80485 8.38775 3.50712 8.38775 3.13985Z"
612
- }
613
- },
614
- {
615
- tag: "path",
616
- attrs: {
617
- fill: "currentColor",
618
- d: "M12.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.13985C14.9808 3.50712 14.683 3.80485 14.3158 3.80485H13.2632C12.8959 3.80485 12.5982 3.50712 12.5982 3.13985Z"
619
- }
620
- },
621
- {
622
- tag: "path",
623
- attrs: {
624
- fill: "currentColor",
625
- d: "M1.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.99972C14.9808 8.36699 14.683 8.66472 14.3158 8.66472H1.68453C1.31726 8.66472 1.01953 8.36699 1.01953 7.99972Z"
626
- }
627
- },
628
- {
629
- tag: "path",
630
- attrs: {
631
- fill: "currentColor",
632
- d: "M1.68453 12.1951C1.31726 12.1951 1.01953 12.4928 1.01953 12.8601C1.01953 13.2273 1.31726 13.5251 1.68453 13.5251H2.73713C3.1044 13.5251 3.40213 13.2273 3.40213 12.8601C3.40213 12.4928 3.1044 12.1951 2.73713 12.1951H1.68453Z"
633
- }
634
- },
635
- {
636
- tag: "path",
637
- attrs: {
638
- fill: "currentColor",
639
- d: "M4.84234 12.1951C4.47507 12.1951 4.17734 12.4928 4.17734 12.8601C4.17734 13.2273 4.47507 13.5251 4.84234 13.5251H6.94754C7.31481 13.5251 7.61254 13.2273 7.61254 12.8601C7.61254 12.4928 7.31481 12.1951 6.94754 12.1951H4.84234Z"
640
- }
641
- },
642
- {
643
- tag: "path",
644
- attrs: {
645
- fill: "currentColor",
646
- d: "M9.05275 12.1951C8.68548 12.1951 8.38775 12.4928 8.38775 12.8601C8.38775 13.2273 8.68548 13.5251 9.05275 13.5251H11.158C11.5252 13.5251 11.823 13.2273 11.823 12.8601C11.823 12.4928 11.5252 12.1951 11.158 12.1951H9.05275Z"
647
- }
648
- },
649
- {
650
- tag: "path",
651
- attrs: {
652
- fill: "currentColor",
653
- d: "M13.2632 12.1951C12.8959 12.1951 12.5982 12.4928 12.5982 12.8601C12.5982 13.2273 12.8959 13.5251 13.2632 13.5251H14.3158C14.683 13.5251 14.9808 13.2273 14.9808 12.8601C14.9808 12.4928 14.683 12.1951 14.3158 12.1951H13.2632Z"
654
- }
655
- }
656
- ]
657
- }, ce = ge(function(e, n) {
658
- return J(X, Object.assign({}, e, {
659
- id: "divider-icon",
660
- ref: n,
661
- icon: Ht
662
- }));
663
- });
664
- ce.displayName = "DividerIcon";
665
- const Kt = {
666
- tag: "svg",
667
- attrs: {
668
- xmlns: "http://www.w3.org/2000/svg",
669
- fill: "none",
670
- viewBox: "0 0 16 16",
671
- width: "1em",
672
- height: "1em"
673
- },
674
- children: [{
675
- tag: "path",
676
- attrs: {
677
- fill: "currentColor",
678
- d: "M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"
679
- }
680
- }]
681
- }, Ue = ge(function(e, n) {
682
- return J(X, Object.assign({}, e, {
683
- id: "increase-icon",
684
- ref: n,
685
- icon: Kt
686
- }));
687
- });
688
- Ue.displayName = "IncreaseIcon";
689
- const Lt = {
690
- tag: "svg",
691
- attrs: {
692
- xmlns: "http://www.w3.org/2000/svg",
693
- fill: "none",
694
- viewBox: "0 0 17 16",
695
- width: "1em",
696
- height: "1em"
697
- },
698
- children: [{
699
- tag: "g",
700
- attrs: {
701
- fill: "currentColor",
702
- clipPath: "url(#text-icon_clip0_1293_26)"
703
- },
704
- children: [{
705
- tag: "path",
706
- attrs: { d: "M2.22891 2.07227C1.89754 2.07227 1.62891 2.34089 1.62891 2.67227C1.62891 3.00364 1.89754 3.27227 2.22891 3.27227H6.29541V14.0056C6.29541 14.337 6.56404 14.6056 6.89541 14.6056C7.22678 14.6056 7.49541 14.337 7.49541 14.0056V3.27227H11.5622C11.8936 3.27227 12.1622 3.00364 12.1622 2.67227C12.1622 2.34089 11.8936 2.07227 11.5622 2.07227H2.22891Z" }
707
- }, {
708
- tag: "path",
709
- attrs: { d: "M10.2289 6.40552C9.89754 6.40552 9.62891 6.67415 9.62891 7.00552C9.62891 7.33689 9.89754 7.60552 10.2289 7.60552H12.2954V14.0055C12.2954 14.3369 12.564 14.6055 12.8954 14.6055C13.2268 14.6055 13.4954 14.3369 13.4954 14.0055V7.60552H15.5622C15.8936 7.60552 16.1622 7.33689 16.1622 7.00552C16.1622 6.67415 15.8936 6.40552 15.5622 6.40552H10.2289Z" }
710
- }]
711
- }, {
712
- tag: "defs",
713
- attrs: {},
714
- children: [{
715
- tag: "clipPath",
716
- attrs: { id: "text-icon_clip0_1293_26" },
717
- children: [{
718
- tag: "path",
719
- attrs: {
720
- fill: "white",
721
- d: "M0 0H16V16H0z",
722
- transform: "translate(.9)"
723
- }
724
- }]
725
- }]
726
- }],
727
- defIds: ["text-icon_clip0_1293_26"]
728
- }, ae = ge(function(e, n) {
729
- return J(X, Object.assign({}, e, {
730
- id: "text-icon",
731
- ref: n,
732
- icon: Lt
733
- }));
734
- });
735
- ae.displayName = "TextIcon";
736
- const Qe = "doc.quick-insert.button";
737
- var At = Object.getOwnPropertyDescriptor, jt = (t, e, n, i) => {
738
- for (var r = i > 1 ? void 0 : i ? At(e, n) : e, s = t.length - 1, c; s >= 0; s--)
739
- (c = t[s]) && (r = c(r) || r);
740
- return r;
741
- }, te = (t, e) => (n, i) => e(n, i, t);
742
- let F = class extends Y {
743
- constructor(e, n, i, r) {
744
- super();
745
- C(this, "_popup$", new A(null));
746
- C(this, "popup$", this._popup$.asObservable());
747
- this._context = e, this._docEventManagerService = n, this._docQuickInsertPopupService = i, this._docCanvasPopManagerService = r, this._init();
748
- }
749
- get popup() {
750
- return this._popup$.value;
751
- }
752
- _init() {
753
- this.disposeWithMe(fe([this._docEventManagerService.hoverParagraphLeftRealTime$, this._docEventManagerService.hoverParagraphRealTime$]).subscribe(([e, n]) => {
754
- var s;
755
- const i = e != null ? e : n, r = this._context.unit.getDisabled();
756
- if (!i || r) {
757
- this._hideMenu(!0);
758
- return;
759
- }
760
- if (i.paragraphStart === i.paragraphEnd) {
761
- if (this._docQuickInsertPopupService.editPopup || i.startIndex === ((s = this.popup) == null ? void 0 : s.startIndex)) return;
762
- this._hideMenu(!0);
763
- const c = this._docCanvasPopManagerService.attachPopupToRect(i.firstLine, {
764
- componentKey: Qe,
765
- direction: "left-center"
766
- }, this._context.unit.getUnitId());
767
- this._popup$.next({
768
- startIndex: i.startIndex,
769
- disposable: c
770
- });
771
- } else
772
- this._hideMenu(!0);
773
- }));
774
- }
775
- _hideMenu(e) {
776
- this._docQuickInsertPopupService.editPopup || this.popup && (e || this.popup.disposable.canDispose()) && (this.popup.disposable.dispose(), this._popup$.next(null));
777
- }
778
- };
779
- F = jt([
780
- te(1, f(Pe)),
781
- te(2, f(I)),
782
- te(3, f(Se))
783
- ], F);
784
- const de = ({ className: t = "" }) => {
785
- const e = _(I), n = _(pe), i = _(he), r = T(se(() => n.getCurrentTypeOfUnit$(H.UNIVER_DOC), [n])), s = r && i.getRenderById(r.getUnitId()), c = s == null ? void 0 : s.with(F), l = _(ut), o = _(le), a = T(e.editPopup$), d = pt((u) => {
786
- var P;
787
- const g = c == null ? void 0 : c.popup;
788
- if (!g)
789
- return;
790
- const S = e.popups, b = {
791
- keyword: "",
792
- menus$: fe(S.map((y) => y.menus$)).pipe(
793
- Me((y) => y.flat())
794
- )
795
- };
796
- o.replaceDocRanges([{
797
- startOffset: g.startIndex,
798
- endOffset: g.startIndex
799
- }]), e.setInputOffset({ start: g.startIndex - 1, end: g.startIndex - 1 }), e.showPopup({
800
- popup: b,
801
- index: g.startIndex - 1,
802
- unitId: (P = r == null ? void 0 : r.getUnitId()) != null ? P : ""
803
- }), setTimeout(() => {
804
- l.focus();
805
- });
806
- });
807
- return /* @__PURE__ */ h(
808
- "div",
809
- {
810
- className: re("univer-mr-1 univer-flex univer-cursor-pointer univer-items-center univer-gap-2.5 univer-rounded-full univer-p-1.5 univer-shadow-sm hover:univer-bg-gray-100 dark:!univer-text-gray-200 dark:hover:!univer-bg-gray-700", It, {
811
- "univer-bg-gray-100 dark:!univer-bg-gray-700": a,
812
- "univer-bg-white dark:!univer-bg-gray-900": !a
813
- }, t),
814
- role: "button",
815
- tabIndex: 0,
816
- onClick: d,
817
- children: /* @__PURE__ */ h(
818
- Ue,
819
- {
820
- className: "univer-text-gray-800 dark:!univer-text-gray-200"
821
- }
822
- )
823
- }
824
- );
825
- };
826
- de.componentKey = Qe;
827
- var Bt = Object.getOwnPropertyDescriptor, Wt = (t, e, n, i) => {
828
- for (var r = i > 1 ? void 0 : i ? Bt(e, n) : e, s = t.length - 1, c; s >= 0; s--)
829
- (c = t[s]) && (r = c(r) || r);
830
- return r;
831
- }, ne = (t, e) => (n, i) => e(n, i, t);
832
- let G = class extends Y {
833
- constructor(t, e, n) {
834
- super(), this._commandService = t, this._docQuickInsertPopupService = e, this._componentManager = n, this._initCommands(), this._initComponents(), this._initMenus();
835
- }
836
- _initCommands() {
837
- [
838
- Oe,
839
- we,
840
- U
841
- ].forEach((t) => {
842
- this.disposeWithMe(this._commandService.registerCommand(t));
843
- });
844
- }
845
- _initComponents() {
846
- [
847
- [Z.componentKey, Z],
848
- [W.componentKey, W],
849
- [q.componentKey, q],
850
- [ce.displayName, ce],
851
- [ae.displayName, ae],
852
- [de.componentKey, de]
853
- ].forEach(([e, n]) => {
854
- e && this.disposeWithMe(this._componentManager.register(e, n));
855
- }), [
856
- {
857
- keyword: "/",
858
- menus$: ft($t),
859
- // only show when the cursor is at the beginning of a line
860
- preconditions: (e) => {
861
- var n;
862
- return ((n = e.range.startNodePosition) == null ? void 0 : n.glyph) === 0;
863
- }
864
- }
865
- ].forEach((e) => {
866
- this.disposeWithMe(this._docQuickInsertPopupService.registerPopup(e));
867
- });
868
- }
869
- _initMenus() {
870
- }
871
- };
872
- G = Wt([
873
- ne(0, Q),
874
- ne(1, f(I)),
875
- ne(2, f(ye))
876
- ], G);
877
- const qt = "docs-quick-insert-ui.config", Ie = {};
878
- var Zt = Object.defineProperty, Vt = Object.getOwnPropertyDescriptor, Ft = (t, e, n) => e in t ? Zt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, Gt = (t, e, n, i) => {
879
- for (var r = i > 1 ? void 0 : i ? Vt(e, n) : e, s = t.length - 1, c; s >= 0; s--)
880
- (c = t[s]) && (r = c(r) || r);
881
- return r;
882
- }, ie = (t, e) => (n, i) => e(n, i, t), He = (t, e, n) => Ft(t, typeof e != "symbol" ? e + "" : e, n);
883
- const zt = "DOC_QUICK_INSERT_UI_PLUGIN";
884
- let z = class extends ze {
885
- constructor(t = Ie, e, n, i) {
886
- super(), this._config = t, this._injector = e, this._renderManagerSrv = n, this._configService = i;
887
- const { menu: r, ...s } = Ye(
888
- {},
889
- Ie,
890
- this._config
891
- );
892
- r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(qt, s);
893
- }
894
- onStarting() {
895
- [
896
- [G],
897
- [V],
898
- [I]
899
- ].forEach((e) => this._injector.add(e)), this._injector.get(G);
900
- }
901
- onRendered() {
902
- this._injector.get(V), this._injector.get(I), [
903
- [F]
904
- ].forEach((t) => {
905
- this._renderManagerSrv.registerRenderModule(H.UNIVER_DOC, t);
906
- });
907
- }
908
- };
909
- He(z, "type", H.UNIVER_DOC);
910
- He(z, "pluginName", zt);
911
- z = Gt([
912
- Ve(Mt, xt, Pt, yt, lt),
913
- ie(1, f(Fe)),
914
- ie(2, f(he)),
915
- ie(3, Ge)
916
- ], z);
917
- export {
918
- I as DocQuickInsertPopupService,
919
- V as DocQuickInsertTriggerController,
920
- G as DocQuickInsertUIController,
921
- Ot as KeywordInputPlaceholderComponentKey,
922
- bt as QuickInsertPlaceholderComponentKey,
923
- z as UniverDocsQuickInsertUIPlugin
924
- };
1
+ import{CommandType as e,DeleteDirection as t,DependentOn as n,Direction as r,Disposable as i,DisposableCollection as a,ICommandService as o,IConfigService as s,IUniverInstanceService as c,Inject as l,Injector as u,LocaleService as d,Plugin as f,RANGE_DIRECTION as p,UniverInstanceType as m,generateRandomId as h,merge as g,toDisposable as _}from"@univerjs/core";import{DocSelectionManagerService as v,DocSkeletonManagerService as y,RichTextEditingMutation as b}from"@univerjs/docs";import{BulletListCommand as ee,CutContentCommand as x,DeleteCommand as S,DeleteLeftCommand as C,DocCanvasPopManagerService as w,DocCreateTableOperation as te,DocEventManagerService as T,HorizontalLineCommand as ne,IMEInputCommand as re,InsertCommand as ie,MoveCursorOperation as ae,NodePositionConvertToCursor as oe,OrderListCommand as se,getAnchorBounding as ce}from"@univerjs/docs-ui";import{ComponentManager as le,ILayoutService as ue,IShortcutService as de,KeyCode as E,UniverUIPlugin as fe,useDependency as D,useEvent as pe,useObservable as O}from"@univerjs/ui";import{IRenderManagerService as k,ptToPixel as me}from"@univerjs/engine-render";import{BehaviorSubject as A,combineLatest as j,distinctUntilChanged as he,map as ge,of as _e,tap as M}from"rxjs";import{useEffect as N,useMemo as P,useRef as F,useState as ve}from"react";import{jsx as I,jsxs as L}from"react/jsx-runtime";import{Tooltip as ye,borderBottomClassName as be,borderClassName as xe,clsx as R,scrollbarClassName as Se}from"@univerjs/design";import{InsertDocImageCommand as Ce,UniverDocsDrawingUIPlugin as we}from"@univerjs/docs-drawing-ui";import{DividerIcon as Te,IncreaseIcon as Ee,TextIcon as De}from"@univerjs/icons";import{UniverDocsDrawingPlugin as Oe}from"@univerjs/docs-drawing";import{UniverDrawingPlugin as ke}from"@univerjs/drawing";import{UniverDrawingUIPlugin as Ae}from"@univerjs/drawing-ui";const je={id:`doc.command.delete-search-key`,type:e.COMMAND,handler:(e,t)=>{let n=e.get(o),{start:r,end:i}=t;return n.syncExecuteCommand(x.id,{segmentId:``,textRanges:[{startOffset:r,endOffset:r,collapsed:!0}],selections:[{startOffset:r,endOffset:i,collapsed:!1,direction:p.FORWARD}]})}},Me=`docs.quick.insert.keyword-input-placeholder`;function Ne(e,t){if(typeof document>`u`)return e.length*11;let n=document.createElement(`canvas`).getContext(`2d`);return n?(n.font=t,Math.ceil(n.measureText(e).width)):e.length*11}const z=({popup:e})=>{var t,n,r,i,a,o,s,c,l,u,f;let p=D(d).t(`docQuickInsert.keywordInputPlaceholder`),m=me((t=(n=e.extraProps)==null?void 0:n.fontSize)==null?11:t),h=(r=(i=e.extraProps)==null?void 0:i.fontString)==null?`${m}px sans-serif`:r,g=(a=(o=e.extraProps)==null?void 0:o.ascent)==null?m:a,_=Math.max((s=(c=e.extraProps)==null?void 0:c.contentHeight)==null?m:s,m),v=P(()=>Ne(p,h),[h,p]);return I(`div`,{className:`
2
+ univer-select-none univer-font-normal univer-text-gray-500 univer-transition-colors
3
+ dark:!univer-text-gray-400
4
+ `,children:I(`svg`,{width:v,height:_,viewBox:`0 0 ${v} ${_}`,style:{overflow:`visible`,display:`block`},children:I(`text`,{x:0,y:g,fill:`currentColor`,style:{font:h,fontFamily:(l=e.extraProps)==null?void 0:l.fontFamily,fontStyle:(u=e.extraProps)==null?void 0:u.fontStyle,fontWeight:(f=e.extraProps)==null?void 0:f.fontWeight},children:p})})})};z.componentKey=Me;function Pe(e){return`children`in e}function B(e){return e.flatMap(e=>Pe(e)?B(e.children):e)}function Fe(e){return B(e).length}function Ie(e){let{menus:t,focusedMenuIndex:n,focusedMenuRef:r,menuNodeMapRef:i,componentManager:a,onFocusedMenuIndexChange:o,onSelect:s}=e,c=P(()=>B(t),[t]);N(()=>{var e,t;let a=Number.isNaN(n)||(e=c[n])==null?null:e;r.current=a,a&&((t=i.current.get(a.id))==null||t.scrollIntoView({block:`nearest`}))},[c,n,r,i]);let l=F(0);l.current=0;function u(e){return e.map((t,r)=>{let c=t.icon,d=c?a.get(c):null;if(Pe(t))return L(`div`,{className:R(`univer-grid univer-gap-1 univer-py-1`,r!==e.length-1&&be),children:[L(`div`,{className:`
5
+ univer-box-border univer-inline-flex univer-items-center univer-gap-2 univer-px-2
6
+ univer-text-xs univer-font-semibold univer-text-gray-600
7
+ dark:!univer-text-gray-300
8
+ `,children:[d&&I(`span`,{className:`univer-inline-flex univer-text-base`,children:I(d,{})}),I(`span`,{children:t.title})]}),I(`div`,{className:`univer-grid univer-gap-1`,children:u(t.children)})]},t.id);let f=l.current,p=n===f;return l.current+=1,I(`div`,{ref:e=>{if(e){i.current.set(t.id,e);return}i.current.delete(t.id)},role:`button`,tabIndex:-1,className:R(`
9
+ univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer
10
+ univer-items-center univer-justify-between univer-gap-3 univer-rounded-md univer-border-none
11
+ univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-900
12
+ univer-outline-none
13
+ hover:univer-bg-gray-50
14
+ dark:!univer-text-white
15
+ dark:hover:!univer-bg-gray-600
16
+ `,{"hover:univer-bg-transparent":!p,"univer-bg-gray-50 dark:!univer-bg-gray-600":p}),onMouseEnter:()=>o(f),onMouseLeave:()=>o(NaN),onClick:()=>s(t),children:L(`div`,{className:`univer-inline-flex univer-w-full univer-items-center univer-gap-2`,children:[d&&I(`span`,{className:`univer-inline-flex univer-text-base`,children:I(d,{})}),I(ye,{showIfEllipsis:!0,title:t.title,placement:`right`,children:I(`span`,{className:`univer-truncate`,children:t.title})})]})},t.id)})}return I(`div`,{className:R(`
17
+ univer-box-border univer-grid univer-max-h-[360px] univer-gap-1 univer-overflow-y-auto
18
+ univer-overflow-x-hidden univer-overscroll-contain univer-rounded-md univer-bg-white univer-px-2
19
+ univer-py-1 univer-text-sm univer-text-gray-900 univer-shadow-md
20
+ dark:!univer-bg-gray-700 dark:!univer-text-white
21
+ `,xe,Se),onWheel:e=>e.stopPropagation(),children:u(t)})}const Le=`docs.quick.insert.placeholder`,V=()=>I(`div`,{className:`
22
+ univer-flex univer-h-full univer-items-center univer-justify-center univer-rounded-lg univer-bg-white
23
+ univer-px-12 univer-py-6 univer-text-gray-400 univer-shadow-lg
24
+ `,children:I(`span`,{children:D(d).t(`docQuickInsert.placeholder`)})});V.componentKey=Le;function H(e,t){return e.map(e=>({...e})).filter(e=>{if(`children`in e)return e.children=H(e.children,t),e.children.length>0;let n=e.keywords;return n?n.some(e=>e.includes(t)):e.title.toLowerCase().includes(t)})}function Re(e,t){return e.map(e=>{let n={...e};return`children`in n&&(n.children=Re(n.children,t)),n.title=t.t(n.title),`keywords`in n&&(n.keywords=n.keywords.concat(n.title).map(e=>e.toLowerCase())),n})}const ze=[E.ARROW_UP,E.ARROW_DOWN,E.ENTER],U=()=>{let t=D(d),n=D(J),i=D(le),s=D(de),c=D(o),l=P(()=>h(),[]),[u,f]=ve(0),p=F(null),m=O(n.filterKeyword$,``),g=O(n.editPopup$),v=O(g==null?void 0:g.popup.menus$,[]),y=P(()=>Re(v,t),[v]),[b,ee]=ve(()=>H(y,m.toLowerCase())),x=P(()=>Fe(b),[b]),S=F(x);N(()=>{S.current=x},[x]),N(()=>{let e=requestIdleCallback(()=>{ee(H(y,m.toLowerCase()))});return()=>{cancelIdleCallback(e)}},[y,m]);let C=e=>{n.emitMenuSelected(e),c.executeCommand(Y.id)};N(()=>{let t=new a;s.getAllShortcuts().filter(e=>e.binding&&ze.includes(e.binding)).forEach(e=>{let n=e.preconditions;e.preconditions=()=>!1,t.add(_(()=>{e.preconditions=n}))});let n={id:`quick.insert.popup.enter.${l}`,type:e.OPERATION,handler:()=>{let e=p.current;e&&C(e)}},i={id:`quick.insert.popup.move.cursor.up.${l}`,type:e.OPERATION,handler:()=>{f(e=>{if(S.current<=0)return 0;let t=e-1;return t>=0?t:S.current-1})}},o={id:`quick.insert.popup.move.cursor.down.${l}`,type:e.OPERATION,handler:()=>{f(e=>{if(S.current<=0)return 0;let t=e+1;return t<=S.current-1?t:0})}};return t.add(c.registerCommand(i)),t.add(c.registerCommand(o)),t.add(c.registerCommand(n)),t.add(s.registerShortcut({priority:1e3,id:i.id,binding:E.ARROW_UP,preconditions:()=>!0,staticParameters:{direction:r.UP}})),t.add(s.registerShortcut({priority:1e3,id:o.id,binding:E.ARROW_DOWN,preconditions:()=>!0,staticParameters:{direction:r.DOWN}})),t.add(s.registerShortcut({priority:1e3,id:n.id,binding:E.ENTER,preconditions:()=>!0})),()=>{t.dispose()}},[c,l,s]),N(()=>{f(0)},[b]);let w=F(new Map);N(()=>()=>{w.current.clear()},[]);let te=b.length>0,T=(g==null?void 0:g.popup.Placeholder)||i.get(V.componentKey);return I(`div`,{className:`univer-mt-2`,children:te?I(Ie,{menus:b,focusedMenuIndex:u,focusedMenuRef:p,menuNodeMapRef:w,componentManager:i,onFocusedMenuIndexChange:f,onSelect:C}):T&&I(T,{})})};U.componentKey=`docs.quick.insert.popup`;function W(e){"@babel/helpers - typeof";return W=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},W(e)}function Be(e,t){if(W(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(W(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ve(e){var t=Be(e,`string`);return W(t)==`symbol`?t:t+``}function G(e,t,n){return(t=Ve(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function K(e,t){return function(n,r){t(n,r,e)}}function q(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const He={dispose:()=>{}};let J=class extends i{get popups(){return Array.from(this._popups)}get editPopup(){return this._editPopup$.value}get isComposing(){return this._isComposing$.value}setIsComposing(e){this._isComposing$.next(e)}get inputOffset(){return this._inputOffset$.value}setInputOffset(e){this._inputOffset$.next(e)}getDocEventManagerService(e){var t;return(t=this._renderManagerService.getRenderById(e))==null?void 0:t.with(T)}constructor(e,t,n,r,i){super(),this._docCanvasPopupManagerService=e,this._univerInstanceService=t,this._commandService=n,this._renderManagerService=r,this._docSelectionManagerService=i,G(this,`_popups`,new Set),G(this,`_editPopup$`,new A(void 0)),G(this,`editPopup$`,this._editPopup$.asObservable()),G(this,`_isComposing$`,new A(!1)),G(this,`isComposing$`,this._isComposing$.asObservable()),G(this,`_inputOffset$`,new A({start:0,end:0})),G(this,`inputOffset$`,this._inputOffset$.asObservable()),G(this,`filterKeyword$`,void 0),G(this,`_menuSelectedCallbacks`,new Set),G(this,`_inputPlaceholderRenderRoot`,null),this.disposeWithMe(this._editPopup$);let a=(e,t)=>{var n;return(n=this._univerInstanceService.getCurrentUnitOfType(m.UNIVER_DOC))==null||(n=n.getBody())==null?void 0:n.dataStream.slice(e,t)},o=``;this.filterKeyword$=this._inputOffset$.pipe(ge(e=>{var t;let n=a(e.start,e.end);return(t=n==null?void 0:n.slice(1))==null?``:t}),he(),M(e=>{o=e})),this.disposeWithMe(j([this.filterKeyword$.pipe(M(e=>{if(e.length>0){var t;(t=this._inputPlaceholderRenderRoot)==null||(t=t.unmount)==null||t.dispose()}else{var n;(n=this._inputPlaceholderRenderRoot)==null||n.mount()}})),this.isComposing$.pipe(M(e=>{if(e){var t;(t=this._inputPlaceholderRenderRoot)==null||(t=t.unmount)==null||t.dispose()}else{var n;o.length<=0&&((n=this._inputPlaceholderRenderRoot)==null||n.mount())}})),this.editPopup$.pipe(M(e=>{if(!e){var t;(t=this._inputPlaceholderRenderRoot)==null||(t=t.unmount)==null||t.dispose(),this._inputPlaceholderRenderRoot=null}}))]).subscribe())}resolvePopup(e){return Array.from(this._popups).find(t=>t.keyword===e)}registerPopup(e){return this._popups.add(e),()=>{this._popups.delete(e)}}_createInputPlaceholderRenderRoot(e){return{isMounted:!1,mount(){if(this.isMounted)return;this.isMounted=!0;let t=e();this.unmount={dispose:()=>{t.dispose(),this.isMounted=!1}}}}}_getParagraphBound(e,t){var n,r;let i=this._univerInstanceService.getUnit(e),a=i==null||(n=i.getBody())==null||(n=n.paragraphs)==null?void 0:n.find(e=>e.startIndex>t);if(!a)return null;let o=this.getDocEventManagerService(e);return(r=o==null?void 0:o.findParagraphBoundByIndex(a.startIndex))==null?null:r}_getKeywordPlaceholderAnchorRect(e,t,n,r){let i=t.findNodePositionByCharIndex(n.startOffset,!0,n.segmentId,n.segmentPage);if(!i)return r;let a=e.getOffsetConfig(),{contentBoxPointGroup:o}=new oe(a,t).getRangePointData(i,i);if(o.length===0)return r;let s=ce(o),c=s.left+a.docsLeft,l=s.top+a.docsTop;return{left:c,right:c,top:l,bottom:l+s.height}}_getKeywordPlaceholderExtraProps(e){var t,n,r,i,a,o,s,c,l,u,d,f,p;return{fontSize:(t=e.ts)==null?void 0:t.fs,fontString:(n=e.fontStyle)==null?void 0:n.fontString,fontFamily:(r=(i=(a=e.fontStyle)==null?void 0:a.fontFamily)==null?(o=e.ts)==null?void 0:o.ff:i)==null?void 0:r,fontStyle:(s=e.ts)!=null&&s.it?`italic`:`normal`,fontWeight:(c=e.ts)!=null&&c.bl?`bold`:`normal`,ascent:(l=e.bBox)==null?void 0:l.ba,contentHeight:((u=(d=e.bBox)==null?void 0:d.ba)==null?0:u)+((f=(p=e.bBox)==null?void 0:p.bd)==null?0:f)||void 0}}_mountInputPlaceholder(e,t){let n=this._renderManagerService.getRenderById(e),r=n==null?void 0:n.with(y),i=this._docSelectionManagerService.getActiveTextRange();if(!n||!r||!i)return He;let a=r.getSkeleton(),o=a.findNodeByCharIndex(i.startOffset,i.segmentId,i.segmentPage);if((o==null?void 0:o.content)!==`\r`||!o)return He;let s=n.mainComponent,c=this._getKeywordPlaceholderAnchorRect(s,a,i,t),l=this._getKeywordPlaceholderExtraProps(o),u=this._docCanvasPopupManagerService.attachPopupToRect(c,{componentKey:z.componentKey,extraProps:l,onClickOutside:()=>{u.dispose()},direction:`horizontal`},e);return u}showPopup(e){let{popup:t,index:n,unitId:r}=e;this.closePopup();let i=this._getParagraphBound(r,n);if(!i)return;this._inputPlaceholderRenderRoot=this._createInputPlaceholderRenderRoot(()=>this._mountInputPlaceholder(r,i.firstLine)),this._inputPlaceholderRenderRoot.mount();let a=this._docCanvasPopupManagerService.attachPopupToRect(i.firstLine,{componentKey:U.componentKey,onClickOutside:()=>{this.closePopup()},direction:`bottom`},r);this._editPopup$.next({disposable:a,popup:t,anchor:n,unitId:r})}closePopup(){this.editPopup&&(this.editPopup.disposable.dispose(),this._editPopup$.next(null))}onMenuSelected(e){return this._menuSelectedCallbacks.add(e),()=>{this._menuSelectedCallbacks.delete(e)}}emitMenuSelected(e){let{start:t,end:n}=this.inputOffset;this._commandService.syncExecuteCommand(je.id,{start:t,end:n}),setTimeout(()=>{this._menuSelectedCallbacks.forEach(t=>t(e))},0)}};J=q([K(0,l(w)),K(1,l(c)),K(2,l(o)),K(3,l(k)),K(4,l(v))],J);const Ue={type:e.OPERATION,id:`doc.operation.show-quick-insert-popup`,handler(e,t){let n=e.get(J);return t?(n.showPopup(t),!0):!1}},Y={type:e.OPERATION,id:`doc.operation.close-quick-insert-popup`,handler(e){return e.get(J).closePopup(),!0}};let We=function(e){return e.Basic=`quick.insert.group.basic`,e.Media=`quick.insert.group.media`,e}({});const Ge={id:`quick-insert.text.menu`,title:`docQuickInsert.menu.text`,icon:`TextIcon`,keywords:[`text`]},Ke={id:se.id,title:`docQuickInsert.menu.numberedList`,icon:`OrderIcon`,keywords:[`numbered`,`list`,`ordered`]},qe={id:ee.id,title:`docQuickInsert.menu.bulletedList`,icon:`UnorderIcon`,keywords:[`bulleted`,`list`,`unordered`]},Je={id:ne.id,title:`docQuickInsert.menu.divider`,icon:`DividerIcon`,keywords:[`divider`,`line`,`separate`]},Ye={id:te.id,title:`docQuickInsert.menu.table`,icon:`GridIcon`,keywords:[`table`,`grid`,`spreadsheet`]},Xe={id:Ce.id,title:`docQuickInsert.menu.image`,icon:`AdditionAndSubtractionIcon`,keywords:[`image`,`picture`,`photo`]},Ze=[{title:`docQuickInsert.group.basics`,id:We.Basic,children:[Ge,Ke,qe,Je,Ye,Xe]}],Qe=new Set([Ke.id,qe.id,Je.id,Ye.id,Xe.id]);let X=class extends i{constructor(e,t,n,r,i){super(),this._commandService=e,this._textSelectionManagerService=t,this._docQuickInsertPopupService=n,this._shortcutService=r,this._univerInstanceService=i,this.disposeWithMe(this._shortcutService.registerShortcut({id:Y.id,binding:E.ESC,preconditions:()=>!!this._docQuickInsertPopupService.editPopup,priority:1e3})),this._initTrigger(),this._initMenuHandler()}_initTrigger(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{let{_docQuickInsertPopupService:n,_textSelectionManagerService:i,_commandService:a}=this,o=this._univerInstanceService.getCurrentUnitOfType(m.UNIVER_DOC);if(!(o!=null&&o.getDisabled())){if(e.id===ie.id){let t=e.params;if(n.editPopup){n.setInputOffset({start:n.inputOffset.start,end:t.range.endOffset+1});return}let r=i.getActiveTextRange();if(!r)return;let o=n.resolvePopup(t.body.dataStream);if(!o||!(!o.preconditions||o.preconditions(t)))return;n.setInputOffset({start:r.startOffset-1,end:r.startOffset}),setTimeout(()=>{a.executeCommand(Ue.id,{index:r.startOffset-1,unitId:t.unitId,popup:o})},100)}if(e.id===re.id){let t=e.params;!n.isComposing&&t.isCompositionStart&&n.setIsComposing(!0),n.isComposing&&t.isCompositionEnd&&n.setIsComposing(!1)}if(e.id===b.id){let t=e.params;if(t.isCompositionEnd){var s;let e=(s=t.textRanges)==null||(s=s[0])==null?void 0:s.endOffset;e&&n.setInputOffset({start:n.inputOffset.start,end:e})}}if(e.id===S.id){let r=e.params;if(n.editPopup&&r.direction===t.LEFT){var c;let e=(c=r.len)==null?0:c;n.setInputOffset({start:n.inputOffset.start,end:r.range.endOffset-e})}}if(e.id===ae.id){let t=e.params;(t.direction===r.LEFT||t.direction===r.RIGHT)&&n.editPopup&&a.executeCommand(Y.id)}if(e.id===C.id){let e=i.getActiveTextRange();if(!n.editPopup||!e)return;e.endOffset<=n.editPopup.anchor&&a.executeCommand(Y.id)}}}))}_initMenuHandler(){this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected(e=>{e.id!==Ge.id&&Qe.has(e.id)&&this._commandService.executeCommand(e.id)}))}};X=q([K(0,o),K(1,l(v)),K(2,l(J)),K(3,l(de)),K(4,l(c))],X);const $e=`doc.quick-insert.button`;let Z=class extends i{get popup(){return this._popup$.value}constructor(e,t,n,r){super(),this._context=e,this._docEventManagerService=t,this._docQuickInsertPopupService=n,this._docCanvasPopManagerService=r,G(this,`_popup$`,new A(null)),G(this,`popup$`,this._popup$.asObservable()),this._init()}_init(){this.disposeWithMe(j([this._docEventManagerService.hoverParagraphLeftRealTime$,this._docEventManagerService.hoverParagraphRealTime$]).subscribe(([e,t])=>{let n=e==null?t:e,r=this._context.unit.getDisabled();if(!n||r){this._hideMenu(!0);return}if(n.paragraphStart===n.paragraphEnd){var i;if(this._docQuickInsertPopupService.editPopup||n.startIndex===((i=this.popup)==null?void 0:i.startIndex))return;this._hideMenu(!0);let e=this._docCanvasPopManagerService.attachPopupToRect(n.firstLine,{componentKey:$e,direction:`left-center`},this._context.unit.getUnitId());this._popup$.next({startIndex:n.startIndex,disposable:e})}else this._hideMenu(!0)}))}_hideMenu(e){this._docQuickInsertPopupService.editPopup||this.popup&&(e||this.popup.disposable.canDispose())&&(this.popup.disposable.dispose(),this._popup$.next(null))}};Z=q([K(1,l(T)),K(2,l(J)),K(3,l(w))],Z);const et=({className:e=``})=>{let t=D(J),n=D(c),r=D(k),i=O(P(()=>n.getCurrentTypeOfUnit$(m.UNIVER_DOC),[n])),a=i&&r.getRenderById(i.getUnitId()),o=a==null?void 0:a.with(Z),s=D(ue),l=D(v),u=O(t.editPopup$),d=pe(e=>{var n;let r=o==null?void 0:o.popup;if(!r)return;let a=t.popups,c={keyword:``,menus$:j(a.map(e=>e.menus$)).pipe(ge(e=>e.flat()))};l.replaceDocRanges([{startOffset:r.startIndex,endOffset:r.startIndex}]),t.setInputOffset({start:r.startIndex-1,end:r.startIndex-1}),t.showPopup({popup:c,index:r.startIndex-1,unitId:(n=i==null?void 0:i.getUnitId())==null?``:n}),setTimeout(()=>{s.focus()})});return I(`div`,{className:R(`
25
+ univer-mr-1 univer-flex univer-cursor-pointer univer-items-center univer-gap-2.5 univer-rounded-full
26
+ univer-p-1.5 univer-shadow-sm
27
+ hover:univer-bg-gray-100
28
+ dark:!univer-text-gray-200
29
+ dark:hover:!univer-bg-gray-700
30
+ `,xe,{"univer-bg-gray-100 dark:!univer-bg-gray-700":u,"univer-bg-white dark:!univer-bg-gray-900":!u},e),role:`button`,tabIndex:0,onClick:d,children:I(Ee,{className:`
31
+ univer-text-gray-800
32
+ dark:!univer-text-gray-200
33
+ `})})};et.componentKey=$e;let Q=class extends i{constructor(e,t,n){super(),this._commandService=e,this._docQuickInsertPopupService=t,this._componentManager=n,this._initCommands(),this._initComponents(),this._initMenus()}_initCommands(){[je,Ue,Y].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initComponents(){[[U.componentKey,U],[z.componentKey,z],[V.componentKey,V],[Te.displayName,Te],[De.displayName,De],[et.componentKey,et]].forEach(([e,t])=>{e&&this.disposeWithMe(this._componentManager.register(e,t))}),[{keyword:`/`,menus$:_e(Ze),preconditions:e=>{var t;return((t=e.range.startNodePosition)==null?void 0:t.glyph)===0}}].forEach(e=>{this.disposeWithMe(this._docQuickInsertPopupService.registerPopup(e))})}_initMenus(){}};Q=q([K(0,o),K(1,l(J)),K(2,l(le))],Q);var tt=`@univerjs/docs-quick-insert-ui`,nt=`0.17.0-insiders.20260318-d69dc16`;const rt=`docs-quick-insert-ui.config`;Symbol(rt);const it={};let $=class extends f{constructor(e=it,t,n,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._configService=r;let{menu:i,...a}=g({},it,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(rt,a)}onStarting(){[[Q],[X],[J]].forEach(e=>this._injector.add(e)),this._injector.get(Q)}onRendered(){this._injector.get(X),this._injector.get(J),[[Z]].forEach(e=>{this._renderManagerSrv.registerRenderModule(m.UNIVER_DOC,e)})}};G($,`type`,m.UNIVER_DOC),G($,`pluginName`,`DOC_QUICK_INSERT_UI_PLUGIN`),G($,`packageName`,tt),G($,`version`,nt),$=q([n(Ae,ke,we,Oe,fe),K(1,l(u)),K(2,l(k)),K(3,s)],$);export{J as DocQuickInsertPopupService,X as DocQuickInsertTriggerController,Q as DocQuickInsertUIController,Me as KeywordInputPlaceholderComponentKey,Le as QuickInsertPlaceholderComponentKey,$ as UniverDocsQuickInsertUIPlugin};