@univerjs/docs-quick-insert-ui 1.0.0-insiders.20260809-70eefdd → 1.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md CHANGED
@@ -39,4 +39,3 @@ univer.registerPlugin(UniverDocsQuickInsertUIPlugin);
39
39
  - [Documentation](https://docs.univer.ai)
40
40
  - [NPM package](https://npmjs.com/package/@univerjs/docs-quick-insert-ui)
41
41
  - [GitHub repository](https://github.com/dream-num/univer)
42
-
package/lib/cjs/index.js CHANGED
@@ -152,7 +152,7 @@ function QuickInsertMenu(props) {
152
152
  },
153
153
  role: "button",
154
154
  tabIndex: -1,
155
- className: (0, _univerjs_design.clsx)("univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-justify-between univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-900 univer-outline-none hover:univer-bg-gray-50 dark:!univer-text-white dark:hover:!univer-bg-gray-600", {
155
+ className: (0, _univerjs_design.clsx)("univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-justify-between univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-900 univer-outline-none hover:univer-bg-gray-50 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-600", {
156
156
  "hover:univer-bg-transparent": !isFocused,
157
157
  "univer-bg-gray-50 dark:!univer-bg-gray-600": isFocused
158
158
  }),
@@ -178,7 +178,7 @@ function QuickInsertMenu(props) {
178
178
  });
179
179
  }
180
180
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
181
- className: (0, _univerjs_design.clsx)("univer-box-border univer-grid univer-max-h-[360px] univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-overscroll-contain univer-rounded-md univer-bg-white univer-px-2 univer-py-1 univer-text-sm univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-700 dark:!univer-text-white", _univerjs_design.borderClassName, _univerjs_design.scrollbarClassName),
181
+ className: (0, _univerjs_design.clsx)("univer-box-border univer-grid univer-max-h-[360px] univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-overscroll-contain univer-rounded-md univer-bg-gray-0 univer-px-2 univer-py-1 univer-text-sm univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-700 dark:!univer-text-gray-0", _univerjs_design.borderClassName, _univerjs_design.scrollbarClassName),
182
182
  onWheel: (event) => event.stopPropagation(),
183
183
  children: renderMenus(menus)
184
184
  });
@@ -189,7 +189,7 @@ function QuickInsertMenu(props) {
189
189
  const QuickInsertPlaceholderComponentKey = "docs.quick.insert.placeholder";
190
190
  const QuickInsertPlaceholder = () => {
191
191
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
192
- 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",
192
+ className: "univer-flex univer-h-full univer-items-center univer-justify-center univer-rounded-lg univer-bg-gray-0 univer-px-12 univer-py-6 univer-text-gray-400 univer-shadow-lg",
193
193
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService).t("docs-quick-insert-ui.placeholder") })
194
194
  });
195
195
  };
@@ -429,17 +429,18 @@ let DocQuickInsertPopupService = class DocQuickInsertPopupService extends _unive
429
429
  setInputOffset(offset) {
430
430
  this._inputOffset$.next(offset);
431
431
  }
432
- getDocEventManagerService(unitId) {
432
+ _getDocEventManagerService(unitId) {
433
433
  var _this$_renderManagerS;
434
434
  return (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(_univerjs_docs_ui.DocEventManagerService);
435
435
  }
436
- constructor(_docCanvasPopupManagerService, _univerInstanceService, _commandService, _renderManagerService, _docSelectionManagerService) {
436
+ constructor(_docCanvasPopupManagerService, _univerInstanceService, _commandService, _renderManagerService, _docSelectionManagerService, _docLayoutInteractionService) {
437
437
  super();
438
438
  this._docCanvasPopupManagerService = _docCanvasPopupManagerService;
439
439
  this._univerInstanceService = _univerInstanceService;
440
440
  this._commandService = _commandService;
441
441
  this._renderManagerService = _renderManagerService;
442
442
  this._docSelectionManagerService = _docSelectionManagerService;
443
+ this._docLayoutInteractionService = _docLayoutInteractionService;
443
444
  _defineProperty(this, "_popups", /* @__PURE__ */ new Set());
444
445
  _defineProperty(this, "_editPopup$", new rxjs.BehaviorSubject(void 0));
445
446
  _defineProperty(this, "editPopup$", this._editPopup$.asObservable());
@@ -521,7 +522,7 @@ let DocQuickInsertPopupService = class DocQuickInsertPopupService extends _unive
521
522
  const currentDoc = this._univerInstanceService.getUnit(unitId);
522
523
  const paragraph = currentDoc === null || currentDoc === void 0 || (_currentDoc$getBody = currentDoc.getBody()) === null || _currentDoc$getBody === void 0 || (_currentDoc$getBody = _currentDoc$getBody.paragraphs) === null || _currentDoc$getBody === void 0 ? void 0 : _currentDoc$getBody.find((p) => p.startIndex > index);
523
524
  if (!paragraph) return null;
524
- const docEventManagerService = this.getDocEventManagerService(unitId);
525
+ const docEventManagerService = this._getDocEventManagerService(unitId);
525
526
  return (docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.findParagraphBoundByIndex(paragraph.startIndex)) ?? null;
526
527
  }
527
528
  _getKeywordPlaceholderAnchorRect(document, skeleton, activeRange, fallbackRect) {
@@ -580,13 +581,17 @@ let DocQuickInsertPopupService = class DocQuickInsertPopupService extends _unive
580
581
  if (!paragraphBound) return;
581
582
  this._inputPlaceholderRenderRoot = this._createInputPlaceholderRenderRoot(() => this._mountInputPlaceholder(unitId, paragraphBound.firstLine));
582
583
  this._inputPlaceholderRenderRoot.mount();
583
- const disposable = this._docCanvasPopupManagerService.attachPopupToRect(paragraphBound.firstLine, {
584
+ const layoutInteraction = this._docLayoutInteractionService.beginInteraction();
585
+ const popupDisposable = this._docCanvasPopupManagerService.attachPopupToRect(paragraphBound.firstLine, {
584
586
  componentKey: QuickInsertPopup.componentKey,
585
587
  onClickOutside: () => {
586
588
  this.closePopup();
587
589
  },
588
590
  direction: "bottom"
589
591
  }, unitId);
592
+ const disposable = new _univerjs_core.DisposableCollection();
593
+ disposable.add(popupDisposable);
594
+ disposable.add(layoutInteraction);
590
595
  this._editPopup$.next({
591
596
  disposable,
592
597
  popup,
@@ -622,7 +627,8 @@ DocQuickInsertPopupService = __decorate([
622
627
  __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
623
628
  __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.ICommandService)),
624
629
  __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_engine_render.IRenderManagerService)),
625
- __decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService))
630
+ __decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService)),
631
+ __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_docs_ui.DocLayoutInteractionService))
626
632
  ], DocQuickInsertPopupService);
627
633
 
628
634
  //#endregion
