@univerjs/docs-quick-insert-ui 0.6.9-nightly.202504091607 → 0.6.10-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ import { DocumentDataModel, Disposable } from '@univerjs/core';
2
+ import { IRenderContext, IRenderModule } from '@univerjs/engine-render';
3
+ import { DocCanvasPopManagerService, DocEventManagerService } from '@univerjs/docs-ui';
4
+ import { DocQuickInsertPopupService } from '../services/doc-quick-insert-popup.service';
5
+ export declare class DocQuickInsertMenuController extends Disposable implements IRenderModule {
6
+ private _context;
7
+ private _docEventManagerService;
8
+ private _docQuickInsertPopupService;
9
+ private _docCanvasPopManagerService;
10
+ private _popup;
11
+ constructor(_context: IRenderContext<DocumentDataModel>, _docEventManagerService: DocEventManagerService, _docQuickInsertPopupService: DocQuickInsertPopupService, _docCanvasPopManagerService: DocCanvasPopManagerService);
12
+ private _init;
13
+ private _hideMenu;
14
+ }
@@ -1,9 +1,11 @@
1
1
  import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
+ import { IRenderManagerService } from '@univerjs/engine-render';
2
3
  export declare class UniverDocsQuickInsertUIPlugin extends Plugin {
3
4
  protected _injector: Injector;
5
+ private _renderManagerSrv;
4
6
  static type: UniverInstanceType;
5
7
  static pluginName: string;
6
- constructor(_injector: Injector);
8
+ constructor(_injector: Injector, _renderManagerSrv: IRenderManagerService);
7
9
  onStarting(): void;
8
10
  onRendered(): void;
9
11
  }
