@univerjs/docs-quick-insert-ui 0.7.0 → 0.8.0-beta.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/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Ie=Object.defineProperty;var Ce=(r,t,e)=>t in r?Ie(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var y=(r,t,e)=>Ce(r,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),Se=require("@univerjs/docs-drawing"),ne=require("@univerjs/docs-drawing-ui"),_e=require("@univerjs/drawing"),ye=require("@univerjs/drawing-ui"),X=require("@univerjs/engine-render"),d=require("@univerjs/ui"),S=require("@univerjs/docs-ui"),I=require("rxjs"),N=require("@univerjs/docs"),g=require("react/jsx-runtime"),M=require("@univerjs/design"),h=require("react"),re={id:"doc.command.delete-search-key",type:o.CommandType.COMMAND,handler:(r,t)=>{const e=r.get(o.ICommandService),{start:n,end:i}=t;return e.syncExecuteCommand(S.CutContentCommand.id,{segmentId:"",textRanges:[{startOffset:n,endOffset:n,collapsed:!0}],selections:[{startOffset:n,endOffset:i,collapsed:!1,direction:o.RANGE_DIRECTION.FORWARD}]})}},ie="docs.quick.insert.keyword-input-placeholder",H=()=>{const r=d.useDependency(o.LocaleService);return g.jsx("div",{className:"univer-translate-y-1.5 univer-text-sm univer-text-gray-500",children:r.t("docQuickInsert.keywordInputPlaceholder")})};H.componentKey=ie;const se={type:o.CommandType.OPERATION,id:"doc.operation.show-quick-insert-popup",handler(r,t){const e=r.get(exports.DocQuickInsertPopupService);return t?(e.showPopup(t),!0):!1}},$={type:o.CommandType.OPERATION,id:"doc.operation.close-quick-insert-popup",handler(r){return r.get(exports.DocQuickInsertPopupService).closePopup(),!0}},oe="docs.quick.insert.placeholder",L=()=>{const r=d.useDependency(o.LocaleService);return g.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:g.jsx("span",{children:r.t("docQuickInsert.placeholder")})})};L.componentKey=oe;function F(r,t){return r.map(e=>({...e})).filter(e=>{if("children"in e)return e.children=F(e.children,t),e.children.length>0;const n=e.keywords;return n?n.some(i=>i.includes(t)):e.title.toLowerCase().includes(t)})}function ce(r,t){return r.map(e=>{const n={...e};return"children"in n&&(n.children=ce(n.children,t)),n.title=t.t(n.title),"keywords"in n&&(n.keywords=n.keywords.concat(n.title).map(i=>i.toLowerCase())),n})}const Pe=[d.KeyCode.ARROW_UP,d.KeyCode.ARROW_DOWN,d.KeyCode.ENTER],q=()=>{const r=d.useDependency(o.LocaleService),t=d.useDependency(exports.DocQuickInsertPopupService),e=d.useDependency(d.ComponentManager),n=d.useDependency(d.IShortcutService),i=d.useDependency(o.ICommandService),s=h.useMemo(()=>o.generateRandomId(),[]),[a,l]=h.useState(0),m=h.useRef(null),c=h.useRef(0);c.current=0;const u=d.useObservable(t.filterKeyword$,""),p=d.useObservable(t.editPopup$),v=d.useObservable(p==null?void 0:p.popup.menus$,[]),x=h.useMemo(()=>ce(v,r),[v]),[b,R]=h.useState(()=>F(x,u.toLowerCase()));h.useEffect(()=>{const C=requestIdleCallback(()=>{R(F(x,u.toLowerCase()))});return()=>{cancelIdleCallback(C)}},[x,u]);const O=C=>{t.emitMenuSelected(C),i.executeCommand($.id)};h.useEffect(()=>{const C=new o.DisposableCollection;n.getAllShortcuts().filter(f=>f.binding&&Pe.includes(f.binding)).forEach(f=>{const k=f.preconditions;f.preconditions=()=>!1,C.add(o.toDisposable(()=>{f.preconditions=k}))});const D={id:`quick.insert.popup.enter.${s}`,type:o.CommandType.OPERATION,handler:()=>{const f=m.current;f&&O(f)}},Q={id:`quick.insert.popup.move.cursor.up.${s}`,type:o.CommandType.OPERATION,handler:()=>{l(f=>{const k=f-1;return k>=0?k:c.current-1})}},w={id:`quick.insert.popup.move.cursor.down.${s}`,type:o.CommandType.OPERATION,handler:()=>{l(f=>{const k=f+1;return k<=c.current-1?k:0})}};return C.add(i.registerCommand(Q)),C.add(i.registerCommand(w)),C.add(i.registerCommand(D)),C.add(n.registerShortcut({priority:1e3,id:Q.id,binding:d.KeyCode.ARROW_UP,preconditions:()=>!0,staticParameters:{direction:o.Direction.UP}})),C.add(n.registerShortcut({priority:1e3,id:w.id,binding:d.KeyCode.ARROW_DOWN,preconditions:()=>!0,staticParameters:{direction:o.Direction.DOWN}})),C.add(n.registerShortcut({priority:1e3,id:D.id,binding:d.KeyCode.ENTER,preconditions:()=>!0})),()=>{C.dispose()}},[]),h.useEffect(()=>{l(0)},[b]);const T=h.useRef(new Map);h.useEffect(()=>()=>{T.current.clear()},[]);function j(C){return C.map(_=>{const W=_.icon,D=W?e.get(W):null;if("children"in _)return g.jsx(M.MenuItemGroup,{title:g.jsxs("div",{className:"univer-mb-2 univer-flex univer-items-center univer-text-xs univer-text-gray-400",children:[D&&g.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:g.jsx(D,{})}),g.jsx("span",{children:_.title})]}),children:j(_.children)},_.id);const Q=c.current,w=a===Q;if(w){m.current=_;const f=T.current.get(_.id);f==null||f.scrollIntoView({block:"nearest"})}return c.current++,g.jsx(M.MenuItem,{ref:f=>{f&&T.current.set(_.id,f)},onMouseEnter:()=>l(Q),onMouseLeave:()=>l(Number.NaN),className:M.clsx("univer-w-[calc(220px-var(--padding-base)*2)] univer-text-sm",{"hover:univer-bg-transparent":!w,"univer-bg-gray-100":w}),onClick:()=>{O(_)},children:g.jsxs("div",{className:"univer-flex univer-w-full univer-items-center univer-px-1",children:[D&&g.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:g.jsx(D,{})}),g.jsx(M.Tooltip,{showIfEllipsis:!0,title:_.title,placement:"right",children:g.jsx("span",{className:"univer-truncate",children:_.title})})]})},_.id)})}const K=b.length>0,Y=(p==null?void 0:p.popup.Placeholder)||e.get(L.componentKey);return g.jsx("div",{className:M.clsx("univer-mt-2"),children:K?g.jsx(M.Menu,{wrapperClass:"univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto univer-overflow-x-hidden",children:j(b)}):Y&&g.jsx(Y,{})})};q.componentKey="docs.quick.insert.popup";var xe=Object.getOwnPropertyDescriptor,be=(r,t,e,n)=>{for(var i=n>1?void 0:n?xe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=a(i)||i);return i},U=(r,t)=>(e,n)=>t(e,n,r);const ee={dispose:()=>{}};exports.DocQuickInsertPopupService=class extends o.Disposable{constructor(e,n,i,s,a){super();y(this,"_popups",new Set);y(this,"_editPopup$",new I.BehaviorSubject(void 0));y(this,"editPopup$",this._editPopup$.asObservable());y(this,"_isComposing$",new I.BehaviorSubject(!1));y(this,"isComposing$",this._isComposing$.asObservable());y(this,"_inputOffset$",new I.BehaviorSubject({start:0,end:0}));y(this,"inputOffset$",this._inputOffset$.asObservable());y(this,"filterKeyword$");y(this,"_menuSelectedCallbacks",new Set);y(this,"_inputPlaceholderRenderRoot",null);this._docCanvasPopupManagerService=e,this._univerInstanceService=n,this._commandService=i,this._renderManagerService=s,this._docSelectionManagerService=a,this.disposeWithMe(this._editPopup$);const l=(c,u)=>{var p,v;return(v=(p=this._univerInstanceService.getCurrentUnitOfType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:p.getBody())==null?void 0:v.dataStream.slice(c,u)};let m="";this.filterKeyword$=this._inputOffset$.pipe(I.map(c=>{var p;const u=l(c.start,c.end);return(p=u==null?void 0:u.slice(1))!=null?p:""}),I.distinctUntilChanged(),I.tap(c=>{m=c})),this.disposeWithMe(I.combineLatest([this.filterKeyword$.pipe(I.tap(c=>{var u,p,v;c.length>0?(p=(u=this._inputPlaceholderRenderRoot)==null?void 0:u.unmount)==null||p.dispose():(v=this._inputPlaceholderRenderRoot)==null||v.mount()})),this.isComposing$.pipe(I.tap(c=>{var u,p,v;c?(p=(u=this._inputPlaceholderRenderRoot)==null?void 0:u.unmount)==null||p.dispose():m.length<=0&&((v=this._inputPlaceholderRenderRoot)==null||v.mount())})),this.editPopup$.pipe(I.tap(c=>{var u,p;c||((p=(u=this._inputPlaceholderRenderRoot)==null?void 0:u.unmount)==null||p.dispose(),this._inputPlaceholderRenderRoot=null)}))]).subscribe())}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 n;return(n=this._renderManagerService.getRenderById(e))==null?void 0:n.with(S.DocEventManagerService)}resolvePopup(e){return Array.from(this._popups).find(n=>n.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 i=e();this.unmount={dispose:()=>{i.dispose(),this.isMounted=!1}}}}}showPopup(e){var p,v;const{popup:n,index:i,unitId:s}=e;this.closePopup();const a=this._univerInstanceService.getUnit(s),l=(v=(p=a==null?void 0:a.getBody())==null?void 0:p.paragraphs)==null?void 0:v.find(x=>x.startIndex>i);if(!l)return;const m=this.getDocEventManagerService(s),c=m==null?void 0:m.findParagraphBoundByIndex(l.startIndex);if(!c)return;this._inputPlaceholderRenderRoot=this._createInputPlaceholderRenderRoot(()=>{var K;const x=(K=this._renderManagerService.getRenderById(s))==null?void 0:K.with(N.DocSkeletonManagerService),b=this._docSelectionManagerService.getActiveTextRange();if(!x||!b)return ee;const O=x.getSkeleton().findNodeByCharIndex(b.startOffset,b.segmentId,b.segmentPage);if(!((O==null?void 0:O.content)==="\r"))return ee;const j=this._docCanvasPopupManagerService.attachPopupToRange({startOffset:i+1,endOffset:i+1,collapsed:!1},{componentKey:H.componentKey,onClickOutside:()=>{j.dispose()},direction:"horizontal"},s);return j}),this._inputPlaceholderRenderRoot.mount();const u=this._docCanvasPopupManagerService.attachPopupToRect(c.firstLine,{componentKey:q.componentKey,onClickOutside:()=>{this.closePopup()},direction:"bottom"},s);this._editPopup$.next({disposable:u,popup:n,anchor:i,unitId:s})}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:n,end:i}=this.inputOffset;this._commandService.syncExecuteCommand(re.id,{start:n,end:i}),setTimeout(()=>{this._menuSelectedCallbacks.forEach(s=>s(e))},0)}};exports.DocQuickInsertPopupService=be([U(0,o.Inject(S.DocCanvasPopManagerService)),U(1,o.Inject(o.IUniverInstanceService)),U(2,o.Inject(o.ICommandService)),U(3,o.Inject(X.IRenderManagerService)),U(4,o.Inject(N.DocSelectionManagerService))],exports.DocQuickInsertPopupService);const ae="doc.quick-insert.button";var Oe=Object.getOwnPropertyDescriptor,Me=(r,t,e,n)=>{for(var i=n>1?void 0:n?Oe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=a(i)||i);return i},V=(r,t)=>(e,n)=>t(e,n,r);let B=class extends o.Disposable{constructor(t,e,n,i){super();y(this,"_popup$",new I.BehaviorSubject(null));y(this,"popup$",this._popup$.asObservable());this._context=t,this._docEventManagerService=e,this._docQuickInsertPopupService=n,this._docCanvasPopManagerService=i,this._init()}get popup(){return this._popup$.value}_init(){this.disposeWithMe(I.combineLatest([this._docEventManagerService.hoverParagraphLeftRealTime$,this._docEventManagerService.hoverParagraphRealTime$]).subscribe(([t,e])=>{var s;const n=t!=null?t:e,i=this._context.unit.getDisabled();if(!n||i){this._hideMenu(!0);return}if(n.paragraphStart===n.paragraphEnd){if(this._docQuickInsertPopupService.editPopup||n.startIndex===((s=this.popup)==null?void 0:s.startIndex))return;this._hideMenu(!0);const a=this._docCanvasPopManagerService.attachPopupToRect(n.firstLine,{componentKey:ae,direction:"left-center"},this._context.unit.getUnitId());this._popup$.next({startIndex:n.startIndex,disposable:a})}else this._hideMenu(!0)}))}_hideMenu(t){this._docQuickInsertPopupService.editPopup||this.popup&&(t||this.popup.disposable.canDispose())&&(this.popup.disposable.dispose(),this._popup$.next(null))}};B=Me([V(1,o.Inject(S.DocEventManagerService)),V(2,o.Inject(exports.DocQuickInsertPopupService)),V(3,o.Inject(S.DocCanvasPopManagerService))],B);const ue={id:"quick-insert.text.menu",title:"docQuickInsert.menu.text",icon:"TextSingle",keywords:["text"]},de={id:S.OrderListCommand.id,title:"docQuickInsert.menu.numberedList",icon:"OrderSingle",keywords:["numbered","list","ordered"]},pe={id:S.BulletListCommand.id,title:"docQuickInsert.menu.bulletedList",icon:"UnorderSingle",keywords:["bulleted","list","unordered"]},le={id:S.HorizontalLineCommand.id,title:"docQuickInsert.menu.divider",icon:"DividerSingle",keywords:["divider","line","separate"]},ve={id:S.DocCreateTableOperation.id,title:"docQuickInsert.menu.table",icon:"GridSingle",keywords:["table","grid","spreadsheet"]},he={id:ne.InsertDocImageCommand.id,title:"docQuickInsert.menu.image",icon:"addition-and-subtraction-single",keywords:["image","picture","photo"]},De=[{title:"docQuickInsert.group.basics",id:"quick.insert.group.basic",children:[ue,de,pe,le,ve,he]}],ke=new Set([de.id,pe.id,le.id,ve.id,he.id]);var we=Object.getOwnPropertyDescriptor,Re=(r,t,e,n)=>{for(var i=n>1?void 0:n?we(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=a(i)||i);return i},E=(r,t)=>(e,n)=>t(e,n,r);exports.DocQuickInsertTriggerController=class extends o.Disposable{constructor(t,e,n,i,s){super(),this._commandService=t,this._textSelectionManagerService=e,this._docQuickInsertPopupService=n,this._shortcutService=i,this._univerInstanceService=s,this.disposeWithMe(this._shortcutService.registerShortcut({id:$.id,binding:d.KeyCode.ESC,preconditions:()=>!!this._docQuickInsertPopupService.editPopup,priority:1e3})),this._initTrigger(),this._initMenuHandler()}_initTrigger(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var a,l,m;const{_docQuickInsertPopupService:e,_textSelectionManagerService:n,_commandService:i}=this,s=this._univerInstanceService.getCurrentUnitOfType(o.UniverInstanceType.UNIVER_DOC);if(!(s!=null&&s.getDisabled())){if(t.id===S.InsertCommand.id){const c=t.params;if(e.editPopup){e.setInputOffset({start:e.inputOffset.start,end:c.range.endOffset+1});return}const u=n.getActiveTextRange();if(!u)return;const p=e.resolvePopup(c.body.dataStream);if(!p||!(p.preconditions?p.preconditions(c):!0))return;e.setInputOffset({start:u.startOffset-1,end:u.startOffset}),setTimeout(()=>{i.executeCommand(se.id,{index:u.startOffset-1,unitId:c.unitId,popup:p})},100)}if(t.id===S.IMEInputCommand.id){const c=t.params;!e.isComposing&&c.isCompositionStart&&e.setIsComposing(!0),e.isComposing&&c.isCompositionEnd&&e.setIsComposing(!1)}if(t.id===N.RichTextEditingMutation.id){const c=t.params;if(c.isCompositionEnd){const u=(l=(a=c.textRanges)==null?void 0:a[0])==null?void 0:l.endOffset;u&&e.setInputOffset({start:e.inputOffset.start,end:u})}}if(t.id===S.DeleteCommand.id){const c=t.params;if(e.editPopup&&c.direction===o.DeleteDirection.LEFT){const u=(m=c.len)!=null?m:0;e.setInputOffset({start:e.inputOffset.start,end:c.range.endOffset-u})}}if(t.id===S.MoveCursorOperation.id){const c=t.params;(c.direction===o.Direction.LEFT||c.direction===o.Direction.RIGHT)&&e.editPopup&&i.executeCommand($.id)}if(t.id===S.DeleteLeftCommand.id){const c=n.getActiveTextRange();if(!e.editPopup||!c)return;c.endOffset<=e.editPopup.anchor&&i.executeCommand($.id)}}}))}_initMenuHandler(){this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected(t=>{t.id!==ue.id&&ke.has(t.id)&&this._commandService.executeCommand(t.id)}))}};exports.DocQuickInsertTriggerController=Re([E(0,o.ICommandService),E(1,o.Inject(N.DocSelectionManagerService)),E(2,o.Inject(exports.DocQuickInsertPopupService)),E(3,o.Inject(d.IShortcutService)),E(4,o.Inject(o.IUniverInstanceService))],exports.DocQuickInsertTriggerController);var P=function(){return P=Object.assign||function(r){for(var t,e=1,n=arguments.length;e<n;e++){t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=t[i])}return r},P.apply(this,arguments)},je=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e},A=h.forwardRef(function(r,t){var e=r.icon,n=r.id,i=r.className,s=r.extend,a=je(r,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),m=h.useRef("_".concat(Ee()));return fe(e,"".concat(n),{defIds:e.defIds,idSuffix:m.current},P({ref:t,className:l},a),s)});function fe(r,t,e,n,i){return h.createElement(r.tag,P(P({key:t},Qe(r,e,i)),n),(Ue(r,e).children||[]).map(function(s,a){return fe(s,"".concat(t,"-").concat(r.tag,"-").concat(a),e,void 0,i)}))}function Qe(r,t,e){var n=P({},r.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1),r.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],l=s[1];a==="mask"&&typeof l=="string"&&(n[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(r.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],l=s[1];typeof l=="string"&&(n[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Ue(r,t){var e,n=t.defIds;return!n||n.length===0?r:r.tag==="defs"&&(!((e=r.children)===null||e===void 0)&&e.length)?P(P({},r),{children:r.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?P(P({},i),{attrs:P(P({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):r}function Ee(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var $e={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"}}]},G=h.forwardRef(function(r,t){return h.createElement(A,Object.assign({},r,{id:"divider-single",ref:t,icon:$e}))});G.displayName="DividerSingle";var Ne={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"}}]},ge=h.forwardRef(function(r,t){return h.createElement(A,Object.assign({},r,{id:"plus-single",ref:t,icon:Ne}))});ge.displayName="PlusSingle";var Te={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"}}]},Z=h.forwardRef(function(r,t){return h.createElement(A,Object.assign({},r,{id:"text-single",ref:t,icon:Te}))});Z.displayName="TextSingle";const J=({className:r=""})=>{const t=d.useDependency(exports.DocQuickInsertPopupService),e=d.useDependency(o.IUniverInstanceService),n=d.useDependency(X.IRenderManagerService),i=d.useObservable(h.useMemo(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_DOC),[e])),s=i&&n.getRenderById(i.getUnitId()),a=s==null?void 0:s.with(B),l=d.useDependency(d.ILayoutService),m=d.useDependency(N.DocSelectionManagerService),c=d.useObservable(t.editPopup$),u=d.useEvent(p=>{var R;const v=a==null?void 0:a.popup;if(!v)return;const x=t.popups,b={keyword:"",menus$:I.combineLatest(x.map(O=>O.menus$)).pipe(I.map(O=>O.flat()))};m.replaceDocRanges([{startOffset:v.startIndex,endOffset:v.startIndex}]),t.setInputOffset({start:v.startIndex-1,end:v.startIndex-1}),t.showPopup({popup:b,index:v.startIndex-1,unitId:(R=i==null?void 0:i.getUnitId())!=null?R:""}),setTimeout(()=>{l.focus()})});return g.jsx("div",{className:M.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",M.borderClassName,{"univer-bg-gray-100":c,"univer-bg-white":!c},r),role:"button",tabIndex:0,onClick:u,children:g.jsx(ge,{className:"univer-text-gray-800"})})};J.componentKey=ae;var Ke=Object.getOwnPropertyDescriptor,He=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ke(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=a(i)||i);return i},z=(r,t)=>(e,n)=>t(e,n,r);exports.DocQuickInsertUIController=class extends o.Disposable{constructor(t,e,n){super(),this._commandService=t,this._docQuickInsertPopupService=e,this._componentManager=n,this._initCommands(),this._initComponents(),this._initMenus()}_initCommands(){[re,se,$].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initComponents(){[[q.componentKey,q],[H.componentKey,H],[L.componentKey,L],[G.displayName,G],[Z.displayName,Z],[J.componentKey,J]].forEach(([e,n])=>{e&&this.disposeWithMe(this._componentManager.register(e,n))}),[{keyword:"/",menus$:I.of(De),preconditions:e=>{var n;return((n=e.range.startNodePosition)==null?void 0:n.glyph)===0}}].forEach(e=>{this.disposeWithMe(this._docQuickInsertPopupService.registerPopup(e))})}_initMenus(){}};exports.DocQuickInsertUIController=He([z(0,o.ICommandService),z(1,o.Inject(exports.DocQuickInsertPopupService)),z(2,o.Inject(d.ComponentManager))],exports.DocQuickInsertUIController);var Le=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,Be=(r,t,e)=>t in r?Le(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ae=(r,t,e,n)=>{for(var i=n>1?void 0:n?qe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=a(i)||i);return i},te=(r,t)=>(e,n)=>t(e,n,r),me=(r,t,e)=>Be(r,typeof t!="symbol"?t+"":t,e);const We="DOC_QUICK_INSERT_UI_PLUGIN";exports.UniverDocsQuickInsertUIPlugin=class extends o.Plugin{constructor(t,e){super(),this._injector=t,this._renderManagerSrv=e}onStarting(){[[exports.DocQuickInsertUIController],[exports.DocQuickInsertTriggerController],[exports.DocQuickInsertPopupService]].forEach(e=>this._injector.add(e)),this._injector.get(exports.DocQuickInsertUIController)}onRendered(){this._injector.get(exports.DocQuickInsertTriggerController),this._injector.get(exports.DocQuickInsertPopupService),[[B]].forEach(t=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,t)})}};me(exports.UniverDocsQuickInsertUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC);me(exports.UniverDocsQuickInsertUIPlugin,"pluginName",We);exports.UniverDocsQuickInsertUIPlugin=Ae([o.DependentOn(ye.UniverDrawingUIPlugin,_e.UniverDrawingPlugin,ne.UniverDocsDrawingUIPlugin,Se.UniverDocsDrawingPlugin,d.UniverUIPlugin),te(0,o.Inject(o.Injector)),te(1,o.Inject(X.IRenderManagerService))],exports.UniverDocsQuickInsertUIPlugin);exports.KeywordInputPlaceholderComponentKey=ie;exports.QuickInsertPlaceholderComponentKey=oe;
1
+ "use strict";var Ie=Object.defineProperty;var Ce=(r,t,e)=>t in r?Ie(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var y=(r,t,e)=>Ce(r,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),Se=require("@univerjs/docs-drawing"),ne=require("@univerjs/docs-drawing-ui"),_e=require("@univerjs/drawing"),ye=require("@univerjs/drawing-ui"),X=require("@univerjs/engine-render"),d=require("@univerjs/ui"),S=require("@univerjs/docs-ui"),I=require("rxjs"),N=require("@univerjs/docs"),g=require("react/jsx-runtime"),M=require("@univerjs/design"),h=require("react"),re={id:"doc.command.delete-search-key",type:o.CommandType.COMMAND,handler:(r,t)=>{const e=r.get(o.ICommandService),{start:n,end:i}=t;return e.syncExecuteCommand(S.CutContentCommand.id,{segmentId:"",textRanges:[{startOffset:n,endOffset:n,collapsed:!0}],selections:[{startOffset:n,endOffset:i,collapsed:!1,direction:o.RANGE_DIRECTION.FORWARD}]})}},ie="docs.quick.insert.keyword-input-placeholder",H=()=>{const r=d.useDependency(o.LocaleService);return g.jsx("div",{className:"univer-translate-y-1.5 univer-text-sm univer-text-gray-500",children:r.t("docQuickInsert.keywordInputPlaceholder")})};H.componentKey=ie;const se={type:o.CommandType.OPERATION,id:"doc.operation.show-quick-insert-popup",handler(r,t){const e=r.get(exports.DocQuickInsertPopupService);return t?(e.showPopup(t),!0):!1}},$={type:o.CommandType.OPERATION,id:"doc.operation.close-quick-insert-popup",handler(r){return r.get(exports.DocQuickInsertPopupService).closePopup(),!0}},oe="docs.quick.insert.placeholder",L=()=>{const r=d.useDependency(o.LocaleService);return g.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:g.jsx("span",{children:r.t("docQuickInsert.placeholder")})})};L.componentKey=oe;function F(r,t){return r.map(e=>({...e})).filter(e=>{if("children"in e)return e.children=F(e.children,t),e.children.length>0;const n=e.keywords;return n?n.some(i=>i.includes(t)):e.title.toLowerCase().includes(t)})}function ce(r,t){return r.map(e=>{const n={...e};return"children"in n&&(n.children=ce(n.children,t)),n.title=t.t(n.title),"keywords"in n&&(n.keywords=n.keywords.concat(n.title).map(i=>i.toLowerCase())),n})}const Pe=[d.KeyCode.ARROW_UP,d.KeyCode.ARROW_DOWN,d.KeyCode.ENTER],q=()=>{const r=d.useDependency(o.LocaleService),t=d.useDependency(exports.DocQuickInsertPopupService),e=d.useDependency(d.ComponentManager),n=d.useDependency(d.IShortcutService),i=d.useDependency(o.ICommandService),s=h.useMemo(()=>o.generateRandomId(),[]),[a,l]=h.useState(0),m=h.useRef(null),c=h.useRef(0);c.current=0;const u=d.useObservable(t.filterKeyword$,""),p=d.useObservable(t.editPopup$),v=d.useObservable(p==null?void 0:p.popup.menus$,[]),x=h.useMemo(()=>ce(v,r),[v]),[b,R]=h.useState(()=>F(x,u.toLowerCase()));h.useEffect(()=>{const C=requestIdleCallback(()=>{R(F(x,u.toLowerCase()))});return()=>{cancelIdleCallback(C)}},[x,u]);const O=C=>{t.emitMenuSelected(C),i.executeCommand($.id)};h.useEffect(()=>{const C=new o.DisposableCollection;n.getAllShortcuts().filter(f=>f.binding&&Pe.includes(f.binding)).forEach(f=>{const k=f.preconditions;f.preconditions=()=>!1,C.add(o.toDisposable(()=>{f.preconditions=k}))});const D={id:`quick.insert.popup.enter.${s}`,type:o.CommandType.OPERATION,handler:()=>{const f=m.current;f&&O(f)}},Q={id:`quick.insert.popup.move.cursor.up.${s}`,type:o.CommandType.OPERATION,handler:()=>{l(f=>{const k=f-1;return k>=0?k:c.current-1})}},w={id:`quick.insert.popup.move.cursor.down.${s}`,type:o.CommandType.OPERATION,handler:()=>{l(f=>{const k=f+1;return k<=c.current-1?k:0})}};return C.add(i.registerCommand(Q)),C.add(i.registerCommand(w)),C.add(i.registerCommand(D)),C.add(n.registerShortcut({priority:1e3,id:Q.id,binding:d.KeyCode.ARROW_UP,preconditions:()=>!0,staticParameters:{direction:o.Direction.UP}})),C.add(n.registerShortcut({priority:1e3,id:w.id,binding:d.KeyCode.ARROW_DOWN,preconditions:()=>!0,staticParameters:{direction:o.Direction.DOWN}})),C.add(n.registerShortcut({priority:1e3,id:D.id,binding:d.KeyCode.ENTER,preconditions:()=>!0})),()=>{C.dispose()}},[]),h.useEffect(()=>{l(0)},[b]);const T=h.useRef(new Map);h.useEffect(()=>()=>{T.current.clear()},[]);function j(C){return C.map(_=>{const W=_.icon,D=W?e.get(W):null;if("children"in _)return g.jsx(M.MenuItemGroup,{title:g.jsxs("div",{className:"univer-mb-2 univer-flex univer-items-center univer-text-xs univer-text-gray-400",children:[D&&g.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:g.jsx(D,{})}),g.jsx("span",{children:_.title})]}),children:j(_.children)},_.id);const Q=c.current,w=a===Q;if(w){m.current=_;const f=T.current.get(_.id);f==null||f.scrollIntoView({block:"nearest"})}return c.current++,g.jsx(M.MenuItem,{ref:f=>{f&&T.current.set(_.id,f)},onMouseEnter:()=>l(Q),onMouseLeave:()=>l(Number.NaN),className:M.clsx("univer-w-[calc(220px-var(--padding-base)*2)] univer-text-sm",{"hover:univer-bg-transparent":!w,"univer-bg-gray-100 dark:!univer-bg-gray-500":w}),onClick:()=>{O(_)},children:g.jsxs("div",{className:"univer-flex univer-w-full univer-items-center univer-px-1",children:[D&&g.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:g.jsx(D,{})}),g.jsx(M.Tooltip,{showIfEllipsis:!0,title:_.title,placement:"right",children:g.jsx("span",{className:"univer-truncate",children:_.title})})]})},_.id)})}const K=b.length>0,Y=(p==null?void 0:p.popup.Placeholder)||e.get(L.componentKey);return g.jsx("div",{className:M.clsx("univer-mt-2"),children:K?g.jsx(M.Menu,{wrapperClass:"univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto univer-overflow-x-hidden",children:j(b)}):Y&&g.jsx(Y,{})})};q.componentKey="docs.quick.insert.popup";var xe=Object.getOwnPropertyDescriptor,be=(r,t,e,n)=>{for(var i=n>1?void 0:n?xe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=a(i)||i);return i},U=(r,t)=>(e,n)=>t(e,n,r);const ee={dispose:()=>{}};exports.DocQuickInsertPopupService=class extends o.Disposable{constructor(e,n,i,s,a){super();y(this,"_popups",new Set);y(this,"_editPopup$",new I.BehaviorSubject(void 0));y(this,"editPopup$",this._editPopup$.asObservable());y(this,"_isComposing$",new I.BehaviorSubject(!1));y(this,"isComposing$",this._isComposing$.asObservable());y(this,"_inputOffset$",new I.BehaviorSubject({start:0,end:0}));y(this,"inputOffset$",this._inputOffset$.asObservable());y(this,"filterKeyword$");y(this,"_menuSelectedCallbacks",new Set);y(this,"_inputPlaceholderRenderRoot",null);this._docCanvasPopupManagerService=e,this._univerInstanceService=n,this._commandService=i,this._renderManagerService=s,this._docSelectionManagerService=a,this.disposeWithMe(this._editPopup$);const l=(c,u)=>{var p,v;return(v=(p=this._univerInstanceService.getCurrentUnitOfType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:p.getBody())==null?void 0:v.dataStream.slice(c,u)};let m="";this.filterKeyword$=this._inputOffset$.pipe(I.map(c=>{var p;const u=l(c.start,c.end);return(p=u==null?void 0:u.slice(1))!=null?p:""}),I.distinctUntilChanged(),I.tap(c=>{m=c})),this.disposeWithMe(I.combineLatest([this.filterKeyword$.pipe(I.tap(c=>{var u,p,v;c.length>0?(p=(u=this._inputPlaceholderRenderRoot)==null?void 0:u.unmount)==null||p.dispose():(v=this._inputPlaceholderRenderRoot)==null||v.mount()})),this.isComposing$.pipe(I.tap(c=>{var u,p,v;c?(p=(u=this._inputPlaceholderRenderRoot)==null?void 0:u.unmount)==null||p.dispose():m.length<=0&&((v=this._inputPlaceholderRenderRoot)==null||v.mount())})),this.editPopup$.pipe(I.tap(c=>{var u,p;c||((p=(u=this._inputPlaceholderRenderRoot)==null?void 0:u.unmount)==null||p.dispose(),this._inputPlaceholderRenderRoot=null)}))]).subscribe())}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 n;return(n=this._renderManagerService.getRenderById(e))==null?void 0:n.with(S.DocEventManagerService)}resolvePopup(e){return Array.from(this._popups).find(n=>n.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 i=e();this.unmount={dispose:()=>{i.dispose(),this.isMounted=!1}}}}}showPopup(e){var p,v;const{popup:n,index:i,unitId:s}=e;this.closePopup();const a=this._univerInstanceService.getUnit(s),l=(v=(p=a==null?void 0:a.getBody())==null?void 0:p.paragraphs)==null?void 0:v.find(x=>x.startIndex>i);if(!l)return;const m=this.getDocEventManagerService(s),c=m==null?void 0:m.findParagraphBoundByIndex(l.startIndex);if(!c)return;this._inputPlaceholderRenderRoot=this._createInputPlaceholderRenderRoot(()=>{var K;const x=(K=this._renderManagerService.getRenderById(s))==null?void 0:K.with(N.DocSkeletonManagerService),b=this._docSelectionManagerService.getActiveTextRange();if(!x||!b)return ee;const O=x.getSkeleton().findNodeByCharIndex(b.startOffset,b.segmentId,b.segmentPage);if(!((O==null?void 0:O.content)==="\r"))return ee;const j=this._docCanvasPopupManagerService.attachPopupToRange({startOffset:i+1,endOffset:i+1,collapsed:!1},{componentKey:H.componentKey,onClickOutside:()=>{j.dispose()},direction:"horizontal"},s);return j}),this._inputPlaceholderRenderRoot.mount();const u=this._docCanvasPopupManagerService.attachPopupToRect(c.firstLine,{componentKey:q.componentKey,onClickOutside:()=>{this.closePopup()},direction:"bottom"},s);this._editPopup$.next({disposable:u,popup:n,anchor:i,unitId:s})}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:n,end:i}=this.inputOffset;this._commandService.syncExecuteCommand(re.id,{start:n,end:i}),setTimeout(()=>{this._menuSelectedCallbacks.forEach(s=>s(e))},0)}};exports.DocQuickInsertPopupService=be([U(0,o.Inject(S.DocCanvasPopManagerService)),U(1,o.Inject(o.IUniverInstanceService)),U(2,o.Inject(o.ICommandService)),U(3,o.Inject(X.IRenderManagerService)),U(4,o.Inject(N.DocSelectionManagerService))],exports.DocQuickInsertPopupService);const ae="doc.quick-insert.button";var Oe=Object.getOwnPropertyDescriptor,Me=(r,t,e,n)=>{for(var i=n>1?void 0:n?Oe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=a(i)||i);return i},V=(r,t)=>(e,n)=>t(e,n,r);let B=class extends o.Disposable{constructor(t,e,n,i){super();y(this,"_popup$",new I.BehaviorSubject(null));y(this,"popup$",this._popup$.asObservable());this._context=t,this._docEventManagerService=e,this._docQuickInsertPopupService=n,this._docCanvasPopManagerService=i,this._init()}get popup(){return this._popup$.value}_init(){this.disposeWithMe(I.combineLatest([this._docEventManagerService.hoverParagraphLeftRealTime$,this._docEventManagerService.hoverParagraphRealTime$]).subscribe(([t,e])=>{var s;const n=t!=null?t:e,i=this._context.unit.getDisabled();if(!n||i){this._hideMenu(!0);return}if(n.paragraphStart===n.paragraphEnd){if(this._docQuickInsertPopupService.editPopup||n.startIndex===((s=this.popup)==null?void 0:s.startIndex))return;this._hideMenu(!0);const a=this._docCanvasPopManagerService.attachPopupToRect(n.firstLine,{componentKey:ae,direction:"left-center"},this._context.unit.getUnitId());this._popup$.next({startIndex:n.startIndex,disposable:a})}else this._hideMenu(!0)}))}_hideMenu(t){this._docQuickInsertPopupService.editPopup||this.popup&&(t||this.popup.disposable.canDispose())&&(this.popup.disposable.dispose(),this._popup$.next(null))}};B=Me([V(1,o.Inject(S.DocEventManagerService)),V(2,o.Inject(exports.DocQuickInsertPopupService)),V(3,o.Inject(S.DocCanvasPopManagerService))],B);const ue={id:"quick-insert.text.menu",title:"docQuickInsert.menu.text",icon:"TextSingle",keywords:["text"]},de={id:S.OrderListCommand.id,title:"docQuickInsert.menu.numberedList",icon:"OrderSingle",keywords:["numbered","list","ordered"]},pe={id:S.BulletListCommand.id,title:"docQuickInsert.menu.bulletedList",icon:"UnorderSingle",keywords:["bulleted","list","unordered"]},le={id:S.HorizontalLineCommand.id,title:"docQuickInsert.menu.divider",icon:"DividerSingle",keywords:["divider","line","separate"]},ve={id:S.DocCreateTableOperation.id,title:"docQuickInsert.menu.table",icon:"GridSingle",keywords:["table","grid","spreadsheet"]},he={id:ne.InsertDocImageCommand.id,title:"docQuickInsert.menu.image",icon:"addition-and-subtraction-single",keywords:["image","picture","photo"]},De=[{title:"docQuickInsert.group.basics",id:"quick.insert.group.basic",children:[ue,de,pe,le,ve,he]}],ke=new Set([de.id,pe.id,le.id,ve.id,he.id]);var we=Object.getOwnPropertyDescriptor,Re=(r,t,e,n)=>{for(var i=n>1?void 0:n?we(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=a(i)||i);return i},E=(r,t)=>(e,n)=>t(e,n,r);exports.DocQuickInsertTriggerController=class extends o.Disposable{constructor(t,e,n,i,s){super(),this._commandService=t,this._textSelectionManagerService=e,this._docQuickInsertPopupService=n,this._shortcutService=i,this._univerInstanceService=s,this.disposeWithMe(this._shortcutService.registerShortcut({id:$.id,binding:d.KeyCode.ESC,preconditions:()=>!!this._docQuickInsertPopupService.editPopup,priority:1e3})),this._initTrigger(),this._initMenuHandler()}_initTrigger(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var a,l,m;const{_docQuickInsertPopupService:e,_textSelectionManagerService:n,_commandService:i}=this,s=this._univerInstanceService.getCurrentUnitOfType(o.UniverInstanceType.UNIVER_DOC);if(!(s!=null&&s.getDisabled())){if(t.id===S.InsertCommand.id){const c=t.params;if(e.editPopup){e.setInputOffset({start:e.inputOffset.start,end:c.range.endOffset+1});return}const u=n.getActiveTextRange();if(!u)return;const p=e.resolvePopup(c.body.dataStream);if(!p||!(p.preconditions?p.preconditions(c):!0))return;e.setInputOffset({start:u.startOffset-1,end:u.startOffset}),setTimeout(()=>{i.executeCommand(se.id,{index:u.startOffset-1,unitId:c.unitId,popup:p})},100)}if(t.id===S.IMEInputCommand.id){const c=t.params;!e.isComposing&&c.isCompositionStart&&e.setIsComposing(!0),e.isComposing&&c.isCompositionEnd&&e.setIsComposing(!1)}if(t.id===N.RichTextEditingMutation.id){const c=t.params;if(c.isCompositionEnd){const u=(l=(a=c.textRanges)==null?void 0:a[0])==null?void 0:l.endOffset;u&&e.setInputOffset({start:e.inputOffset.start,end:u})}}if(t.id===S.DeleteCommand.id){const c=t.params;if(e.editPopup&&c.direction===o.DeleteDirection.LEFT){const u=(m=c.len)!=null?m:0;e.setInputOffset({start:e.inputOffset.start,end:c.range.endOffset-u})}}if(t.id===S.MoveCursorOperation.id){const c=t.params;(c.direction===o.Direction.LEFT||c.direction===o.Direction.RIGHT)&&e.editPopup&&i.executeCommand($.id)}if(t.id===S.DeleteLeftCommand.id){const c=n.getActiveTextRange();if(!e.editPopup||!c)return;c.endOffset<=e.editPopup.anchor&&i.executeCommand($.id)}}}))}_initMenuHandler(){this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected(t=>{t.id!==ue.id&&ke.has(t.id)&&this._commandService.executeCommand(t.id)}))}};exports.DocQuickInsertTriggerController=Re([E(0,o.ICommandService),E(1,o.Inject(N.DocSelectionManagerService)),E(2,o.Inject(exports.DocQuickInsertPopupService)),E(3,o.Inject(d.IShortcutService)),E(4,o.Inject(o.IUniverInstanceService))],exports.DocQuickInsertTriggerController);var P=function(){return P=Object.assign||function(r){for(var t,e=1,n=arguments.length;e<n;e++){t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=t[i])}return r},P.apply(this,arguments)},je=function(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e},A=h.forwardRef(function(r,t){var e=r.icon,n=r.id,i=r.className,s=r.extend,a=je(r,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),m=h.useRef("_".concat(Ee()));return fe(e,"".concat(n),{defIds:e.defIds,idSuffix:m.current},P({ref:t,className:l},a),s)});function fe(r,t,e,n,i){return h.createElement(r.tag,P(P({key:t},Qe(r,e,i)),n),(Ue(r,e).children||[]).map(function(s,a){return fe(s,"".concat(t,"-").concat(r.tag,"-").concat(a),e,void 0,i)}))}function Qe(r,t,e){var n=P({},r.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1),r.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],l=s[1];a==="mask"&&typeof l=="string"&&(n[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(r.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var a=s[0],l=s[1];typeof l=="string"&&(n[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Ue(r,t){var e,n=t.defIds;return!n||n.length===0?r:r.tag==="defs"&&(!((e=r.children)===null||e===void 0)&&e.length)?P(P({},r),{children:r.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?P(P({},i),{attrs:P(P({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):r}function Ee(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var $e={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"}}]},G=h.forwardRef(function(r,t){return h.createElement(A,Object.assign({},r,{id:"divider-single",ref:t,icon:$e}))});G.displayName="DividerSingle";var Ne={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"}}]},ge=h.forwardRef(function(r,t){return h.createElement(A,Object.assign({},r,{id:"plus-single",ref:t,icon:Ne}))});ge.displayName="PlusSingle";var Te={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"}}]},Z=h.forwardRef(function(r,t){return h.createElement(A,Object.assign({},r,{id:"text-single",ref:t,icon:Te}))});Z.displayName="TextSingle";const J=({className:r=""})=>{const t=d.useDependency(exports.DocQuickInsertPopupService),e=d.useDependency(o.IUniverInstanceService),n=d.useDependency(X.IRenderManagerService),i=d.useObservable(h.useMemo(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_DOC),[e])),s=i&&n.getRenderById(i.getUnitId()),a=s==null?void 0:s.with(B),l=d.useDependency(d.ILayoutService),m=d.useDependency(N.DocSelectionManagerService),c=d.useObservable(t.editPopup$),u=d.useEvent(p=>{var R;const v=a==null?void 0:a.popup;if(!v)return;const x=t.popups,b={keyword:"",menus$:I.combineLatest(x.map(O=>O.menus$)).pipe(I.map(O=>O.flat()))};m.replaceDocRanges([{startOffset:v.startIndex,endOffset:v.startIndex}]),t.setInputOffset({start:v.startIndex-1,end:v.startIndex-1}),t.showPopup({popup:b,index:v.startIndex-1,unitId:(R=i==null?void 0:i.getUnitId())!=null?R:""}),setTimeout(()=>{l.focus()})});return g.jsx("div",{className:M.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 dark:!univer-text-gray-200 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",M.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-700":c,"univer-bg-white dark:!univer-bg-gray-900":!c},r),role:"button",tabIndex:0,onClick:u,children:g.jsx(ge,{className:"univer-text-gray-800 dark:!univer-text-gray-200"})})};J.componentKey=ae;var Ke=Object.getOwnPropertyDescriptor,He=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ke(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=a(i)||i);return i},z=(r,t)=>(e,n)=>t(e,n,r);exports.DocQuickInsertUIController=class extends o.Disposable{constructor(t,e,n){super(),this._commandService=t,this._docQuickInsertPopupService=e,this._componentManager=n,this._initCommands(),this._initComponents(),this._initMenus()}_initCommands(){[re,se,$].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initComponents(){[[q.componentKey,q],[H.componentKey,H],[L.componentKey,L],[G.displayName,G],[Z.displayName,Z],[J.componentKey,J]].forEach(([e,n])=>{e&&this.disposeWithMe(this._componentManager.register(e,n))}),[{keyword:"/",menus$:I.of(De),preconditions:e=>{var n;return((n=e.range.startNodePosition)==null?void 0:n.glyph)===0}}].forEach(e=>{this.disposeWithMe(this._docQuickInsertPopupService.registerPopup(e))})}_initMenus(){}};exports.DocQuickInsertUIController=He([z(0,o.ICommandService),z(1,o.Inject(exports.DocQuickInsertPopupService)),z(2,o.Inject(d.ComponentManager))],exports.DocQuickInsertUIController);var Le=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,Be=(r,t,e)=>t in r?Le(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ae=(r,t,e,n)=>{for(var i=n>1?void 0:n?qe(t,e):t,s=r.length-1,a;s>=0;s--)(a=r[s])&&(i=a(i)||i);return i},te=(r,t)=>(e,n)=>t(e,n,r),me=(r,t,e)=>Be(r,typeof t!="symbol"?t+"":t,e);const We="DOC_QUICK_INSERT_UI_PLUGIN";exports.UniverDocsQuickInsertUIPlugin=class extends o.Plugin{constructor(t,e){super(),this._injector=t,this._renderManagerSrv=e}onStarting(){[[exports.DocQuickInsertUIController],[exports.DocQuickInsertTriggerController],[exports.DocQuickInsertPopupService]].forEach(e=>this._injector.add(e)),this._injector.get(exports.DocQuickInsertUIController)}onRendered(){this._injector.get(exports.DocQuickInsertTriggerController),this._injector.get(exports.DocQuickInsertPopupService),[[B]].forEach(t=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,t)})}};me(exports.UniverDocsQuickInsertUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC);me(exports.UniverDocsQuickInsertUIPlugin,"pluginName",We);exports.UniverDocsQuickInsertUIPlugin=Ae([o.DependentOn(ye.UniverDrawingUIPlugin,_e.UniverDrawingPlugin,ne.UniverDocsDrawingUIPlugin,Se.UniverDocsDrawingPlugin,d.UniverUIPlugin),te(0,o.Inject(o.Injector)),te(1,o.Inject(X.IRenderManagerService))],exports.UniverDocsQuickInsertUIPlugin);exports.KeywordInputPlaceholderComponentKey=ie;exports.QuickInsertPlaceholderComponentKey=oe;
package/lib/es/index.js CHANGED
@@ -7,14 +7,14 @@ import { InsertDocImageCommand as Je, UniverDocsDrawingUIPlugin as Xe } from "@u
7
7
  import { UniverDrawingPlugin as Ye } from "@univerjs/drawing";
8
8
  import { UniverDrawingUIPlugin as et } from "@univerjs/drawing-ui";
9
9
  import { IRenderManagerService as he } from "@univerjs/engine-render";
10
- import { useDependency as I, KeyCode as b, ComponentManager as Se, IShortcutService as ye, useObservable as U, ILayoutService as tt, useEvent as nt, UniverUIPlugin as it } from "@univerjs/ui";
10
+ import { useDependency as I, KeyCode as M, ComponentManager as Se, IShortcutService as ye, useObservable as U, ILayoutService as tt, useEvent as nt, UniverUIPlugin as it } from "@univerjs/ui";
11
11
  import { CutContentCommand as rt, DocCanvasPopManagerService as Pe, DocEventManagerService as Oe, OrderListCommand as st, BulletListCommand as ot, HorizontalLineCommand as ct, DocCreateTableOperation as at, InsertCommand as dt, IMEInputCommand as ut, DeleteCommand as pt, MoveCursorOperation as lt, DeleteLeftCommand as ht } from "@univerjs/docs-ui";
12
12
  import { map as xe, distinctUntilChanged as ft, tap as j, combineLatest as fe, BehaviorSubject as A, of as vt } from "rxjs";
13
13
  import { DocSelectionManagerService as ve, DocSkeletonManagerService as mt, RichTextEditingMutation as gt } from "@univerjs/docs";
14
14
  import { jsx as h, jsxs as ge } from "react/jsx-runtime";
15
15
  import { clsx as se, Menu as _t, MenuItemGroup as Ct, MenuItem as It, Tooltip as St, borderClassName as yt } from "@univerjs/design";
16
16
  import { useMemo as oe, useState as _e, useRef as B, useEffect as L, forwardRef as Y, createElement as ee } from "react";
17
- const Me = {
17
+ const be = {
18
18
  id: "doc.command.delete-search-key",
19
19
  type: D.COMMAND,
20
20
  handler: (t, e) => {
@@ -39,7 +39,7 @@ const Me = {
39
39
  return /* @__PURE__ */ h("div", { className: "univer-translate-y-1.5 univer-text-sm univer-text-gray-500", children: t.t("docQuickInsert.keywordInputPlaceholder") });
40
40
  };
41
41
  V.componentKey = Pt;
42
- const be = {
42
+ const Me = {
43
43
  type: D.OPERATION,
44
44
  id: "doc.operation.show-quick-insert-popup",
45
45
  handler(t, e) {
@@ -77,7 +77,7 @@ function we(t, e) {
77
77
  return "children" in n && (n.children = we(n.children, e)), n.title = e.t(n.title), "keywords" in n && (n.keywords = n.keywords.concat(n.title).map((r) => r.toLowerCase())), n;
78
78
  });
79
79
  }
80
- const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
80
+ const xt = [M.ARROW_UP, M.ARROW_DOWN, M.ENTER], z = () => {
81
81
  const t = I(pe), e = I(S), i = I(Se), n = I(ye), r = I(H), s = oe(() => Be(), []), [c, u] = _e(0), o = B(null), a = B(0);
82
82
  a.current = 0;
83
83
  const d = U(e.filterKeyword$, ""), p = U(e.editPopup$), v = U(p == null ? void 0 : p.popup.menus$, []), y = oe(() => we(v, t), [v]), [w, P] = _e(() => ce(y, d.toLowerCase()));
@@ -95,9 +95,9 @@ const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
95
95
  L(() => {
96
96
  const m = new We();
97
97
  n.getAllShortcuts().filter((l) => l.binding && xt.includes(l.binding)).forEach((l) => {
98
- const M = l.preconditions;
98
+ const b = l.preconditions;
99
99
  l.preconditions = () => !1, m.add(Ve(() => {
100
- l.preconditions = M;
100
+ l.preconditions = b;
101
101
  }));
102
102
  });
103
103
  const x = {
@@ -112,32 +112,32 @@ const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
112
112
  type: D.OPERATION,
113
113
  handler: () => {
114
114
  u((l) => {
115
- const M = l - 1;
116
- return M >= 0 ? M : a.current - 1;
115
+ const b = l - 1;
116
+ return b >= 0 ? b : a.current - 1;
117
117
  });
118
118
  }
119
- }, k = {
119
+ }, R = {
120
120
  id: `quick.insert.popup.move.cursor.down.${s}`,
121
121
  type: D.OPERATION,
122
122
  handler: () => {
123
123
  u((l) => {
124
- const M = l + 1;
125
- return M <= a.current - 1 ? M : 0;
124
+ const b = l + 1;
125
+ return b <= a.current - 1 ? b : 0;
126
126
  });
127
127
  }
128
128
  };
129
- return m.add(r.registerCommand(E)), m.add(r.registerCommand(k)), m.add(r.registerCommand(x)), m.add(n.registerShortcut({
129
+ return m.add(r.registerCommand(E)), m.add(r.registerCommand(R)), m.add(r.registerCommand(x)), m.add(n.registerShortcut({
130
130
  priority: 1e3,
131
131
  id: E.id,
132
- binding: b.ARROW_UP,
132
+ binding: M.ARROW_UP,
133
133
  preconditions: () => !0,
134
134
  staticParameters: {
135
135
  direction: W.UP
136
136
  }
137
137
  })), m.add(n.registerShortcut({
138
138
  priority: 1e3,
139
- id: k.id,
140
- binding: b.ARROW_DOWN,
139
+ id: R.id,
140
+ binding: M.ARROW_DOWN,
141
141
  preconditions: () => !0,
142
142
  staticParameters: {
143
143
  direction: W.DOWN
@@ -145,7 +145,7 @@ const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
145
145
  })), m.add(n.registerShortcut({
146
146
  priority: 1e3,
147
147
  id: x.id,
148
- binding: b.ENTER,
148
+ binding: M.ENTER,
149
149
  preconditions: () => !0
150
150
  })), () => {
151
151
  m.dispose();
@@ -153,9 +153,9 @@ const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
153
153
  }, []), L(() => {
154
154
  u(0);
155
155
  }, [w]);
156
- const R = B(/* @__PURE__ */ new Map());
156
+ const k = B(/* @__PURE__ */ new Map());
157
157
  L(() => () => {
158
- R.current.clear();
158
+ k.current.clear();
159
159
  }, []);
160
160
  function $(m) {
161
161
  return m.map((g) => {
@@ -178,10 +178,10 @@ const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
178
178
  },
179
179
  g.id
180
180
  );
181
- const E = a.current, k = c === E;
182
- if (k) {
181
+ const E = a.current, R = c === E;
182
+ if (R) {
183
183
  o.current = g;
184
- const l = R.current.get(g.id);
184
+ const l = k.current.get(g.id);
185
185
  l == null || l.scrollIntoView({
186
186
  block: "nearest"
187
187
  });
@@ -190,13 +190,13 @@ const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
190
190
  It,
191
191
  {
192
192
  ref: (l) => {
193
- l && R.current.set(g.id, l);
193
+ l && k.current.set(g.id, l);
194
194
  },
195
195
  onMouseEnter: () => u(E),
196
196
  onMouseLeave: () => u(Number.NaN),
197
197
  className: se("univer-w-[calc(220px-var(--padding-base)*2)] univer-text-sm", {
198
- "hover:univer-bg-transparent": !k,
199
- "univer-bg-gray-100": k
198
+ "hover:univer-bg-transparent": !R,
199
+ "univer-bg-gray-100 dark:!univer-bg-gray-500": R
200
200
  }),
201
201
  onClick: () => {
202
202
  O(g);
@@ -220,8 +220,8 @@ const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
220
220
  return /* @__PURE__ */ h("div", { className: se("univer-mt-2"), children: Ke ? /* @__PURE__ */ h(_t, { wrapperClass: "univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto univer-overflow-x-hidden", children: $(w) }) : me && /* @__PURE__ */ h(me, {}) });
221
221
  };
222
222
  z.componentKey = "docs.quick.insert.popup";
223
- var Mt = Object.getOwnPropertyDescriptor, bt = (t, e, i, n) => {
224
- for (var r = n > 1 ? void 0 : n ? Mt(e, i) : e, s = t.length - 1, c; s >= 0; s--)
223
+ var bt = Object.getOwnPropertyDescriptor, Mt = (t, e, i, n) => {
224
+ for (var r = n > 1 ? void 0 : n ? bt(e, i) : e, s = t.length - 1, c; s >= 0; s--)
225
225
  (c = t[s]) && (r = c(r) || r);
226
226
  return r;
227
227
  }, N = (t, e) => (i, n) => e(i, n, t);
@@ -337,18 +337,18 @@ let S = class extends X {
337
337
  const P = v.getSkeleton().findNodeByCharIndex(y.startOffset, y.segmentId, y.segmentPage);
338
338
  if (!((P == null ? void 0 : P.content) === "\r"))
339
339
  return Ce;
340
- const R = this._docCanvasPopupManagerService.attachPopupToRange(
340
+ const k = this._docCanvasPopupManagerService.attachPopupToRange(
341
341
  { startOffset: n + 1, endOffset: n + 1, collapsed: !1 },
342
342
  {
343
343
  componentKey: V.componentKey,
344
344
  onClickOutside: () => {
345
- R.dispose();
345
+ k.dispose();
346
346
  },
347
347
  direction: "horizontal"
348
348
  },
349
349
  r
350
350
  );
351
- return R;
351
+ return k;
352
352
  }), this._inputPlaceholderRenderRoot.mount();
353
353
  const a = this._docCanvasPopupManagerService.attachPopupToRect(
354
354
  o.firstLine,
@@ -373,7 +373,7 @@ let S = class extends X {
373
373
  }
374
374
  emitMenuSelected(e) {
375
375
  const { start: i, end: n } = this.inputOffset;
376
- this._commandService.syncExecuteCommand(Me.id, {
376
+ this._commandService.syncExecuteCommand(be.id, {
377
377
  start: i,
378
378
  end: n
379
379
  }), setTimeout(() => {
@@ -381,15 +381,15 @@ let S = class extends X {
381
381
  }, 0);
382
382
  }
383
383
  };
384
- S = bt([
384
+ S = Mt([
385
385
  N(0, f(Pe)),
386
386
  N(1, f(le)),
387
387
  N(2, f(H)),
388
388
  N(3, f(he)),
389
389
  N(4, f(ve))
390
390
  ], S);
391
- const Re = "doc.quick-insert.button";
392
- var wt = Object.getOwnPropertyDescriptor, Rt = (t, e, i, n) => {
391
+ const ke = "doc.quick-insert.button";
392
+ var wt = Object.getOwnPropertyDescriptor, kt = (t, e, i, n) => {
393
393
  for (var r = n > 1 ? void 0 : n ? wt(e, i) : e, s = t.length - 1, c; s >= 0; s--)
394
394
  (c = t[s]) && (r = c(r) || r);
395
395
  return r;
@@ -416,7 +416,7 @@ let F = class extends X {
416
416
  if (this._docQuickInsertPopupService.editPopup || n.startIndex === ((s = this.popup) == null ? void 0 : s.startIndex)) return;
417
417
  this._hideMenu(!0);
418
418
  const c = this._docCanvasPopManagerService.attachPopupToRect(n.firstLine, {
419
- componentKey: Re,
419
+ componentKey: ke,
420
420
  direction: "left-center"
421
421
  }, this._context.unit.getUnitId());
422
422
  this._popup$.next({
@@ -431,12 +431,12 @@ let F = class extends X {
431
431
  this._docQuickInsertPopupService.editPopup || this.popup && (e || this.popup.disposable.canDispose()) && (this.popup.disposable.dispose(), this._popup$.next(null));
432
432
  }
433
433
  };
434
- F = Rt([
434
+ F = kt([
435
435
  ie(1, f(Oe)),
436
436
  ie(2, f(S)),
437
437
  ie(3, f(Pe))
438
438
  ], F);
439
- const ke = {
439
+ const Re = {
440
440
  id: "quick-insert.text.menu",
441
441
  title: "docQuickInsert.menu.text",
442
442
  icon: "TextSingle",
@@ -466,12 +466,12 @@ const ke = {
466
466
  title: "docQuickInsert.menu.image",
467
467
  icon: "addition-and-subtraction-single",
468
468
  keywords: ["image", "picture", "photo"]
469
- }, kt = [
469
+ }, Rt = [
470
470
  {
471
471
  title: "docQuickInsert.group.basics",
472
472
  id: "quick.insert.group.basic",
473
473
  children: [
474
- ke,
474
+ Re,
475
475
  De,
476
476
  $e,
477
477
  Ee,
@@ -495,7 +495,7 @@ let G = class extends X {
495
495
  constructor(t, e, i, n, r) {
496
496
  super(), this._commandService = t, this._textSelectionManagerService = e, this._docQuickInsertPopupService = i, this._shortcutService = n, this._univerInstanceService = r, this.disposeWithMe(this._shortcutService.registerShortcut({
497
497
  id: Q.id,
498
- binding: b.ESC,
498
+ binding: M.ESC,
499
499
  preconditions: () => !!this._docQuickInsertPopupService.editPopup,
500
500
  priority: 1e3
501
501
  })), this._initTrigger(), this._initMenuHandler();
@@ -524,7 +524,7 @@ let G = class extends X {
524
524
  if (!d || !(d.preconditions ? d.preconditions(o) : !0))
525
525
  return;
526
526
  e.setInputOffset({ start: a.startOffset - 1, end: a.startOffset }), setTimeout(() => {
527
- n.executeCommand(be.id, {
527
+ n.executeCommand(Me.id, {
528
528
  index: a.startOffset - 1,
529
529
  unitId: o.unitId,
530
530
  popup: d
@@ -565,7 +565,7 @@ let G = class extends X {
565
565
  }
566
566
  _initMenuHandler() {
567
567
  this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected((t) => {
568
- t.id !== ke.id && Dt.has(t.id) && this._commandService.executeCommand(t.id);
568
+ t.id !== Re.id && Dt.has(t.id) && this._commandService.executeCommand(t.id);
569
569
  }));
570
570
  }
571
571
  };
@@ -672,18 +672,23 @@ const ue = ({ className: t = "" }) => {
672
672
  return /* @__PURE__ */ h(
673
673
  "div",
674
674
  {
675
- className: se("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", yt, {
676
- "univer-bg-gray-100": a,
677
- "univer-bg-white": !a
675
+ className: se("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 dark:!univer-text-gray-200 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100", yt, {
676
+ "univer-bg-gray-100 dark:!univer-bg-gray-700": a,
677
+ "univer-bg-white dark:!univer-bg-gray-900": !a
678
678
  }, t),
679
679
  role: "button",
680
680
  tabIndex: 0,
681
681
  onClick: d,
682
- children: /* @__PURE__ */ h(Qe, { className: "univer-text-gray-800" })
682
+ children: /* @__PURE__ */ h(
683
+ Qe,
684
+ {
685
+ className: "univer-text-gray-800 dark:!univer-text-gray-200"
686
+ }
687
+ )
683
688
  }
684
689
  );
685
690
  };
686
- ue.componentKey = Re;
691
+ ue.componentKey = ke;
687
692
  var Lt = Object.getOwnPropertyDescriptor, At = (t, e, i, n) => {
688
693
  for (var r = n > 1 ? void 0 : n ? Lt(e, i) : e, s = t.length - 1, c; s >= 0; s--)
689
694
  (c = t[s]) && (r = c(r) || r);
@@ -695,8 +700,8 @@ let Z = class extends X {
695
700
  }
696
701
  _initCommands() {
697
702
  [
698
- Me,
699
703
  be,
704
+ Me,
700
705
  Q
701
706
  ].forEach((t) => {
702
707
  this.disposeWithMe(this._commandService.registerCommand(t));
@@ -715,7 +720,7 @@ let Z = class extends X {
715
720
  }), [
716
721
  {
717
722
  keyword: "/",
718
- menus$: vt(kt),
723
+ menus$: vt(Rt),
719
724
  // only show when the cursor is at the beginning of a line
720
725
  preconditions: (e) => {
721
726
  var i;
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- .univer-mb-2{margin-bottom:8px}.univer-mr-1{margin-right:4px}.univer-mr-2{margin-right:8px}.univer-mt-2{margin-top:8px}.univer-flex{display:flex}.univer-inline-flex{display:inline-flex}.univer-h-full{height:100%}.univer-max-h-\[360px\]{max-height:360px}.univer-w-\[220px\]{width:220px}.univer-w-\[calc\(220px-var\(--padding-base\)\*2\)\]{width:calc(220px - var(--padding-base) * 2)}.univer-w-full{width:100%}.univer-translate-y-1\.5{--tw-translate-y: 6px;transform:translate(var(--tw-translate-x),6px) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.univer-cursor-pointer{cursor:pointer}.univer-items-center{align-items:center}.univer-justify-center{justify-content:center}.univer-gap-2\.5{gap:10px}.univer-overflow-y-auto{overflow-y:auto}.univer-overflow-x-hidden{overflow-x:hidden}.univer-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-rounded-full{border-radius:9999px}.univer-rounded-lg{border-radius:8px}.univer-bg-gray-100{background-color:var(--univer-gray-100)}.univer-bg-transparent{background-color:transparent}.univer-bg-white{background-color:var(--univer-white)}.univer-p-1\.5{padding:6px}.univer-px-1{padding-left:4px;padding-right:4px}.univer-px-12{padding-left:48px;padding-right:48px}.univer-py-6{padding-top:24px;padding-bottom:24px}.univer-text-base{font-size:16px;line-height:24px}.univer-text-sm{font-size:14px;line-height:20px}.univer-text-xs{font-size:12px;line-height:16px}.univer-text-gray-400{color:var(--univer-gray-400)}.univer-text-gray-500{color:var(--univer-gray-500)}.univer-text-gray-800{color:var(--univer-gray-800)}.univer-shadow-lg{--tw-shadow: 0px 4px 6px 0px rgba(30, 40, 77, .05), 0px 10px 15px -3px rgba(30, 40, 77, .1);--tw-shadow-colored: 0px 4px 6px 0px var(--tw-shadow-color), 0px 10px 15px -3px var(--tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 4px 6px #1e284d0d,0 10px 15px -3px #1e284d1a;box-shadow:var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--tw-shadow)}.univer-shadow-sm{--tw-shadow: 0px 1px 2px 0px rgba(30, 40, 77, .08);--tw-shadow-colored: 0px 1px 2px 0px var(--tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 2px #1e284d14;box-shadow:var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--tw-shadow)}.hover\:univer-bg-gray-100:hover{background-color:var(--univer-gray-100)}.hover\:univer-bg-transparent:hover{background-color:transparent}
1
+ .univer-mb-2{margin-bottom:8px}.univer-mr-1{margin-right:4px}.univer-mr-2{margin-right:8px}.univer-mt-2{margin-top:8px}.univer-flex{display:flex}.univer-inline-flex{display:inline-flex}.univer-h-full{height:100%}.univer-max-h-\[360px\]{max-height:360px}.univer-w-\[220px\]{width:220px}.univer-w-\[calc\(220px-var\(--padding-base\)\*2\)\]{width:calc(220px - var(--padding-base) * 2)}.univer-w-full{width:100%}.univer-translate-y-1\.5{--tw-translate-y: 6px;transform:translate(var(--tw-translate-x),6px) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.univer-cursor-pointer{cursor:pointer}.univer-items-center{align-items:center}.univer-justify-center{justify-content:center}.univer-gap-2\.5{gap:10px}.univer-overflow-y-auto{overflow-y:auto}.univer-overflow-x-hidden{overflow-x:hidden}.univer-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-rounded-full{border-radius:9999px}.univer-rounded-lg{border-radius:8px}.\!univer-bg-gray-500{background-color:var(--univer-gray-500)!important}.\!univer-bg-gray-700{background-color:var(--univer-gray-700)!important}.\!univer-bg-gray-900{background-color:var(--univer-gray-900)!important}.univer-bg-gray-100{background-color:var(--univer-gray-100)}.univer-bg-transparent{background-color:transparent}.univer-bg-white{background-color:var(--univer-white)}.univer-p-1\.5{padding:6px}.univer-px-1{padding-left:4px;padding-right:4px}.univer-px-12{padding-left:48px;padding-right:48px}.univer-py-6{padding-top:24px;padding-bottom:24px}.univer-text-base{font-size:16px;line-height:24px}.univer-text-sm{font-size:14px;line-height:20px}.univer-text-xs{font-size:12px;line-height:16px}.univer-text-gray-400{color:var(--univer-gray-400)}.univer-text-gray-500{color:var(--univer-gray-500)}.univer-text-gray-800{color:var(--univer-gray-800)}.univer-shadow-lg{--tw-shadow: 0px 4px 6px 0px rgba(30, 40, 77, .05), 0px 10px 15px -3px rgba(30, 40, 77, .1);--tw-shadow-colored: 0px 4px 6px 0px var(--tw-shadow-color), 0px 10px 15px -3px var(--tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 4px 6px #1e284d0d,0 10px 15px -3px #1e284d1a;box-shadow:var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--tw-shadow)}.univer-shadow-sm{--tw-shadow: 0px 1px 2px 0px rgba(30, 40, 77, .08);--tw-shadow-colored: 0px 1px 2px 0px var(--tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 1px 2px #1e284d14;box-shadow:var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--tw-shadow)}.hover\:univer-bg-gray-100:hover{background-color:var(--univer-gray-100)}.hover\:univer-bg-transparent:hover{background-color:transparent}.dark\:\!univer-bg-gray-500:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-500)!important}.dark\:\!univer-bg-gray-700:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}.dark\:\!univer-bg-gray-900:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-900)!important}.dark\:\!univer-text-gray-200:where(.univer-dark,.univer-dark *){color:var(--univer-gray-200)!important}.dark\:hover\:\!univer-bg-gray-700:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}
package/lib/index.js CHANGED
@@ -7,14 +7,14 @@ import { InsertDocImageCommand as Je, UniverDocsDrawingUIPlugin as Xe } from "@u
7
7
  import { UniverDrawingPlugin as Ye } from "@univerjs/drawing";
8
8
  import { UniverDrawingUIPlugin as et } from "@univerjs/drawing-ui";
9
9
  import { IRenderManagerService as he } from "@univerjs/engine-render";
10
- import { useDependency as I, KeyCode as b, ComponentManager as Se, IShortcutService as ye, useObservable as U, ILayoutService as tt, useEvent as nt, UniverUIPlugin as it } from "@univerjs/ui";
10
+ import { useDependency as I, KeyCode as M, ComponentManager as Se, IShortcutService as ye, useObservable as U, ILayoutService as tt, useEvent as nt, UniverUIPlugin as it } from "@univerjs/ui";
11
11
  import { CutContentCommand as rt, DocCanvasPopManagerService as Pe, DocEventManagerService as Oe, OrderListCommand as st, BulletListCommand as ot, HorizontalLineCommand as ct, DocCreateTableOperation as at, InsertCommand as dt, IMEInputCommand as ut, DeleteCommand as pt, MoveCursorOperation as lt, DeleteLeftCommand as ht } from "@univerjs/docs-ui";
12
12
  import { map as xe, distinctUntilChanged as ft, tap as j, combineLatest as fe, BehaviorSubject as A, of as vt } from "rxjs";
13
13
  import { DocSelectionManagerService as ve, DocSkeletonManagerService as mt, RichTextEditingMutation as gt } from "@univerjs/docs";
14
14
  import { jsx as h, jsxs as ge } from "react/jsx-runtime";
15
15
  import { clsx as se, Menu as _t, MenuItemGroup as Ct, MenuItem as It, Tooltip as St, borderClassName as yt } from "@univerjs/design";
16
16
  import { useMemo as oe, useState as _e, useRef as B, useEffect as L, forwardRef as Y, createElement as ee } from "react";
17
- const Me = {
17
+ const be = {
18
18
  id: "doc.command.delete-search-key",
19
19
  type: D.COMMAND,
20
20
  handler: (t, e) => {
@@ -39,7 +39,7 @@ const Me = {
39
39
  return /* @__PURE__ */ h("div", { className: "univer-translate-y-1.5 univer-text-sm univer-text-gray-500", children: t.t("docQuickInsert.keywordInputPlaceholder") });
40
40
  };
41
41
  V.componentKey = Pt;
42
- const be = {
42
+ const Me = {
43
43
  type: D.OPERATION,
44
44
  id: "doc.operation.show-quick-insert-popup",
45
45
  handler(t, e) {
@@ -77,7 +77,7 @@ function we(t, e) {
77
77
  return "children" in n && (n.children = we(n.children, e)), n.title = e.t(n.title), "keywords" in n && (n.keywords = n.keywords.concat(n.title).map((r) => r.toLowerCase())), n;
78
78
  });
79
79
  }
80
- const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
80
+ const xt = [M.ARROW_UP, M.ARROW_DOWN, M.ENTER], z = () => {
81
81
  const t = I(pe), e = I(S), i = I(Se), n = I(ye), r = I(H), s = oe(() => Be(), []), [c, u] = _e(0), o = B(null), a = B(0);
82
82
  a.current = 0;
83
83
  const d = U(e.filterKeyword$, ""), p = U(e.editPopup$), v = U(p == null ? void 0 : p.popup.menus$, []), y = oe(() => we(v, t), [v]), [w, P] = _e(() => ce(y, d.toLowerCase()));
@@ -95,9 +95,9 @@ const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
95
95
  L(() => {
96
96
  const m = new We();
97
97
  n.getAllShortcuts().filter((l) => l.binding && xt.includes(l.binding)).forEach((l) => {
98
- const M = l.preconditions;
98
+ const b = l.preconditions;
99
99
  l.preconditions = () => !1, m.add(Ve(() => {
100
- l.preconditions = M;
100
+ l.preconditions = b;
101
101
  }));
102
102
  });
103
103
  const x = {
@@ -112,32 +112,32 @@ const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
112
112
  type: D.OPERATION,
113
113
  handler: () => {
114
114
  u((l) => {
115
- const M = l - 1;
116
- return M >= 0 ? M : a.current - 1;
115
+ const b = l - 1;
116
+ return b >= 0 ? b : a.current - 1;
117
117
  });
118
118
  }
119
- }, k = {
119
+ }, R = {
120
120
  id: `quick.insert.popup.move.cursor.down.${s}`,
121
121
  type: D.OPERATION,
122
122
  handler: () => {
123
123
  u((l) => {
124
- const M = l + 1;
125
- return M <= a.current - 1 ? M : 0;
124
+ const b = l + 1;
125
+ return b <= a.current - 1 ? b : 0;
126
126
  });
127
127
  }
128
128
  };
129
- return m.add(r.registerCommand(E)), m.add(r.registerCommand(k)), m.add(r.registerCommand(x)), m.add(n.registerShortcut({
129
+ return m.add(r.registerCommand(E)), m.add(r.registerCommand(R)), m.add(r.registerCommand(x)), m.add(n.registerShortcut({
130
130
  priority: 1e3,
131
131
  id: E.id,
132
- binding: b.ARROW_UP,
132
+ binding: M.ARROW_UP,
133
133
  preconditions: () => !0,
134
134
  staticParameters: {
135
135
  direction: W.UP
136
136
  }
137
137
  })), m.add(n.registerShortcut({
138
138
  priority: 1e3,
139
- id: k.id,
140
- binding: b.ARROW_DOWN,
139
+ id: R.id,
140
+ binding: M.ARROW_DOWN,
141
141
  preconditions: () => !0,
142
142
  staticParameters: {
143
143
  direction: W.DOWN
@@ -145,7 +145,7 @@ const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
145
145
  })), m.add(n.registerShortcut({
146
146
  priority: 1e3,
147
147
  id: x.id,
148
- binding: b.ENTER,
148
+ binding: M.ENTER,
149
149
  preconditions: () => !0
150
150
  })), () => {
151
151
  m.dispose();
@@ -153,9 +153,9 @@ const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
153
153
  }, []), L(() => {
154
154
  u(0);
155
155
  }, [w]);
156
- const R = B(/* @__PURE__ */ new Map());
156
+ const k = B(/* @__PURE__ */ new Map());
157
157
  L(() => () => {
158
- R.current.clear();
158
+ k.current.clear();
159
159
  }, []);
160
160
  function $(m) {
161
161
  return m.map((g) => {
@@ -178,10 +178,10 @@ const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
178
178
  },
179
179
  g.id
180
180
  );
181
- const E = a.current, k = c === E;
182
- if (k) {
181
+ const E = a.current, R = c === E;
182
+ if (R) {
183
183
  o.current = g;
184
- const l = R.current.get(g.id);
184
+ const l = k.current.get(g.id);
185
185
  l == null || l.scrollIntoView({
186
186
  block: "nearest"
187
187
  });
@@ -190,13 +190,13 @@ const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
190
190
  It,
191
191
  {
192
192
  ref: (l) => {
193
- l && R.current.set(g.id, l);
193
+ l && k.current.set(g.id, l);
194
194
  },
195
195
  onMouseEnter: () => u(E),
196
196
  onMouseLeave: () => u(Number.NaN),
197
197
  className: se("univer-w-[calc(220px-var(--padding-base)*2)] univer-text-sm", {
198
- "hover:univer-bg-transparent": !k,
199
- "univer-bg-gray-100": k
198
+ "hover:univer-bg-transparent": !R,
199
+ "univer-bg-gray-100 dark:!univer-bg-gray-500": R
200
200
  }),
201
201
  onClick: () => {
202
202
  O(g);
@@ -220,8 +220,8 @@ const xt = [b.ARROW_UP, b.ARROW_DOWN, b.ENTER], z = () => {
220
220
  return /* @__PURE__ */ h("div", { className: se("univer-mt-2"), children: Ke ? /* @__PURE__ */ h(_t, { wrapperClass: "univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto univer-overflow-x-hidden", children: $(w) }) : me && /* @__PURE__ */ h(me, {}) });
221
221
  };
222
222
  z.componentKey = "docs.quick.insert.popup";
223
- var Mt = Object.getOwnPropertyDescriptor, bt = (t, e, i, n) => {
224
- for (var r = n > 1 ? void 0 : n ? Mt(e, i) : e, s = t.length - 1, c; s >= 0; s--)
223
+ var bt = Object.getOwnPropertyDescriptor, Mt = (t, e, i, n) => {
224
+ for (var r = n > 1 ? void 0 : n ? bt(e, i) : e, s = t.length - 1, c; s >= 0; s--)
225
225
  (c = t[s]) && (r = c(r) || r);
226
226
  return r;
227
227
  }, N = (t, e) => (i, n) => e(i, n, t);
@@ -337,18 +337,18 @@ let S = class extends X {
337
337
  const P = v.getSkeleton().findNodeByCharIndex(y.startOffset, y.segmentId, y.segmentPage);
338
338
  if (!((P == null ? void 0 : P.content) === "\r"))
339
339
  return Ce;
340
- const R = this._docCanvasPopupManagerService.attachPopupToRange(
340
+ const k = this._docCanvasPopupManagerService.attachPopupToRange(
341
341
  { startOffset: n + 1, endOffset: n + 1, collapsed: !1 },
342
342
  {
343
343
  componentKey: V.componentKey,
344
344
  onClickOutside: () => {
345
- R.dispose();
345
+ k.dispose();
346
346
  },
347
347
  direction: "horizontal"
348
348
  },
349
349
  r
350
350
  );
351
- return R;
351
+ return k;
352
352
  }), this._inputPlaceholderRenderRoot.mount();
353
353
  const a = this._docCanvasPopupManagerService.attachPopupToRect(
354
354
  o.firstLine,
@@ -373,7 +373,7 @@ let S = class extends X {
373
373
  }
374
374
  emitMenuSelected(e) {
375
375
  const { start: i, end: n } = this.inputOffset;
376
- this._commandService.syncExecuteCommand(Me.id, {
376
+ this._commandService.syncExecuteCommand(be.id, {
377
377
  start: i,
378
378
  end: n
379
379
  }), setTimeout(() => {
@@ -381,15 +381,15 @@ let S = class extends X {
381
381
  }, 0);
382
382
  }
383
383
  };
384
- S = bt([
384
+ S = Mt([
385
385
  N(0, f(Pe)),
386
386
  N(1, f(le)),
387
387
  N(2, f(H)),
388
388
  N(3, f(he)),
389
389
  N(4, f(ve))
390
390
  ], S);
391
- const Re = "doc.quick-insert.button";
392
- var wt = Object.getOwnPropertyDescriptor, Rt = (t, e, i, n) => {
391
+ const ke = "doc.quick-insert.button";
392
+ var wt = Object.getOwnPropertyDescriptor, kt = (t, e, i, n) => {
393
393
  for (var r = n > 1 ? void 0 : n ? wt(e, i) : e, s = t.length - 1, c; s >= 0; s--)
394
394
  (c = t[s]) && (r = c(r) || r);
395
395
  return r;
@@ -416,7 +416,7 @@ let F = class extends X {
416
416
  if (this._docQuickInsertPopupService.editPopup || n.startIndex === ((s = this.popup) == null ? void 0 : s.startIndex)) return;
417
417
  this._hideMenu(!0);
418
418
  const c = this._docCanvasPopManagerService.attachPopupToRect(n.firstLine, {
419
- componentKey: Re,
419
+ componentKey: ke,
420
420
  direction: "left-center"
421
421
  }, this._context.unit.getUnitId());
422
422
  this._popup$.next({
@@ -431,12 +431,12 @@ let F = class extends X {
431
431
  this._docQuickInsertPopupService.editPopup || this.popup && (e || this.popup.disposable.canDispose()) && (this.popup.disposable.dispose(), this._popup$.next(null));
432
432
  }
433
433
  };
434
- F = Rt([
434
+ F = kt([
435
435
  ie(1, f(Oe)),
436
436
  ie(2, f(S)),
437
437
  ie(3, f(Pe))
438
438
  ], F);
439
- const ke = {
439
+ const Re = {
440
440
  id: "quick-insert.text.menu",
441
441
  title: "docQuickInsert.menu.text",
442
442
  icon: "TextSingle",
@@ -466,12 +466,12 @@ const ke = {
466
466
  title: "docQuickInsert.menu.image",
467
467
  icon: "addition-and-subtraction-single",
468
468
  keywords: ["image", "picture", "photo"]
469
- }, kt = [
469
+ }, Rt = [
470
470
  {
471
471
  title: "docQuickInsert.group.basics",
472
472
  id: "quick.insert.group.basic",
473
473
  children: [
474
- ke,
474
+ Re,
475
475
  De,
476
476
  $e,
477
477
  Ee,
@@ -495,7 +495,7 @@ let G = class extends X {
495
495
  constructor(t, e, i, n, r) {
496
496
  super(), this._commandService = t, this._textSelectionManagerService = e, this._docQuickInsertPopupService = i, this._shortcutService = n, this._univerInstanceService = r, this.disposeWithMe(this._shortcutService.registerShortcut({
497
497
  id: Q.id,
498
- binding: b.ESC,
498
+ binding: M.ESC,
499
499
  preconditions: () => !!this._docQuickInsertPopupService.editPopup,
500
500
  priority: 1e3
501
501
  })), this._initTrigger(), this._initMenuHandler();
@@ -524,7 +524,7 @@ let G = class extends X {
524
524
  if (!d || !(d.preconditions ? d.preconditions(o) : !0))
525
525
  return;
526
526
  e.setInputOffset({ start: a.startOffset - 1, end: a.startOffset }), setTimeout(() => {
527
- n.executeCommand(be.id, {
527
+ n.executeCommand(Me.id, {
528
528
  index: a.startOffset - 1,
529
529
  unitId: o.unitId,
530
530
  popup: d
@@ -565,7 +565,7 @@ let G = class extends X {
565
565
  }
566
566
  _initMenuHandler() {
567
567
  this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected((t) => {
568
- t.id !== ke.id && Dt.has(t.id) && this._commandService.executeCommand(t.id);
568
+ t.id !== Re.id && Dt.has(t.id) && this._commandService.executeCommand(t.id);
569
569
  }));
570
570
  }
571
571
  };
@@ -672,18 +672,23 @@ const ue = ({ className: t = "" }) => {
672
672
  return /* @__PURE__ */ h(
673
673
  "div",
674
674
  {
675
- className: se("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", yt, {
676
- "univer-bg-gray-100": a,
677
- "univer-bg-white": !a
675
+ className: se("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 dark:!univer-text-gray-200 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100", yt, {
676
+ "univer-bg-gray-100 dark:!univer-bg-gray-700": a,
677
+ "univer-bg-white dark:!univer-bg-gray-900": !a
678
678
  }, t),
679
679
  role: "button",
680
680
  tabIndex: 0,
681
681
  onClick: d,
682
- children: /* @__PURE__ */ h(Qe, { className: "univer-text-gray-800" })
682
+ children: /* @__PURE__ */ h(
683
+ Qe,
684
+ {
685
+ className: "univer-text-gray-800 dark:!univer-text-gray-200"
686
+ }
687
+ )
683
688
  }
684
689
  );
685
690
  };
686
- ue.componentKey = Re;
691
+ ue.componentKey = ke;
687
692
  var Lt = Object.getOwnPropertyDescriptor, At = (t, e, i, n) => {
688
693
  for (var r = n > 1 ? void 0 : n ? Lt(e, i) : e, s = t.length - 1, c; s >= 0; s--)
689
694
  (c = t[s]) && (r = c(r) || r);
@@ -695,8 +700,8 @@ let Z = class extends X {
695
700
  }
696
701
  _initCommands() {
697
702
  [
698
- Me,
699
703
  be,
704
+ Me,
700
705
  Q
701
706
  ].forEach((t) => {
702
707
  this.disposeWithMe(this._commandService.registerCommand(t));
@@ -715,7 +720,7 @@ let Z = class extends X {
715
720
  }), [
716
721
  {
717
722
  keyword: "/",
718
- menus$: vt(kt),
723
+ menus$: vt(Rt),
719
724
  // only show when the cursor is at the beginning of a line
720
725
  preconditions: (e) => {
721
726
  var i;
@@ -1,3 +1,33 @@
1
- import { default as zhCN } from './zh-CN';
2
- declare const locale: typeof zhCN;
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
+ declare const locale: {
17
+ docQuickInsert: {
18
+ menu: {
19
+ numberedList: string;
20
+ bulletedList: string;
21
+ divider: string;
22
+ text: string;
23
+ table: string;
24
+ image: string;
25
+ };
26
+ group: {
27
+ basics: string;
28
+ };
29
+ placeholder: string;
30
+ keywordInputPlaceholder: string;
31
+ };
32
+ };
3
33
  export default locale;
@@ -1,3 +1,3 @@
1
- import { default as zhCN } from './zh-CN';
2
- declare const locale: typeof zhCN;
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
3
3
  export default locale;
@@ -1,3 +1,3 @@
1
- import { default as zhCN } from './zh-CN';
2
- declare const locale: typeof zhCN;
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
3
3
  export default locale;
@@ -1,3 +1,3 @@
1
- import { default as zhCN } from './zh-CN';
2
- declare const locale: typeof zhCN;
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
3
3
  export default locale;
@@ -1,33 +1,3 @@
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
- declare const locale: {
17
- docQuickInsert: {
18
- menu: {
19
- numberedList: string;
20
- bulletedList: string;
21
- divider: string;
22
- text: string;
23
- table: string;
24
- image: string;
25
- };
26
- group: {
27
- basics: string;
28
- };
29
- placeholder: string;
30
- keywordInputPlaceholder: string;
31
- };
32
- };
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
33
3
  export default locale;
@@ -1,3 +1,3 @@
1
- import { default as zhCN } from './zh-CN';
2
- declare const locale: typeof zhCN;
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
3
3
  export default locale;
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
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,R,te,Se,_e,z,p,S,C,E,m,k,f){"use strict";var We=Object.defineProperty;var Ve=(c,s,R)=>s in c?We(c,s,{enumerable:!0,configurable:!0,writable:!0,value:R}):c[s]=R;var P=(c,s,R)=>Ve(c,typeof s!="symbol"?s+"":s,R);const ne={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(S.CutContentCommand.id,{segmentId:"",textRanges:[{startOffset:t,endOffset:t,collapsed:!0}],selections:[{startOffset:t,endOffset:r,collapsed:!1,direction:s.RANGE_DIRECTION.FORWARD}]})}},ie="docs.quick.insert.keyword-input-placeholder",H=()=>{const i=p.useDependency(s.LocaleService);return m.jsx("div",{className:"univer-translate-y-1.5 univer-text-sm univer-text-gray-500",children:i.t("docQuickInsert.keywordInputPlaceholder")})};H.componentKey=ie;const re={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}},U={type:s.CommandType.OPERATION,id:"doc.operation.close-quick-insert-popup",handler(i){return i.get(c.DocQuickInsertPopupService).closePopup(),!0}},se="docs.quick.insert.placeholder",L=()=>{const i=p.useDependency(s.LocaleService);return m.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:m.jsx("span",{children:i.t("docQuickInsert.placeholder")})})};L.componentKey=se;function F(i,n){return i.map(e=>({...e})).filter(e=>{if("children"in e)return e.children=F(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 oe(i,n){return i.map(e=>{const t={...e};return"children"in t&&(t.children=oe(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 ye=[p.KeyCode.ARROW_UP,p.KeyCode.ARROW_DOWN,p.KeyCode.ENTER],q=()=>{const i=p.useDependency(s.LocaleService),n=p.useDependency(c.DocQuickInsertPopupService),e=p.useDependency(p.ComponentManager),t=p.useDependency(p.IShortcutService),r=p.useDependency(s.ICommandService),o=f.useMemo(()=>s.generateRandomId(),[]),[u,v]=f.useState(0),I=f.useRef(null),a=f.useRef(0);a.current=0;const d=p.useObservable(n.filterKeyword$,""),l=p.useObservable(n.editPopup$),h=p.useObservable(l==null?void 0:l.popup.menus$,[]),O=f.useMemo(()=>oe(h,i),[h]),[M,T]=f.useState(()=>F(O,d.toLowerCase()));f.useEffect(()=>{const _=requestIdleCallback(()=>{T(F(O,d.toLowerCase()))});return()=>{cancelIdleCallback(_)}},[O,d]);const b=_=>{n.emitMenuSelected(_),r.executeCommand(U.id)};f.useEffect(()=>{const _=new s.DisposableCollection;t.getAllShortcuts().filter(g=>g.binding&&ye.includes(g.binding)).forEach(g=>{const x=g.preconditions;g.preconditions=()=>!1,_.add(s.toDisposable(()=>{g.preconditions=x}))});const w={id:`quick.insert.popup.enter.${o}`,type:s.CommandType.OPERATION,handler:()=>{const g=I.current;g&&b(g)}},K={id:`quick.insert.popup.move.cursor.up.${o}`,type:s.CommandType.OPERATION,handler:()=>{v(g=>{const x=g-1;return x>=0?x:a.current-1})}},Q={id:`quick.insert.popup.move.cursor.down.${o}`,type:s.CommandType.OPERATION,handler:()=>{v(g=>{const x=g+1;return x<=a.current-1?x:0})}};return _.add(r.registerCommand(K)),_.add(r.registerCommand(Q)),_.add(r.registerCommand(w)),_.add(t.registerShortcut({priority:1e3,id:K.id,binding:p.KeyCode.ARROW_UP,preconditions:()=>!0,staticParameters:{direction:s.Direction.UP}})),_.add(t.registerShortcut({priority:1e3,id:Q.id,binding:p.KeyCode.ARROW_DOWN,preconditions:()=>!0,staticParameters:{direction:s.Direction.DOWN}})),_.add(t.registerShortcut({priority:1e3,id:w.id,binding:p.KeyCode.ENTER,preconditions:()=>!0})),()=>{_.dispose()}},[]),f.useEffect(()=>{v(0)},[M]);const W=f.useRef(new Map);f.useEffect(()=>()=>{W.current.clear()},[]);function N(_){return _.map(y=>{const ee=y.icon,w=ee?e.get(ee):null;if("children"in y)return m.jsx(k.MenuItemGroup,{title:m.jsxs("div",{className:"univer-mb-2 univer-flex univer-items-center univer-text-xs univer-text-gray-400",children:[w&&m.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:m.jsx(w,{})}),m.jsx("span",{children:y.title})]}),children:N(y.children)},y.id);const K=a.current,Q=u===K;if(Q){I.current=y;const g=W.current.get(y.id);g==null||g.scrollIntoView({block:"nearest"})}return a.current++,m.jsx(k.MenuItem,{ref:g=>{g&&W.current.set(y.id,g)},onMouseEnter:()=>v(K),onMouseLeave:()=>v(Number.NaN),className:k.clsx("univer-w-[calc(220px-var(--padding-base)*2)] univer-text-sm",{"hover:univer-bg-transparent":!Q,"univer-bg-gray-100":Q}),onClick:()=>{b(y)},children:m.jsxs("div",{className:"univer-flex univer-w-full univer-items-center univer-px-1",children:[w&&m.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:m.jsx(w,{})}),m.jsx(k.Tooltip,{showIfEllipsis:!0,title:y.title,placement:"right",children:m.jsx("span",{className:"univer-truncate",children:y.title})})]})},y.id)})}const V=M.length>0,Ce=(l==null?void 0:l.popup.Placeholder)||e.get(L.componentKey);return m.jsx("div",{className:k.clsx("univer-mt-2"),children:V?m.jsx(k.Menu,{wrapperClass:"univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto univer-overflow-x-hidden",children:N(M)}):Ce&&m.jsx(Ce,{})})};q.componentKey="docs.quick.insert.popup";var Pe=Object.getOwnPropertyDescriptor,De=(i,n,e,t)=>{for(var r=t>1?void 0:t?Pe(n,e):n,o=i.length-1,u;o>=0;o--)(u=i[o])&&(r=u(r)||r);return r},j=(i,n)=>(e,t)=>n(e,t,i);const ce={dispose:()=>{}};c.DocQuickInsertPopupService=class extends s.Disposable{constructor(e,t,r,o,u){super();P(this,"_popups",new Set);P(this,"_editPopup$",new C.BehaviorSubject(void 0));P(this,"editPopup$",this._editPopup$.asObservable());P(this,"_isComposing$",new C.BehaviorSubject(!1));P(this,"isComposing$",this._isComposing$.asObservable());P(this,"_inputOffset$",new C.BehaviorSubject({start:0,end:0}));P(this,"inputOffset$",this._inputOffset$.asObservable());P(this,"filterKeyword$");P(this,"_menuSelectedCallbacks",new Set);P(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 l,h;return(h=(l=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_DOC))==null?void 0:l.getBody())==null?void 0:h.dataStream.slice(a,d)};let I="";this.filterKeyword$=this._inputOffset$.pipe(C.map(a=>{var l;const d=v(a.start,a.end);return(l=d==null?void 0:d.slice(1))!=null?l:""}),C.distinctUntilChanged(),C.tap(a=>{I=a})),this.disposeWithMe(C.combineLatest([this.filterKeyword$.pipe(C.tap(a=>{var d,l,h;a.length>0?(l=(d=this._inputPlaceholderRenderRoot)==null?void 0:d.unmount)==null||l.dispose():(h=this._inputPlaceholderRenderRoot)==null||h.mount()})),this.isComposing$.pipe(C.tap(a=>{var d,l,h;a?(l=(d=this._inputPlaceholderRenderRoot)==null?void 0:d.unmount)==null||l.dispose():I.length<=0&&((h=this._inputPlaceholderRenderRoot)==null||h.mount())})),this.editPopup$.pipe(C.tap(a=>{var d,l;a||((l=(d=this._inputPlaceholderRenderRoot)==null?void 0:d.unmount)==null||l.dispose(),this._inputPlaceholderRenderRoot=null)}))]).subscribe())}get popups(){return Array.from(this._popups)}get editPopup(){return this._editPopup$.value}get isComposing(){return this._isComposing$.value}setIsComposing(e){this._isComposing$.next(e)}get inputOffset(){return this._inputOffset$.value}setInputOffset(e){this._inputOffset$.next(e)}getDocEventManagerService(e){var t;return(t=this._renderManagerService.getRenderById(e))==null?void 0:t.with(S.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 l,h;const{popup:t,index:r,unitId:o}=e;this.closePopup();const u=this._univerInstanceService.getUnit(o),v=(h=(l=u==null?void 0:u.getBody())==null?void 0:l.paragraphs)==null?void 0:h.find(O=>O.startIndex>r);if(!v)return;const I=this.getDocEventManagerService(o),a=I==null?void 0:I.findParagraphBoundByIndex(v.startIndex);if(!a)return;this._inputPlaceholderRenderRoot=this._createInputPlaceholderRenderRoot(()=>{var V;const O=(V=this._renderManagerService.getRenderById(o))==null?void 0:V.with(E.DocSkeletonManagerService),M=this._docSelectionManagerService.getActiveTextRange();if(!O||!M)return ce;const b=O.getSkeleton().findNodeByCharIndex(M.startOffset,M.segmentId,M.segmentPage);if(!((b==null?void 0:b.content)==="\r"))return ce;const N=this._docCanvasPopupManagerService.attachPopupToRange({startOffset:r+1,endOffset:r+1,collapsed:!1},{componentKey:H.componentKey,onClickOutside:()=>{N.dispose()},direction:"horizontal"},o);return N}),this._inputPlaceholderRenderRoot.mount();const d=this._docCanvasPopupManagerService.attachPopupToRect(a.firstLine,{componentKey:q.componentKey,onClickOutside:()=>{this.closePopup()},direction:"bottom"},o);this._editPopup$.next({disposable:d,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(ne.id,{start:t,end:r}),setTimeout(()=>{this._menuSelectedCallbacks.forEach(o=>o(e))},0)}},c.DocQuickInsertPopupService=De([j(0,s.Inject(S.DocCanvasPopManagerService)),j(1,s.Inject(s.IUniverInstanceService)),j(2,s.Inject(s.ICommandService)),j(3,s.Inject(z.IRenderManagerService)),j(4,s.Inject(E.DocSelectionManagerService))],c.DocQuickInsertPopupService);const ae="doc.quick-insert.button";var Oe=Object.getOwnPropertyDescriptor,Me=(i,n,e,t)=>{for(var r=t>1?void 0:t?Oe(n,e):n,o=i.length-1,u;o>=0;o--)(u=i[o])&&(r=u(r)||r);return r},G=(i,n)=>(e,t)=>n(e,t,i);let B=class extends s.Disposable{constructor(n,e,t,r){super();P(this,"_popup$",new C.BehaviorSubject(null));P(this,"popup$",this._popup$.asObservable());this._context=n,this._docEventManagerService=e,this._docQuickInsertPopupService=t,this._docCanvasPopManagerService=r,this._init()}get popup(){return this._popup$.value}_init(){this.disposeWithMe(C.combineLatest([this._docEventManagerService.hoverParagraphLeftRealTime$,this._docEventManagerService.hoverParagraphRealTime$]).subscribe(([n,e])=>{var o;const t=n!=null?n:e,r=this._context.unit.getDisabled();if(!t||r){this._hideMenu(!0);return}if(t.paragraphStart===t.paragraphEnd){if(this._docQuickInsertPopupService.editPopup||t.startIndex===((o=this.popup)==null?void 0:o.startIndex))return;this._hideMenu(!0);const u=this._docCanvasPopManagerService.attachPopupToRect(t.firstLine,{componentKey:ae,direction:"left-center"},this._context.unit.getUnitId());this._popup$.next({startIndex:t.startIndex,disposable:u})}else this._hideMenu(!0)}))}_hideMenu(n){this._docQuickInsertPopupService.editPopup||this.popup&&(n||this.popup.disposable.canDispose())&&(this.popup.disposable.dispose(),this._popup$.next(null))}};B=Me([G(1,s.Inject(S.DocEventManagerService)),G(2,s.Inject(c.DocQuickInsertPopupService)),G(3,s.Inject(S.DocCanvasPopManagerService))],B);const ue={id:"quick-insert.text.menu",title:"docQuickInsert.menu.text",icon:"TextSingle",keywords:["text"]},de={id:S.OrderListCommand.id,title:"docQuickInsert.menu.numberedList",icon:"OrderSingle",keywords:["numbered","list","ordered"]},pe={id:S.BulletListCommand.id,title:"docQuickInsert.menu.bulletedList",icon:"UnorderSingle",keywords:["bulleted","list","unordered"]},le={id:S.HorizontalLineCommand.id,title:"docQuickInsert.menu.divider",icon:"DividerSingle",keywords:["divider","line","separate"]},ve={id:S.DocCreateTableOperation.id,title:"docQuickInsert.menu.table",icon:"GridSingle",keywords:["table","grid","spreadsheet"]},he={id:te.InsertDocImageCommand.id,title:"docQuickInsert.menu.image",icon:"addition-and-subtraction-single",keywords:["image","picture","photo"]},be=[{title:"docQuickInsert.group.basics",id:"quick.insert.group.basic",children:[ue,de,pe,le,ve,he]}],ke=new Set([de.id,pe.id,le.id,ve.id,he.id]);var we=Object.getOwnPropertyDescriptor,xe=(i,n,e,t)=>{for(var r=t>1?void 0:t?we(n,e):n,o=i.length-1,u;o>=0;o--)(u=i[o])&&(r=u(r)||r);return r},$=(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:U.id,binding:p.KeyCode.ESC,preconditions:()=>!!this._docQuickInsertPopupService.editPopup,priority:1e3})),this._initTrigger(),this._initMenuHandler()}_initTrigger(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var u,v,I;const{_docQuickInsertPopupService:e,_textSelectionManagerService:t,_commandService:r}=this,o=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_DOC);if(!(o!=null&&o.getDisabled())){if(n.id===S.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 l=e.resolvePopup(a.body.dataStream);if(!l||!(l.preconditions?l.preconditions(a):!0))return;e.setInputOffset({start:d.startOffset-1,end:d.startOffset}),setTimeout(()=>{r.executeCommand(re.id,{index:d.startOffset-1,unitId:a.unitId,popup:l})},100)}if(n.id===S.IMEInputCommand.id){const a=n.params;!e.isComposing&&a.isCompositionStart&&e.setIsComposing(!0),e.isComposing&&a.isCompositionEnd&&e.setIsComposing(!1)}if(n.id===E.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===S.DeleteCommand.id){const a=n.params;if(e.editPopup&&a.direction===s.DeleteDirection.LEFT){const d=(I=a.len)!=null?I:0;e.setInputOffset({start:e.inputOffset.start,end:a.range.endOffset-d})}}if(n.id===S.MoveCursorOperation.id){const a=n.params;(a.direction===s.Direction.LEFT||a.direction===s.Direction.RIGHT)&&e.editPopup&&r.executeCommand(U.id)}if(n.id===S.DeleteLeftCommand.id){const a=t.getActiveTextRange();if(!e.editPopup||!a)return;a.endOffset<=e.editPopup.anchor&&r.executeCommand(U.id)}}}))}_initMenuHandler(){this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected(n=>{n.id!==ue.id&&ke.has(n.id)&&this._commandService.executeCommand(n.id)}))}},c.DocQuickInsertTriggerController=xe([$(0,s.ICommandService),$(1,s.Inject(E.DocSelectionManagerService)),$(2,s.Inject(c.DocQuickInsertPopupService)),$(3,s.Inject(p.IShortcutService)),$(4,s.Inject(s.IUniverInstanceService))],c.DocQuickInsertTriggerController);var D=function(){return D=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},D.apply(this,arguments)},Re=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},A=f.forwardRef(function(i,n){var e=i.icon,t=i.id,r=i.className,o=i.extend,u=Re(i,["icon","id","className","extend"]),v="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),I=f.useRef("_".concat(Ue()));return fe(e,"".concat(t),{defIds:e.defIds,idSuffix:I.current},D({ref:n,className:v},u),o)});function fe(i,n,e,t,r){return f.createElement(i.tag,D(D({key:n},Qe(i,e,r)),t),(Ee(i,e).children||[]).map(function(o,u){return fe(o,"".concat(n,"-").concat(i.tag,"-").concat(u),e,void 0,r)}))}function Qe(i,n,e){var t=D({},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 Ee(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)?D(D({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?D(D({},r),{attrs:D(D({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):i}function Ue(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var je={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.01953 3.13985C1.01953 2.77258 1.31726 2.47485 1.68453 2.47485H2.73713C3.1044 2.47485 3.40213 2.77258 3.40213 3.13985 3.40213 3.50712 3.1044 3.80485 2.73713 3.80485H1.68453C1.31726 3.80485 1.01953 3.50712 1.01953 3.13985zM4.17734 3.13985C4.17734 2.77258 4.47507 2.47485 4.84234 2.47485H6.94754C7.31481 2.47485 7.61254 2.77258 7.61254 3.13985 7.61254 3.50712 7.31481 3.80485 6.94754 3.80485H4.84234C4.47507 3.80485 4.17734 3.50712 4.17734 3.13985zM8.38775 3.13985C8.38775 2.77258 8.68548 2.47485 9.05275 2.47485H11.158C11.5252 2.47485 11.823 2.77258 11.823 3.13985 11.823 3.50712 11.5252 3.80485 11.158 3.80485H9.05275C8.68548 3.80485 8.38775 3.50712 8.38775 3.13985zM12.5982 3.13985C12.5982 2.77258 12.8959 2.47485 13.2632 2.47485H14.3158C14.683 2.47485 14.9808 2.77258 14.9808 3.13985 14.9808 3.50712 14.683 3.80485 14.3158 3.80485H13.2632C12.8959 3.80485 12.5982 3.50712 12.5982 3.13985zM1.01953 7.99972C1.01953 7.63245 1.31726 7.33472 1.68453 7.33472H14.3158C14.683 7.33472 14.9808 7.63245 14.9808 7.99972 14.9808 8.36699 14.683 8.66472 14.3158 8.66472H1.68453C1.31726 8.66472 1.01953 8.36699 1.01953 7.99972zM1.68453 12.1951C1.31726 12.1951 1.01953 12.4928 1.01953 12.8601 1.01953 13.2273 1.31726 13.5251 1.68453 13.5251H2.73713C3.1044 13.5251 3.40213 13.2273 3.40213 12.8601 3.40213 12.4928 3.1044 12.1951 2.73713 12.1951H1.68453zM4.84234 12.1951C4.47507 12.1951 4.17734 12.4928 4.17734 12.8601 4.17734 13.2273 4.47507 13.5251 4.84234 13.5251H6.94754C7.31481 13.5251 7.61254 13.2273 7.61254 12.8601 7.61254 12.4928 7.31481 12.1951 6.94754 12.1951H4.84234zM9.05275 12.1951C8.68548 12.1951 8.38775 12.4928 8.38775 12.8601 8.38775 13.2273 8.68548 13.5251 9.05275 13.5251H11.158C11.5252 13.5251 11.823 13.2273 11.823 12.8601 11.823 12.4928 11.5252 12.1951 11.158 12.1951H9.05275zM13.2632 12.1951C12.8959 12.1951 12.5982 12.4928 12.5982 12.8601 12.5982 13.2273 12.8959 13.5251 13.2632 13.5251H14.3158C14.683 13.5251 14.9808 13.2273 14.9808 12.8601 14.9808 12.4928 14.683 12.1951 14.3158 12.1951H13.2632z"}}]},Z=f.forwardRef(function(i,n){return f.createElement(A,Object.assign({},i,{id:"divider-single",ref:n,icon:je}))});Z.displayName="DividerSingle";var $e={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"}}]},ge=f.forwardRef(function(i,n){return f.createElement(A,Object.assign({},i,{id:"plus-single",ref:n,icon:$e}))});ge.displayName="PlusSingle";var Te={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.66695 1.33496C2.29968 1.33496 2.00195 1.63269 2.00195 1.99996V3.64439C2.00195 4.01166 2.29968 4.30939 2.66695 4.30939C3.03422 4.30939 3.33195 4.01166 3.33195 3.64439V2.66496H7.33521V13.335H5.3337C4.96643 13.335 4.6687 13.6327 4.6687 14C4.6687 14.3672 4.96643 14.665 5.3337 14.665H10.667C11.0343 14.665 11.332 14.3672 11.332 14C11.332 13.6327 11.0343 13.335 10.667 13.335H8.66521V2.66496H12.6686V3.64439C12.6686 4.01166 12.9664 4.30939 13.3336 4.30939C13.7009 4.30939 13.9986 4.01166 13.9986 3.64439V1.99996C13.9986 1.63269 13.7009 1.33496 13.3336 1.33496H2.66695Z"}}]},J=f.forwardRef(function(i,n){return f.createElement(A,Object.assign({},i,{id:"text-single",ref:n,icon:Te}))});J.displayName="TextSingle";const X=({className:i=""})=>{const n=p.useDependency(c.DocQuickInsertPopupService),e=p.useDependency(s.IUniverInstanceService),t=p.useDependency(z.IRenderManagerService),r=p.useObservable(f.useMemo(()=>e.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_DOC),[e])),o=r&&t.getRenderById(r.getUnitId()),u=o==null?void 0:o.with(B),v=p.useDependency(p.ILayoutService),I=p.useDependency(E.DocSelectionManagerService),a=p.useObservable(n.editPopup$),d=p.useEvent(l=>{var T;const h=u==null?void 0:u.popup;if(!h)return;const O=n.popups,M={keyword:"",menus$:C.combineLatest(O.map(b=>b.menus$)).pipe(C.map(b=>b.flat()))};I.replaceDocRanges([{startOffset:h.startIndex,endOffset:h.startIndex}]),n.setInputOffset({start:h.startIndex-1,end:h.startIndex-1}),n.showPopup({popup:M,index:h.startIndex-1,unitId:(T=r==null?void 0:r.getUnitId())!=null?T:""}),setTimeout(()=>{v.focus()})});return m.jsx("div",{className:k.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",k.borderClassName,{"univer-bg-gray-100":a,"univer-bg-white":!a},i),role:"button",tabIndex:0,onClick:d,children:m.jsx(ge,{className:"univer-text-gray-800"})})};X.componentKey=ae;var Ne=Object.getOwnPropertyDescriptor,Ke=(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},Y=(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(){[ne,re,U].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initComponents(){[[q.componentKey,q],[H.componentKey,H],[L.componentKey,L],[Z.displayName,Z],[J.displayName,J],[X.componentKey,X]].forEach(([e,t])=>{e&&this.disposeWithMe(this._componentManager.register(e,t))}),[{keyword:"/",menus$:C.of(be),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=Ke([Y(0,s.ICommandService),Y(1,s.Inject(c.DocQuickInsertPopupService)),Y(2,s.Inject(p.ComponentManager))],c.DocQuickInsertUIController);var He=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,qe=(i,n,e)=>n in i?He(i,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[n]=e,Be=(i,n,e,t)=>{for(var r=t>1?void 0:t?Le(n,e):n,o=i.length-1,u;o>=0;o--)(u=i[o])&&(r=u(r)||r);return r},me=(i,n)=>(e,t)=>n(e,t,i),Ie=(i,n,e)=>qe(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),[[B]].forEach(n=>{this._renderManagerSrv.registerRenderModule(s.UniverInstanceType.UNIVER_DOC,n)})}},Ie(c.UniverDocsQuickInsertUIPlugin,"type",s.UniverInstanceType.UNIVER_DOC),Ie(c.UniverDocsQuickInsertUIPlugin,"pluginName",Ae),c.UniverDocsQuickInsertUIPlugin=Be([s.DependentOn(_e.UniverDrawingUIPlugin,Se.UniverDrawingPlugin,te.UniverDocsDrawingUIPlugin,R.UniverDocsDrawingPlugin,p.UniverUIPlugin),me(0,s.Inject(s.Injector)),me(1,s.Inject(z.IRenderManagerService))],c.UniverDocsQuickInsertUIPlugin),c.KeywordInputPlaceholderComponentKey=ie,c.QuickInsertPlaceholderComponentKey=se,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
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,R,te,Se,_e,z,p,S,C,E,m,k,f){"use strict";var We=Object.defineProperty;var Ve=(c,s,R)=>s in c?We(c,s,{enumerable:!0,configurable:!0,writable:!0,value:R}):c[s]=R;var P=(c,s,R)=>Ve(c,typeof s!="symbol"?s+"":s,R);const ne={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(S.CutContentCommand.id,{segmentId:"",textRanges:[{startOffset:t,endOffset:t,collapsed:!0}],selections:[{startOffset:t,endOffset:r,collapsed:!1,direction:s.RANGE_DIRECTION.FORWARD}]})}},ie="docs.quick.insert.keyword-input-placeholder",H=()=>{const i=p.useDependency(s.LocaleService);return m.jsx("div",{className:"univer-translate-y-1.5 univer-text-sm univer-text-gray-500",children:i.t("docQuickInsert.keywordInputPlaceholder")})};H.componentKey=ie;const re={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}},U={type:s.CommandType.OPERATION,id:"doc.operation.close-quick-insert-popup",handler(i){return i.get(c.DocQuickInsertPopupService).closePopup(),!0}},se="docs.quick.insert.placeholder",L=()=>{const i=p.useDependency(s.LocaleService);return m.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:m.jsx("span",{children:i.t("docQuickInsert.placeholder")})})};L.componentKey=se;function F(i,n){return i.map(e=>({...e})).filter(e=>{if("children"in e)return e.children=F(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 oe(i,n){return i.map(e=>{const t={...e};return"children"in t&&(t.children=oe(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 ye=[p.KeyCode.ARROW_UP,p.KeyCode.ARROW_DOWN,p.KeyCode.ENTER],q=()=>{const i=p.useDependency(s.LocaleService),n=p.useDependency(c.DocQuickInsertPopupService),e=p.useDependency(p.ComponentManager),t=p.useDependency(p.IShortcutService),r=p.useDependency(s.ICommandService),o=f.useMemo(()=>s.generateRandomId(),[]),[u,v]=f.useState(0),I=f.useRef(null),a=f.useRef(0);a.current=0;const d=p.useObservable(n.filterKeyword$,""),l=p.useObservable(n.editPopup$),h=p.useObservable(l==null?void 0:l.popup.menus$,[]),O=f.useMemo(()=>oe(h,i),[h]),[M,T]=f.useState(()=>F(O,d.toLowerCase()));f.useEffect(()=>{const _=requestIdleCallback(()=>{T(F(O,d.toLowerCase()))});return()=>{cancelIdleCallback(_)}},[O,d]);const b=_=>{n.emitMenuSelected(_),r.executeCommand(U.id)};f.useEffect(()=>{const _=new s.DisposableCollection;t.getAllShortcuts().filter(g=>g.binding&&ye.includes(g.binding)).forEach(g=>{const x=g.preconditions;g.preconditions=()=>!1,_.add(s.toDisposable(()=>{g.preconditions=x}))});const w={id:`quick.insert.popup.enter.${o}`,type:s.CommandType.OPERATION,handler:()=>{const g=I.current;g&&b(g)}},K={id:`quick.insert.popup.move.cursor.up.${o}`,type:s.CommandType.OPERATION,handler:()=>{v(g=>{const x=g-1;return x>=0?x:a.current-1})}},Q={id:`quick.insert.popup.move.cursor.down.${o}`,type:s.CommandType.OPERATION,handler:()=>{v(g=>{const x=g+1;return x<=a.current-1?x:0})}};return _.add(r.registerCommand(K)),_.add(r.registerCommand(Q)),_.add(r.registerCommand(w)),_.add(t.registerShortcut({priority:1e3,id:K.id,binding:p.KeyCode.ARROW_UP,preconditions:()=>!0,staticParameters:{direction:s.Direction.UP}})),_.add(t.registerShortcut({priority:1e3,id:Q.id,binding:p.KeyCode.ARROW_DOWN,preconditions:()=>!0,staticParameters:{direction:s.Direction.DOWN}})),_.add(t.registerShortcut({priority:1e3,id:w.id,binding:p.KeyCode.ENTER,preconditions:()=>!0})),()=>{_.dispose()}},[]),f.useEffect(()=>{v(0)},[M]);const W=f.useRef(new Map);f.useEffect(()=>()=>{W.current.clear()},[]);function N(_){return _.map(y=>{const ee=y.icon,w=ee?e.get(ee):null;if("children"in y)return m.jsx(k.MenuItemGroup,{title:m.jsxs("div",{className:"univer-mb-2 univer-flex univer-items-center univer-text-xs univer-text-gray-400",children:[w&&m.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:m.jsx(w,{})}),m.jsx("span",{children:y.title})]}),children:N(y.children)},y.id);const K=a.current,Q=u===K;if(Q){I.current=y;const g=W.current.get(y.id);g==null||g.scrollIntoView({block:"nearest"})}return a.current++,m.jsx(k.MenuItem,{ref:g=>{g&&W.current.set(y.id,g)},onMouseEnter:()=>v(K),onMouseLeave:()=>v(Number.NaN),className:k.clsx("univer-w-[calc(220px-var(--padding-base)*2)] univer-text-sm",{"hover:univer-bg-transparent":!Q,"univer-bg-gray-100 dark:!univer-bg-gray-500":Q}),onClick:()=>{b(y)},children:m.jsxs("div",{className:"univer-flex univer-w-full univer-items-center univer-px-1",children:[w&&m.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:m.jsx(w,{})}),m.jsx(k.Tooltip,{showIfEllipsis:!0,title:y.title,placement:"right",children:m.jsx("span",{className:"univer-truncate",children:y.title})})]})},y.id)})}const V=M.length>0,Ce=(l==null?void 0:l.popup.Placeholder)||e.get(L.componentKey);return m.jsx("div",{className:k.clsx("univer-mt-2"),children:V?m.jsx(k.Menu,{wrapperClass:"univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto univer-overflow-x-hidden",children:N(M)}):Ce&&m.jsx(Ce,{})})};q.componentKey="docs.quick.insert.popup";var Pe=Object.getOwnPropertyDescriptor,De=(i,n,e,t)=>{for(var r=t>1?void 0:t?Pe(n,e):n,o=i.length-1,u;o>=0;o--)(u=i[o])&&(r=u(r)||r);return r},j=(i,n)=>(e,t)=>n(e,t,i);const ce={dispose:()=>{}};c.DocQuickInsertPopupService=class extends s.Disposable{constructor(e,t,r,o,u){super();P(this,"_popups",new Set);P(this,"_editPopup$",new C.BehaviorSubject(void 0));P(this,"editPopup$",this._editPopup$.asObservable());P(this,"_isComposing$",new C.BehaviorSubject(!1));P(this,"isComposing$",this._isComposing$.asObservable());P(this,"_inputOffset$",new C.BehaviorSubject({start:0,end:0}));P(this,"inputOffset$",this._inputOffset$.asObservable());P(this,"filterKeyword$");P(this,"_menuSelectedCallbacks",new Set);P(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 l,h;return(h=(l=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_DOC))==null?void 0:l.getBody())==null?void 0:h.dataStream.slice(a,d)};let I="";this.filterKeyword$=this._inputOffset$.pipe(C.map(a=>{var l;const d=v(a.start,a.end);return(l=d==null?void 0:d.slice(1))!=null?l:""}),C.distinctUntilChanged(),C.tap(a=>{I=a})),this.disposeWithMe(C.combineLatest([this.filterKeyword$.pipe(C.tap(a=>{var d,l,h;a.length>0?(l=(d=this._inputPlaceholderRenderRoot)==null?void 0:d.unmount)==null||l.dispose():(h=this._inputPlaceholderRenderRoot)==null||h.mount()})),this.isComposing$.pipe(C.tap(a=>{var d,l,h;a?(l=(d=this._inputPlaceholderRenderRoot)==null?void 0:d.unmount)==null||l.dispose():I.length<=0&&((h=this._inputPlaceholderRenderRoot)==null||h.mount())})),this.editPopup$.pipe(C.tap(a=>{var d,l;a||((l=(d=this._inputPlaceholderRenderRoot)==null?void 0:d.unmount)==null||l.dispose(),this._inputPlaceholderRenderRoot=null)}))]).subscribe())}get popups(){return Array.from(this._popups)}get editPopup(){return this._editPopup$.value}get isComposing(){return this._isComposing$.value}setIsComposing(e){this._isComposing$.next(e)}get inputOffset(){return this._inputOffset$.value}setInputOffset(e){this._inputOffset$.next(e)}getDocEventManagerService(e){var t;return(t=this._renderManagerService.getRenderById(e))==null?void 0:t.with(S.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 l,h;const{popup:t,index:r,unitId:o}=e;this.closePopup();const u=this._univerInstanceService.getUnit(o),v=(h=(l=u==null?void 0:u.getBody())==null?void 0:l.paragraphs)==null?void 0:h.find(O=>O.startIndex>r);if(!v)return;const I=this.getDocEventManagerService(o),a=I==null?void 0:I.findParagraphBoundByIndex(v.startIndex);if(!a)return;this._inputPlaceholderRenderRoot=this._createInputPlaceholderRenderRoot(()=>{var V;const O=(V=this._renderManagerService.getRenderById(o))==null?void 0:V.with(E.DocSkeletonManagerService),M=this._docSelectionManagerService.getActiveTextRange();if(!O||!M)return ce;const b=O.getSkeleton().findNodeByCharIndex(M.startOffset,M.segmentId,M.segmentPage);if(!((b==null?void 0:b.content)==="\r"))return ce;const N=this._docCanvasPopupManagerService.attachPopupToRange({startOffset:r+1,endOffset:r+1,collapsed:!1},{componentKey:H.componentKey,onClickOutside:()=>{N.dispose()},direction:"horizontal"},o);return N}),this._inputPlaceholderRenderRoot.mount();const d=this._docCanvasPopupManagerService.attachPopupToRect(a.firstLine,{componentKey:q.componentKey,onClickOutside:()=>{this.closePopup()},direction:"bottom"},o);this._editPopup$.next({disposable:d,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(ne.id,{start:t,end:r}),setTimeout(()=>{this._menuSelectedCallbacks.forEach(o=>o(e))},0)}},c.DocQuickInsertPopupService=De([j(0,s.Inject(S.DocCanvasPopManagerService)),j(1,s.Inject(s.IUniverInstanceService)),j(2,s.Inject(s.ICommandService)),j(3,s.Inject(z.IRenderManagerService)),j(4,s.Inject(E.DocSelectionManagerService))],c.DocQuickInsertPopupService);const ae="doc.quick-insert.button";var Oe=Object.getOwnPropertyDescriptor,Me=(i,n,e,t)=>{for(var r=t>1?void 0:t?Oe(n,e):n,o=i.length-1,u;o>=0;o--)(u=i[o])&&(r=u(r)||r);return r},G=(i,n)=>(e,t)=>n(e,t,i);let B=class extends s.Disposable{constructor(n,e,t,r){super();P(this,"_popup$",new C.BehaviorSubject(null));P(this,"popup$",this._popup$.asObservable());this._context=n,this._docEventManagerService=e,this._docQuickInsertPopupService=t,this._docCanvasPopManagerService=r,this._init()}get popup(){return this._popup$.value}_init(){this.disposeWithMe(C.combineLatest([this._docEventManagerService.hoverParagraphLeftRealTime$,this._docEventManagerService.hoverParagraphRealTime$]).subscribe(([n,e])=>{var o;const t=n!=null?n:e,r=this._context.unit.getDisabled();if(!t||r){this._hideMenu(!0);return}if(t.paragraphStart===t.paragraphEnd){if(this._docQuickInsertPopupService.editPopup||t.startIndex===((o=this.popup)==null?void 0:o.startIndex))return;this._hideMenu(!0);const u=this._docCanvasPopManagerService.attachPopupToRect(t.firstLine,{componentKey:ae,direction:"left-center"},this._context.unit.getUnitId());this._popup$.next({startIndex:t.startIndex,disposable:u})}else this._hideMenu(!0)}))}_hideMenu(n){this._docQuickInsertPopupService.editPopup||this.popup&&(n||this.popup.disposable.canDispose())&&(this.popup.disposable.dispose(),this._popup$.next(null))}};B=Me([G(1,s.Inject(S.DocEventManagerService)),G(2,s.Inject(c.DocQuickInsertPopupService)),G(3,s.Inject(S.DocCanvasPopManagerService))],B);const ue={id:"quick-insert.text.menu",title:"docQuickInsert.menu.text",icon:"TextSingle",keywords:["text"]},de={id:S.OrderListCommand.id,title:"docQuickInsert.menu.numberedList",icon:"OrderSingle",keywords:["numbered","list","ordered"]},pe={id:S.BulletListCommand.id,title:"docQuickInsert.menu.bulletedList",icon:"UnorderSingle",keywords:["bulleted","list","unordered"]},le={id:S.HorizontalLineCommand.id,title:"docQuickInsert.menu.divider",icon:"DividerSingle",keywords:["divider","line","separate"]},ve={id:S.DocCreateTableOperation.id,title:"docQuickInsert.menu.table",icon:"GridSingle",keywords:["table","grid","spreadsheet"]},he={id:te.InsertDocImageCommand.id,title:"docQuickInsert.menu.image",icon:"addition-and-subtraction-single",keywords:["image","picture","photo"]},be=[{title:"docQuickInsert.group.basics",id:"quick.insert.group.basic",children:[ue,de,pe,le,ve,he]}],ke=new Set([de.id,pe.id,le.id,ve.id,he.id]);var we=Object.getOwnPropertyDescriptor,xe=(i,n,e,t)=>{for(var r=t>1?void 0:t?we(n,e):n,o=i.length-1,u;o>=0;o--)(u=i[o])&&(r=u(r)||r);return r},$=(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:U.id,binding:p.KeyCode.ESC,preconditions:()=>!!this._docQuickInsertPopupService.editPopup,priority:1e3})),this._initTrigger(),this._initMenuHandler()}_initTrigger(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var u,v,I;const{_docQuickInsertPopupService:e,_textSelectionManagerService:t,_commandService:r}=this,o=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_DOC);if(!(o!=null&&o.getDisabled())){if(n.id===S.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 l=e.resolvePopup(a.body.dataStream);if(!l||!(l.preconditions?l.preconditions(a):!0))return;e.setInputOffset({start:d.startOffset-1,end:d.startOffset}),setTimeout(()=>{r.executeCommand(re.id,{index:d.startOffset-1,unitId:a.unitId,popup:l})},100)}if(n.id===S.IMEInputCommand.id){const a=n.params;!e.isComposing&&a.isCompositionStart&&e.setIsComposing(!0),e.isComposing&&a.isCompositionEnd&&e.setIsComposing(!1)}if(n.id===E.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===S.DeleteCommand.id){const a=n.params;if(e.editPopup&&a.direction===s.DeleteDirection.LEFT){const d=(I=a.len)!=null?I:0;e.setInputOffset({start:e.inputOffset.start,end:a.range.endOffset-d})}}if(n.id===S.MoveCursorOperation.id){const a=n.params;(a.direction===s.Direction.LEFT||a.direction===s.Direction.RIGHT)&&e.editPopup&&r.executeCommand(U.id)}if(n.id===S.DeleteLeftCommand.id){const a=t.getActiveTextRange();if(!e.editPopup||!a)return;a.endOffset<=e.editPopup.anchor&&r.executeCommand(U.id)}}}))}_initMenuHandler(){this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected(n=>{n.id!==ue.id&&ke.has(n.id)&&this._commandService.executeCommand(n.id)}))}},c.DocQuickInsertTriggerController=xe([$(0,s.ICommandService),$(1,s.Inject(E.DocSelectionManagerService)),$(2,s.Inject(c.DocQuickInsertPopupService)),$(3,s.Inject(p.IShortcutService)),$(4,s.Inject(s.IUniverInstanceService))],c.DocQuickInsertTriggerController);var D=function(){return D=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},D.apply(this,arguments)},Re=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},A=f.forwardRef(function(i,n){var e=i.icon,t=i.id,r=i.className,o=i.extend,u=Re(i,["icon","id","className","extend"]),v="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),I=f.useRef("_".concat(Ue()));return fe(e,"".concat(t),{defIds:e.defIds,idSuffix:I.current},D({ref:n,className:v},u),o)});function fe(i,n,e,t,r){return f.createElement(i.tag,D(D({key:n},Qe(i,e,r)),t),(Ee(i,e).children||[]).map(function(o,u){return fe(o,"".concat(n,"-").concat(i.tag,"-").concat(u),e,void 0,r)}))}function Qe(i,n,e){var t=D({},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 Ee(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)?D(D({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?D(D({},r),{attrs:D(D({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):i}function Ue(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var je={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.01953 3.13985C1.01953 2.77258 1.31726 2.47485 1.68453 2.47485H2.73713C3.1044 2.47485 3.40213 2.77258 3.40213 3.13985 3.40213 3.50712 3.1044 3.80485 2.73713 3.80485H1.68453C1.31726 3.80485 1.01953 3.50712 1.01953 3.13985zM4.17734 3.13985C4.17734 2.77258 4.47507 2.47485 4.84234 2.47485H6.94754C7.31481 2.47485 7.61254 2.77258 7.61254 3.13985 7.61254 3.50712 7.31481 3.80485 6.94754 3.80485H4.84234C4.47507 3.80485 4.17734 3.50712 4.17734 3.13985zM8.38775 3.13985C8.38775 2.77258 8.68548 2.47485 9.05275 2.47485H11.158C11.5252 2.47485 11.823 2.77258 11.823 3.13985 11.823 3.50712 11.5252 3.80485 11.158 3.80485H9.05275C8.68548 3.80485 8.38775 3.50712 8.38775 3.13985zM12.5982 3.13985C12.5982 2.77258 12.8959 2.47485 13.2632 2.47485H14.3158C14.683 2.47485 14.9808 2.77258 14.9808 3.13985 14.9808 3.50712 14.683 3.80485 14.3158 3.80485H13.2632C12.8959 3.80485 12.5982 3.50712 12.5982 3.13985zM1.01953 7.99972C1.01953 7.63245 1.31726 7.33472 1.68453 7.33472H14.3158C14.683 7.33472 14.9808 7.63245 14.9808 7.99972 14.9808 8.36699 14.683 8.66472 14.3158 8.66472H1.68453C1.31726 8.66472 1.01953 8.36699 1.01953 7.99972zM1.68453 12.1951C1.31726 12.1951 1.01953 12.4928 1.01953 12.8601 1.01953 13.2273 1.31726 13.5251 1.68453 13.5251H2.73713C3.1044 13.5251 3.40213 13.2273 3.40213 12.8601 3.40213 12.4928 3.1044 12.1951 2.73713 12.1951H1.68453zM4.84234 12.1951C4.47507 12.1951 4.17734 12.4928 4.17734 12.8601 4.17734 13.2273 4.47507 13.5251 4.84234 13.5251H6.94754C7.31481 13.5251 7.61254 13.2273 7.61254 12.8601 7.61254 12.4928 7.31481 12.1951 6.94754 12.1951H4.84234zM9.05275 12.1951C8.68548 12.1951 8.38775 12.4928 8.38775 12.8601 8.38775 13.2273 8.68548 13.5251 9.05275 13.5251H11.158C11.5252 13.5251 11.823 13.2273 11.823 12.8601 11.823 12.4928 11.5252 12.1951 11.158 12.1951H9.05275zM13.2632 12.1951C12.8959 12.1951 12.5982 12.4928 12.5982 12.8601 12.5982 13.2273 12.8959 13.5251 13.2632 13.5251H14.3158C14.683 13.5251 14.9808 13.2273 14.9808 12.8601 14.9808 12.4928 14.683 12.1951 14.3158 12.1951H13.2632z"}}]},Z=f.forwardRef(function(i,n){return f.createElement(A,Object.assign({},i,{id:"divider-single",ref:n,icon:je}))});Z.displayName="DividerSingle";var $e={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"}}]},ge=f.forwardRef(function(i,n){return f.createElement(A,Object.assign({},i,{id:"plus-single",ref:n,icon:$e}))});ge.displayName="PlusSingle";var Te={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.66695 1.33496C2.29968 1.33496 2.00195 1.63269 2.00195 1.99996V3.64439C2.00195 4.01166 2.29968 4.30939 2.66695 4.30939C3.03422 4.30939 3.33195 4.01166 3.33195 3.64439V2.66496H7.33521V13.335H5.3337C4.96643 13.335 4.6687 13.6327 4.6687 14C4.6687 14.3672 4.96643 14.665 5.3337 14.665H10.667C11.0343 14.665 11.332 14.3672 11.332 14C11.332 13.6327 11.0343 13.335 10.667 13.335H8.66521V2.66496H12.6686V3.64439C12.6686 4.01166 12.9664 4.30939 13.3336 4.30939C13.7009 4.30939 13.9986 4.01166 13.9986 3.64439V1.99996C13.9986 1.63269 13.7009 1.33496 13.3336 1.33496H2.66695Z"}}]},J=f.forwardRef(function(i,n){return f.createElement(A,Object.assign({},i,{id:"text-single",ref:n,icon:Te}))});J.displayName="TextSingle";const X=({className:i=""})=>{const n=p.useDependency(c.DocQuickInsertPopupService),e=p.useDependency(s.IUniverInstanceService),t=p.useDependency(z.IRenderManagerService),r=p.useObservable(f.useMemo(()=>e.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_DOC),[e])),o=r&&t.getRenderById(r.getUnitId()),u=o==null?void 0:o.with(B),v=p.useDependency(p.ILayoutService),I=p.useDependency(E.DocSelectionManagerService),a=p.useObservable(n.editPopup$),d=p.useEvent(l=>{var T;const h=u==null?void 0:u.popup;if(!h)return;const O=n.popups,M={keyword:"",menus$:C.combineLatest(O.map(b=>b.menus$)).pipe(C.map(b=>b.flat()))};I.replaceDocRanges([{startOffset:h.startIndex,endOffset:h.startIndex}]),n.setInputOffset({start:h.startIndex-1,end:h.startIndex-1}),n.showPopup({popup:M,index:h.startIndex-1,unitId:(T=r==null?void 0:r.getUnitId())!=null?T:""}),setTimeout(()=>{v.focus()})});return m.jsx("div",{className:k.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 dark:!univer-text-gray-200 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",k.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-700":a,"univer-bg-white dark:!univer-bg-gray-900":!a},i),role:"button",tabIndex:0,onClick:d,children:m.jsx(ge,{className:"univer-text-gray-800 dark:!univer-text-gray-200"})})};X.componentKey=ae;var Ne=Object.getOwnPropertyDescriptor,Ke=(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},Y=(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(){[ne,re,U].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initComponents(){[[q.componentKey,q],[H.componentKey,H],[L.componentKey,L],[Z.displayName,Z],[J.displayName,J],[X.componentKey,X]].forEach(([e,t])=>{e&&this.disposeWithMe(this._componentManager.register(e,t))}),[{keyword:"/",menus$:C.of(be),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=Ke([Y(0,s.ICommandService),Y(1,s.Inject(c.DocQuickInsertPopupService)),Y(2,s.Inject(p.ComponentManager))],c.DocQuickInsertUIController);var He=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,qe=(i,n,e)=>n in i?He(i,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[n]=e,Be=(i,n,e,t)=>{for(var r=t>1?void 0:t?Le(n,e):n,o=i.length-1,u;o>=0;o--)(u=i[o])&&(r=u(r)||r);return r},me=(i,n)=>(e,t)=>n(e,t,i),Ie=(i,n,e)=>qe(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),[[B]].forEach(n=>{this._renderManagerSrv.registerRenderModule(s.UniverInstanceType.UNIVER_DOC,n)})}},Ie(c.UniverDocsQuickInsertUIPlugin,"type",s.UniverInstanceType.UNIVER_DOC),Ie(c.UniverDocsQuickInsertUIPlugin,"pluginName",Ae),c.UniverDocsQuickInsertUIPlugin=Be([s.DependentOn(_e.UniverDrawingUIPlugin,Se.UniverDrawingPlugin,te.UniverDocsDrawingUIPlugin,R.UniverDocsDrawingPlugin,p.UniverUIPlugin),me(0,s.Inject(s.Injector)),me(1,s.Inject(z.IRenderManagerService))],c.UniverDocsQuickInsertUIPlugin),c.KeywordInputPlaceholderComponentKey=ie,c.QuickInsertPlaceholderComponentKey=se,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.7.0",
3
+ "version": "0.8.0-beta.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,16 +53,16 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@univerjs/icons": "^0.3.24",
56
- "@univerjs/core": "0.7.0",
57
- "@univerjs/design": "0.7.0",
58
- "@univerjs/docs": "0.7.0",
59
- "@univerjs/docs-drawing": "0.7.0",
60
- "@univerjs/docs-drawing-ui": "0.7.0",
61
- "@univerjs/docs-ui": "0.7.0",
62
- "@univerjs/drawing": "0.7.0",
63
- "@univerjs/drawing-ui": "0.7.0",
64
- "@univerjs/engine-render": "0.7.0",
65
- "@univerjs/ui": "0.7.0"
56
+ "@univerjs/core": "0.8.0-beta.0",
57
+ "@univerjs/docs": "0.8.0-beta.0",
58
+ "@univerjs/design": "0.8.0-beta.0",
59
+ "@univerjs/docs-drawing": "0.8.0-beta.0",
60
+ "@univerjs/drawing": "0.8.0-beta.0",
61
+ "@univerjs/docs-ui": "0.8.0-beta.0",
62
+ "@univerjs/drawing-ui": "0.8.0-beta.0",
63
+ "@univerjs/engine-render": "0.8.0-beta.0",
64
+ "@univerjs/docs-drawing-ui": "0.8.0-beta.0",
65
+ "@univerjs/ui": "0.8.0-beta.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "postcss": "^8.5.3",
@@ -71,8 +71,8 @@
71
71
  "tailwindcss": "^3.4.17",
72
72
  "typescript": "^5.8.3",
73
73
  "vite": "^6.3.5",
74
- "vitest": "^3.1.3",
75
- "@univerjs-infra/shared": "0.7.0"
74
+ "vitest": "^3.1.4",
75
+ "@univerjs-infra/shared": "0.8.0-beta.0"
76
76
  },
77
77
  "scripts": {
78
78
  "test": "vitest run",