@@ -865,7 +871,7 @@ DocQuickInsertUIController = __decorate([__decorateParam(0, _univerjs_core.IComm
865
871
  //#endregion
866
872
  //#region package.json
867
873
  var name = "@univerjs/docs-quick-insert-ui";
868
- var version = "1.0.0-insiders.20260809-70eefdd";
874
+ var version = "1.0.0-rc.0";
869
875
 
870
876
  //#endregion
871
877
  //#region src/config/config.ts
@@ -967,7 +973,7 @@ const QuickInsertButton = ({ className = "" }) => {
967
973
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
968
974
  className: (0, _univerjs_design.clsx)("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", _univerjs_design.borderClassName, {
969
975
  "univer-bg-gray-100 dark:!univer-bg-gray-700": editPopup,
970
- "univer-bg-white dark:!univer-bg-gray-900": !editPopup
976
+ "univer-bg-gray-0 dark:!univer-bg-gray-900": !editPopup
971
977
  }, className),
972
978
  role: "button",
973
979
  tabIndex: 0,
package/lib/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CommandType, DeleteDirection, DependentOn, Direction, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, LocaleService, Plugin, RANGE_DIRECTION, UniverInstanceType, generateRandomId, merge, toDisposable } from "@univerjs/core";
2
2
  import { DeleteTextCommand, DocSelectionManagerService, DocSkeletonManagerService, InsertTextCommand, RichTextEditingMutation, UniverDocsPlugin } from "@univerjs/docs";
3
- import { BulletListCommand, CutContentCommand, DeleteLeftCommand, DocCanvasPopManagerService, DocCreateTableOperation, DocEventManagerService, HorizontalLineCommand, IMEInputCommand, MoveCursorOperation, NodePositionConvertToCursor, OrderListCommand, UniverDocsUIPlugin, getAnchorBounding } from "@univerjs/docs-ui";
3
+ import { BulletListCommand, CutContentCommand, DeleteLeftCommand, DocCanvasPopManagerService, DocCreateTableOperation, DocEventManagerService, DocLayoutInteractionService, HorizontalLineCommand, IMEInputCommand, MoveCursorOperation, NodePositionConvertToCursor, OrderListCommand, UniverDocsUIPlugin, getAnchorBounding } from "@univerjs/docs-ui";
4
4
  import { ComponentManager, ILayoutService, IShortcutService, IconManager, KeyCode, useDependency, useEvent, useObservable } from "@univerjs/ui";
5
5
  import { IRenderManagerService, UniverRenderEnginePlugin, ptToPixel } from "@univerjs/engine-render";
6
6
  import { BehaviorSubject, combineLatest, distinctUntilChanged, map, of, tap } from "rxjs";
@@ -151,7 +151,7 @@ function QuickInsertMenu(props) {
151
151
  },
152
152
  role: "button",
153
153
  tabIndex: -1,
154
- className: clsx("univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-justify-between univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-900 univer-outline-none hover:univer-bg-gray-50 dark:!univer-text-white dark:hover:!univer-bg-gray-600", {
154
+ className: clsx("univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-justify-between univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-900 univer-outline-none hover:univer-bg-gray-50 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-600", {
155
155
  "hover:univer-bg-transparent": !isFocused,
156
156
  "univer-bg-gray-50 dark:!univer-bg-gray-600": isFocused
157
157
  }),
@@ -177,7 +177,7 @@ function QuickInsertMenu(props) {
177
177
  });
178
178
  }
179
179
  return /* @__PURE__ */ jsx("div", {
180
- className: clsx("univer-box-border univer-grid univer-max-h-[360px] univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-overscroll-contain univer-rounded-md univer-bg-white univer-px-2 univer-py-1 univer-text-sm univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-700 dark:!univer-text-white", borderClassName, scrollbarClassName),
180
+ className: clsx("univer-box-border univer-grid univer-max-h-[360px] univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-overscroll-contain univer-rounded-md univer-bg-gray-0 univer-px-2 univer-py-1 univer-text-sm univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-700 dark:!univer-text-gray-0", borderClassName, scrollbarClassName),
181
181
  onWheel: (event) => event.stopPropagation(),
182
182
  children: renderMenus(menus)
183
183
  });
@@ -188,7 +188,7 @@ function QuickInsertMenu(props) {
188
188
  const QuickInsertPlaceholderComponentKey = "docs.quick.insert.placeholder";
189
189
  const QuickInsertPlaceholder = () => {
190
190
  return /* @__PURE__ */ jsx("div", {
191
- 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",
191
+ className: "univer-flex univer-h-full univer-items-center univer-justify-center univer-rounded-lg univer-bg-gray-0 univer-px-12 univer-py-6 univer-text-gray-400 univer-shadow-lg",
192
192
  children: /* @__PURE__ */ jsx("span", { children: useDependency(LocaleService).t("docs-quick-insert-ui.placeholder") })
193
193
  });
194
194
  };
@@ -428,17 +428,18 @@ let DocQuickInsertPopupService = class DocQuickInsertPopupService extends Dispos
428
428
  setInputOffset(offset) {
429
429
  this._inputOffset$.next(offset);
430
430
  }
431
- getDocEventManagerService(unitId) {
431
+ _getDocEventManagerService(unitId) {
432
432
  var _this$_renderManagerS;
433
433
  return (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(DocEventManagerService);
434
434
  }
435
- constructor(_docCanvasPopupManagerService, _univerInstanceService, _commandService, _renderManagerService, _docSelectionManagerService) {
435
+ constructor(_docCanvasPopupManagerService, _univerInstanceService, _commandService, _renderManagerService, _docSelectionManagerService, _docLayoutInteractionService) {
436
436
  super();
437
437
  this._docCanvasPopupManagerService = _docCanvasPopupManagerService;
438
438
  this._univerInstanceService = _univerInstanceService;
439
439
  this._commandService = _commandService;
440
440
  this._renderManagerService = _renderManagerService;
441
441
  this._docSelectionManagerService = _docSelectionManagerService;
442
+ this._docLayoutInteractionService = _docLayoutInteractionService;
442
443
  _defineProperty(this, "_popups", /* @__PURE__ */ new Set());
443
444
  _defineProperty(this, "_editPopup$", new BehaviorSubject(void 0));
444
445
  _defineProperty(this, "editPopup$", this._editPopup$.asObservable());
@@ -520,7 +521,7 @@ let DocQuickInsertPopupService = class DocQuickInsertPopupService extends Dispos
520
521
  const currentDoc = this._univerInstanceService.getUnit(unitId);
521
522
  const paragraph = currentDoc === null || currentDoc === void 0 || (_currentDoc$getBody = currentDoc.getBody()) === null || _currentDoc$getBody === void 0 || (_currentDoc$getBody = _currentDoc$getBody.paragraphs) === null || _currentDoc$getBody === void 0 ? void 0 : _currentDoc$getBody.find((p) => p.startIndex > index);
522
523
  if (!paragraph) return null;
523
- const docEventManagerService = this.getDocEventManagerService(unitId);
524
+ const docEventManagerService = this._getDocEventManagerService(unitId);
524
525
  return (docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.findParagraphBoundByIndex(paragraph.startIndex)) ?? null;
525
526
  }
526
527
  _getKeywordPlaceholderAnchorRect(document, skeleton, activeRange, fallbackRect) {
@@ -579,13 +580,17 @@ let DocQuickInsertPopupService = class DocQuickInsertPopupService extends Dispos
579
580
  if (!paragraphBound) return;
580
581
  this._inputPlaceholderRenderRoot = this._createInputPlaceholderRenderRoot(() => this._mountInputPlaceholder(unitId, paragraphBound.firstLine));
581
582
  this._inputPlaceholderRenderRoot.mount();
582
- const disposable = this._docCanvasPopupManagerService.attachPopupToRect(paragraphBound.firstLine, {
583
+ const layoutInteraction = this._docLayoutInteractionService.beginInteraction();
584
+ const popupDisposable = this._docCanvasPopupManagerService.attachPopupToRect(paragraphBound.firstLine, {
583
585
  componentKey: QuickInsertPopup.componentKey,
584
586
  onClickOutside: () => {
585
587
  this.closePopup();
586
588
  },
587
589
  direction: "bottom"
588
590
  }, unitId);
591
+ const disposable = new DisposableCollection();
592
+ disposable.add(popupDisposable);
593
+ disposable.add(layoutInteraction);
589
594
  this._editPopup$.next({
590
595
  disposable,
591
596
  popup,
@@ -621,7 +626,8 @@ DocQuickInsertPopupService = __decorate([
621
626
  __decorateParam(1, Inject(IUniverInstanceService)),
622
627
  __decorateParam(2, Inject(ICommandService)),
623
628
  __decorateParam(3, Inject(IRenderManagerService)),
624
- __decorateParam(4, Inject(DocSelectionManagerService))
629
+ __decorateParam(4, Inject(DocSelectionManagerService)),
630
+ __decorateParam(5, Inject(DocLayoutInteractionService))
625
631
  ], DocQuickInsertPopupService);
626
632
 
627
633
  //#endregion
@@ -864,7 +870,7 @@ DocQuickInsertUIController = __decorate([__decorateParam(0, ICommandService), __
864
870
  //#endregion
865
871
  //#region package.json
866
872
  var name = "@univerjs/docs-quick-insert-ui";
867
- var version = "1.0.0-insiders.20260809-70eefdd";
873
+ var version = "1.0.0-rc.0";
868
874
 
869
875
  //#endregion
870
876
  //#region src/config/config.ts
@@ -966,7 +972,7 @@ const QuickInsertButton = ({ className = "" }) => {
966
972
  return /* @__PURE__ */ jsx("div", {
967
973
  className: clsx("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", borderClassName, {
968
974
  "univer-bg-gray-100 dark:!univer-bg-gray-700": editPopup,
969
- "univer-bg-white dark:!univer-bg-gray-900": !editPopup
975
+ "univer-bg-gray-0 dark:!univer-bg-gray-900": !editPopup
970
976
  }, className),
971
977
  role: "button",
972
978
  tabIndex: 0,
package/lib/index.css CHANGED
@@ -124,6 +124,10 @@
124
124
  background-color: var(--univer-gray-900) !important;
125
125
  }
126
126
 
127
+ .univer-bg-gray-0 {
128
+ background-color: var(--univer-gray-0);
129
+ }
130
+
127
131
  .univer-bg-gray-100 {
128
132
  background-color: var(--univer-gray-100);
129
133
  }
@@ -136,10 +140,6 @@
136
140
  background-color: #0000;
137
141
  }
138
142
 
139
- .univer-bg-white {
140
- background-color: var(--univer-white);
141
- }
142
-
143
143
  .univer-p-1\.5 {
144
144
  padding: .375rem;
145
145
  }
@@ -243,16 +243,18 @@
243
243
  transition-timing-function: cubic-bezier(.4, 0, .2, 1);
244
244
  }
245
245
 
246
- .hover\:univer-bg-gray-100:hover {
247
- background-color: var(--univer-gray-100);
248
- }
246
+ @media (hover: hover) and (pointer: fine) {
247
+ .hover\:univer-bg-gray-100:hover {
248
+ background-color: var(--univer-gray-100);
249
+ }
249
250
 
250
- .hover\:univer-bg-gray-50:hover {
251
- background-color: var(--univer-gray-50);
252
- }
251
+ .hover\:univer-bg-gray-50:hover {
252
+ background-color: var(--univer-gray-50);
253
+ }
253
254
 
254
- .hover\:univer-bg-transparent:hover {
255
- background-color: #0000;
255
+ .hover\:univer-bg-transparent:hover {
256
+ background-color: #0000;
257
+ }
256
258
  }
257
259
 
258
260
  .dark\:\!univer-bg-gray-600:where(.univer-dark, .univer-dark *) {
@@ -267,6 +269,10 @@
267
269
  background-color: var(--univer-gray-900) !important;
268
270
  }
269
271
 
272
+ .dark\:\!univer-text-gray-0:where(.univer-dark, .univer-dark *) {
273
+ color: var(--univer-gray-0) !important;
274
+ }
275
+
270
276
  .dark\:\!univer-text-gray-200:where(.univer-dark, .univer-dark *) {
271
277
  color: var(--univer-gray-200) !important;
272
278
  }
@@ -279,14 +285,12 @@
279
285
  color: var(--univer-gray-400) !important;
280
286
  }
281
287
 
282
- .dark\:\!univer-text-white:where(.univer-dark, .univer-dark *) {
283
- color: var(--univer-white) !important;
284
- }
285
-
286
- .dark\:hover\:\!univer-bg-gray-600:hover:where(.univer-dark, .univer-dark *) {
287
- background-color: var(--univer-gray-600) !important;
288
- }
288
+ @media (hover: hover) and (pointer: fine) {
289
+ .dark\:hover\:\!univer-bg-gray-600:hover:where(.univer-dark, .univer-dark *) {
290
+ background-color: var(--univer-gray-600) !important;
291
+ }
289
292
 
290
- .dark\:hover\:\!univer-bg-gray-700:hover:where(.univer-dark, .univer-dark *) {
291
- background-color: var(--univer-gray-700) !important;
293
+ .dark\:hover\:\!univer-bg-gray-700:hover:where(.univer-dark, .univer-dark *) {
294
+ background-color: var(--univer-gray-700) !important;
295
+ }
292
296
  }
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CommandType, DeleteDirection, DependentOn, Direction, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, LocaleService, Plugin, RANGE_DIRECTION, UniverInstanceType, generateRandomId, merge, toDisposable } from "@univerjs/core";
2
2
  import { DeleteTextCommand, DocSelectionManagerService, DocSkeletonManagerService, InsertTextCommand, RichTextEditingMutation, UniverDocsPlugin } from "@univerjs/docs";
3
- import { BulletListCommand, CutContentCommand, DeleteLeftCommand, DocCanvasPopManagerService, DocCreateTableOperation, DocEventManagerService, HorizontalLineCommand, IMEInputCommand, MoveCursorOperation, NodePositionConvertToCursor, OrderListCommand, UniverDocsUIPlugin, getAnchorBounding } from "@univerjs/docs-ui";
3
+ import { BulletListCommand, CutContentCommand, DeleteLeftCommand, DocCanvasPopManagerService, DocCreateTableOperation, DocEventManagerService, DocLayoutInteractionService, HorizontalLineCommand, IMEInputCommand, MoveCursorOperation, NodePositionConvertToCursor, OrderListCommand, UniverDocsUIPlugin, getAnchorBounding } from "@univerjs/docs-ui";
4
4
  import { ComponentManager, ILayoutService, IShortcutService, IconManager, KeyCode, useDependency, useEvent, useObservable } from "@univerjs/ui";
5
5
  import { IRenderManagerService, UniverRenderEnginePlugin, ptToPixel } from "@univerjs/engine-render";
6
6
  import { BehaviorSubject, combineLatest, distinctUntilChanged, map, of, tap } from "rxjs";
@@ -151,7 +151,7 @@ function QuickInsertMenu(props) {
151
151
  },
152
152
  role: "button",
153
153
  tabIndex: -1,
154
- className: clsx("univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-justify-between univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-900 univer-outline-none hover:univer-bg-gray-50 dark:!univer-text-white dark:hover:!univer-bg-gray-600", {
154
+ className: clsx("univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-justify-between univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-900 univer-outline-none hover:univer-bg-gray-50 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-600", {
155
155
  "hover:univer-bg-transparent": !isFocused,
156
156
  "univer-bg-gray-50 dark:!univer-bg-gray-600": isFocused
157
157
  }),
@@ -177,7 +177,7 @@ function QuickInsertMenu(props) {
177
177
  });
178
178
  }
179
179
  return /* @__PURE__ */ jsx("div", {
180
- className: clsx("univer-box-border univer-grid univer-max-h-[360px] univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-overscroll-contain univer-rounded-md univer-bg-white univer-px-2 univer-py-1 univer-text-sm univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-700 dark:!univer-text-white", borderClassName, scrollbarClassName),
180
+ className: clsx("univer-box-border univer-grid univer-max-h-[360px] univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-overscroll-contain univer-rounded-md univer-bg-gray-0 univer-px-2 univer-py-1 univer-text-sm univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-700 dark:!univer-text-gray-0", borderClassName, scrollbarClassName),
181
181
  onWheel: (event) => event.stopPropagation(),
182
182
  children: renderMenus(menus)
183
183
  });
@@ -188,7 +188,7 @@ function QuickInsertMenu(props) {
188
188
  const QuickInsertPlaceholderComponentKey = "docs.quick.insert.placeholder";
189
189
  const QuickInsertPlaceholder = () => {
190
190
  return /* @__PURE__ */ jsx("div", {
191
- 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",
191
+ className: "univer-flex univer-h-full univer-items-center univer-justify-center univer-rounded-lg univer-bg-gray-0 univer-px-12 univer-py-6 univer-text-gray-400 univer-shadow-lg",
192
192
  children: /* @__PURE__ */ jsx("span", { children: useDependency(LocaleService).t("docs-quick-insert-ui.placeholder") })
193
193
  });
194
194
  };
@@ -428,17 +428,18 @@ let DocQuickInsertPopupService = class DocQuickInsertPopupService extends Dispos
428
428
  setInputOffset(offset) {
429
429
  this._inputOffset$.next(offset);
430
430
  }
431
- getDocEventManagerService(unitId) {
431
+ _getDocEventManagerService(unitId) {
432
432
  var _this$_renderManagerS;
433
433
  return (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.with(DocEventManagerService);
434
434
  }
435
- constructor(_docCanvasPopupManagerService, _univerInstanceService, _commandService, _renderManagerService, _docSelectionManagerService) {
435
+ constructor(_docCanvasPopupManagerService, _univerInstanceService, _commandService, _renderManagerService, _docSelectionManagerService, _docLayoutInteractionService) {
436
436
  super();
437
437
  this._docCanvasPopupManagerService = _docCanvasPopupManagerService;
438
438
  this._univerInstanceService = _univerInstanceService;
439
439
  this._commandService = _commandService;
440
440
  this._renderManagerService = _renderManagerService;
441
441
  this._docSelectionManagerService = _docSelectionManagerService;
442
+ this._docLayoutInteractionService = _docLayoutInteractionService;
442
443
  _defineProperty(this, "_popups", /* @__PURE__ */ new Set());
443
444
  _defineProperty(this, "_editPopup$", new BehaviorSubject(void 0));
444
445
  _defineProperty(this, "editPopup$", this._editPopup$.asObservable());
@@ -520,7 +521,7 @@ let DocQuickInsertPopupService = class DocQuickInsertPopupService extends Dispos
520
521
  const currentDoc = this._univerInstanceService.getUnit(unitId);
521
522
  const paragraph = currentDoc === null || currentDoc === void 0 || (_currentDoc$getBody = currentDoc.getBody()) === null || _currentDoc$getBody === void 0 || (_currentDoc$getBody = _currentDoc$getBody.paragraphs) === null || _currentDoc$getBody === void 0 ? void 0 : _currentDoc$getBody.find((p) => p.startIndex > index);
522
523
  if (!paragraph) return null;
523
- const docEventManagerService = this.getDocEventManagerService(unitId);
524
+ const docEventManagerService = this._getDocEventManagerService(unitId);
524
525
  return (docEventManagerService === null || docEventManagerService === void 0 ? void 0 : docEventManagerService.findParagraphBoundByIndex(paragraph.startIndex)) ?? null;
525
526
  }
526
527
  _getKeywordPlaceholderAnchorRect(document, skeleton, activeRange, fallbackRect) {
@@ -579,13 +580,17 @@ let DocQuickInsertPopupService = class DocQuickInsertPopupService extends Dispos
579
580
  if (!paragraphBound) return;
580
581
  this._inputPlaceholderRenderRoot = this._createInputPlaceholderRenderRoot(() => this._mountInputPlaceholder(unitId, paragraphBound.firstLine));
581
582
  this._inputPlaceholderRenderRoot.mount();
582
- const disposable = this._docCanvasPopupManagerService.attachPopupToRect(paragraphBound.firstLine, {
583
+ const layoutInteraction = this._docLayoutInteractionService.beginInteraction();
584
+ const popupDisposable = this._docCanvasPopupManagerService.attachPopupToRect(paragraphBound.firstLine, {
583
585
  componentKey: QuickInsertPopup.componentKey,
584
586
  onClickOutside: () => {
585
587
  this.closePopup();
586
588
  },
587
589
  direction: "bottom"
588
590
  }, unitId);
591
+ const disposable = new DisposableCollection();
592
+ disposable.add(popupDisposable);
593
+ disposable.add(layoutInteraction);
589
594
  this._editPopup$.next({
590
595
  disposable,
591
596
  popup,
@@ -621,7 +626,8 @@ DocQuickInsertPopupService = __decorate([
621
626
  __decorateParam(1, Inject(IUniverInstanceService)),
622
627
  __decorateParam(2, Inject(ICommandService)),
623
628
  __decorateParam(3, Inject(IRenderManagerService)),
624
- __decorateParam(4, Inject(DocSelectionManagerService))
629
+ __decorateParam(4, Inject(DocSelectionManagerService)),
630
+ __decorateParam(5, Inject(DocLayoutInteractionService))
625
631
  ], DocQuickInsertPopupService);
626
632
 
627
633
  //#endregion
@@ -864,7 +870,7 @@ DocQuickInsertUIController = __decorate([__decorateParam(0, ICommandService), __
864
870
  //#endregion
865
871
  //#region package.json
866
872
  var name = "@univerjs/docs-quick-insert-ui";
867
- var version = "1.0.0-insiders.20260809-70eefdd";
873
+ var version = "1.0.0-rc.0";
868
874
 
869
875
  //#endregion
870
876
  //#region src/config/config.ts
@@ -966,7 +972,7 @@ const QuickInsertButton = ({ className = "" }) => {
966
972
  return /* @__PURE__ */ jsx("div", {
967
973
  className: clsx("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", borderClassName, {
968
974
  "univer-bg-gray-100 dark:!univer-bg-gray-700": editPopup,
969
- "univer-bg-white dark:!univer-bg-gray-900": !editPopup
975
+ "univer-bg-gray-0 dark:!univer-bg-gray-900": !editPopup
970
976
  }, className),
971
977
  role: "button",
972
978
  tabIndex: 0,
@@ -18,7 +18,7 @@ import type { IInsertTextCommandParams } from '@univerjs/docs';
18
18
  import type { Observable } from 'rxjs';
19
19
  import { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
20
20
  import { DocSelectionManagerService } from '@univerjs/docs';
21
- import { DocCanvasPopManagerService } from '@univerjs/docs-ui';
21
+ import { DocCanvasPopManagerService, DocLayoutInteractionService } from '@univerjs/docs-ui';
22
22
  import { IRenderManagerService } from '@univerjs/engine-render';
23
23
  export interface IDocPopupGroupItem {
24
24
  id: string;
@@ -45,6 +45,7 @@ export declare class DocQuickInsertPopupService extends Disposable {
45
45
  private readonly _commandService;
46
46
  private readonly _renderManagerService;
47
47
  private readonly _docSelectionManagerService;
48
+ private readonly _docLayoutInteractionService;
48
49
  private readonly _popups;
49
50
  get popups(): IDocPopup[];
50
51
  private readonly _editPopup$;
@@ -80,8 +81,8 @@ export declare class DocQuickInsertPopupService extends Disposable {
80
81
  readonly filterKeyword$: Observable<string>;
81
82
  private _menuSelectedCallbacks;
82
83
  private _inputPlaceholderRenderRoot;
83
- private getDocEventManagerService;
84
- constructor(_docCanvasPopupManagerService: DocCanvasPopManagerService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _renderManagerService: IRenderManagerService, _docSelectionManagerService: DocSelectionManagerService);
84
+ private _getDocEventManagerService;
85
+ constructor(_docCanvasPopupManagerService: DocCanvasPopManagerService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _renderManagerService: IRenderManagerService, _docSelectionManagerService: DocSelectionManagerService, _docLayoutInteractionService: DocLayoutInteractionService);
85
86
  resolvePopup(keyword: string): IDocPopup | undefined;
86
87
  registerPopup(popup: IDocPopup): () => void;
87
88
  private _createInputPlaceholderRenderRoot;
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/ui"),require("@univerjs/engine-render"),require("rxjs"),require("react"),require("react/jsx-runtime"),require("@univerjs/design"),require("@univerjs/docs-drawing-ui"),require("@univerjs/docs-drawing"),require("@univerjs/drawing"),require("@univerjs/drawing-ui")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/docs`,`@univerjs/docs-ui`,`@univerjs/ui`,`@univerjs/engine-render`,`rxjs`,`react`,`react/jsx-runtime`,`@univerjs/design`,`@univerjs/docs-drawing-ui`,`@univerjs/docs-drawing`,`@univerjs/drawing`,`@univerjs/drawing-ui`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsQuickInsertUi={},e.UniverCore,e.UniverDocs,e.UniverDocsUi,e.UniverUi,e.UniverEngineRender,e.rxjs,e.React,e.React,e.UniverDesign,e.UniverDocsDrawingUi,e.UniverDocsDrawing,e.UniverDrawing,e.UniverDrawingUi))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let m={id:`doc.command.delete-search-key`,type:t.CommandType.COMMAND,handler:(e,n)=>{let i=e.get(t.ICommandService),{start:a,end:o}=n;return i.syncExecuteCommand(r.CutContentCommand.id,{segmentId:``,textRanges:[{startOffset:a,endOffset:a,collapsed:!0}],selections:[{startOffset:a,endOffset:o,collapsed:!1,direction:t.RANGE_DIRECTION.FORWARD}]})}},h=`docs.quick.insert.keyword-input-placeholder`;function g(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}let _=({popup:e})=>{var n,r,o,l,u,d,f;let p=(0,i.useDependency)(t.LocaleService).t(`docs-quick-insert-ui.keywordInputPlaceholder`),m=(0,a.ptToPixel)(((n=e.extraProps)==null?void 0:n.fontSize)??11),h=((r=e.extraProps)==null?void 0:r.fontString)??`${m}px sans-serif`,_=((o=e.extraProps)==null?void 0:o.ascent)??m,v=Math.max(((l=e.extraProps)==null?void 0:l.contentHeight)??m,m),y=(0,s.useMemo)(()=>g(p,h),[h,p]);return(0,c.jsx)(`div`,{className:`univer-select-none univer-font-normal univer-text-gray-500 univer-transition-colors dark:!univer-text-gray-400`,children:(0,c.jsx)(`svg`,{width:y,height:v,viewBox:`0 0 ${y} ${v}`,style:{overflow:`visible`,display:`block`},children:(0,c.jsx)(`text`,{x:0,y:_,fill:`currentColor`,style:{font:h,fontFamily:(u=e.extraProps)==null?void 0:u.fontFamily,fontStyle:(d=e.extraProps)==null?void 0:d.fontStyle,fontWeight:(f=e.extraProps)==null?void 0:f.fontWeight},children:p})})})};_.componentKey=h;function v(e){return`children`in e}function y(e){return e.flatMap(e=>v(e)?y(e.children):e)}function ee(e){return y(e).length}function te(e){let{menus:t,focusedMenuIndex:n,onFocusedMenuIndexChange:r,onFocusedMenuChange:a,onSelect:o}=e,u=(0,i.useDependency)(i.IconManager),d=(0,s.useMemo)(()=>y(t),[t]),f=(0,s.useRef)(new Map);(0,s.useEffect)(()=>{var e;let t=Number.isNaN(n)?null:d[n]??null;a(t),t&&((e=f.current.get(t.id))==null||e.scrollIntoView({block:`nearest`}))},[d,n,a]),(0,s.useEffect)(()=>{let e=f.current;return()=>{e.clear()}},[]);let p=(0,s.useRef)(0);p.current=0;function m(e){return e.map((t,i)=>{let a=t.icon,s=a?u.get(a):null;if(v(t))return(0,c.jsxs)(`div`,{className:(0,l.clsx)(`univer-grid univer-gap-1 univer-py-1`,i!==e.length-1&&l.borderBottomClassName),children:[(0,c.jsxs)(`div`,{className:`univer-box-border univer-inline-flex univer-items-center univer-gap-2 univer-px-2 univer-text-xs univer-font-semibold univer-text-gray-600 dark:!univer-text-gray-300`,children:[s&&(0,c.jsx)(`span`,{className:`univer-inline-flex univer-text-base`,children:(0,c.jsx)(s,{})}),(0,c.jsx)(`span`,{children:t.title})]}),(0,c.jsx)(`div`,{className:`univer-grid univer-gap-1`,children:m(t.children)})]},t.id);let d=p.current,h=n===d;return p.current+=1,(0,c.jsx)(`div`,{ref:e=>{if(e){f.current.set(t.id,e);return}f.current.delete(t.id)},role:`button`,tabIndex:-1,className:(0,l.clsx)(`univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-justify-between univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-900 univer-outline-none hover:univer-bg-gray-50 dark:!univer-text-white dark:hover:!univer-bg-gray-600`,{"hover:univer-bg-transparent":!h,"univer-bg-gray-50 dark:!univer-bg-gray-600":h}),onMouseEnter:()=>r(d),onMouseLeave:()=>r(NaN),onClick:()=>o(t),children:(0,c.jsxs)(`div`,{className:`univer-inline-flex univer-w-full univer-items-center univer-gap-2`,children:[s&&(0,c.jsx)(`span`,{className:`univer-inline-flex univer-text-base`,children:(0,c.jsx)(s,{})}),(0,c.jsx)(l.Tooltip,{showIfEllipsis:!0,title:t.title,placement:`right`,children:(0,c.jsx)(`span`,{className:`univer-truncate`,children:t.title})})]})},t.id)})}return(0,c.jsx)(`div`,{className:(0,l.clsx)(`univer-box-border univer-grid univer-max-h-[360px] univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-overscroll-contain univer-rounded-md univer-bg-white univer-px-2 univer-py-1 univer-text-sm univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-700 dark:!univer-text-white`,l.borderClassName,l.scrollbarClassName),onWheel:e=>e.stopPropagation(),children:m(t)})}let b=`docs.quick.insert.placeholder`,x=()=>(0,c.jsx)(`div`,{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`,children:(0,c.jsx)(`span`,{children:(0,i.useDependency)(t.LocaleService).t(`docs-quick-insert-ui.placeholder`)})});x.componentKey=b;function S(e,t){return e.map(e=>({...e})).filter(e=>{if(`children`in e)return e.children=S(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 C(e,t){return e.map(e=>{let n={...e};return`children`in n&&(n.children=C(n.children,t)),n.title=t.t(n.title),`keywords`in n&&(n.keywords=n.keywords.concat(n.title).map(e=>e.toLowerCase())),n})}let w=[i.KeyCode.ARROW_UP,i.KeyCode.ARROW_DOWN,i.KeyCode.ENTER],T=()=>{let e=(0,i.useDependency)(t.LocaleService),n=(0,i.useDependency)(M),r=(0,i.useDependency)(i.IShortcutService),a=(0,i.useDependency)(t.ICommandService),o=(0,s.useMemo)(()=>(0,t.generateRandomId)(),[]),[l,u]=(0,s.useState)(0),d=(0,s.useRef)(null),f=(0,i.useObservable)(n.filterKeyword$,``),p=(0,i.useObservable)(n.editPopup$),m=(0,i.useObservable)(p==null?void 0:p.popup.menus$,[]),h=(0,s.useMemo)(()=>C(m,e),[m]),[g,_]=(0,s.useState)(()=>S(h,f.toLowerCase())),v=(0,s.useMemo)(()=>ee(g),[g]),y=(0,s.useRef)(v);(0,s.useEffect)(()=>{y.current=v},[v]),(0,s.useEffect)(()=>{let e=requestIdleCallback(()=>{_(S(h,f.toLowerCase()))});return()=>{cancelIdleCallback(e)}},[h,f]);let b=e=>{n.emitMenuSelected(e),a.executeCommand(P.id)},T=(0,s.useCallback)(e=>{d.current=e},[]);(0,s.useEffect)(()=>{let e=new t.DisposableCollection;r.getAllShortcuts().filter(e=>e.binding&&w.includes(e.binding)).forEach(n=>{let r=n.preconditions;n.preconditions=()=>!1,e.add((0,t.toDisposable)(()=>{n.preconditions=r}))});let n={id:`quick.insert.popup.enter.${o}`,type:t.CommandType.OPERATION,handler:()=>{let e=d.current;e&&b(e)}},s={id:`quick.insert.popup.move.cursor.up.${o}`,type:t.CommandType.OPERATION,handler:()=>{u(e=>{if(y.current<=0)return 0;let t=e-1;return t>=0?t:y.current-1})}},c={id:`quick.insert.popup.move.cursor.down.${o}`,type:t.CommandType.OPERATION,handler:()=>{u(e=>{if(y.current<=0)return 0;let t=e+1;return t<=y.current-1?t:0})}};return e.add(a.registerCommand(s)),e.add(a.registerCommand(c)),e.add(a.registerCommand(n)),e.add(r.registerShortcut({priority:1e3,id:s.id,binding:i.KeyCode.ARROW_UP,preconditions:()=>!0,staticParameters:{direction:t.Direction.UP}})),e.add(r.registerShortcut({priority:1e3,id:c.id,binding:i.KeyCode.ARROW_DOWN,preconditions:()=>!0,staticParameters:{direction:t.Direction.DOWN}})),e.add(r.registerShortcut({priority:1e3,id:n.id,binding:i.KeyCode.ENTER,preconditions:()=>!0})),()=>{e.dispose()}},[a,o,r]),(0,s.useEffect)(()=>{u(0)},[g]);let E=g.length>0,D=(p==null?void 0:p.popup.Placeholder)||x;return(0,c.jsx)(`div`,{className:`univer-mt-2`,children:E?(0,c.jsx)(te,{menus:g,focusedMenuIndex:l,onFocusedMenuIndexChange:u,onFocusedMenuChange:T,onSelect:b}):D&&(0,c.jsx)(D,{})})};T.componentKey=`docs.quick.insert.popup`;function E(e){"@babel/helpers - typeof";return E=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},E(e)}function D(e,t){if(E(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(E(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ne(e){var t=D(e,`string`);return E(t)==`symbol`?t:t+``}function O(e,t,n){return(t=ne(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 A(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}let j={dispose:()=>{}},M=class extends t.Disposable{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.getRenderUnitById(e))==null?void 0:t.with(r.DocEventManagerService)}constructor(e,n,r,i,a){super(),this._docCanvasPopupManagerService=e,this._univerInstanceService=n,this._commandService=r,this._renderManagerService=i,this._docSelectionManagerService=a,O(this,`_popups`,new Set),O(this,`_editPopup$`,new o.BehaviorSubject(void 0)),O(this,`editPopup$`,this._editPopup$.asObservable()),O(this,`_isComposing$`,new o.BehaviorSubject(!1)),O(this,`isComposing$`,this._isComposing$.asObservable()),O(this,`_inputOffset$`,new o.BehaviorSubject({start:0,end:0})),O(this,`inputOffset$`,this._inputOffset$.asObservable()),O(this,`filterKeyword$`,void 0),O(this,`_menuSelectedCallbacks`,new Set),O(this,`_inputPlaceholderRenderRoot`,null),this.disposeWithMe(this._editPopup$);let s=(e,n)=>{var r;return(r=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC))==null||(r=r.getBody())==null?void 0:r.dataStream.slice(e,n)},c=``;this.filterKeyword$=this._inputOffset$.pipe((0,o.map)(e=>{let t=s(e.start,e.end);return(t==null?void 0:t.slice(1))??``}),(0,o.distinctUntilChanged)(),(0,o.tap)(e=>{c=e})),this.disposeWithMe((0,o.combineLatest)([this.filterKeyword$.pipe((0,o.tap)(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((0,o.tap)(e=>{if(e){var t;(t=this._inputPlaceholderRenderRoot)==null||(t=t.unmount)==null||t.dispose()}else{var n;c.length<=0&&((n=this._inputPlaceholderRenderRoot)==null||n.mount())}})),this.editPopup$.pipe((0,o.tap)(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;let r=this._univerInstanceService.getUnit(e),i=r==null||(n=r.getBody())==null||(n=n.paragraphs)==null?void 0:n.find(e=>e.startIndex>t);if(!i)return null;let a=this.getDocEventManagerService(e);return(a==null?void 0:a.findParagraphBoundByIndex(i.startIndex))??null}_getKeywordPlaceholderAnchorRect(e,t,n,i){let a=t.findNodePositionByCharIndex(n.startOffset,!0,n.segmentId,n.segmentPage);if(!a)return i;let o=e.getOffsetConfig(),{contentBoxPointGroup:s}=new r.NodePositionConvertToCursor(o,t).getRangePointData(a,a);if(s.length===0)return i;let c=(0,r.getAnchorBounding)(s),l=c.left+o.docsLeft,u=c.top+o.docsTop;return{left:l,right:l,top:u,bottom:u+c.height}}_getKeywordPlaceholderExtraProps(e){var t,n,r,i,a,o,s,c,l;return{fontSize:(t=e.ts)==null?void 0:t.fs,fontString:(n=e.fontStyle)==null?void 0:n.fontString,fontFamily:((r=e.fontStyle)==null?void 0:r.fontFamily)??((i=e.ts)==null?void 0:i.ff)??void 0,fontStyle:(a=e.ts)!=null&&a.it?`italic`:`normal`,fontWeight:(o=e.ts)!=null&&o.bl?`bold`:`normal`,ascent:(s=e.bBox)==null?void 0:s.ba,contentHeight:(((c=e.bBox)==null?void 0:c.ba)??0)+(((l=e.bBox)==null?void 0:l.bd)??0)||void 0}}_mountInputPlaceholder(e,t){let r=this._renderManagerService.getRenderUnitById(e),i=r==null?void 0:r.with(n.DocSkeletonManagerService),a=this._docSelectionManagerService.getActiveTextRange();if(!r||!i||!a)return j;let o=i.getSkeleton(),s=o.findNodeByCharIndex(a.startOffset,a.segmentId,a.segmentPage);if((s==null?void 0:s.content)!==`\r`||!s)return j;let c=r.mainComponent,l=this._getKeywordPlaceholderAnchorRect(c,o,a,t),u=this._getKeywordPlaceholderExtraProps(s),d=this._docCanvasPopupManagerService.attachPopupToRect(l,{componentKey:_.componentKey,extraProps:u,onClickOutside:()=>{d.dispose()},direction:`horizontal`},e);return d}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:T.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(m.id,{start:t,end:n}),setTimeout(()=>{this._menuSelectedCallbacks.forEach(t=>t(e))},0)}};M=A([k(0,(0,t.Inject)(r.DocCanvasPopManagerService)),k(1,(0,t.Inject)(t.IUniverInstanceService)),k(2,(0,t.Inject)(t.ICommandService)),k(3,(0,t.Inject)(a.IRenderManagerService)),k(4,(0,t.Inject)(n.DocSelectionManagerService))],M);let N={type:t.CommandType.OPERATION,id:`doc.operation.show-quick-insert-popup`,handler(e,t){let n=e.get(M);return t?(n.showPopup(t),!0):!1}},P={type:t.CommandType.OPERATION,id:`doc.operation.close-quick-insert-popup`,handler(e){return e.get(M).closePopup(),!0}},F={id:`quick-insert.text.menu`,title:`docs-quick-insert-ui.menu.text`,icon:`TextIcon`,keywords:[`text`]},I={id:r.OrderListCommand.id,title:`docs-quick-insert-ui.menu.numberedList`,icon:`OrderIcon`,keywords:[`numbered`,`list`,`ordered`]},L={id:r.BulletListCommand.id,title:`docs-quick-insert-ui.menu.bulletedList`,icon:`UnorderIcon`,keywords:[`bulleted`,`list`,`unordered`]},R={id:r.HorizontalLineCommand.id,title:`docs-quick-insert-ui.menu.divider`,icon:`DividerIcon`,keywords:[`divider`,`line`,`separate`]},z={id:r.DocCreateTableOperation.id,title:`docs-quick-insert-ui.menu.table`,icon:`GridIcon`,keywords:[`table`,`grid`,`spreadsheet`]},B={id:u.InsertDocImageCommand.id,title:`docs-quick-insert-ui.menu.image`,icon:`AdditionAndSubtractionIcon`,keywords:[`image`,`picture`,`photo`]},re=[{title:`docs-quick-insert-ui.group.basics`,id:`quick.insert.group.basic`,children:[F,I,L,R,z,B]}],ie=new Set([I.id,L.id,R.id,z.id,B.id]),V=class extends t.Disposable{constructor(e,t,n,r,a){super(),this._commandService=e,this._textSelectionManagerService=t,this._docQuickInsertPopupService=n,this._shortcutService=r,this._univerInstanceService=a,this.disposeWithMe(this._shortcutService.registerShortcut({id:P.id,binding:i.KeyCode.ESC,preconditions:()=>!!this._docQuickInsertPopupService.editPopup,priority:1e3})),this._initTrigger(),this._initMenuHandler()}_initTrigger(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{let{_docQuickInsertPopupService:i,_textSelectionManagerService:a,_commandService:o}=this,s=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!(s!=null&&s.getDisabled())){if(e.id===n.InsertTextCommand.id){let t=e.params;if(i.editPopup){i.setInputOffset({start:i.inputOffset.start,end:t.range.endOffset+1});return}let n=a.getActiveTextRange();if(!n)return;let r=i.resolvePopup(t.body.dataStream);if(!r||!(!r.preconditions||r.preconditions(t)))return;i.setInputOffset({start:n.startOffset-1,end:n.startOffset}),setTimeout(()=>{o.executeCommand(N.id,{index:n.startOffset-1,unitId:t.unitId,popup:r})},100)}if(e.id===r.IMEInputCommand.id){let t=e.params;!i.isComposing&&t.isCompositionStart&&i.setIsComposing(!0),i.isComposing&&t.isCompositionEnd&&i.setIsComposing(!1)}if(e.id===n.RichTextEditingMutation.id){let t=e.params;if(t.isCompositionEnd){var c;let e=(c=t.textRanges)==null||(c=c[0])==null?void 0:c.endOffset;e&&i.setInputOffset({start:i.inputOffset.start,end:e})}}if(e.id===n.DeleteTextCommand.id){let n=e.params;if(i.editPopup&&n.direction===t.DeleteDirection.LEFT){let e=n.len??0;i.setInputOffset({start:i.inputOffset.start,end:n.range.endOffset-e})}}if(e.id===r.MoveCursorOperation.id){let n=e.params;(n.direction===t.Direction.LEFT||n.direction===t.Direction.RIGHT)&&i.editPopup&&o.executeCommand(P.id)}if(e.id===r.DeleteLeftCommand.id){let e=a.getActiveTextRange();if(!i.editPopup||!e)return;e.endOffset<=i.editPopup.anchor&&o.executeCommand(P.id)}}}))}_initMenuHandler(){this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected(e=>{e.id!==F.id&&ie.has(e.id)&&this._commandService.executeCommand(e.id)}))}};V=A([k(0,t.ICommandService),k(1,(0,t.Inject)(n.DocSelectionManagerService)),k(2,(0,t.Inject)(M)),k(3,(0,t.Inject)(i.IShortcutService)),k(4,(0,t.Inject)(t.IUniverInstanceService))],V);let H=class extends t.Disposable{constructor(e,t){super(),this._commandService=e,this._docQuickInsertPopupService=t,this._initCommands(),this._initComponents(),this._initMenus()}_initCommands(){[m,N,P].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initComponents(){[{keyword:`/`,menus$:(0,o.of)(re),preconditions:e=>{var t;return((t=e.range.startNodePosition)==null?void 0:t.glyph)===0}}].forEach(e=>{this.disposeWithMe(this._docQuickInsertPopupService.registerPopup(e))})}_initMenus(){}};H=A([k(0,t.ICommandService),k(1,(0,t.Inject)(M))],H);var ae=`@univerjs/docs-quick-insert-ui`,oe=`1.0.0-insiders.20260809-70eefdd`;let U={};function W({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,c=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),l=(0,s.useRef)(`_${le()}`);return G(n,`${r}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:c,...o},a)}function G(e,t,n,r,i){return(0,s.createElement)(e.tag,{key:t,...se(e,n,i),...r},(ce(e,n).children||[]).map((r,a)=>G(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function se(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function ce(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function le(){return Math.random().toString(36).substring(2,8)}W.displayName=`UniverIcon`;let ue={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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.13985C3.40213 3.50712 3.1044 3.80485 2.73713 3.80485H1.68453C1.31726 3.80485 1.01953 3.50712 1.01953 3.13985Z`}},{tag:`path`,attrs:{fill:`currentColor`,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`}},{tag:`path`,attrs:{fill:`currentColor`,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`}},{tag:`path`,attrs:{fill:`currentColor`,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`}},{tag:`path`,attrs:{fill:`currentColor`,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`}},{tag:`path`,attrs:{fill:`currentColor`,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`}},{tag:`path`,attrs:{fill:`currentColor`,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`}},{tag:`path`,attrs:{fill:`currentColor`,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`}},{tag:`path`,attrs:{fill:`currentColor`,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`}}]},K=(0,s.forwardRef)(function(e,t){return(0,s.createElement)(W,Object.assign({},e,{id:`divider-icon`,ref:t,icon:ue}))});K.displayName=`DividerIcon`;let de={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,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`}}]},q=(0,s.forwardRef)(function(e,t){return(0,s.createElement)(W,Object.assign({},e,{id:`increase-icon`,ref:t,icon:de}))});q.displayName=`IncreaseIcon`;let fe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`g`,attrs:{fill:`currentColor`,clipPath:`url(#text-icon_clip0_1293_26)`},children:[{tag:`path`,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`}},{tag:`path`,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`}}]},{tag:`defs`,attrs:{},children:[{tag:`clipPath`,attrs:{id:`text-icon_clip0_1293_26`},children:[{tag:`path`,attrs:{fill:`white`,d:`M0 0H16V16H0z`,transform:`translate(.9)`}}]}]}],defIds:[`text-icon_clip0_1293_26`]},J=(0,s.forwardRef)(function(e,t){return(0,s.createElement)(W,Object.assign({},e,{id:`text-icon`,ref:t,icon:fe}))});J.displayName=`TextIcon`;let Y=class extends t.Disposable{get popup(){return this._popup$.value}constructor(e,t,n,r){super(),this._context=e,this._docEventManagerService=t,this._docQuickInsertPopupService=n,this._docCanvasPopManagerService=r,O(this,`_popup$`,new o.BehaviorSubject(null)),O(this,`popup$`,this._popup$.asObservable()),this._init()}_init(){this.disposeWithMe((0,o.combineLatest)([this._docEventManagerService.hoverParagraphLeftRealTime$,this._docEventManagerService.hoverParagraphRealTime$]).subscribe(([e,t])=>{let n=e??t,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:X,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))}};Y=A([k(1,(0,t.Inject)(r.DocEventManagerService)),k(2,(0,t.Inject)(M)),k(3,(0,t.Inject)(r.DocCanvasPopManagerService))],Y);let X=`doc.quick-insert.button`,Z=({className:e=``})=>{let r=(0,i.useDependency)(M),u=(0,i.useDependency)(t.IUniverInstanceService),d=(0,i.useDependency)(a.IRenderManagerService),f=(0,i.useObservable)((0,s.useMemo)(()=>u.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),[u])),p=f&&d.getRenderUnitById(f.getUnitId()),m=p==null?void 0:p.with(Y),h=(0,i.useDependency)(i.ILayoutService),g=(0,i.useDependency)(n.DocSelectionManagerService),_=(0,i.useObservable)(r.editPopup$),v=(0,i.useEvent)(()=>{let e=m==null?void 0:m.popup;if(!e)return;let t=r.popups,n={keyword:``,menus$:(0,o.combineLatest)(t.map(e=>e.menus$)).pipe((0,o.map)(e=>e.flat()))};g.replaceDocRanges([{startOffset:e.startIndex,endOffset:e.startIndex}]),r.setInputOffset({start:e.startIndex-1,end:e.startIndex-1}),r.showPopup({popup:n,index:e.startIndex-1,unitId:(f==null?void 0:f.getUnitId())??``}),setTimeout(()=>{h.focus()})});return(0,c.jsx)(`div`,{className:(0,l.clsx)(`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`,l.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-700":_,"univer-bg-white dark:!univer-bg-gray-900":!_},e),role:`button`,tabIndex:0,onClick:v,children:(0,c.jsx)(q,{className:`univer-text-gray-800 dark:!univer-text-gray-200`})})};Z.componentKey=X;let Q=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerIcons(),this._registerComponents()}_registerIcons(){this.disposeWithMe(this._iconManager.register({DividerIcon:K,TextIcon:J}))}_registerComponents(){[[T.componentKey,T],[_.componentKey,_],[x.componentKey,x],[Z.componentKey,Z]].forEach(([e,t])=>{e&&this.disposeWithMe(this._componentManager.register(e,t))})}};Q=A([k(0,(0,t.Inject)(i.ComponentManager)),k(1,(0,t.Inject)(i.IconManager))],Q);let $=class extends t.Plugin{constructor(e=U,n,r,i){super(),this._config=e,this._injector=n,this._renderManagerSrv=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},U,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(`docs-quick-insert-ui.config`,o)}onStarting(){this._injector.add([Q]),this._injector.get(Q),[[H],[V],[M]].forEach(e=>this._injector.add(e)),this._injector.get(H)}onRendered(){this._injector.get(V),this._injector.get(M),[[Y]].forEach(e=>{this._renderManagerSrv.registerRenderModule(t.UniverInstanceType.UNIVER_DOC,e)})}};O($,`type`,t.UniverInstanceType.UNIVER_DOC),O($,`pluginName`,`DOC_QUICK_INSERT_UI_PLUGIN`),O($,`packageName`,ae),O($,`version`,oe),$=A([(0,t.DependentOn)(n.UniverDocsPlugin,f.UniverDrawingPlugin,a.UniverRenderEnginePlugin,d.UniverDocsDrawingPlugin,r.UniverDocsUIPlugin,p.UniverDrawingUIPlugin,u.UniverDocsDrawingUIPlugin),k(1,(0,t.Inject)(t.Injector)),k(2,(0,t.Inject)(a.IRenderManagerService)),k(3,t.IConfigService)],$),Object.defineProperty(e,"DocQuickInsertPopupService",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"DocQuickInsertTriggerController",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DocQuickInsertUIController",{enumerable:!0,get:function(){return H}}),e.KeywordInputPlaceholderComponentKey=h,e.QuickInsertPlaceholderComponentKey=b,Object.defineProperty(e,"UniverDocsQuickInsertUIPlugin",{enumerable:!0,get:function(){return $}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/ui"),require("@univerjs/engine-render"),require("rxjs"),require("react"),require("react/jsx-runtime"),require("@univerjs/design"),require("@univerjs/docs-drawing-ui"),require("@univerjs/docs-drawing"),require("@univerjs/drawing"),require("@univerjs/drawing-ui")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/docs`,`@univerjs/docs-ui`,`@univerjs/ui`,`@univerjs/engine-render`,`rxjs`,`react`,`react/jsx-runtime`,`@univerjs/design`,`@univerjs/docs-drawing-ui`,`@univerjs/docs-drawing`,`@univerjs/drawing`,`@univerjs/drawing-ui`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsQuickInsertUi={},e.UniverCore,e.UniverDocs,e.UniverDocsUi,e.UniverUi,e.UniverEngineRender,e.rxjs,e.React,e.React,e.UniverDesign,e.UniverDocsDrawingUi,e.UniverDocsDrawing,e.UniverDrawing,e.UniverDrawingUi))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let m={id:`doc.command.delete-search-key`,type:t.CommandType.COMMAND,handler:(e,n)=>{let i=e.get(t.ICommandService),{start:a,end:o}=n;return i.syncExecuteCommand(r.CutContentCommand.id,{segmentId:``,textRanges:[{startOffset:a,endOffset:a,collapsed:!0}],selections:[{startOffset:a,endOffset:o,collapsed:!1,direction:t.RANGE_DIRECTION.FORWARD}]})}},h=`docs.quick.insert.keyword-input-placeholder`;function g(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}let _=({popup:e})=>{var n,r,o,l,u,d,f;let p=(0,i.useDependency)(t.LocaleService).t(`docs-quick-insert-ui.keywordInputPlaceholder`),m=(0,a.ptToPixel)(((n=e.extraProps)==null?void 0:n.fontSize)??11),h=((r=e.extraProps)==null?void 0:r.fontString)??`${m}px sans-serif`,_=((o=e.extraProps)==null?void 0:o.ascent)??m,v=Math.max(((l=e.extraProps)==null?void 0:l.contentHeight)??m,m),y=(0,s.useMemo)(()=>g(p,h),[h,p]);return(0,c.jsx)(`div`,{className:`univer-select-none univer-font-normal univer-text-gray-500 univer-transition-colors dark:!univer-text-gray-400`,children:(0,c.jsx)(`svg`,{width:y,height:v,viewBox:`0 0 ${y} ${v}`,style:{overflow:`visible`,display:`block`},children:(0,c.jsx)(`text`,{x:0,y:_,fill:`currentColor`,style:{font:h,fontFamily:(u=e.extraProps)==null?void 0:u.fontFamily,fontStyle:(d=e.extraProps)==null?void 0:d.fontStyle,fontWeight:(f=e.extraProps)==null?void 0:f.fontWeight},children:p})})})};_.componentKey=h;function v(e){return`children`in e}function y(e){return e.flatMap(e=>v(e)?y(e.children):e)}function ee(e){return y(e).length}function te(e){let{menus:t,focusedMenuIndex:n,onFocusedMenuIndexChange:r,onFocusedMenuChange:a,onSelect:o}=e,u=(0,i.useDependency)(i.IconManager),d=(0,s.useMemo)(()=>y(t),[t]),f=(0,s.useRef)(new Map);(0,s.useEffect)(()=>{var e;let t=Number.isNaN(n)?null:d[n]??null;a(t),t&&((e=f.current.get(t.id))==null||e.scrollIntoView({block:`nearest`}))},[d,n,a]),(0,s.useEffect)(()=>{let e=f.current;return()=>{e.clear()}},[]);let p=(0,s.useRef)(0);p.current=0;function m(e){return e.map((t,i)=>{let a=t.icon,s=a?u.get(a):null;if(v(t))return(0,c.jsxs)(`div`,{className:(0,l.clsx)(`univer-grid univer-gap-1 univer-py-1`,i!==e.length-1&&l.borderBottomClassName),children:[(0,c.jsxs)(`div`,{className:`univer-box-border univer-inline-flex univer-items-center univer-gap-2 univer-px-2 univer-text-xs univer-font-semibold univer-text-gray-600 dark:!univer-text-gray-300`,children:[s&&(0,c.jsx)(`span`,{className:`univer-inline-flex univer-text-base`,children:(0,c.jsx)(s,{})}),(0,c.jsx)(`span`,{children:t.title})]}),(0,c.jsx)(`div`,{className:`univer-grid univer-gap-1`,children:m(t.children)})]},t.id);let d=p.current,h=n===d;return p.current+=1,(0,c.jsx)(`div`,{ref:e=>{if(e){f.current.set(t.id,e);return}f.current.delete(t.id)},role:`button`,tabIndex:-1,className:(0,l.clsx)(`univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-justify-between univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-900 univer-outline-none hover:univer-bg-gray-50 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-600`,{"hover:univer-bg-transparent":!h,"univer-bg-gray-50 dark:!univer-bg-gray-600":h}),onMouseEnter:()=>r(d),onMouseLeave:()=>r(NaN),onClick:()=>o(t),children:(0,c.jsxs)(`div`,{className:`univer-inline-flex univer-w-full univer-items-center univer-gap-2`,children:[s&&(0,c.jsx)(`span`,{className:`univer-inline-flex univer-text-base`,children:(0,c.jsx)(s,{})}),(0,c.jsx)(l.Tooltip,{showIfEllipsis:!0,title:t.title,placement:`right`,children:(0,c.jsx)(`span`,{className:`univer-truncate`,children:t.title})})]})},t.id)})}return(0,c.jsx)(`div`,{className:(0,l.clsx)(`univer-box-border univer-grid univer-max-h-[360px] univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-overscroll-contain univer-rounded-md univer-bg-gray-0 univer-px-2 univer-py-1 univer-text-sm univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-700 dark:!univer-text-gray-0`,l.borderClassName,l.scrollbarClassName),onWheel:e=>e.stopPropagation(),children:m(t)})}let b=`docs.quick.insert.placeholder`,x=()=>(0,c.jsx)(`div`,{className:`univer-flex univer-h-full univer-items-center univer-justify-center univer-rounded-lg univer-bg-gray-0 univer-px-12 univer-py-6 univer-text-gray-400 univer-shadow-lg`,children:(0,c.jsx)(`span`,{children:(0,i.useDependency)(t.LocaleService).t(`docs-quick-insert-ui.placeholder`)})});x.componentKey=b;function S(e,t){return e.map(e=>({...e})).filter(e=>{if(`children`in e)return e.children=S(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 C(e,t){return e.map(e=>{let n={...e};return`children`in n&&(n.children=C(n.children,t)),n.title=t.t(n.title),`keywords`in n&&(n.keywords=n.keywords.concat(n.title).map(e=>e.toLowerCase())),n})}let w=[i.KeyCode.ARROW_UP,i.KeyCode.ARROW_DOWN,i.KeyCode.ENTER],T=()=>{let e=(0,i.useDependency)(t.LocaleService),n=(0,i.useDependency)(M),r=(0,i.useDependency)(i.IShortcutService),a=(0,i.useDependency)(t.ICommandService),o=(0,s.useMemo)(()=>(0,t.generateRandomId)(),[]),[l,u]=(0,s.useState)(0),d=(0,s.useRef)(null),f=(0,i.useObservable)(n.filterKeyword$,``),p=(0,i.useObservable)(n.editPopup$),m=(0,i.useObservable)(p==null?void 0:p.popup.menus$,[]),h=(0,s.useMemo)(()=>C(m,e),[m]),[g,_]=(0,s.useState)(()=>S(h,f.toLowerCase())),v=(0,s.useMemo)(()=>ee(g),[g]),y=(0,s.useRef)(v);(0,s.useEffect)(()=>{y.current=v},[v]),(0,s.useEffect)(()=>{let e=requestIdleCallback(()=>{_(S(h,f.toLowerCase()))});return()=>{cancelIdleCallback(e)}},[h,f]);let b=e=>{n.emitMenuSelected(e),a.executeCommand(P.id)},T=(0,s.useCallback)(e=>{d.current=e},[]);(0,s.useEffect)(()=>{let e=new t.DisposableCollection;r.getAllShortcuts().filter(e=>e.binding&&w.includes(e.binding)).forEach(n=>{let r=n.preconditions;n.preconditions=()=>!1,e.add((0,t.toDisposable)(()=>{n.preconditions=r}))});let n={id:`quick.insert.popup.enter.${o}`,type:t.CommandType.OPERATION,handler:()=>{let e=d.current;e&&b(e)}},s={id:`quick.insert.popup.move.cursor.up.${o}`,type:t.CommandType.OPERATION,handler:()=>{u(e=>{if(y.current<=0)return 0;let t=e-1;return t>=0?t:y.current-1})}},c={id:`quick.insert.popup.move.cursor.down.${o}`,type:t.CommandType.OPERATION,handler:()=>{u(e=>{if(y.current<=0)return 0;let t=e+1;return t<=y.current-1?t:0})}};return e.add(a.registerCommand(s)),e.add(a.registerCommand(c)),e.add(a.registerCommand(n)),e.add(r.registerShortcut({priority:1e3,id:s.id,binding:i.KeyCode.ARROW_UP,preconditions:()=>!0,staticParameters:{direction:t.Direction.UP}})),e.add(r.registerShortcut({priority:1e3,id:c.id,binding:i.KeyCode.ARROW_DOWN,preconditions:()=>!0,staticParameters:{direction:t.Direction.DOWN}})),e.add(r.registerShortcut({priority:1e3,id:n.id,binding:i.KeyCode.ENTER,preconditions:()=>!0})),()=>{e.dispose()}},[a,o,r]),(0,s.useEffect)(()=>{u(0)},[g]);let E=g.length>0,D=(p==null?void 0:p.popup.Placeholder)||x;return(0,c.jsx)(`div`,{className:`univer-mt-2`,children:E?(0,c.jsx)(te,{menus:g,focusedMenuIndex:l,onFocusedMenuIndexChange:u,onFocusedMenuChange:T,onSelect:b}):D&&(0,c.jsx)(D,{})})};T.componentKey=`docs.quick.insert.popup`;function E(e){"@babel/helpers - typeof";return E=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},E(e)}function D(e,t){if(E(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(E(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ne(e){var t=D(e,`string`);return E(t)==`symbol`?t:t+``}function O(e,t,n){return(t=ne(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 A(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}let j={dispose:()=>{}},M=class extends t.Disposable{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.getRenderUnitById(e))==null?void 0:t.with(r.DocEventManagerService)}constructor(e,n,r,i,a,s){super(),this._docCanvasPopupManagerService=e,this._univerInstanceService=n,this._commandService=r,this._renderManagerService=i,this._docSelectionManagerService=a,this._docLayoutInteractionService=s,O(this,`_popups`,new Set),O(this,`_editPopup$`,new o.BehaviorSubject(void 0)),O(this,`editPopup$`,this._editPopup$.asObservable()),O(this,`_isComposing$`,new o.BehaviorSubject(!1)),O(this,`isComposing$`,this._isComposing$.asObservable()),O(this,`_inputOffset$`,new o.BehaviorSubject({start:0,end:0})),O(this,`inputOffset$`,this._inputOffset$.asObservable()),O(this,`filterKeyword$`,void 0),O(this,`_menuSelectedCallbacks`,new Set),O(this,`_inputPlaceholderRenderRoot`,null),this.disposeWithMe(this._editPopup$);let c=(e,n)=>{var r;return(r=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC))==null||(r=r.getBody())==null?void 0:r.dataStream.slice(e,n)},l=``;this.filterKeyword$=this._inputOffset$.pipe((0,o.map)(e=>{let t=c(e.start,e.end);return(t==null?void 0:t.slice(1))??``}),(0,o.distinctUntilChanged)(),(0,o.tap)(e=>{l=e})),this.disposeWithMe((0,o.combineLatest)([this.filterKeyword$.pipe((0,o.tap)(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((0,o.tap)(e=>{if(e){var t;(t=this._inputPlaceholderRenderRoot)==null||(t=t.unmount)==null||t.dispose()}else{var n;l.length<=0&&((n=this._inputPlaceholderRenderRoot)==null||n.mount())}})),this.editPopup$.pipe((0,o.tap)(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;let r=this._univerInstanceService.getUnit(e),i=r==null||(n=r.getBody())==null||(n=n.paragraphs)==null?void 0:n.find(e=>e.startIndex>t);if(!i)return null;let a=this._getDocEventManagerService(e);return(a==null?void 0:a.findParagraphBoundByIndex(i.startIndex))??null}_getKeywordPlaceholderAnchorRect(e,t,n,i){let a=t.findNodePositionByCharIndex(n.startOffset,!0,n.segmentId,n.segmentPage);if(!a)return i;let o=e.getOffsetConfig(),{contentBoxPointGroup:s}=new r.NodePositionConvertToCursor(o,t).getRangePointData(a,a);if(s.length===0)return i;let c=(0,r.getAnchorBounding)(s),l=c.left+o.docsLeft,u=c.top+o.docsTop;return{left:l,right:l,top:u,bottom:u+c.height}}_getKeywordPlaceholderExtraProps(e){var t,n,r,i,a,o,s,c,l;return{fontSize:(t=e.ts)==null?void 0:t.fs,fontString:(n=e.fontStyle)==null?void 0:n.fontString,fontFamily:((r=e.fontStyle)==null?void 0:r.fontFamily)??((i=e.ts)==null?void 0:i.ff)??void 0,fontStyle:(a=e.ts)!=null&&a.it?`italic`:`normal`,fontWeight:(o=e.ts)!=null&&o.bl?`bold`:`normal`,ascent:(s=e.bBox)==null?void 0:s.ba,contentHeight:(((c=e.bBox)==null?void 0:c.ba)??0)+(((l=e.bBox)==null?void 0:l.bd)??0)||void 0}}_mountInputPlaceholder(e,t){let r=this._renderManagerService.getRenderUnitById(e),i=r==null?void 0:r.with(n.DocSkeletonManagerService),a=this._docSelectionManagerService.getActiveTextRange();if(!r||!i||!a)return j;let o=i.getSkeleton(),s=o.findNodeByCharIndex(a.startOffset,a.segmentId,a.segmentPage);if((s==null?void 0:s.content)!==`\r`||!s)return j;let c=r.mainComponent,l=this._getKeywordPlaceholderAnchorRect(c,o,a,t),u=this._getKeywordPlaceholderExtraProps(s),d=this._docCanvasPopupManagerService.attachPopupToRect(l,{componentKey:_.componentKey,extraProps:u,onClickOutside:()=>{d.dispose()},direction:`horizontal`},e);return d}showPopup(e){let{popup:n,index:r,unitId:i}=e;this.closePopup();let a=this._getParagraphBound(i,r);if(!a)return;this._inputPlaceholderRenderRoot=this._createInputPlaceholderRenderRoot(()=>this._mountInputPlaceholder(i,a.firstLine)),this._inputPlaceholderRenderRoot.mount();let o=this._docLayoutInteractionService.beginInteraction(),s=this._docCanvasPopupManagerService.attachPopupToRect(a.firstLine,{componentKey:T.componentKey,onClickOutside:()=>{this.closePopup()},direction:`bottom`},i),c=new t.DisposableCollection;c.add(s),c.add(o),this._editPopup$.next({disposable:c,popup:n,anchor:r,unitId:i})}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(m.id,{start:t,end:n}),setTimeout(()=>{this._menuSelectedCallbacks.forEach(t=>t(e))},0)}};M=A([k(0,(0,t.Inject)(r.DocCanvasPopManagerService)),k(1,(0,t.Inject)(t.IUniverInstanceService)),k(2,(0,t.Inject)(t.ICommandService)),k(3,(0,t.Inject)(a.IRenderManagerService)),k(4,(0,t.Inject)(n.DocSelectionManagerService)),k(5,(0,t.Inject)(r.DocLayoutInteractionService))],M);let N={type:t.CommandType.OPERATION,id:`doc.operation.show-quick-insert-popup`,handler(e,t){let n=e.get(M);return t?(n.showPopup(t),!0):!1}},P={type:t.CommandType.OPERATION,id:`doc.operation.close-quick-insert-popup`,handler(e){return e.get(M).closePopup(),!0}},F={id:`quick-insert.text.menu`,title:`docs-quick-insert-ui.menu.text`,icon:`TextIcon`,keywords:[`text`]},I={id:r.OrderListCommand.id,title:`docs-quick-insert-ui.menu.numberedList`,icon:`OrderIcon`,keywords:[`numbered`,`list`,`ordered`]},L={id:r.BulletListCommand.id,title:`docs-quick-insert-ui.menu.bulletedList`,icon:`UnorderIcon`,keywords:[`bulleted`,`list`,`unordered`]},R={id:r.HorizontalLineCommand.id,title:`docs-quick-insert-ui.menu.divider`,icon:`DividerIcon`,keywords:[`divider`,`line`,`separate`]},z={id:r.DocCreateTableOperation.id,title:`docs-quick-insert-ui.menu.table`,icon:`GridIcon`,keywords:[`table`,`grid`,`spreadsheet`]},B={id:u.InsertDocImageCommand.id,title:`docs-quick-insert-ui.menu.image`,icon:`AdditionAndSubtractionIcon`,keywords:[`image`,`picture`,`photo`]},re=[{title:`docs-quick-insert-ui.group.basics`,id:`quick.insert.group.basic`,children:[F,I,L,R,z,B]}],ie=new Set([I.id,L.id,R.id,z.id,B.id]),V=class extends t.Disposable{constructor(e,t,n,r,a){super(),this._commandService=e,this._textSelectionManagerService=t,this._docQuickInsertPopupService=n,this._shortcutService=r,this._univerInstanceService=a,this.disposeWithMe(this._shortcutService.registerShortcut({id:P.id,binding:i.KeyCode.ESC,preconditions:()=>!!this._docQuickInsertPopupService.editPopup,priority:1e3})),this._initTrigger(),this._initMenuHandler()}_initTrigger(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{let{_docQuickInsertPopupService:i,_textSelectionManagerService:a,_commandService:o}=this,s=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!(s!=null&&s.getDisabled())){if(e.id===n.InsertTextCommand.id){let t=e.params;if(i.editPopup){i.setInputOffset({start:i.inputOffset.start,end:t.range.endOffset+1});return}let n=a.getActiveTextRange();if(!n)return;let r=i.resolvePopup(t.body.dataStream);if(!r||!(!r.preconditions||r.preconditions(t)))return;i.setInputOffset({start:n.startOffset-1,end:n.startOffset}),setTimeout(()=>{o.executeCommand(N.id,{index:n.startOffset-1,unitId:t.unitId,popup:r})},100)}if(e.id===r.IMEInputCommand.id){let t=e.params;!i.isComposing&&t.isCompositionStart&&i.setIsComposing(!0),i.isComposing&&t.isCompositionEnd&&i.setIsComposing(!1)}if(e.id===n.RichTextEditingMutation.id){let t=e.params;if(t.isCompositionEnd){var c;let e=(c=t.textRanges)==null||(c=c[0])==null?void 0:c.endOffset;e&&i.setInputOffset({start:i.inputOffset.start,end:e})}}if(e.id===n.DeleteTextCommand.id){let n=e.params;if(i.editPopup&&n.direction===t.DeleteDirection.LEFT){let e=n.len??0;i.setInputOffset({start:i.inputOffset.start,end:n.range.endOffset-e})}}if(e.id===r.MoveCursorOperation.id){let n=e.params;(n.direction===t.Direction.LEFT||n.direction===t.Direction.RIGHT)&&i.editPopup&&o.executeCommand(P.id)}if(e.id===r.DeleteLeftCommand.id){let e=a.getActiveTextRange();if(!i.editPopup||!e)return;e.endOffset<=i.editPopup.anchor&&o.executeCommand(P.id)}}}))}_initMenuHandler(){this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected(e=>{e.id!==F.id&&ie.has(e.id)&&this._commandService.executeCommand(e.id)}))}};V=A([k(0,t.ICommandService),k(1,(0,t.Inject)(n.DocSelectionManagerService)),k(2,(0,t.Inject)(M)),k(3,(0,t.Inject)(i.IShortcutService)),k(4,(0,t.Inject)(t.IUniverInstanceService))],V);let H=class extends t.Disposable{constructor(e,t){super(),this._commandService=e,this._docQuickInsertPopupService=t,this._initCommands(),this._initComponents(),this._initMenus()}_initCommands(){[m,N,P].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initComponents(){[{keyword:`/`,menus$:(0,o.of)(re),preconditions:e=>{var t;return((t=e.range.startNodePosition)==null?void 0:t.glyph)===0}}].forEach(e=>{this.disposeWithMe(this._docQuickInsertPopupService.registerPopup(e))})}_initMenus(){}};H=A([k(0,t.ICommandService),k(1,(0,t.Inject)(M))],H);var ae=`@univerjs/docs-quick-insert-ui`,oe=`1.0.0-rc.0`;let U={};function W({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...c}=t,l=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,s.useId)()}`,d=(0,s.useRef)(null);return(0,s.useImperativeHandle)(e,()=>d.current),(0,s.useLayoutEffect)(()=>{if(!(!n||!d.current||d.current.localName!==r.tag))return le(d.current)},[n,r]),G(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:l,...c},o)}function G(e,t,n,r,i){return(0,s.createElement)(e.tag,{key:t,...se(e,n,i),...r},(ce(e,n).children||[]).map((r,a)=>G(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function se(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function ce(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function le(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:ue(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(de(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function ue(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function de(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}W.displayName=`UniverIcon`;let fe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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.13985C3.40213 3.50712 3.1044 3.80485 2.73713 3.80485H1.68453C1.31726 3.80485 1.01953 3.50712 1.01953 3.13985Z`}},{tag:`path`,attrs:{fill:`currentColor`,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`}},{tag:`path`,attrs:{fill:`currentColor`,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`}},{tag:`path`,attrs:{fill:`currentColor`,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`}},{tag:`path`,attrs:{fill:`currentColor`,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`}},{tag:`path`,attrs:{fill:`currentColor`,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`}},{tag:`path`,attrs:{fill:`currentColor`,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`}},{tag:`path`,attrs:{fill:`currentColor`,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`}},{tag:`path`,attrs:{fill:`currentColor`,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`}}]},K=(0,s.forwardRef)(function(e,t){return(0,s.createElement)(W,Object.assign({},e,{id:`divider-icon`,ref:t,icon:fe}))});K.displayName=`DividerIcon`;let pe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,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`}}]},q=(0,s.forwardRef)(function(e,t){return(0,s.createElement)(W,Object.assign({},e,{id:`increase-icon`,ref:t,icon:pe}))});q.displayName=`IncreaseIcon`;let me={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.22891 2.67227H11.5622M6.89541 2.67227V14.0056M10.2289 7.00552H15.5622M12.8954 7.00552V14.0055`,strokeLinecap:`round`,strokeWidth:1.2}}]},J=(0,s.forwardRef)(function(e,t){return(0,s.createElement)(W,Object.assign({},e,{id:`text-icon`,ref:t,icon:me}))});J.displayName=`TextIcon`;let Y=class extends t.Disposable{get popup(){return this._popup$.value}constructor(e,t,n,r){super(),this._context=e,this._docEventManagerService=t,this._docQuickInsertPopupService=n,this._docCanvasPopManagerService=r,O(this,`_popup$`,new o.BehaviorSubject(null)),O(this,`popup$`,this._popup$.asObservable()),this._init()}_init(){this.disposeWithMe((0,o.combineLatest)([this._docEventManagerService.hoverParagraphLeftRealTime$,this._docEventManagerService.hoverParagraphRealTime$]).subscribe(([e,t])=>{let n=e??t,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:X,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))}};Y=A([k(1,(0,t.Inject)(r.DocEventManagerService)),k(2,(0,t.Inject)(M)),k(3,(0,t.Inject)(r.DocCanvasPopManagerService))],Y);let X=`doc.quick-insert.button`,Z=({className:e=``})=>{let r=(0,i.useDependency)(M),u=(0,i.useDependency)(t.IUniverInstanceService),d=(0,i.useDependency)(a.IRenderManagerService),f=(0,i.useObservable)((0,s.useMemo)(()=>u.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),[u])),p=f&&d.getRenderUnitById(f.getUnitId()),m=p==null?void 0:p.with(Y),h=(0,i.useDependency)(i.ILayoutService),g=(0,i.useDependency)(n.DocSelectionManagerService),_=(0,i.useObservable)(r.editPopup$),v=(0,i.useEvent)(()=>{let e=m==null?void 0:m.popup;if(!e)return;let t=r.popups,n={keyword:``,menus$:(0,o.combineLatest)(t.map(e=>e.menus$)).pipe((0,o.map)(e=>e.flat()))};g.replaceDocRanges([{startOffset:e.startIndex,endOffset:e.startIndex}]),r.setInputOffset({start:e.startIndex-1,end:e.startIndex-1}),r.showPopup({popup:n,index:e.startIndex-1,unitId:(f==null?void 0:f.getUnitId())??``}),setTimeout(()=>{h.focus()})});return(0,c.jsx)(`div`,{className:(0,l.clsx)(`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`,l.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-700":_,"univer-bg-gray-0 dark:!univer-bg-gray-900":!_},e),role:`button`,tabIndex:0,onClick:v,children:(0,c.jsx)(q,{className:`univer-text-gray-800 dark:!univer-text-gray-200`})})};Z.componentKey=X;let Q=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerIcons(),this._registerComponents()}_registerIcons(){this.disposeWithMe(this._iconManager.register({DividerIcon:K,TextIcon:J}))}_registerComponents(){[[T.componentKey,T],[_.componentKey,_],[x.componentKey,x],[Z.componentKey,Z]].forEach(([e,t])=>{e&&this.disposeWithMe(this._componentManager.register(e,t))})}};Q=A([k(0,(0,t.Inject)(i.ComponentManager)),k(1,(0,t.Inject)(i.IconManager))],Q);let $=class extends t.Plugin{constructor(e=U,n,r,i){super(),this._config=e,this._injector=n,this._renderManagerSrv=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},U,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(`docs-quick-insert-ui.config`,o)}onStarting(){this._injector.add([Q]),this._injector.get(Q),[[H],[V],[M]].forEach(e=>this._injector.add(e)),this._injector.get(H)}onRendered(){this._injector.get(V),this._injector.get(M),[[Y]].forEach(e=>{this._renderManagerSrv.registerRenderModule(t.UniverInstanceType.UNIVER_DOC,e)})}};O($,`type`,t.UniverInstanceType.UNIVER_DOC),O($,`pluginName`,`DOC_QUICK_INSERT_UI_PLUGIN`),O($,`packageName`,ae),O($,`version`,oe),$=A([(0,t.DependentOn)(n.UniverDocsPlugin,f.UniverDrawingPlugin,a.UniverRenderEnginePlugin,d.UniverDocsDrawingPlugin,r.UniverDocsUIPlugin,p.UniverDrawingUIPlugin,u.UniverDocsDrawingUIPlugin),k(1,(0,t.Inject)(t.Injector)),k(2,(0,t.Inject)(a.IRenderManagerService)),k(3,t.IConfigService)],$),Object.defineProperty(e,"DocQuickInsertPopupService",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"DocQuickInsertTriggerController",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DocQuickInsertUIController",{enumerable:!0,get:function(){return H}}),e.KeywordInputPlaceholderComponentKey=h,e.QuickInsertPlaceholderComponentKey=b,Object.defineProperty(e,"UniverDocsQuickInsertUIPlugin",{enumerable:!0,get:function(){return $}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-quick-insert-ui",
3
- "version": "1.0.0-insiders.20260809-70eefdd",
3
+ "version": "1.0.0-rc.0",
4
4
  "private": false,
5
5
  "description": "Quick insert UI integration for Univer Docs.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -58,26 +58,26 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/icons": "1.35.0",
62
- "@univerjs/core": "1.0.0-insiders.20260809-70eefdd",
63
- "@univerjs/design": "1.0.0-insiders.20260809-70eefdd",
64
- "@univerjs/docs": "1.0.0-insiders.20260809-70eefdd",
65
- "@univerjs/docs-drawing": "1.0.0-insiders.20260809-70eefdd",
66
- "@univerjs/docs-drawing-ui": "1.0.0-insiders.20260809-70eefdd",
67
- "@univerjs/drawing": "1.0.0-insiders.20260809-70eefdd",
68
- "@univerjs/drawing-ui": "1.0.0-insiders.20260809-70eefdd",
69
- "@univerjs/docs-ui": "1.0.0-insiders.20260809-70eefdd",
70
- "@univerjs/engine-render": "1.0.0-insiders.20260809-70eefdd",
71
- "@univerjs/ui": "1.0.0-insiders.20260809-70eefdd"
61
+ "@univerjs/icons": "1.38.0",
62
+ "@univerjs/core": "1.0.0-rc.0",
63
+ "@univerjs/docs": "1.0.0-rc.0",
64
+ "@univerjs/design": "1.0.0-rc.0",
65
+ "@univerjs/engine-render": "1.0.0-rc.0",
66
+ "@univerjs/drawing": "1.0.0-rc.0",
67
+ "@univerjs/docs-drawing": "1.0.0-rc.0",
68
+ "@univerjs/drawing-ui": "1.0.0-rc.0",
69
+ "@univerjs/docs-drawing-ui": "1.0.0-rc.0",
70
+ "@univerjs/ui": "1.0.0-rc.0",
71
+ "@univerjs/docs-ui": "1.0.0-rc.0"
72
72
  },
73
73
  "devDependencies": {
74
- "postcss": "^8.5.25",
74
+ "postcss": "^8.5.26",
75
75
  "react": "18.3.1",
76
76
  "rxjs": "^7.8.2",
77
77
  "tailwindcss": "3.4.18",
78
78
  "typescript": "^6.0.3",
79
- "vitest": "^4.1.10",
80
- "@univerjs-infra/shared": "1.0.0-beta.0"
79
+ "vitest": "^5.0.0",
80
+ "@univerjs-infra/shared": "1.0.0-rc.0"
81
81
  },
82
82
  "scripts": {
83
83
  "test": "vitest run",