@@ -62,6 +62,7 @@ export declare class DocQuickInsertPopupService extends Disposable {
62
62
  readonly filterKeyword$: Observable<string>;
63
63
  private _menuSelectedCallbacks;
64
64
  private _inputPlaceholderRenderRoot;
65
+ private getDocEventManagerService;
65
66
  constructor(_docCanvasPopupManagerService: DocCanvasPopManagerService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _renderManagerService: IRenderManagerService, _docSelectionManagerService: DocSelectionManagerService);
66
67
  resolvePopup(keyword: string): IDocPopup | undefined;
67
68
  registerPopup(popup: IDocPopup): () => void;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ interface IQuickInsertButtonProps {
17
+ className?: string;
18
+ }
19
+ export declare const QuickInsertButton: {
20
+ ({ className, }: IQuickInsertButtonProps): import("react/jsx-runtime").JSX.Element;
21
+ componentKey: string;
22
+ };
23
+ export {};
package/lib/umd/index.js CHANGED
@@ -1,11 +1,11 @@
1
- (function(o,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/docs-drawing"),require("@univerjs/docs-drawing-ui"),require("@univerjs/drawing"),require("@univerjs/drawing-ui"),require("@univerjs/ui"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/engine-render"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-drawing","@univerjs/docs-drawing-ui","@univerjs/drawing","@univerjs/drawing-ui","@univerjs/ui","@univerjs/docs","@univerjs/docs-ui","@univerjs/engine-render","rxjs","react/jsx-runtime","@univerjs/design","react"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o.UniverDocsQuickInsertUi={},o.UniverCore,o.UniverDocsDrawing,o.UniverDocsDrawingUi,o.UniverDrawing,o.UniverDrawingUi,o.UniverUi,o.UniverDocs,o.UniverDocsUi,o.UniverEngineRender,o.rxjs,o.React,o.UniverDesign,o.React))})(this,function(o,s,w,V,le,pe,p,E,y,ve,P,h,M,m){"use strict";var Te=Object.defineProperty;var $e=(o,s,w)=>s in o?Te(o,s,{enumerable:!0,configurable:!0,writable:!0,value:w}):o[s]=w;var O=(o,s,w)=>$e(o,typeof s!="symbol"?s+"":s,w);const F={id:"doc.command.delete-search-key",type:s.CommandType.COMMAND,handler:(i,n)=>{const e=i.get(s.ICommandService),{start:t,end:r}=n;return e.syncExecuteCommand(y.CutContentCommand.id,{segmentId:"",textRanges:[{startOffset:t,endOffset:t,collapsed:!0}],selections:[{startOffset:t,endOffset:r,collapsed:!1,direction:s.RANGE_DIRECTION.FORWARD}]})}},G="docs.quick.insert.keyword-input-placeholder",N=()=>{const i=p.useDependency(s.LocaleService);return h.jsx("div",{className:"univer-translate-y-1.5 univer-text-sm univer-text-gray-500",children:i.t("docQuickInsert.keywordInputPlaceholder")})};N.componentKey=G;const Z="docs.quick.insert.placeholder",T=()=>{const i=p.useDependency(s.LocaleService);return h.jsx("div",{className:`
1
+ (function(c,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/docs-drawing"),require("@univerjs/docs-drawing-ui"),require("@univerjs/drawing"),require("@univerjs/drawing-ui"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("@univerjs/docs-ui"),require("rxjs"),require("@univerjs/docs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-drawing","@univerjs/docs-drawing-ui","@univerjs/drawing","@univerjs/drawing-ui","@univerjs/engine-render","@univerjs/ui","@univerjs/docs-ui","rxjs","@univerjs/docs","react/jsx-runtime","@univerjs/design","react"],s):(c=typeof globalThis<"u"?globalThis:c||self,s(c.UniverDocsQuickInsertUi={},c.UniverCore,c.UniverDocsDrawing,c.UniverDocsDrawingUi,c.UniverDrawing,c.UniverDrawingUi,c.UniverEngineRender,c.UniverUi,c.UniverDocsUi,c.rxjs,c.UniverDocs,c.React,c.UniverDesign,c.React))})(this,function(c,s,w,ee,Ce,_e,V,l,I,y,T,g,R,h){"use strict";var Be=Object.defineProperty;var We=(c,s,w)=>s in c?Be(c,s,{enumerable:!0,configurable:!0,writable:!0,value:w}):c[s]=w;var O=(c,s,w)=>We(c,typeof s!="symbol"?s+"":s,w);const te={id:"doc.command.delete-search-key",type:s.CommandType.COMMAND,handler:(i,n)=>{const e=i.get(s.ICommandService),{start:t,end:r}=n;return e.syncExecuteCommand(I.CutContentCommand.id,{segmentId:"",textRanges:[{startOffset:t,endOffset:t,collapsed:!0}],selections:[{startOffset:t,endOffset:r,collapsed:!1,direction:s.RANGE_DIRECTION.FORWARD}]})}},ne="docs.quick.insert.keyword-input-placeholder",K=()=>{const i=l.useDependency(s.LocaleService);return g.jsx("div",{className:"univer-translate-y-1.5 univer-text-sm univer-text-gray-500",children:i.t("docQuickInsert.keywordInputPlaceholder")})};K.componentKey=ne;const ie={type:s.CommandType.OPERATION,id:"doc.operation.show-quick-insert-popup",handler(i,n){const e=i.get(c.DocQuickInsertPopupService);return n?(e.showPopup(n),!0):!1}},j={type:s.CommandType.OPERATION,id:"doc.operation.close-quick-insert-popup",handler(i){return i.get(c.DocQuickInsertPopupService).closePopup(),!0}},re="docs.quick.insert.placeholder",H=()=>{const i=l.useDependency(s.LocaleService);return g.jsx("div",{className:`
2
2
  univer-flex univer-h-full univer-items-center univer-justify-center univer-rounded-lg univer-bg-white
3
3
  univer-px-12 univer-py-6 univer-text-gray-400
4
- `,children:h.jsx("span",{children:i.t("docQuickInsert.placeholder")})})};T.componentKey=Z;function K(i,n){return i.map(e=>({...e})).filter(e=>{if("children"in e)return e.children=K(e.children,n),e.children.length>0;const t=e.keywords;return t?t.some(r=>r.includes(n)):e.title.toLowerCase().includes(n)})}function J(i,n){return i.map(e=>{const t={...e};return"children"in t&&(t.children=J(t.children,n)),t.title=n.t(t.title),"keywords"in t&&(t.keywords=t.keywords.concat(t.title).map(r=>r.toLowerCase())),t})}const fe=[p.KeyCode.ARROW_UP,p.KeyCode.ARROW_DOWN,p.KeyCode.ENTER],$=()=>{const i=p.useDependency(s.LocaleService),n=p.useDependency(o.DocQuickInsertPopupService),e=p.useDependency(p.ComponentManager),t=p.useDependency(p.IShortcutService),r=p.useDependency(s.ICommandService),c=m.useMemo(()=>s.generateRandomId(),[]),[a,v]=m.useState(0),g=m.useRef(null),d=m.useRef(0);d.current=0;const u=p.useObservable(n.filterKeyword$,""),l=p.useObservable(n.editPopup$),I=p.useObservable(l==null?void 0:l.popup.menus$,[]),b=m.useMemo(()=>J(I,i),[I]),[W,Ee]=m.useState(()=>K(b,u.toLowerCase()));m.useEffect(()=>{const C=requestIdleCallback(()=>{Ee(K(b,u.toLowerCase()))});return()=>{cancelIdleCallback(C)}},[b,u]);const de=C=>{n.emitMenuSelected(C),r.executeCommand(j.id)};m.useEffect(()=>{const C=new s.DisposableCollection;t.getAllShortcuts().filter(f=>f.binding&&fe.includes(f.binding)).forEach(f=>{const k=f.preconditions;f.preconditions=()=>!1,C.add(s.toDisposable(()=>{f.preconditions=k}))});const D={id:`quick.insert.popup.enter.${c}`,type:s.CommandType.OPERATION,handler:()=>{const f=g.current;f&&de(f)}},U={id:`quick.insert.popup.move.cursor.up.${c}`,type:s.CommandType.OPERATION,handler:()=>{v(f=>{const k=f-1;return k>=0?k:d.current-1})}},R={id:`quick.insert.popup.move.cursor.down.${c}`,type:s.CommandType.OPERATION,handler:()=>{v(f=>{const k=f+1;return k<=d.current-1?k:0})}};return C.add(r.registerCommand(U)),C.add(r.registerCommand(R)),C.add(r.registerCommand(D)),C.add(t.registerShortcut({priority:1e3,id:U.id,binding:p.KeyCode.ARROW_UP,preconditions:()=>!0,staticParameters:{direction:s.Direction.UP}})),C.add(t.registerShortcut({priority:1e3,id:R.id,binding:p.KeyCode.ARROW_DOWN,preconditions:()=>!0,staticParameters:{direction:s.Direction.DOWN}})),C.add(t.registerShortcut({priority:1e3,id:D.id,binding:p.KeyCode.ENTER,preconditions:()=>!0})),()=>{C.dispose()}},[]),m.useEffect(()=>{v(0)},[W]);const B=m.useRef(new Map);m.useEffect(()=>()=>{B.current.clear()},[]);function ue(C){return C.map(_=>{const z=_.icon,D=z?e.get(z):null;if("children"in _)return h.jsx(M.MenuItemGroup,{title:h.jsxs("div",{className:`
4
+ `,children:g.jsx("span",{children:i.t("docQuickInsert.placeholder")})})};H.componentKey=re;function z(i,n){return i.map(e=>({...e})).filter(e=>{if("children"in e)return e.children=z(e.children,n),e.children.length>0;const t=e.keywords;return t?t.some(r=>r.includes(n)):e.title.toLowerCase().includes(n)})}function se(i,n){return i.map(e=>{const t={...e};return"children"in t&&(t.children=se(t.children,n)),t.title=n.t(t.title),"keywords"in t&&(t.keywords=t.keywords.concat(t.title).map(r=>r.toLowerCase())),t})}const Se=[l.KeyCode.ARROW_UP,l.KeyCode.ARROW_DOWN,l.KeyCode.ENTER],L=()=>{const i=l.useDependency(s.LocaleService),n=l.useDependency(c.DocQuickInsertPopupService),e=l.useDependency(l.ComponentManager),t=l.useDependency(l.IShortcutService),r=l.useDependency(s.ICommandService),o=h.useMemo(()=>s.generateRandomId(),[]),[u,v]=h.useState(0),C=h.useRef(null),a=h.useRef(0);a.current=0;const d=l.useObservable(n.filterKeyword$,""),p=l.useObservable(n.editPopup$),m=l.useObservable(p==null?void 0:p.popup.menus$,[]),D=h.useMemo(()=>se(m,i),[m]),[M,me]=h.useState(()=>z(D,d.toLowerCase()));h.useEffect(()=>{const _=requestIdleCallback(()=>{me(z(D,d.toLowerCase()))});return()=>{cancelIdleCallback(_)}},[D,d]);const x=_=>{n.emitMenuSelected(_),r.executeCommand(j.id)};h.useEffect(()=>{const _=new s.DisposableCollection;t.getAllShortcuts().filter(f=>f.binding&&Se.includes(f.binding)).forEach(f=>{const k=f.preconditions;f.preconditions=()=>!1,_.add(s.toDisposable(()=>{f.preconditions=k}))});const b={id:`quick.insert.popup.enter.${o}`,type:s.CommandType.OPERATION,handler:()=>{const f=C.current;f&&x(f)}},N={id:`quick.insert.popup.move.cursor.up.${o}`,type:s.CommandType.OPERATION,handler:()=>{v(f=>{const k=f-1;return k>=0?k:a.current-1})}},Q={id:`quick.insert.popup.move.cursor.down.${o}`,type:s.CommandType.OPERATION,handler:()=>{v(f=>{const k=f+1;return k<=a.current-1?k:0})}};return _.add(r.registerCommand(N)),_.add(r.registerCommand(Q)),_.add(r.registerCommand(b)),_.add(t.registerShortcut({priority:1e3,id:N.id,binding:l.KeyCode.ARROW_UP,preconditions:()=>!0,staticParameters:{direction:s.Direction.UP}})),_.add(t.registerShortcut({priority:1e3,id:Q.id,binding:l.KeyCode.ARROW_DOWN,preconditions:()=>!0,staticParameters:{direction:s.Direction.DOWN}})),_.add(t.registerShortcut({priority:1e3,id:b.id,binding:l.KeyCode.ENTER,preconditions:()=>!0})),()=>{_.dispose()}},[]),h.useEffect(()=>{v(0)},[M]);const B=h.useRef(new Map);h.useEffect(()=>()=>{B.current.clear()},[]);function $(_){return _.map(S=>{const Y=S.icon,b=Y?e.get(Y):null;if("children"in S)return g.jsx(R.MenuItemGroup,{title:g.jsxs("div",{className:`
5
5
  univer-mb-2 univer-flex univer-items-center univer-text-xs univer-text-gray-400
6
- `,children:[D&&h.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:h.jsx(D,{})}),h.jsx("span",{children:_.title})]}),children:ue(_.children)},_.id);const U=d.current,R=a===U;if(R){g.current=_;const f=B.current.get(_.id);f==null||f.scrollIntoView({block:"nearest"})}return d.current++,h.jsx(M.MenuItem,{ref:f=>{f&&B.current.set(_.id,f)},onMouseEnter:()=>v(U),onMouseLeave:()=>v(Number.NaN),className:M.clsx("univer-w-[calc(220px-var(--padding-base)*2)] univer-text-sm",{"hover:univer-bg-transparent":!R,"univer-bg-gray-100":R}),onClick:()=>{de(_)},children:h.jsxs("div",{className:"univer-flex univer-w-full univer-items-center univer-px-1",children:[D&&h.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:h.jsx(D,{})}),h.jsx(M.Tooltip,{showIfEllipsis:!0,title:_.title,placement:"right",children:h.jsx("span",{className:"univer-truncate",children:_.title})})]})},_.id)})}const Ne=W.length>0,ae=(l==null?void 0:l.popup.Placeholder)||e.get(T.componentKey);return h.jsx("div",{className:M.clsx(`
7
- univer-rounded-lg univer-border univer-border-solid univer-border-gray-100 univer-bg-white
8
- univer-shadow-[0_0_10px_0_rgba(0,0,0,0.1)]
9
- `),children:Ne?h.jsx("div",{className:`
10
- univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto univer-overflow-x-hidden
11
- `,children:h.jsx(M.Menu,{children:ue(W)})}):ae&&h.jsx(ae,{})})};$.componentKey="docs.quick.insert.popup";var he=Object.getOwnPropertyDescriptor,me=(i,n,e,t)=>{for(var r=t>1?void 0:t?he(n,e):n,c=i.length-1,a;c>=0;c--)(a=i[c])&&(r=a(r)||r);return r},Q=(i,n)=>(e,t)=>n(e,t,i);const X={dispose:()=>{}};o.DocQuickInsertPopupService=class extends s.Disposable{constructor(e,t,r,c,a){super();O(this,"_popups",new Set);O(this,"_editPopup$",new P.BehaviorSubject(void 0));O(this,"editPopup$",this._editPopup$.asObservable());O(this,"_isComposing$",new P.BehaviorSubject(!1));O(this,"isComposing$",this._isComposing$.asObservable());O(this,"_inputOffset$",new P.BehaviorSubject({start:0,end:0}));O(this,"inputOffset$",this._inputOffset$.asObservable());O(this,"filterKeyword$");O(this,"_menuSelectedCallbacks",new Set);O(this,"_inputPlaceholderRenderRoot",null);this._docCanvasPopupManagerService=e,this._univerInstanceService=t,this._commandService=r,this._renderManagerService=c,this._docSelectionManagerService=a,this.disposeWithMe(this._editPopup$);const v=(d,u)=>{var l,I;return(I=(l=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_DOC))==null?void 0:l.getBody())==null?void 0:I.dataStream.slice(d,u)};let g="";this.filterKeyword$=this._inputOffset$.pipe(P.map(d=>{var l;const u=v(d.start,d.end);return(l=u==null?void 0:u.slice(1))!=null?l:""}),P.distinctUntilChanged(),P.tap(d=>{g=d})),this.disposeWithMe(P.combineLatest([this.filterKeyword$.pipe(P.tap(d=>{var u,l,I;d.length>0?(l=(u=this._inputPlaceholderRenderRoot)==null?void 0:u.unmount)==null||l.dispose():(I=this._inputPlaceholderRenderRoot)==null||I.mount()})),this.isComposing$.pipe(P.tap(d=>{var u,l,I;d?(l=(u=this._inputPlaceholderRenderRoot)==null?void 0:u.unmount)==null||l.dispose():g.length<=0&&((I=this._inputPlaceholderRenderRoot)==null||I.mount())})),this.editPopup$.pipe(P.tap(d=>{var u,l;d||((l=(u=this._inputPlaceholderRenderRoot)==null?void 0:u.unmount)==null||l.dispose(),this._inputPlaceholderRenderRoot=null)}))]).subscribe())}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)}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;const r=e();this.unmount={dispose:()=>{r.dispose(),this.isMounted=!1}}}}}showPopup(e){const{popup:t,index:r,unitId:c}=e;this.closePopup(),this._inputPlaceholderRenderRoot=this._createInputPlaceholderRenderRoot(()=>{var b;const v=(b=this._renderManagerService.getRenderById(c))==null?void 0:b.with(E.DocSkeletonManagerService),g=this._docSelectionManagerService.getActiveTextRange();if(!v||!g)return X;const u=v.getSkeleton().findNodeByCharIndex(g.startOffset,g.segmentId,g.segmentPage);if(!((u==null?void 0:u.content)==="\r"))return X;const I=this._docCanvasPopupManagerService.attachPopupToRange({startOffset:r+1,endOffset:r+1,collapsed:!1},{componentKey:N.componentKey,onClickOutside:()=>{I.dispose()},direction:"horizontal"},c);return I}),this._inputPlaceholderRenderRoot.mount();const a=this._docCanvasPopupManagerService.attachPopupToRange({startOffset:r,endOffset:r,collapsed:!0},{componentKey:$.componentKey,onClickOutside:()=>{this.closePopup()},direction:"bottom"},c);this._editPopup$.next({disposable:a,popup:t,anchor:r,unitId:c})}closePopup(){this.editPopup&&(this.editPopup.disposable.dispose(),this._editPopup$.next(null))}onMenuSelected(e){return this._menuSelectedCallbacks.add(e),()=>{this._menuSelectedCallbacks.delete(e)}}emitMenuSelected(e){const{start:t,end:r}=this.inputOffset;this._commandService.syncExecuteCommand(F.id,{start:t,end:r}),setTimeout(()=>{this._menuSelectedCallbacks.forEach(c=>c(e))},0)}},o.DocQuickInsertPopupService=me([Q(0,s.Inject(y.DocCanvasPopManagerService)),Q(1,s.Inject(s.IUniverInstanceService)),Q(2,s.Inject(s.ICommandService)),Q(3,s.Inject(ve.IRenderManagerService)),Q(4,s.Inject(E.DocSelectionManagerService))],o.DocQuickInsertPopupService);const Y={type:s.CommandType.OPERATION,id:"doc.operation.show-quick-insert-popup",handler(i,n){const e=i.get(o.DocQuickInsertPopupService);return n?(e.showPopup(n),!0):!1}},j={type:s.CommandType.OPERATION,id:"doc.operation.close-quick-insert-popup",handler(i){return i.get(o.DocQuickInsertPopupService).closePopup(),!0}},ee={id:"quick-insert.text.menu",title:"docQuickInsert.menu.text",icon:"TextSingle",keywords:["text"]},te={id:y.OrderListCommand.id,title:"docQuickInsert.menu.numberedList",icon:"OrderSingle",keywords:["numbered","list","ordered"]},ne={id:y.BulletListCommand.id,title:"docQuickInsert.menu.bulletedList",icon:"UnorderSingle",keywords:["bulleted","list","unordered"]},ie={id:y.HorizontalLineCommand.id,title:"docQuickInsert.menu.divider",icon:"DividerSingle",keywords:["divider","line","separate"]},re={id:y.DocCreateTableOperation.id,title:"docQuickInsert.menu.table",icon:"GridSingle",keywords:["table","grid","spreadsheet"]},se={id:V.InsertDocImageCommand.id,title:"docQuickInsert.menu.image",icon:"addition-and-subtraction-single",keywords:["image","picture","photo"]},ge=[{title:"docQuickInsert.group.basics",id:"quick.insert.group.basic",children:[ee,te,ne,ie,re,se]}],Ie=new Set([te.id,ne.id,ie.id,re.id,se.id]);var Ce=Object.getOwnPropertyDescriptor,_e=(i,n,e,t)=>{for(var r=t>1?void 0:t?Ce(n,e):n,c=i.length-1,a;c>=0;c--)(a=i[c])&&(r=a(r)||r);return r},x=(i,n)=>(e,t)=>n(e,t,i);o.DocQuickInsertTriggerController=class extends s.Disposable{constructor(n,e,t,r,c){super(),this._commandService=n,this._textSelectionManagerService=e,this._docQuickInsertPopupService=t,this._shortcutService=r,this._univerInstanceService=c,this.disposeWithMe(this._shortcutService.registerShortcut({id:j.id,binding:p.KeyCode.ESC,preconditions:()=>!!this._docQuickInsertPopupService.editPopup,priority:1e3})),this._initTrigger(),this._initMenuHandler()}_initTrigger(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var a,v,g;const{_docQuickInsertPopupService:e,_textSelectionManagerService:t,_commandService:r}=this,c=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_DOC);if(!(c!=null&&c.getDisabled())){if(n.id===y.InsertCommand.id){const d=n.params;if(e.editPopup){e.setInputOffset({start:e.inputOffset.start,end:d.range.endOffset+1});return}const u=t.getActiveTextRange();if(!u)return;const l=e.resolvePopup(d.body.dataStream);if(!l||!(l.preconditions?l.preconditions(d):!0))return;e.setInputOffset({start:u.startOffset-1,end:u.startOffset}),setTimeout(()=>{r.executeCommand(Y.id,{index:u.startOffset-1,unitId:d.unitId,popup:l})},100)}if(n.id===y.IMEInputCommand.id){const d=n.params;!e.isComposing&&d.isCompositionStart&&e.setIsComposing(!0),e.isComposing&&d.isCompositionEnd&&e.setIsComposing(!1)}if(n.id===E.RichTextEditingMutation.id){const d=n.params;if(d.isCompositionEnd){const u=(v=(a=d.textRanges)==null?void 0:a[0])==null?void 0:v.endOffset;u&&e.setInputOffset({start:e.inputOffset.start,end:u})}}if(n.id===y.DeleteCommand.id){const d=n.params;if(e.editPopup&&d.direction===s.DeleteDirection.LEFT){const u=(g=d.len)!=null?g:0;e.setInputOffset({start:e.inputOffset.start,end:d.range.endOffset-u})}}if(n.id===y.MoveCursorOperation.id){const d=n.params;(d.direction===s.Direction.LEFT||d.direction===s.Direction.RIGHT)&&e.editPopup&&r.executeCommand(j.id)}if(n.id===y.DeleteLeftCommand.id){const d=t.getActiveTextRange();if(!e.editPopup||!d)return;d.endOffset<=e.editPopup.anchor&&r.executeCommand(j.id)}}}))}_initMenuHandler(){this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected(n=>{n.id!==ee.id&&Ie.has(n.id)&&this._commandService.executeCommand(n.id)}))}},o.DocQuickInsertTriggerController=_e([x(0,s.ICommandService),x(1,s.Inject(E.DocSelectionManagerService)),x(2,s.Inject(o.DocQuickInsertPopupService)),x(3,s.Inject(p.IShortcutService)),x(4,s.Inject(s.IUniverInstanceService))],o.DocQuickInsertTriggerController);var S=function(){return S=Object.assign||function(i){for(var n,e=1,t=arguments.length;e<t;e++){n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])}return i},S.apply(this,arguments)},Se=function(i,n){var e={};for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&n.indexOf(t)<0&&(e[t]=i[t]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(i);r<t.length;r++)n.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(i,t[r])&&(e[t[r]]=i[t[r]]);return e},H=m.forwardRef(function(i,n){var e=i.icon,t=i.id,r=i.className,c=i.extend,a=Se(i,["icon","id","className","extend"]),v="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),g=m.useRef("_".concat(Oe()));return oe(e,"".concat(t),{defIds:e.defIds,idSuffix:g.current},S({ref:n,className:v},a),c)});function oe(i,n,e,t,r){return m.createElement(i.tag,S(S({key:n},ye(i,e,r)),t),(Pe(i,e).children||[]).map(function(c,a){return oe(c,"".concat(n,"-").concat(i.tag,"-").concat(a),e,void 0,r)}))}function ye(i,n,e){var t=S({},i.attrs);e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1),i.tag==="mask"&&t.id&&(t.id=t.id+n.idSuffix),Object.entries(t).forEach(function(c){var a=c[0],v=c[1];a==="mask"&&typeof v=="string"&&(t[a]=v.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var r=n.defIds;return!r||r.length===0||(i.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(c){var a=c[0],v=c[1];typeof v=="string"&&(t[a]=v.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function Pe(i,n){var e,t=n.defIds;return!t||t.length===0?i:i.tag==="defs"&&(!((e=i.children)===null||e===void 0)&&e.length)?S(S({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?S(S({},r),{attrs:S(S({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):i}function Oe(){return Math.random().toString(36).substring(2,8)}H.displayName="UniverIcon";var De={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.01953 3.13985C1.01953 2.77258 1.31726 2.47485 1.68453 2.47485H2.73713C3.1044 2.47485 3.40213 2.77258 3.40213 3.13985 3.40213 3.50712 3.1044 3.80485 2.73713 3.80485H1.68453C1.31726 3.80485 1.01953 3.50712 1.01953 3.13985zM4.17734 3.13985C4.17734 2.77258 4.47507 2.47485 4.84234 2.47485H6.94754C7.31481 2.47485 7.61254 2.77258 7.61254 3.13985 7.61254 3.50712 7.31481 3.80485 6.94754 3.80485H4.84234C4.47507 3.80485 4.17734 3.50712 4.17734 3.13985zM8.38775 3.13985C8.38775 2.77258 8.68548 2.47485 9.05275 2.47485H11.158C11.5252 2.47485 11.823 2.77258 11.823 3.13985 11.823 3.50712 11.5252 3.80485 11.158 3.80485H9.05275C8.68548 3.80485 8.38775 3.50712 8.38775 3.13985zM12.5982 3.13985C12.5982 2.77258 12.8959 2.47485 13.2632 2.47485H14.3158C14.683 2.47485 14.9808 2.77258 14.9808 3.13985 14.9808 3.50712 14.683 3.80485 14.3158 3.80485H13.2632C12.8959 3.80485 12.5982 3.50712 12.5982 3.13985zM1.01953 7.99972C1.01953 7.63245 1.31726 7.33472 1.68453 7.33472H14.3158C14.683 7.33472 14.9808 7.63245 14.9808 7.99972 14.9808 8.36699 14.683 8.66472 14.3158 8.66472H1.68453C1.31726 8.66472 1.01953 8.36699 1.01953 7.99972zM1.68453 12.1951C1.31726 12.1951 1.01953 12.4928 1.01953 12.8601 1.01953 13.2273 1.31726 13.5251 1.68453 13.5251H2.73713C3.1044 13.5251 3.40213 13.2273 3.40213 12.8601 3.40213 12.4928 3.1044 12.1951 2.73713 12.1951H1.68453zM4.84234 12.1951C4.47507 12.1951 4.17734 12.4928 4.17734 12.8601 4.17734 13.2273 4.47507 13.5251 4.84234 13.5251H6.94754C7.31481 13.5251 7.61254 13.2273 7.61254 12.8601 7.61254 12.4928 7.31481 12.1951 6.94754 12.1951H4.84234zM9.05275 12.1951C8.68548 12.1951 8.38775 12.4928 8.38775 12.8601 8.38775 13.2273 8.68548 13.5251 9.05275 13.5251H11.158C11.5252 13.5251 11.823 13.2273 11.823 12.8601 11.823 12.4928 11.5252 12.1951 11.158 12.1951H9.05275zM13.2632 12.1951C12.8959 12.1951 12.5982 12.4928 12.5982 12.8601 12.5982 13.2273 12.8959 13.5251 13.2632 13.5251H14.3158C14.683 13.5251 14.9808 13.2273 14.9808 12.8601 14.9808 12.4928 14.683 12.1951 14.3158 12.1951H13.2632z"}}]},q=m.forwardRef(function(i,n){return m.createElement(H,Object.assign({},i,{id:"divider-single",ref:n,icon:De}))});q.displayName="DividerSingle";var ke={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.66695 1.33496C2.29968 1.33496 2.00195 1.63269 2.00195 1.99996V3.64439C2.00195 4.01166 2.29968 4.30939 2.66695 4.30939C3.03422 4.30939 3.33195 4.01166 3.33195 3.64439V2.66496H7.33521V13.335H5.3337C4.96643 13.335 4.6687 13.6327 4.6687 14C4.6687 14.3672 4.96643 14.665 5.3337 14.665H10.667C11.0343 14.665 11.332 14.3672 11.332 14C11.332 13.6327 11.0343 13.335 10.667 13.335H8.66521V2.66496H12.6686V3.64439C12.6686 4.01166 12.9664 4.30939 13.3336 4.30939C13.7009 4.30939 13.9986 4.01166 13.9986 3.64439V1.99996C13.9986 1.63269 13.7009 1.33496 13.3336 1.33496H2.66695Z"}}]},L=m.forwardRef(function(i,n){return m.createElement(H,Object.assign({},i,{id:"text-single",ref:n,icon:ke}))});L.displayName="TextSingle";var we=Object.getOwnPropertyDescriptor,Me=(i,n,e,t)=>{for(var r=t>1?void 0:t?we(n,e):n,c=i.length-1,a;c>=0;c--)(a=i[c])&&(r=a(r)||r);return r},A=(i,n)=>(e,t)=>n(e,t,i);o.DocQuickInsertUIController=class extends s.Disposable{constructor(n,e,t){super(),this._commandService=n,this._docQuickInsertPopupService=e,this._componentManager=t,this._initCommands(),this._initComponents(),this._initMenus()}_initCommands(){[F,Y,j].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initComponents(){[[$.componentKey,$],[N.componentKey,N],[T.componentKey,T],[q.displayName,q],[L.displayName,L]].forEach(([e,t])=>{e&&this.disposeWithMe(this._componentManager.register(e,t))}),[{keyword:"/",menus$:P.of(ge),preconditions:e=>{var t;return((t=e.range.startNodePosition)==null?void 0:t.glyph)===0}}].forEach(e=>{this.disposeWithMe(this._docQuickInsertPopupService.registerPopup(e))})}_initMenus(){}},o.DocQuickInsertUIController=Me([A(0,s.ICommandService),A(1,s.Inject(o.DocQuickInsertPopupService)),A(2,s.Inject(p.ComponentManager))],o.DocQuickInsertUIController);var be=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Qe=(i,n,e)=>n in i?be(i,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[n]=e,je=(i,n,e,t)=>{for(var r=t>1?void 0:t?Re(n,e):n,c=i.length-1,a;c>=0;c--)(a=i[c])&&(r=a(r)||r);return r},xe=(i,n)=>(e,t)=>n(e,t,i),ce=(i,n,e)=>Qe(i,typeof n!="symbol"?n+"":n,e);const Ue="DOC_QUICK_INSERT_UI_PLUGIN";o.UniverDocsQuickInsertUIPlugin=class extends s.Plugin{constructor(n){super(),this._injector=n}onStarting(){[[o.DocQuickInsertUIController],[o.DocQuickInsertTriggerController],[o.DocQuickInsertPopupService]].forEach(e=>this._injector.add(e)),this._injector.get(o.DocQuickInsertUIController)}onRendered(){this._injector.get(o.DocQuickInsertTriggerController),this._injector.get(o.DocQuickInsertPopupService)}},ce(o.UniverDocsQuickInsertUIPlugin,"type",s.UniverInstanceType.UNIVER_DOC),ce(o.UniverDocsQuickInsertUIPlugin,"pluginName",Ue),o.UniverDocsQuickInsertUIPlugin=je([s.DependentOn(pe.UniverDrawingUIPlugin,le.UniverDrawingPlugin,V.UniverDocsDrawingUIPlugin,w.UniverDocsDrawingPlugin,p.UniverUIPlugin),xe(0,s.Inject(s.Injector))],o.UniverDocsQuickInsertUIPlugin),o.KeywordInputPlaceholderComponentKey=G,o.QuickInsertPlaceholderComponentKey=Z,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
6
+ `,children:[b&&g.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:g.jsx(b,{})}),g.jsx("span",{children:S.title})]}),children:$(S.children)},S.id);const N=a.current,Q=u===N;if(Q){C.current=S;const f=B.current.get(S.id);f==null||f.scrollIntoView({block:"nearest"})}return a.current++,g.jsx(R.MenuItem,{ref:f=>{f&&B.current.set(S.id,f)},onMouseEnter:()=>v(N),onMouseLeave:()=>v(Number.NaN),className:R.clsx("univer-w-[calc(220px-var(--padding-base)*2)] univer-text-sm",{"hover:univer-bg-transparent":!Q,"univer-bg-gray-100":Q}),onClick:()=>{x(S)},children:g.jsxs("div",{className:"univer-flex univer-w-full univer-items-center univer-px-1",children:[b&&g.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:g.jsx(b,{})}),g.jsx(R.Tooltip,{showIfEllipsis:!0,title:S.title,placement:"right",children:g.jsx("span",{className:"univer-truncate",children:S.title})})]})},S.id)})}const W=M.length>0,Ie=(p==null?void 0:p.popup.Placeholder)||e.get(H.componentKey);return g.jsx("div",{className:R.clsx("univer-mt-2"),children:W?g.jsx(R.Menu,{wrapperClass:"univer-max-h-[360px] univer-w-[220px]",children:$(M)}):Ie&&g.jsx(Ie,{})})};L.componentKey="docs.quick.insert.popup";var ye=Object.getOwnPropertyDescriptor,Pe=(i,n,e,t)=>{for(var r=t>1?void 0:t?ye(n,e):n,o=i.length-1,u;o>=0;o--)(u=i[o])&&(r=u(r)||r);return r},E=(i,n)=>(e,t)=>n(e,t,i);const oe={dispose:()=>{}};c.DocQuickInsertPopupService=class extends s.Disposable{constructor(e,t,r,o,u){super();O(this,"_popups",new Set);O(this,"_editPopup$",new y.BehaviorSubject(void 0));O(this,"editPopup$",this._editPopup$.asObservable());O(this,"_isComposing$",new y.BehaviorSubject(!1));O(this,"isComposing$",this._isComposing$.asObservable());O(this,"_inputOffset$",new y.BehaviorSubject({start:0,end:0}));O(this,"inputOffset$",this._inputOffset$.asObservable());O(this,"filterKeyword$");O(this,"_menuSelectedCallbacks",new Set);O(this,"_inputPlaceholderRenderRoot",null);this._docCanvasPopupManagerService=e,this._univerInstanceService=t,this._commandService=r,this._renderManagerService=o,this._docSelectionManagerService=u,this.disposeWithMe(this._editPopup$);const v=(a,d)=>{var p,m;return(m=(p=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_DOC))==null?void 0:p.getBody())==null?void 0:m.dataStream.slice(a,d)};let C="";this.filterKeyword$=this._inputOffset$.pipe(y.map(a=>{var p;const d=v(a.start,a.end);return(p=d==null?void 0:d.slice(1))!=null?p:""}),y.distinctUntilChanged(),y.tap(a=>{C=a})),this.disposeWithMe(y.combineLatest([this.filterKeyword$.pipe(y.tap(a=>{var d,p,m;a.length>0?(p=(d=this._inputPlaceholderRenderRoot)==null?void 0:d.unmount)==null||p.dispose():(m=this._inputPlaceholderRenderRoot)==null||m.mount()})),this.isComposing$.pipe(y.tap(a=>{var d,p,m;a?(p=(d=this._inputPlaceholderRenderRoot)==null?void 0:d.unmount)==null||p.dispose():C.length<=0&&((m=this._inputPlaceholderRenderRoot)==null||m.mount())})),this.editPopup$.pipe(y.tap(a=>{var d,p;a||((p=(d=this._inputPlaceholderRenderRoot)==null?void 0:d.unmount)==null||p.dispose(),this._inputPlaceholderRenderRoot=null)}))]).subscribe())}get editPopup(){return this._editPopup$.value}get isComposing(){return this._isComposing$.value}setIsComposing(e){this._isComposing$.next(e)}get inputOffset(){return this._inputOffset$.value}setInputOffset(e){this._inputOffset$.next(e)}getDocEventManagerService(e){var t;return(t=this._renderManagerService.getRenderById(e))==null?void 0:t.with(I.DocEventManagerService)}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;const r=e();this.unmount={dispose:()=>{r.dispose(),this.isMounted=!1}}}}}showPopup(e){var d,p,m;const{popup:t,index:r,unitId:o}=e;this.closePopup();const u=this._univerInstanceService.getUnit(o),v=(p=(d=u==null?void 0:u.getBody())==null?void 0:d.paragraphs)==null?void 0:p.find(D=>D.startIndex>r);if(!v)return;const C=(m=this.getDocEventManagerService(o))==null?void 0:m.paragraphBounds.get(v.startIndex);if(!C)return;this._inputPlaceholderRenderRoot=this._createInputPlaceholderRenderRoot(()=>{var W;const D=(W=this._renderManagerService.getRenderById(o))==null?void 0:W.with(T.DocSkeletonManagerService),M=this._docSelectionManagerService.getActiveTextRange();if(!D||!M)return oe;const x=D.getSkeleton().findNodeByCharIndex(M.startOffset,M.segmentId,M.segmentPage);if(!((x==null?void 0:x.content)==="\r"))return oe;const $=this._docCanvasPopupManagerService.attachPopupToRange({startOffset:r+1,endOffset:r+1,collapsed:!1},{componentKey:K.componentKey,onClickOutside:()=>{$.dispose()},direction:"horizontal"},o);return $}),this._inputPlaceholderRenderRoot.mount();const a=this._docCanvasPopupManagerService.attachPopupToRect(C.firstLine,{componentKey:L.componentKey,onClickOutside:()=>{this.closePopup()},direction:"bottom"},o);this._editPopup$.next({disposable:a,popup:t,anchor:r,unitId:o})}closePopup(){this.editPopup&&(this.editPopup.disposable.dispose(),this._editPopup$.next(null))}onMenuSelected(e){return this._menuSelectedCallbacks.add(e),()=>{this._menuSelectedCallbacks.delete(e)}}emitMenuSelected(e){const{start:t,end:r}=this.inputOffset;this._commandService.syncExecuteCommand(te.id,{start:t,end:r}),setTimeout(()=>{this._menuSelectedCallbacks.forEach(o=>o(e))},0)}},c.DocQuickInsertPopupService=Pe([E(0,s.Inject(I.DocCanvasPopManagerService)),E(1,s.Inject(s.IUniverInstanceService)),E(2,s.Inject(s.ICommandService)),E(3,s.Inject(V.IRenderManagerService)),E(4,s.Inject(T.DocSelectionManagerService))],c.DocQuickInsertPopupService);var P=function(){return P=Object.assign||function(i){for(var n,e=1,t=arguments.length;e<t;e++){n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])}return i},P.apply(this,arguments)},Oe=function(i,n){var e={};for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&n.indexOf(t)<0&&(e[t]=i[t]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(i);r<t.length;r++)n.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(i,t[r])&&(e[t[r]]=i[t[r]]);return e},q=h.forwardRef(function(i,n){var e=i.icon,t=i.id,r=i.className,o=i.extend,u=Oe(i,["icon","id","className","extend"]),v="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),C=h.useRef("_".concat(be()));return ce(e,"".concat(t),{defIds:e.defIds,idSuffix:C.current},P({ref:n,className:v},u),o)});function ce(i,n,e,t,r){return h.createElement(i.tag,P(P({key:n},De(i,e,r)),t),(Me(i,e).children||[]).map(function(o,u){return ce(o,"".concat(n,"-").concat(i.tag,"-").concat(u),e,void 0,r)}))}function De(i,n,e){var t=P({},i.attrs);e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1),i.tag==="mask"&&t.id&&(t.id=t.id+n.idSuffix),Object.entries(t).forEach(function(o){var u=o[0],v=o[1];u==="mask"&&typeof v=="string"&&(t[u]=v.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var r=n.defIds;return!r||r.length===0||(i.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(o){var u=o[0],v=o[1];typeof v=="string"&&(t[u]=v.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function Me(i,n){var e,t=n.defIds;return!t||t.length===0?i:i.tag==="defs"&&(!((e=i.children)===null||e===void 0)&&e.length)?P(P({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?P(P({},r),{attrs:P(P({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):i}function be(){return Math.random().toString(36).substring(2,8)}q.displayName="UniverIcon";var ke={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.01953 3.13985C1.01953 2.77258 1.31726 2.47485 1.68453 2.47485H2.73713C3.1044 2.47485 3.40213 2.77258 3.40213 3.13985 3.40213 3.50712 3.1044 3.80485 2.73713 3.80485H1.68453C1.31726 3.80485 1.01953 3.50712 1.01953 3.13985zM4.17734 3.13985C4.17734 2.77258 4.47507 2.47485 4.84234 2.47485H6.94754C7.31481 2.47485 7.61254 2.77258 7.61254 3.13985 7.61254 3.50712 7.31481 3.80485 6.94754 3.80485H4.84234C4.47507 3.80485 4.17734 3.50712 4.17734 3.13985zM8.38775 3.13985C8.38775 2.77258 8.68548 2.47485 9.05275 2.47485H11.158C11.5252 2.47485 11.823 2.77258 11.823 3.13985 11.823 3.50712 11.5252 3.80485 11.158 3.80485H9.05275C8.68548 3.80485 8.38775 3.50712 8.38775 3.13985zM12.5982 3.13985C12.5982 2.77258 12.8959 2.47485 13.2632 2.47485H14.3158C14.683 2.47485 14.9808 2.77258 14.9808 3.13985 14.9808 3.50712 14.683 3.80485 14.3158 3.80485H13.2632C12.8959 3.80485 12.5982 3.50712 12.5982 3.13985zM1.01953 7.99972C1.01953 7.63245 1.31726 7.33472 1.68453 7.33472H14.3158C14.683 7.33472 14.9808 7.63245 14.9808 7.99972 14.9808 8.36699 14.683 8.66472 14.3158 8.66472H1.68453C1.31726 8.66472 1.01953 8.36699 1.01953 7.99972zM1.68453 12.1951C1.31726 12.1951 1.01953 12.4928 1.01953 12.8601 1.01953 13.2273 1.31726 13.5251 1.68453 13.5251H2.73713C3.1044 13.5251 3.40213 13.2273 3.40213 12.8601 3.40213 12.4928 3.1044 12.1951 2.73713 12.1951H1.68453zM4.84234 12.1951C4.47507 12.1951 4.17734 12.4928 4.17734 12.8601 4.17734 13.2273 4.47507 13.5251 4.84234 13.5251H6.94754C7.31481 13.5251 7.61254 13.2273 7.61254 12.8601 7.61254 12.4928 7.31481 12.1951 6.94754 12.1951H4.84234zM9.05275 12.1951C8.68548 12.1951 8.38775 12.4928 8.38775 12.8601 8.38775 13.2273 8.68548 13.5251 9.05275 13.5251H11.158C11.5252 13.5251 11.823 13.2273 11.823 12.8601 11.823 12.4928 11.5252 12.1951 11.158 12.1951H9.05275zM13.2632 12.1951C12.8959 12.1951 12.5982 12.4928 12.5982 12.8601 12.5982 13.2273 12.8959 13.5251 13.2632 13.5251H14.3158C14.683 13.5251 14.9808 13.2273 14.9808 12.8601 14.9808 12.4928 14.683 12.1951 14.3158 12.1951H13.2632z"}}]},F=h.forwardRef(function(i,n){return h.createElement(q,Object.assign({},i,{id:"divider-single",ref:n,icon:ke}))});F.displayName="DividerSingle";var we={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.00033 2.66699C8.36852 2.66699 8.66699 2.96547 8.66699 3.33366V7.33366H12.667C13.0352 7.33366 13.3337 7.63214 13.3337 8.00033C13.3337 8.36852 13.0352 8.66699 12.667 8.66699H8.66699V12.667C8.66699 13.0352 8.36852 13.3337 8.00033 13.3337C7.63214 13.3337 7.33366 13.0352 7.33366 12.667V8.66699H3.33366C2.96547 8.66699 2.66699 8.36852 2.66699 8.00033C2.66699 7.63214 2.96547 7.33366 3.33366 7.33366H7.33366V3.33366C7.33366 2.96547 7.63214 2.66699 8.00033 2.66699Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ae=h.forwardRef(function(i,n){return h.createElement(q,Object.assign({},i,{id:"plus-single",ref:n,icon:we}))});ae.displayName="PlusSingle";var Re={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.66695 1.33496C2.29968 1.33496 2.00195 1.63269 2.00195 1.99996V3.64439C2.00195 4.01166 2.29968 4.30939 2.66695 4.30939C3.03422 4.30939 3.33195 4.01166 3.33195 3.64439V2.66496H7.33521V13.335H5.3337C4.96643 13.335 4.6687 13.6327 4.6687 14C4.6687 14.3672 4.96643 14.665 5.3337 14.665H10.667C11.0343 14.665 11.332 14.3672 11.332 14C11.332 13.6327 11.0343 13.335 10.667 13.335H8.66521V2.66496H12.6686V3.64439C12.6686 4.01166 12.9664 4.30939 13.3336 4.30939C13.7009 4.30939 13.9986 4.01166 13.9986 3.64439V1.99996C13.9986 1.63269 13.7009 1.33496 13.3336 1.33496H2.66695Z"}}]},G=h.forwardRef(function(i,n){return h.createElement(q,Object.assign({},i,{id:"text-single",ref:n,icon:Re}))});G.displayName="TextSingle";const A=({className:i=""})=>{const n=l.useDependency(c.DocQuickInsertPopupService),e=l.useDependency(s.IUniverInstanceService),t=l.useDependency(V.IRenderManagerService),r=l.useObservable(h.useMemo(()=>e.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_DOC),[e])),o=r&&t.getRenderById(r.getUnitId()),u=o==null?void 0:o.with(I.DocEventManagerService),v=l.useObservable(u==null?void 0:u.hoverParagraph$),C=l.useObservable(u==null?void 0:u.hoverParagraphLeft$),a=()=>{var m;const d=v!=null?v:C;if(!d)return;const p=n.resolvePopup("/");p&&n.showPopup({popup:p,index:d.startIndex-1,unitId:(m=r==null?void 0:r.getUnitId())!=null?m:""})};return g.jsx("div",{className:`
7
+ univer-mr-1 univer-flex univer-cursor-pointer univer-items-center univer-gap-2.5 univer-rounded-full
8
+ univer-border univer-border-gray-200 univer-bg-white univer-p-1.5 univer-shadow-sm
9
+ hover:univer-bg-gray-100
10
+ ${i}
11
+ `,onClick:a,role:"button",tabIndex:0,children:g.jsx(ae,{className:"univer-text-gray-800"})})};A.componentKey="doc.quick-insert.button";var xe=Object.getOwnPropertyDescriptor,Qe=(i,n,e,t)=>{for(var r=t>1?void 0:t?xe(n,e):n,o=i.length-1,u;o>=0;o--)(u=i[o])&&(r=u(r)||r);return r},Z=(i,n)=>(e,t)=>n(e,t,i);let J=class extends s.Disposable{constructor(n,e,t,r){super();O(this,"_popup",null);this._context=n,this._docEventManagerService=e,this._docQuickInsertPopupService=t,this._docCanvasPopManagerService=r,this._init()}_init(){this.disposeWithMe(y.combineLatest([this._docEventManagerService.hoverParagraphLeft$,this._docEventManagerService.hoverParagraph$]).subscribe(([n,e])=>{var r;const t=n!=null?n:e;if(!t){this._hideMenu(!0);return}if(t.paragraphStart===t.paragraphEnd&&t.startIndex!==((r=this._popup)==null?void 0:r.startIndex)){this._hideMenu(!0);const o=this._docCanvasPopManagerService.attachPopupToRect(t.firstLine,{componentKey:A.componentKey,direction:"left-center"},this._context.unit.getUnitId());this._popup={startIndex:t.startIndex,disposable:o}}else this._hideMenu(!0)}))}_hideMenu(n){this._popup&&(n||this._popup.disposable.canDispose())&&(this._popup.disposable.dispose(),this._popup=null)}};J=Qe([Z(1,s.Inject(I.DocEventManagerService)),Z(2,s.Inject(c.DocQuickInsertPopupService)),Z(3,s.Inject(I.DocCanvasPopManagerService))],J);const ue={id:"quick-insert.text.menu",title:"docQuickInsert.menu.text",icon:"TextSingle",keywords:["text"]},de={id:I.OrderListCommand.id,title:"docQuickInsert.menu.numberedList",icon:"OrderSingle",keywords:["numbered","list","ordered"]},pe={id:I.BulletListCommand.id,title:"docQuickInsert.menu.bulletedList",icon:"UnorderSingle",keywords:["bulleted","list","unordered"]},le={id:I.HorizontalLineCommand.id,title:"docQuickInsert.menu.divider",icon:"DividerSingle",keywords:["divider","line","separate"]},ve={id:I.DocCreateTableOperation.id,title:"docQuickInsert.menu.table",icon:"GridSingle",keywords:["table","grid","spreadsheet"]},he={id:ee.InsertDocImageCommand.id,title:"docQuickInsert.menu.image",icon:"addition-and-subtraction-single",keywords:["image","picture","photo"]},je=[{title:"docQuickInsert.group.basics",id:"quick.insert.group.basic",children:[ue,de,pe,le,ve,he]}],Ee=new Set([de.id,pe.id,le.id,ve.id,he.id]);var Ue=Object.getOwnPropertyDescriptor,$e=(i,n,e,t)=>{for(var r=t>1?void 0:t?Ue(n,e):n,o=i.length-1,u;o>=0;o--)(u=i[o])&&(r=u(r)||r);return r},U=(i,n)=>(e,t)=>n(e,t,i);c.DocQuickInsertTriggerController=class extends s.Disposable{constructor(n,e,t,r,o){super(),this._commandService=n,this._textSelectionManagerService=e,this._docQuickInsertPopupService=t,this._shortcutService=r,this._univerInstanceService=o,this.disposeWithMe(this._shortcutService.registerShortcut({id:j.id,binding:l.KeyCode.ESC,preconditions:()=>!!this._docQuickInsertPopupService.editPopup,priority:1e3})),this._initTrigger(),this._initMenuHandler()}_initTrigger(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var u,v,C;const{_docQuickInsertPopupService:e,_textSelectionManagerService:t,_commandService:r}=this,o=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_DOC);if(!(o!=null&&o.getDisabled())){if(n.id===I.InsertCommand.id){const a=n.params;if(e.editPopup){e.setInputOffset({start:e.inputOffset.start,end:a.range.endOffset+1});return}const d=t.getActiveTextRange();if(!d)return;const p=e.resolvePopup(a.body.dataStream);if(!p||!(p.preconditions?p.preconditions(a):!0))return;e.setInputOffset({start:d.startOffset-1,end:d.startOffset}),setTimeout(()=>{r.executeCommand(ie.id,{index:d.startOffset-1,unitId:a.unitId,popup:p})},100)}if(n.id===I.IMEInputCommand.id){const a=n.params;!e.isComposing&&a.isCompositionStart&&e.setIsComposing(!0),e.isComposing&&a.isCompositionEnd&&e.setIsComposing(!1)}if(n.id===T.RichTextEditingMutation.id){const a=n.params;if(a.isCompositionEnd){const d=(v=(u=a.textRanges)==null?void 0:u[0])==null?void 0:v.endOffset;d&&e.setInputOffset({start:e.inputOffset.start,end:d})}}if(n.id===I.DeleteCommand.id){const a=n.params;if(e.editPopup&&a.direction===s.DeleteDirection.LEFT){const d=(C=a.len)!=null?C:0;e.setInputOffset({start:e.inputOffset.start,end:a.range.endOffset-d})}}if(n.id===I.MoveCursorOperation.id){const a=n.params;(a.direction===s.Direction.LEFT||a.direction===s.Direction.RIGHT)&&e.editPopup&&r.executeCommand(j.id)}if(n.id===I.DeleteLeftCommand.id){const a=t.getActiveTextRange();if(!e.editPopup||!a)return;a.endOffset<=e.editPopup.anchor&&r.executeCommand(j.id)}}}))}_initMenuHandler(){this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected(n=>{n.id!==ue.id&&Ee.has(n.id)&&this._commandService.executeCommand(n.id)}))}},c.DocQuickInsertTriggerController=$e([U(0,s.ICommandService),U(1,s.Inject(T.DocSelectionManagerService)),U(2,s.Inject(c.DocQuickInsertPopupService)),U(3,s.Inject(l.IShortcutService)),U(4,s.Inject(s.IUniverInstanceService))],c.DocQuickInsertTriggerController);var Ne=Object.getOwnPropertyDescriptor,Te=(i,n,e,t)=>{for(var r=t>1?void 0:t?Ne(n,e):n,o=i.length-1,u;o>=0;o--)(u=i[o])&&(r=u(r)||r);return r},X=(i,n)=>(e,t)=>n(e,t,i);c.DocQuickInsertUIController=class extends s.Disposable{constructor(n,e,t){super(),this._commandService=n,this._docQuickInsertPopupService=e,this._componentManager=t,this._initCommands(),this._initComponents(),this._initMenus()}_initCommands(){[te,ie,j].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initComponents(){[[L.componentKey,L],[K.componentKey,K],[H.componentKey,H],[F.displayName,F],[G.displayName,G],[A.componentKey,A]].forEach(([e,t])=>{e&&this.disposeWithMe(this._componentManager.register(e,t))}),[{keyword:"/",menus$:y.of(je),preconditions:e=>{var t;return((t=e.range.startNodePosition)==null?void 0:t.glyph)===0}}].forEach(e=>{this.disposeWithMe(this._docQuickInsertPopupService.registerPopup(e))})}_initMenus(){}},c.DocQuickInsertUIController=Te([X(0,s.ICommandService),X(1,s.Inject(c.DocQuickInsertPopupService)),X(2,s.Inject(l.ComponentManager))],c.DocQuickInsertUIController);var Ke=Object.defineProperty,He=Object.getOwnPropertyDescriptor,Le=(i,n,e)=>n in i?Ke(i,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[n]=e,qe=(i,n,e,t)=>{for(var r=t>1?void 0:t?He(n,e):n,o=i.length-1,u;o>=0;o--)(u=i[o])&&(r=u(r)||r);return r},fe=(i,n)=>(e,t)=>n(e,t,i),ge=(i,n,e)=>Le(i,typeof n!="symbol"?n+"":n,e);const Ae="DOC_QUICK_INSERT_UI_PLUGIN";c.UniverDocsQuickInsertUIPlugin=class extends s.Plugin{constructor(n,e){super(),this._injector=n,this._renderManagerSrv=e}onStarting(){[[c.DocQuickInsertUIController],[c.DocQuickInsertTriggerController],[c.DocQuickInsertPopupService]].forEach(e=>this._injector.add(e)),this._injector.get(c.DocQuickInsertUIController)}onRendered(){this._injector.get(c.DocQuickInsertTriggerController),this._injector.get(c.DocQuickInsertPopupService),[[J]].forEach(n=>{this._renderManagerSrv.registerRenderModule(s.UniverInstanceType.UNIVER_DOC,n)})}},ge(c.UniverDocsQuickInsertUIPlugin,"type",s.UniverInstanceType.UNIVER_DOC),ge(c.UniverDocsQuickInsertUIPlugin,"pluginName",Ae),c.UniverDocsQuickInsertUIPlugin=qe([s.DependentOn(_e.UniverDrawingUIPlugin,Ce.UniverDrawingPlugin,ee.UniverDocsDrawingUIPlugin,w.UniverDocsDrawingPlugin,l.UniverUIPlugin),fe(0,s.Inject(s.Injector)),fe(1,s.Inject(V.IRenderManagerService))],c.UniverDocsQuickInsertUIPlugin),c.KeywordInputPlaceholderComponentKey=ne,c.QuickInsertPlaceholderComponentKey=re,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-quick-insert-ui",
3
- "version": "0.6.9-nightly.202504091607",
3
+ "version": "0.6.10-alpha.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -52,17 +52,17 @@
52
52
  "rxjs": ">=7.0.0"
53
53
  },
54
54
  "dependencies": {
55
- "@univerjs/icons": "^0.2.34",
56
- "@univerjs/core": "0.6.9-nightly.202504091607",
57
- "@univerjs/design": "0.6.9-nightly.202504091607",
58
- "@univerjs/docs": "0.6.9-nightly.202504091607",
59
- "@univerjs/docs-drawing-ui": "0.6.9-nightly.202504091607",
60
- "@univerjs/docs-ui": "0.6.9-nightly.202504091607",
61
- "@univerjs/drawing-ui": "0.6.9-nightly.202504091607",
62
- "@univerjs/engine-render": "0.6.9-nightly.202504091607",
63
- "@univerjs/ui": "0.6.9-nightly.202504091607",
64
- "@univerjs/drawing": "0.6.9-nightly.202504091607",
65
- "@univerjs/docs-drawing": "0.6.9-nightly.202504091607"
55
+ "@univerjs/icons": "^0.2.35",
56
+ "@univerjs/core": "0.6.10-alpha.0",
57
+ "@univerjs/docs": "0.6.10-alpha.0",
58
+ "@univerjs/design": "0.6.10-alpha.0",
59
+ "@univerjs/docs-drawing": "0.6.10-alpha.0",
60
+ "@univerjs/docs-ui": "0.6.10-alpha.0",
61
+ "@univerjs/docs-drawing-ui": "0.6.10-alpha.0",
62
+ "@univerjs/drawing": "0.6.10-alpha.0",
63
+ "@univerjs/engine-render": "0.6.10-alpha.0",
64
+ "@univerjs/drawing-ui": "0.6.10-alpha.0",
65
+ "@univerjs/ui": "0.6.10-alpha.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "postcss": "^8.5.3",
@@ -72,7 +72,7 @@
72
72
  "typescript": "^5.8.2",
73
73
  "vite": "^6.2.3",
74
74
  "vitest": "^3.0.9",
75
- "@univerjs-infra/shared": "0.6.9"
75
+ "@univerjs-infra/shared": "0.6.10-alpha.0"
76
76
  },
77
77
  "scripts": {
78
78
  "test": "vitest run",