@univerjs/docs-quick-insert-ui 0.6.6-nightly.202503151606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/lib/cjs/index.js +6 -0
- package/lib/cjs/locale/en-US.js +1 -0
- package/lib/cjs/locale/fa-IR.js +1 -0
- package/lib/cjs/locale/fr-FR.js +1 -0
- package/lib/cjs/locale/ru-RU.js +1 -0
- package/lib/cjs/locale/vi-VN.js +1 -0
- package/lib/cjs/locale/zh-CN.js +1 -0
- package/lib/cjs/locale/zh-TW.js +1 -0
- package/lib/es/index.js +536 -0
- package/lib/es/locale/en-US.js +16 -0
- package/lib/es/locale/fa-IR.js +16 -0
- package/lib/es/locale/fr-FR.js +16 -0
- package/lib/es/locale/ru-RU.js +16 -0
- package/lib/es/locale/vi-VN.js +16 -0
- package/lib/es/locale/zh-CN.js +16 -0
- package/lib/es/locale/zh-TW.js +16 -0
- package/lib/index.css +1 -0
- package/lib/types/commands/commands/doc-quick-insert.command.d.ts +7 -0
- package/lib/types/commands/operations/quick-insert-popup.operation.d.ts +9 -0
- package/lib/types/controllers/built-in-menus.d.ts +11 -0
- package/lib/types/controllers/doc-quick-insert-trigger.controller.d.ts +13 -0
- package/lib/types/controllers/doc-quick-insert-ui.controller.d.ts +13 -0
- package/lib/types/index.d.ts +21 -0
- package/lib/types/locale/en-US.d.ts +3 -0
- package/lib/types/locale/fa-IR.d.ts +3 -0
- package/lib/types/locale/fr-FR.d.ts +3 -0
- package/lib/types/locale/ru-RU.d.ts +3 -0
- package/lib/types/locale/vi-VN.d.ts +3 -0
- package/lib/types/locale/zh-CN.d.ts +29 -0
- package/lib/types/locale/zh-TW.d.ts +3 -0
- package/lib/types/plugin.d.ts +9 -0
- package/lib/types/services/doc-quick-insert-popup.service.d.ts +67 -0
- package/lib/types/views/QuickInsertPopup.d.ts +20 -0
- package/lib/umd/index.js +6 -0
- package/lib/umd/locale/en-US.js +1 -0
- package/lib/umd/locale/fa-IR.js +1 -0
- package/lib/umd/locale/fr-FR.js +1 -0
- package/lib/umd/locale/ru-RU.js +1 -0
- package/lib/umd/locale/vi-VN.js +1 -0
- package/lib/umd/locale/zh-CN.js +1 -0
- package/lib/umd/locale/zh-TW.js +1 -0
- package/package.json +84 -0
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @univerjs/docs-quick-insert-ui
|
|
2
|
+
|
|
3
|
+
## Package Overview
|
|
4
|
+
|
|
5
|
+
| Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
|
|
6
|
+
| --- | --- | --- | --- | --- | :---: | :---: |
|
|
7
|
+
| `@univerjs/docs-quick-insert-ui` | `UniverDocsDrawingUi` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ⭕️ | ⭕️ |
|
|
8
|
+
|
|
9
|
+
## Introduction
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Installation
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
# Using npm
|
|
17
|
+
npm install @univerjs/docs-quick-insert-ui
|
|
18
|
+
|
|
19
|
+
# Using pnpm
|
|
20
|
+
pnpm add @univerjs/docs-quick-insert-ui
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
<!-- Links -->
|
|
24
|
+
[npm-version-shield]: https://img.shields.io/npm/v/@univerjs/docs-quick-insert-ui?style=flat-square
|
|
25
|
+
[npm-version-link]: https://npmjs.com/package/@univerjs/docs-quick-insert-ui
|
|
26
|
+
[npm-license-shield]: https://img.shields.io/npm/l/@univerjs/docs-quick-insert-ui?style=flat-square
|
|
27
|
+
[npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/docs-quick-insert-ui?style=flat-square
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";var te=Object.defineProperty;var ne=(r,t,e)=>t in r?te(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var C=(r,t,e)=>ne(r,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),re=require("@univerjs/docs-drawing"),ie=require("@univerjs/drawing"),se=require("@univerjs/drawing-ui"),d=require("@univerjs/ui"),q=require("@univerjs/docs"),I=require("@univerjs/docs-ui"),D=require("rxjs"),m=require("react/jsx-runtime"),b=require("@univerjs/design"),p=require("react"),A={id:"doc.command.delete-search-key",type:s.CommandType.COMMAND,handler:(r,t)=>{const e=r.get(s.ICommandService),{start:n,end:i}=t;return e.syncExecuteCommand(I.CutContentCommand.id,{segmentId:"",textRanges:[{startOffset:n,endOffset:n,collapsed:!0}],selections:[{startOffset:n,endOffset:i,collapsed:!1,direction:s.RANGE_DIRECTION.FORWARD}]})}};function K(r,t){return r.map(e=>({...e})).filter(e=>{if("children"in e)return e.children=K(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 L(r,t){return r.map(e=>{const n={...e};return"children"in n&&(n.children=L(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 oe=[d.KeyCode.ARROW_UP,d.KeyCode.ARROW_DOWN,d.KeyCode.ENTER],j=()=>{const r=d.useDependency(s.LocaleService),t=d.useDependency(exports.DocQuickInsertPopupService),e=d.useDependency(d.ComponentManager),n=d.useDependency(d.IShortcutService),i=d.useDependency(s.ICommandService),o=p.useMemo(()=>s.generateRandomId(),[]),[c,a]=p.useState(0),u=p.useRef(null),l=p.useRef(0);l.current=0;const _=d.useObservable(t.filterKeyword$,""),S=d.useObservable(t.editPopup$),E=d.useObservable(S==null?void 0:S.popup.menus$,[]),[Q,Y]=p.useState([]),N=p.useMemo(()=>L(E,r),[E]);p.useEffect(()=>{const f=requestIdleCallback(()=>{Y(K(N,_.toLowerCase()))});return()=>{cancelIdleCallback(f)}},[N,_]);const $=f=>{t.emitMenuSelected(f),i.executeCommand(M.id)};p.useEffect(()=>{const f=new s.DisposableCollection;n.getAllShortcuts().filter(v=>v.binding&&oe.includes(v.binding)).forEach(v=>{const y=v.preconditions;v.preconditions=()=>!1,f.add(s.toDisposable(()=>{v.preconditions=y}))});const O={id:`quick.insert.popup.enter.${o}`,type:s.CommandType.OPERATION,handler:()=>{const v=u.current;v&&$(v)}},x={id:`quick.insert.popup.move.cursor.up.${o}`,type:s.CommandType.OPERATION,handler:()=>{a(v=>{const y=v-1;return y>=0?y:l.current-1})}},P={id:`quick.insert.popup.move.cursor.down.${o}`,type:s.CommandType.OPERATION,handler:()=>{a(v=>{const y=v+1;return y<=l.current-1?y:0})}};return f.add(i.registerCommand(x)),f.add(i.registerCommand(P)),f.add(i.registerCommand(O)),f.add(n.registerShortcut({priority:1e3,id:x.id,binding:d.KeyCode.ARROW_UP,preconditions:()=>!0,staticParameters:{direction:s.Direction.UP}})),f.add(n.registerShortcut({priority:1e3,id:P.id,binding:d.KeyCode.ARROW_DOWN,preconditions:()=>!0,staticParameters:{direction:s.Direction.DOWN}})),f.add(n.registerShortcut({priority:1e3,id:O.id,binding:d.KeyCode.ENTER,preconditions:()=>!0})),()=>{f.dispose()}},[]),p.useEffect(()=>{a(0)},[Q]);function H(f){return f.map(g=>{const U=g.icon,O=U?e.get(U):null;if("children"in g)return m.jsx(b.MenuItemGroup,{title:m.jsxs("div",{className:`
|
|
2
|
+
univer-mb-2 univer-flex univer-items-center univer-text-xs univer-text-gray-400
|
|
3
|
+
`,children:[O&&m.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:m.jsx(O,{})}),m.jsx("span",{children:g.title})]}),children:H(g.children)},g.id);const x=l.current,P=c===x;return P&&(u.current=g),l.current++,m.jsx(b.MenuItem,{onMouseEnter:()=>a(x),onMouseLeave:()=>a(Number.NaN),className:b.clsx("univer-text-sm",{"hover:univer-bg-transparent":!P,"univer-bg-gray-100":P}),onClick:()=>{$(g)},children:m.jsxs("div",{className:"univer-flex univer-items-center univer-px-1",children:[O&&m.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:m.jsx(O,{})}),m.jsx("span",{children:g.title})]})},g.id)})}const ee=Q.length>0;return m.jsx("div",{className:b.clsx(`
|
|
4
|
+
univer-rounded-lg univer-border univer-border-solid univer-border-gray-100
|
|
5
|
+
univer-shadow-[0_0_10px_0_rgba(0,0,0,0.1)]
|
|
6
|
+
`),children:ee?m.jsx("div",{className:"univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto",children:m.jsx(b.Menu,{children:H(Q)})}):S==null?void 0:S.popup.placeholder})};j.componentKey="doc.quick-insert-popup";var ce=Object.getOwnPropertyDescriptor,ue=(r,t,e,n)=>{for(var i=n>1?void 0:n?ce(t,e):t,o=r.length-1,c;o>=0;o--)(c=r[o])&&(i=c(i)||i);return i},R=(r,t)=>(e,n)=>t(e,n,r);exports.DocQuickInsertPopupService=class extends s.Disposable{constructor(e,n,i){super();C(this,"_popups",new Set);C(this,"_editPopup$",new D.BehaviorSubject(void 0));C(this,"editPopup$",this._editPopup$.asObservable());C(this,"_inputOffset$",new D.BehaviorSubject({start:0,end:0}));C(this,"inputOffset$",this._inputOffset$.asObservable());C(this,"filterKeyword$");C(this,"_menuSelectedCallbacks",new Set);this._docCanvasPopupManagerService=e,this._univerInstanceService=n,this._commandService=i,this.disposeWithMe(this._editPopup$);const o=(c,a)=>{var u,l;return(l=(u=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_DOC))==null?void 0:u.getBody())==null?void 0:l.dataStream.slice(c,a)};this.filterKeyword$=this._inputOffset$.pipe(D.map(c=>{var u;const a=o(c.start,c.end);return(u=a==null?void 0:a.slice(1))!=null?u:""}),D.distinctUntilChanged())}get editPopup(){return this._editPopup$.value}get inputOffset(){return this._inputOffset$.value}setInputOffset(e){this._inputOffset$.next(e)}resolvePopup(e){return Array.from(this._popups).find(n=>n.keyword===e)}registerPopup(e){return this._popups.add(e),()=>{this._popups.delete(e)}}showPopup(e){const{popup:n,index:i,unitId:o}=e;this.closePopup();const c=this._docCanvasPopupManagerService.attachPopupToRange({startOffset:i,endOffset:i,collapsed:!0},{componentKey:j.componentKey,onClickOutside:()=>{this.closePopup()},direction:"bottom"},o);this._editPopup$.next({disposable:c,popup:n,anchor:i,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:n,end:i}=this.inputOffset;this._commandService.syncExecuteCommand(A.id,{start:n,end:i}),setTimeout(()=>{this._menuSelectedCallbacks.forEach(o=>o(e))},0)}};exports.DocQuickInsertPopupService=ue([R(0,s.Inject(I.DocCanvasPopManagerService)),R(1,s.Inject(s.IUniverInstanceService)),R(2,s.Inject(s.ICommandService))],exports.DocQuickInsertPopupService);const W={type:s.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}},M={type:s.CommandType.OPERATION,id:"doc.operation.close-quick-insert-popup",handler(r){return r.get(exports.DocQuickInsertPopupService).closePopup(),!0}},z={id:"quick-insert.text.menu",title:"docQuickInsert.menu.text",icon:"TextSingle",keywords:["text"]},B={id:I.OrderListCommand.id,title:"docQuickInsert.menu.numberedList",icon:"OrderSingle",keywords:["numbered","list","ordered"]},V={id:I.BulletListCommand.id,title:"docQuickInsert.menu.bulletedList",icon:"UnorderSingle",keywords:["bulleted","list","unordered"]},F={id:I.HorizontalLineCommand.id,title:"docQuickInsert.menu.divider",icon:"DividerSingle",keywords:["divider","line","separate"]},ae=[{title:"docQuickInsert.group.basics",id:"quick.insert.group.basic",children:[z,B,V,F]}],de=new Set([B.id,V.id,F.id]);var le=Object.getOwnPropertyDescriptor,pe=(r,t,e,n)=>{for(var i=n>1?void 0:n?le(t,e):t,o=r.length-1,c;o>=0;o--)(c=r[o])&&(i=c(i)||i);return i},k=(r,t)=>(e,n)=>t(e,n,r);exports.DocQuickInsertTriggerController=class extends s.Disposable{constructor(t,e,n,i){super(),this._commandService=t,this._textSelectionManagerService=e,this._docQuickInsertPopupService=n,this._shortcutService=i,this.disposeWithMe(this._shortcutService.registerShortcut({id:M.id,binding:d.KeyCode.ESC,preconditions:()=>!!this._docQuickInsertPopupService.editPopup,priority:1e3})),this._initTrigger(),this._initMenuHandler()}_initTrigger(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var o,c,a;const{_docQuickInsertPopupService:e,_textSelectionManagerService:n,_commandService:i}=this;if(t.id===I.InsertCommand.id){const u=t.params;if(e.editPopup){e.setInputOffset({start:e.inputOffset.start,end:u.range.endOffset+1});return}const l=n.getActiveTextRange();if(!l)return;const _=e.resolvePopup(u.body.dataStream);if(!_||!(_.preconditions?_.preconditions(u):!0))return;e.setInputOffset({start:l.startOffset-1,end:l.startOffset}),setTimeout(()=>{i.executeCommand(W.id,{index:l.startOffset-1,unitId:u.unitId,popup:_})},100)}if(t.id===q.RichTextEditingMutation.id){const u=t.params;if(u.isCompositionEnd){const l=(c=(o=u.textRanges)==null?void 0:o[0])==null?void 0:c.endOffset;l&&e.setInputOffset({start:e.inputOffset.start,end:l})}}if(t.id===I.DeleteCommand.id){const u=t.params;if(e.editPopup&&u.direction===s.DeleteDirection.LEFT){const l=(a=u.len)!=null?a:0;e.setInputOffset({start:e.inputOffset.start,end:u.range.endOffset-l})}}if(t.id===I.MoveCursorOperation.id){const u=t.params;(u.direction===s.Direction.LEFT||u.direction===s.Direction.RIGHT)&&e.editPopup&&i.executeCommand(M.id)}if(t.id===I.DeleteLeftCommand.id){const u=n.getActiveTextRange();if(!e.editPopup||!u)return;u.endOffset<=e.editPopup.anchor&&i.executeCommand(M.id)}}))}_initMenuHandler(){this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected(t=>{t.id!==z.id&&de.has(t.id)&&this._commandService.executeCommand(t.id)}))}};exports.DocQuickInsertTriggerController=pe([k(0,s.ICommandService),k(1,s.Inject(q.DocSelectionManagerService)),k(2,s.Inject(exports.DocQuickInsertPopupService)),k(3,s.Inject(d.IShortcutService))],exports.DocQuickInsertTriggerController);var h=function(){return h=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},h.apply(this,arguments)},fe=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},T=p.forwardRef(function(r,t){var e=r.icon,n=r.id,i=r.className,o=r.extend,c=fe(r,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),u=p.useRef("_".concat(he()));return G(e,"".concat(n),{defIds:e.defIds,idSuffix:u.current},h({ref:t,className:a},c),o)});function G(r,t,e,n,i){return p.createElement(r.tag,h(h({key:t},ve(r,e,i)),n),(me(r,e).children||[]).map(function(o,c){return G(o,"".concat(t,"-").concat(r.tag,"-").concat(c),e,void 0,i)}))}function ve(r,t,e){var n=h({},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(o){var c=o[0],a=o[1];c==="mask"&&typeof a=="string"&&(n[c]=a.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(o){var c=o[0],a=o[1];typeof a=="string"&&(n[c]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function me(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)?h(h({},r),{children:r.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?h(h({},i),{attrs:h(h({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):r}function he(){return Math.random().toString(36).substring(2,8)}T.displayName="UniverIcon";var ge={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=p.forwardRef(function(r,t){return p.createElement(T,Object.assign({},r,{id:"divider-single",ref:t,icon:ge}))});Z.displayName="DividerSingle";var Ie={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=p.forwardRef(function(r,t){return p.createElement(T,Object.assign({},r,{id:"text-single",ref:t,icon:Ie}))});J.displayName="TextSingle";var Ce=Object.getOwnPropertyDescriptor,_e=(r,t,e,n)=>{for(var i=n>1?void 0:n?Ce(t,e):t,o=r.length-1,c;o>=0;o--)(c=r[o])&&(i=c(i)||i);return i},w=(r,t)=>(e,n)=>t(e,n,r);exports.DocQuickInsertUIController=class extends s.Disposable{constructor(t,e,n,i){super(),this._commandService=t,this._docQuickInsertPopupService=e,this._componentManager=n,this._menuManagerService=i,this._initCommands(),this._initComponents(),this._initMenus()}_initCommands(){[A,W,M].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initComponents(){this.disposeWithMe(this._componentManager.register(j.componentKey,j)),this.disposeWithMe(this._componentManager.register("DividerSingle",Z)),this.disposeWithMe(this._componentManager.register("TextSingle",J)),[{keyword:"/",menus$:D.of(ae),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=_e([w(0,s.ICommandService),w(1,s.Inject(exports.DocQuickInsertPopupService)),w(2,s.Inject(d.ComponentManager)),w(3,s.Inject(d.IMenuManagerService))],exports.DocQuickInsertUIController);var Se=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,ye=(r,t,e)=>t in r?Se(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Pe=(r,t,e,n)=>{for(var i=n>1?void 0:n?Oe(t,e):t,o=r.length-1,c;o>=0;o--)(c=r[o])&&(i=c(i)||i);return i},xe=(r,t)=>(e,n)=>t(e,n,r),X=(r,t,e)=>ye(r,typeof t!="symbol"?t+"":t,e);const be="DOC_QUICK_INSERT_UI_PLUGIN";exports.UniverDocsQuickInsertUIPlugin=class extends s.Plugin{constructor(t){super(),this._injector=t}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)}};X(exports.UniverDocsQuickInsertUIPlugin,"type",s.UniverInstanceType.UNIVER_DOC);X(exports.UniverDocsQuickInsertUIPlugin,"pluginName",be);exports.UniverDocsQuickInsertUIPlugin=Pe([s.DependentOn(se.UniverDrawingUIPlugin,ie.UniverDrawingPlugin,re.UniverDocsDrawingPlugin,d.UniverUIPlugin),xe(0,s.Inject(s.Injector))],exports.UniverDocsQuickInsertUIPlugin);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={docQuickInsert:{menu:{numberedList:"Numbered List",bulletedList:"Bulleted List",divider:"Divider",text:"Text"},group:{basics:"Basics"}}};module.exports=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={docQuickInsert:{menu:{numberedList:"لیست شمارهدار",bulletedList:"لیست نقطهدار",divider:"خط تقسیم",text:"متن"},group:{basics:"بنیادی"}}};module.exports=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={docQuickInsert:{menu:{numberedList:"Liste numérotée",bulletedList:"Liste à puces",divider:"Ligne de séparation",text:"Texte"},group:{basics:"Basiques"}}};module.exports=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={docQuickInsert:{menu:{numberedList:"Список с нумерацией",bulletedList:"Маркированный список",divider:"Разделительная линия",text:"Текст"},group:{basics:"Основные"}}};module.exports=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n={docQuickInsert:{menu:{numberedList:"Danh sách được đánh số",bulletedList:"Danh sách không được đánh số",divider:"Đường phân cách",text:"Văn bản"},group:{basics:"Cơ bản"}}};module.exports=n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={docQuickInsert:{menu:{numberedList:"有序列表",bulletedList:"无序列表",divider:"分隔线",text:"文本"},group:{basics:"基础"}}};module.exports=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={docQuickInsert:{menu:{numberedList:"有序列表",bulletedList:"無序列表",divider:"分隔線",text:"文本"},group:{basics:"基礎"}}};module.exports=e;
|
package/lib/es/index.js
ADDED
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
var _e = Object.defineProperty;
|
|
2
|
+
var Ce = (t, e, i) => e in t ? _e(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
|
|
3
|
+
var g = (t, e, i) => Ce(t, typeof e != "symbol" ? e + "" : e, i);
|
|
4
|
+
import { CommandType as x, ICommandService as b, RANGE_DIRECTION as Oe, LocaleService as Se, generateRandomId as Ie, DisposableCollection as xe, toDisposable as Pe, Direction as D, Inject as h, IUniverInstanceService as ye, Disposable as W, UniverInstanceType as te, DeleteDirection as Me, DependentOn as be, Injector as we, Plugin as ke } from "@univerjs/core";
|
|
5
|
+
import { UniverDocsDrawingPlugin as De } from "@univerjs/docs-drawing";
|
|
6
|
+
import { UniverDrawingPlugin as Ne } from "@univerjs/drawing";
|
|
7
|
+
import { UniverDrawingUIPlugin as Re } from "@univerjs/drawing-ui";
|
|
8
|
+
import { KeyCode as O, useDependency as y, ComponentManager as ne, IShortcutService as ie, useObservable as j, IMenuManagerService as Ee, UniverUIPlugin as $e } from "@univerjs/ui";
|
|
9
|
+
import { DocSelectionManagerService as He, RichTextEditingMutation as Te } from "@univerjs/docs";
|
|
10
|
+
import { CutContentCommand as Ue, DocCanvasPopManagerService as je, OrderListCommand as Qe, BulletListCommand as Ae, HorizontalLineCommand as Le, InsertCommand as We, DeleteCommand as Ke, MoveCursorOperation as ze, DeleteLeftCommand as qe } from "@univerjs/docs-ui";
|
|
11
|
+
import { map as Be, distinctUntilChanged as Ve, BehaviorSubject as Z, of as Fe } from "rxjs";
|
|
12
|
+
import { jsx as p, jsxs as J } from "react/jsx-runtime";
|
|
13
|
+
import { clsx as X, Menu as Ge, MenuItemGroup as Ze, MenuItem as Je } from "@univerjs/design";
|
|
14
|
+
import { useMemo as Y, useState as ee, useRef as L, useEffect as Q, forwardRef as K, createElement as z } from "react";
|
|
15
|
+
const re = {
|
|
16
|
+
id: "doc.command.delete-search-key",
|
|
17
|
+
type: x.COMMAND,
|
|
18
|
+
handler: (t, e) => {
|
|
19
|
+
const i = t.get(b), { start: n, end: r } = e;
|
|
20
|
+
return i.syncExecuteCommand(Ue.id, {
|
|
21
|
+
segmentId: "",
|
|
22
|
+
textRanges: [{
|
|
23
|
+
startOffset: n,
|
|
24
|
+
endOffset: n,
|
|
25
|
+
collapsed: !0
|
|
26
|
+
}],
|
|
27
|
+
selections: [{
|
|
28
|
+
startOffset: n,
|
|
29
|
+
endOffset: r,
|
|
30
|
+
collapsed: !1,
|
|
31
|
+
direction: Oe.FORWARD
|
|
32
|
+
}]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
function se(t, e) {
|
|
37
|
+
return t.map((i) => ({ ...i })).filter((i) => {
|
|
38
|
+
if ("children" in i)
|
|
39
|
+
return i.children = se(i.children, e), i.children.length > 0;
|
|
40
|
+
const n = i.keywords;
|
|
41
|
+
return n ? n.some((r) => r.includes(e)) : i.title.toLowerCase().includes(e);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function oe(t, e) {
|
|
45
|
+
return t.map((i) => {
|
|
46
|
+
const n = { ...i };
|
|
47
|
+
return "children" in n && (n.children = oe(n.children, e)), n.title = e.t(n.title), "keywords" in n && (n.keywords = n.keywords.concat(n.title).map((r) => r.toLowerCase())), n;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const Xe = [O.ARROW_UP, O.ARROW_DOWN, O.ENTER], N = () => {
|
|
51
|
+
const t = y(Se), e = y(v), i = y(ne), n = y(ie), r = y(b), s = Y(() => Ie(), []), [c, o] = ee(0), a = L(null), f = L(0);
|
|
52
|
+
f.current = 0;
|
|
53
|
+
const H = j(e.filterKeyword$, ""), S = j(e.editPopup$), B = j(S == null ? void 0 : S.popup.menus$, []), [T, ve] = ee([]), V = Y(() => oe(B, t), [B]);
|
|
54
|
+
Q(() => {
|
|
55
|
+
const d = requestIdleCallback(() => {
|
|
56
|
+
ve(se(V, H.toLowerCase()));
|
|
57
|
+
});
|
|
58
|
+
return () => {
|
|
59
|
+
cancelIdleCallback(d);
|
|
60
|
+
};
|
|
61
|
+
}, [V, H]);
|
|
62
|
+
const F = (d) => {
|
|
63
|
+
e.emitMenuSelected(d), r.executeCommand(M.id);
|
|
64
|
+
};
|
|
65
|
+
Q(() => {
|
|
66
|
+
const d = new xe();
|
|
67
|
+
n.getAllShortcuts().filter((u) => u.binding && Xe.includes(u.binding)).forEach((u) => {
|
|
68
|
+
const C = u.preconditions;
|
|
69
|
+
u.preconditions = () => !1, d.add(Pe(() => {
|
|
70
|
+
u.preconditions = C;
|
|
71
|
+
}));
|
|
72
|
+
});
|
|
73
|
+
const _ = {
|
|
74
|
+
id: `quick.insert.popup.enter.${s}`,
|
|
75
|
+
type: x.OPERATION,
|
|
76
|
+
handler: () => {
|
|
77
|
+
const u = a.current;
|
|
78
|
+
u && F(u);
|
|
79
|
+
}
|
|
80
|
+
}, P = {
|
|
81
|
+
id: `quick.insert.popup.move.cursor.up.${s}`,
|
|
82
|
+
type: x.OPERATION,
|
|
83
|
+
handler: () => {
|
|
84
|
+
o((u) => {
|
|
85
|
+
const C = u - 1;
|
|
86
|
+
return C >= 0 ? C : f.current - 1;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}, I = {
|
|
90
|
+
id: `quick.insert.popup.move.cursor.down.${s}`,
|
|
91
|
+
type: x.OPERATION,
|
|
92
|
+
handler: () => {
|
|
93
|
+
o((u) => {
|
|
94
|
+
const C = u + 1;
|
|
95
|
+
return C <= f.current - 1 ? C : 0;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return d.add(r.registerCommand(P)), d.add(r.registerCommand(I)), d.add(r.registerCommand(_)), d.add(n.registerShortcut({
|
|
100
|
+
priority: 1e3,
|
|
101
|
+
id: P.id,
|
|
102
|
+
binding: O.ARROW_UP,
|
|
103
|
+
preconditions: () => !0,
|
|
104
|
+
staticParameters: {
|
|
105
|
+
direction: D.UP
|
|
106
|
+
}
|
|
107
|
+
})), d.add(n.registerShortcut({
|
|
108
|
+
priority: 1e3,
|
|
109
|
+
id: I.id,
|
|
110
|
+
binding: O.ARROW_DOWN,
|
|
111
|
+
preconditions: () => !0,
|
|
112
|
+
staticParameters: {
|
|
113
|
+
direction: D.DOWN
|
|
114
|
+
}
|
|
115
|
+
})), d.add(n.registerShortcut({
|
|
116
|
+
priority: 1e3,
|
|
117
|
+
id: _.id,
|
|
118
|
+
binding: O.ENTER,
|
|
119
|
+
preconditions: () => !0
|
|
120
|
+
})), () => {
|
|
121
|
+
d.dispose();
|
|
122
|
+
};
|
|
123
|
+
}, []), Q(() => {
|
|
124
|
+
o(0);
|
|
125
|
+
}, [T]);
|
|
126
|
+
function G(d) {
|
|
127
|
+
return d.map((m) => {
|
|
128
|
+
const U = m.icon, _ = U ? i.get(U) : null;
|
|
129
|
+
if ("children" in m)
|
|
130
|
+
return /* @__PURE__ */ p(
|
|
131
|
+
Ze,
|
|
132
|
+
{
|
|
133
|
+
title: /* @__PURE__ */ J(
|
|
134
|
+
"div",
|
|
135
|
+
{
|
|
136
|
+
className: `
|
|
137
|
+
univer-mb-2 univer-flex univer-items-center univer-text-xs univer-text-gray-400
|
|
138
|
+
`,
|
|
139
|
+
children: [
|
|
140
|
+
_ && /* @__PURE__ */ p("span", { className: "univer-mr-2 univer-inline-flex univer-text-base", children: /* @__PURE__ */ p(_, {}) }),
|
|
141
|
+
/* @__PURE__ */ p("span", { children: m.title })
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
children: G(m.children)
|
|
146
|
+
},
|
|
147
|
+
m.id
|
|
148
|
+
);
|
|
149
|
+
const P = f.current, I = c === P;
|
|
150
|
+
return I && (a.current = m), f.current++, /* @__PURE__ */ p(
|
|
151
|
+
Je,
|
|
152
|
+
{
|
|
153
|
+
onMouseEnter: () => o(P),
|
|
154
|
+
onMouseLeave: () => o(Number.NaN),
|
|
155
|
+
className: X("univer-text-sm", {
|
|
156
|
+
"hover:univer-bg-transparent": !I,
|
|
157
|
+
"univer-bg-gray-100": I
|
|
158
|
+
}),
|
|
159
|
+
onClick: () => {
|
|
160
|
+
F(m);
|
|
161
|
+
},
|
|
162
|
+
children: /* @__PURE__ */ J("div", { className: "univer-flex univer-items-center univer-px-1", children: [
|
|
163
|
+
_ && /* @__PURE__ */ p("span", { className: "univer-mr-2 univer-inline-flex univer-text-base", children: /* @__PURE__ */ p(_, {}) }),
|
|
164
|
+
/* @__PURE__ */ p("span", { children: m.title })
|
|
165
|
+
] })
|
|
166
|
+
},
|
|
167
|
+
m.id
|
|
168
|
+
);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
const ge = T.length > 0;
|
|
172
|
+
return /* @__PURE__ */ p(
|
|
173
|
+
"div",
|
|
174
|
+
{
|
|
175
|
+
className: X(`
|
|
176
|
+
univer-rounded-lg univer-border univer-border-solid univer-border-gray-100
|
|
177
|
+
univer-shadow-[0_0_10px_0_rgba(0,0,0,0.1)]
|
|
178
|
+
`),
|
|
179
|
+
children: ge ? /* @__PURE__ */ p("div", { className: "univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto", children: /* @__PURE__ */ p(Ge, { children: G(T) }) }) : S == null ? void 0 : S.popup.placeholder
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
};
|
|
183
|
+
N.componentKey = "doc.quick-insert-popup";
|
|
184
|
+
var Ye = Object.getOwnPropertyDescriptor, et = (t, e, i, n) => {
|
|
185
|
+
for (var r = n > 1 ? void 0 : n ? Ye(e, i) : e, s = t.length - 1, c; s >= 0; s--)
|
|
186
|
+
(c = t[s]) && (r = c(r) || r);
|
|
187
|
+
return r;
|
|
188
|
+
}, A = (t, e) => (i, n) => e(i, n, t);
|
|
189
|
+
let v = class extends W {
|
|
190
|
+
constructor(e, i, n) {
|
|
191
|
+
super();
|
|
192
|
+
g(this, "_popups", /* @__PURE__ */ new Set());
|
|
193
|
+
g(this, "_editPopup$", new Z(void 0));
|
|
194
|
+
g(this, "editPopup$", this._editPopup$.asObservable());
|
|
195
|
+
g(this, "_inputOffset$", new Z({ start: 0, end: 0 }));
|
|
196
|
+
g(this, "inputOffset$", this._inputOffset$.asObservable());
|
|
197
|
+
g(this, "filterKeyword$");
|
|
198
|
+
g(this, "_menuSelectedCallbacks", /* @__PURE__ */ new Set());
|
|
199
|
+
this._docCanvasPopupManagerService = e, this._univerInstanceService = i, this._commandService = n, this.disposeWithMe(this._editPopup$);
|
|
200
|
+
const r = (s, c) => {
|
|
201
|
+
var o, a;
|
|
202
|
+
return (a = (o = this._univerInstanceService.getCurrentUnitOfType(te.UNIVER_DOC)) == null ? void 0 : o.getBody()) == null ? void 0 : a.dataStream.slice(s, c);
|
|
203
|
+
};
|
|
204
|
+
this.filterKeyword$ = this._inputOffset$.pipe(
|
|
205
|
+
Be((s) => {
|
|
206
|
+
var o;
|
|
207
|
+
const c = r(s.start, s.end);
|
|
208
|
+
return (o = c == null ? void 0 : c.slice(1)) != null ? o : "";
|
|
209
|
+
}),
|
|
210
|
+
Ve()
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
get editPopup() {
|
|
214
|
+
return this._editPopup$.value;
|
|
215
|
+
}
|
|
216
|
+
get inputOffset() {
|
|
217
|
+
return this._inputOffset$.value;
|
|
218
|
+
}
|
|
219
|
+
setInputOffset(e) {
|
|
220
|
+
this._inputOffset$.next(e);
|
|
221
|
+
}
|
|
222
|
+
resolvePopup(e) {
|
|
223
|
+
return Array.from(this._popups).find((i) => i.keyword === e);
|
|
224
|
+
}
|
|
225
|
+
registerPopup(e) {
|
|
226
|
+
return this._popups.add(e), () => {
|
|
227
|
+
this._popups.delete(e);
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
showPopup(e) {
|
|
231
|
+
const { popup: i, index: n, unitId: r } = e;
|
|
232
|
+
this.closePopup();
|
|
233
|
+
const s = this._docCanvasPopupManagerService.attachPopupToRange(
|
|
234
|
+
{ startOffset: n, endOffset: n, collapsed: !0 },
|
|
235
|
+
{
|
|
236
|
+
componentKey: N.componentKey,
|
|
237
|
+
onClickOutside: () => {
|
|
238
|
+
this.closePopup();
|
|
239
|
+
},
|
|
240
|
+
direction: "bottom"
|
|
241
|
+
},
|
|
242
|
+
r
|
|
243
|
+
);
|
|
244
|
+
this._editPopup$.next({ disposable: s, popup: i, anchor: n, unitId: r });
|
|
245
|
+
}
|
|
246
|
+
closePopup() {
|
|
247
|
+
this.editPopup && (this.editPopup.disposable.dispose(), this._editPopup$.next(null));
|
|
248
|
+
}
|
|
249
|
+
onMenuSelected(e) {
|
|
250
|
+
return this._menuSelectedCallbacks.add(e), () => {
|
|
251
|
+
this._menuSelectedCallbacks.delete(e);
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
emitMenuSelected(e) {
|
|
255
|
+
const { start: i, end: n } = this.inputOffset;
|
|
256
|
+
this._commandService.syncExecuteCommand(re.id, {
|
|
257
|
+
start: i,
|
|
258
|
+
end: n
|
|
259
|
+
}), setTimeout(() => {
|
|
260
|
+
this._menuSelectedCallbacks.forEach((r) => r(e));
|
|
261
|
+
}, 0);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
v = et([
|
|
265
|
+
A(0, h(je)),
|
|
266
|
+
A(1, h(ye)),
|
|
267
|
+
A(2, h(b))
|
|
268
|
+
], v);
|
|
269
|
+
const ce = {
|
|
270
|
+
type: x.OPERATION,
|
|
271
|
+
id: "doc.operation.show-quick-insert-popup",
|
|
272
|
+
handler(t, e) {
|
|
273
|
+
const i = t.get(v);
|
|
274
|
+
return e ? (i.showPopup(e), !0) : !1;
|
|
275
|
+
}
|
|
276
|
+
}, M = {
|
|
277
|
+
type: x.OPERATION,
|
|
278
|
+
id: "doc.operation.close-quick-insert-popup",
|
|
279
|
+
handler(t) {
|
|
280
|
+
return t.get(v).closePopup(), !0;
|
|
281
|
+
}
|
|
282
|
+
}, ae = {
|
|
283
|
+
id: "quick-insert.text.menu",
|
|
284
|
+
title: "docQuickInsert.menu.text",
|
|
285
|
+
icon: "TextSingle",
|
|
286
|
+
keywords: ["text"]
|
|
287
|
+
}, de = {
|
|
288
|
+
id: Qe.id,
|
|
289
|
+
title: "docQuickInsert.menu.numberedList",
|
|
290
|
+
icon: "OrderSingle",
|
|
291
|
+
keywords: ["numbered", "list", "ordered"]
|
|
292
|
+
}, ue = {
|
|
293
|
+
id: Ae.id,
|
|
294
|
+
title: "docQuickInsert.menu.bulletedList",
|
|
295
|
+
icon: "UnorderSingle",
|
|
296
|
+
keywords: ["bulleted", "list", "unordered"]
|
|
297
|
+
}, le = {
|
|
298
|
+
id: Le.id,
|
|
299
|
+
title: "docQuickInsert.menu.divider",
|
|
300
|
+
icon: "DividerSingle",
|
|
301
|
+
keywords: ["divider", "line", "separate"]
|
|
302
|
+
}, tt = [
|
|
303
|
+
{
|
|
304
|
+
title: "docQuickInsert.group.basics",
|
|
305
|
+
id: "quick.insert.group.basic",
|
|
306
|
+
children: [
|
|
307
|
+
ae,
|
|
308
|
+
de,
|
|
309
|
+
ue,
|
|
310
|
+
le
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
], nt = /* @__PURE__ */ new Set([
|
|
314
|
+
de.id,
|
|
315
|
+
ue.id,
|
|
316
|
+
le.id
|
|
317
|
+
]);
|
|
318
|
+
var it = Object.getOwnPropertyDescriptor, rt = (t, e, i, n) => {
|
|
319
|
+
for (var r = n > 1 ? void 0 : n ? it(e, i) : e, s = t.length - 1, c; s >= 0; s--)
|
|
320
|
+
(c = t[s]) && (r = c(r) || r);
|
|
321
|
+
return r;
|
|
322
|
+
}, w = (t, e) => (i, n) => e(i, n, t);
|
|
323
|
+
let R = class extends W {
|
|
324
|
+
constructor(t, e, i, n) {
|
|
325
|
+
super(), this._commandService = t, this._textSelectionManagerService = e, this._docQuickInsertPopupService = i, this._shortcutService = n, this.disposeWithMe(this._shortcutService.registerShortcut({
|
|
326
|
+
id: M.id,
|
|
327
|
+
binding: O.ESC,
|
|
328
|
+
preconditions: () => !!this._docQuickInsertPopupService.editPopup,
|
|
329
|
+
priority: 1e3
|
|
330
|
+
})), this._initTrigger(), this._initMenuHandler();
|
|
331
|
+
}
|
|
332
|
+
_initTrigger() {
|
|
333
|
+
this.disposeWithMe(
|
|
334
|
+
// eslint-disable-next-line complexity
|
|
335
|
+
this._commandService.onCommandExecuted((t) => {
|
|
336
|
+
var r, s, c;
|
|
337
|
+
const { _docQuickInsertPopupService: e, _textSelectionManagerService: i, _commandService: n } = this;
|
|
338
|
+
if (t.id === We.id) {
|
|
339
|
+
const o = t.params;
|
|
340
|
+
if (e.editPopup) {
|
|
341
|
+
e.setInputOffset({
|
|
342
|
+
start: e.inputOffset.start,
|
|
343
|
+
end: o.range.endOffset + 1
|
|
344
|
+
});
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
const a = i.getActiveTextRange();
|
|
348
|
+
if (!a)
|
|
349
|
+
return;
|
|
350
|
+
const f = e.resolvePopup(o.body.dataStream);
|
|
351
|
+
if (!f || !(f.preconditions ? f.preconditions(o) : !0))
|
|
352
|
+
return;
|
|
353
|
+
e.setInputOffset({ start: a.startOffset - 1, end: a.startOffset }), setTimeout(() => {
|
|
354
|
+
n.executeCommand(ce.id, {
|
|
355
|
+
index: a.startOffset - 1,
|
|
356
|
+
unitId: o.unitId,
|
|
357
|
+
popup: f
|
|
358
|
+
});
|
|
359
|
+
}, 100);
|
|
360
|
+
}
|
|
361
|
+
if (t.id === Te.id) {
|
|
362
|
+
const o = t.params;
|
|
363
|
+
if (o.isCompositionEnd) {
|
|
364
|
+
const a = (s = (r = o.textRanges) == null ? void 0 : r[0]) == null ? void 0 : s.endOffset;
|
|
365
|
+
a && e.setInputOffset({ start: e.inputOffset.start, end: a });
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (t.id === Ke.id) {
|
|
369
|
+
const o = t.params;
|
|
370
|
+
if (e.editPopup && o.direction === Me.LEFT) {
|
|
371
|
+
const a = (c = o.len) != null ? c : 0;
|
|
372
|
+
e.setInputOffset({ start: e.inputOffset.start, end: o.range.endOffset - a });
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (t.id === ze.id) {
|
|
376
|
+
const o = t.params;
|
|
377
|
+
(o.direction === D.LEFT || o.direction === D.RIGHT) && e.editPopup && n.executeCommand(M.id);
|
|
378
|
+
}
|
|
379
|
+
if (t.id === qe.id) {
|
|
380
|
+
const o = i.getActiveTextRange();
|
|
381
|
+
if (!e.editPopup || !o)
|
|
382
|
+
return;
|
|
383
|
+
o.endOffset <= e.editPopup.anchor && n.executeCommand(M.id);
|
|
384
|
+
}
|
|
385
|
+
})
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
_initMenuHandler() {
|
|
389
|
+
this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected((t) => {
|
|
390
|
+
t.id !== ae.id && nt.has(t.id) && this._commandService.executeCommand(t.id);
|
|
391
|
+
}));
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
R = rt([
|
|
395
|
+
w(0, b),
|
|
396
|
+
w(1, h(He)),
|
|
397
|
+
w(2, h(v)),
|
|
398
|
+
w(3, h(ie))
|
|
399
|
+
], R);
|
|
400
|
+
var l = function() {
|
|
401
|
+
return l = Object.assign || function(t) {
|
|
402
|
+
for (var e, i = 1, n = arguments.length; i < n; i++) {
|
|
403
|
+
e = arguments[i];
|
|
404
|
+
for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
|
|
405
|
+
}
|
|
406
|
+
return t;
|
|
407
|
+
}, l.apply(this, arguments);
|
|
408
|
+
}, st = function(t, e) {
|
|
409
|
+
var i = {};
|
|
410
|
+
for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (i[n] = t[n]);
|
|
411
|
+
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
412
|
+
for (var r = 0, n = Object.getOwnPropertySymbols(t); r < n.length; r++)
|
|
413
|
+
e.indexOf(n[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[r]) && (i[n[r]] = t[n[r]]);
|
|
414
|
+
return i;
|
|
415
|
+
}, q = K(function(t, e) {
|
|
416
|
+
var i = t.icon, n = t.id, r = t.className, s = t.extend, c = st(t, ["icon", "id", "className", "extend"]), o = "univerjs-icon univerjs-icon-".concat(n, " ").concat(r || "").trim(), a = L("_".concat(at()));
|
|
417
|
+
return pe(i, "".concat(n), { defIds: i.defIds, idSuffix: a.current }, l({ ref: e, className: o }, c), s);
|
|
418
|
+
});
|
|
419
|
+
function pe(t, e, i, n, r) {
|
|
420
|
+
return z(t.tag, l(l({ key: e }, ot(t, i, r)), n), (ct(t, i).children || []).map(function(s, c) {
|
|
421
|
+
return pe(s, "".concat(e, "-").concat(t.tag, "-").concat(c), i, void 0, r);
|
|
422
|
+
}));
|
|
423
|
+
}
|
|
424
|
+
function ot(t, e, i) {
|
|
425
|
+
var n = l({}, t.attrs);
|
|
426
|
+
i != null && i.colorChannel1 && n.fill === "colorChannel1" && (n.fill = i.colorChannel1), t.tag === "mask" && n.id && (n.id = n.id + e.idSuffix), Object.entries(n).forEach(function(s) {
|
|
427
|
+
var c = s[0], o = s[1];
|
|
428
|
+
c === "mask" && typeof o == "string" && (n[c] = o.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
429
|
+
});
|
|
430
|
+
var r = e.defIds;
|
|
431
|
+
return !r || r.length === 0 || (t.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + e.idSuffix), Object.entries(n).forEach(function(s) {
|
|
432
|
+
var c = s[0], o = s[1];
|
|
433
|
+
typeof o == "string" && (n[c] = o.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
434
|
+
})), n;
|
|
435
|
+
}
|
|
436
|
+
function ct(t, e) {
|
|
437
|
+
var i, n = e.defIds;
|
|
438
|
+
return !n || n.length === 0 ? t : t.tag === "defs" && (!((i = t.children) === null || i === void 0) && i.length) ? l(l({}, t), { children: t.children.map(function(r) {
|
|
439
|
+
return typeof r.attrs.id == "string" && n && n.indexOf(r.attrs.id) > -1 ? l(l({}, r), { attrs: l(l({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
|
|
440
|
+
}) }) : t;
|
|
441
|
+
}
|
|
442
|
+
function at() {
|
|
443
|
+
return Math.random().toString(36).substring(2, 8);
|
|
444
|
+
}
|
|
445
|
+
q.displayName = "UniverIcon";
|
|
446
|
+
var dt = { 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" } }] }, fe = K(function(t, e) {
|
|
447
|
+
return z(q, Object.assign({}, t, {
|
|
448
|
+
id: "divider-single",
|
|
449
|
+
ref: e,
|
|
450
|
+
icon: dt
|
|
451
|
+
}));
|
|
452
|
+
});
|
|
453
|
+
fe.displayName = "DividerSingle";
|
|
454
|
+
var ut = { 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" } }] }, me = K(function(t, e) {
|
|
455
|
+
return z(q, Object.assign({}, t, {
|
|
456
|
+
id: "text-single",
|
|
457
|
+
ref: e,
|
|
458
|
+
icon: ut
|
|
459
|
+
}));
|
|
460
|
+
});
|
|
461
|
+
me.displayName = "TextSingle";
|
|
462
|
+
var lt = Object.getOwnPropertyDescriptor, pt = (t, e, i, n) => {
|
|
463
|
+
for (var r = n > 1 ? void 0 : n ? lt(e, i) : e, s = t.length - 1, c; s >= 0; s--)
|
|
464
|
+
(c = t[s]) && (r = c(r) || r);
|
|
465
|
+
return r;
|
|
466
|
+
}, k = (t, e) => (i, n) => e(i, n, t);
|
|
467
|
+
let E = class extends W {
|
|
468
|
+
constructor(t, e, i, n) {
|
|
469
|
+
super(), this._commandService = t, this._docQuickInsertPopupService = e, this._componentManager = i, this._menuManagerService = n, this._initCommands(), this._initComponents(), this._initMenus();
|
|
470
|
+
}
|
|
471
|
+
_initCommands() {
|
|
472
|
+
[
|
|
473
|
+
re,
|
|
474
|
+
ce,
|
|
475
|
+
M
|
|
476
|
+
].forEach((t) => {
|
|
477
|
+
this.disposeWithMe(this._commandService.registerCommand(t));
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
_initComponents() {
|
|
481
|
+
this.disposeWithMe(this._componentManager.register(N.componentKey, N)), this.disposeWithMe(this._componentManager.register("DividerSingle", fe)), this.disposeWithMe(this._componentManager.register("TextSingle", me)), [
|
|
482
|
+
{
|
|
483
|
+
keyword: "/",
|
|
484
|
+
menus$: Fe(tt),
|
|
485
|
+
// only show when the cursor is at the beginning of a line
|
|
486
|
+
preconditions: (e) => {
|
|
487
|
+
var i;
|
|
488
|
+
return ((i = e.range.startNodePosition) == null ? void 0 : i.glyph) === 0;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
].forEach((e) => {
|
|
492
|
+
this.disposeWithMe(this._docQuickInsertPopupService.registerPopup(e));
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
_initMenus() {
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
E = pt([
|
|
499
|
+
k(0, b),
|
|
500
|
+
k(1, h(v)),
|
|
501
|
+
k(2, h(ne)),
|
|
502
|
+
k(3, h(Ee))
|
|
503
|
+
], E);
|
|
504
|
+
var ft = Object.defineProperty, mt = Object.getOwnPropertyDescriptor, ht = (t, e, i) => e in t ? ft(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i, vt = (t, e, i, n) => {
|
|
505
|
+
for (var r = n > 1 ? void 0 : n ? mt(e, i) : e, s = t.length - 1, c; s >= 0; s--)
|
|
506
|
+
(c = t[s]) && (r = c(r) || r);
|
|
507
|
+
return r;
|
|
508
|
+
}, gt = (t, e) => (i, n) => e(i, n, t), he = (t, e, i) => ht(t, typeof e != "symbol" ? e + "" : e, i);
|
|
509
|
+
const _t = "DOC_QUICK_INSERT_UI_PLUGIN";
|
|
510
|
+
let $ = class extends ke {
|
|
511
|
+
constructor(t) {
|
|
512
|
+
super(), this._injector = t;
|
|
513
|
+
}
|
|
514
|
+
onStarting() {
|
|
515
|
+
[
|
|
516
|
+
[E],
|
|
517
|
+
[R],
|
|
518
|
+
[v]
|
|
519
|
+
].forEach((e) => this._injector.add(e)), this._injector.get(E);
|
|
520
|
+
}
|
|
521
|
+
onRendered() {
|
|
522
|
+
this._injector.get(R), this._injector.get(v);
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
he($, "type", te.UNIVER_DOC);
|
|
526
|
+
he($, "pluginName", _t);
|
|
527
|
+
$ = vt([
|
|
528
|
+
be(Re, Ne, De, $e),
|
|
529
|
+
gt(0, h(we))
|
|
530
|
+
], $);
|
|
531
|
+
export {
|
|
532
|
+
v as DocQuickInsertPopupService,
|
|
533
|
+
R as DocQuickInsertTriggerController,
|
|
534
|
+
E as DocQuickInsertUIController,
|
|
535
|
+
$ as UniverDocsQuickInsertUIPlugin
|
|
536
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
docQuickInsert: {
|
|
3
|
+
menu: {
|
|
4
|
+
numberedList: "Список с нумерацией",
|
|
5
|
+
bulletedList: "Маркированный список",
|
|
6
|
+
divider: "Разделительная линия",
|
|
7
|
+
text: "Текст"
|
|
8
|
+
},
|
|
9
|
+
group: {
|
|
10
|
+
basics: "Основные"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
e as default
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const n = {
|
|
2
|
+
docQuickInsert: {
|
|
3
|
+
menu: {
|
|
4
|
+
numberedList: "Danh sách được đánh số",
|
|
5
|
+
bulletedList: "Danh sách không được đánh số",
|
|
6
|
+
divider: "Đường phân cách",
|
|
7
|
+
text: "Văn bản"
|
|
8
|
+
},
|
|
9
|
+
group: {
|
|
10
|
+
basics: "Cơ bản"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
n as default
|
|
16
|
+
};
|
package/lib/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.univer-mb-2{margin-bottom:.5rem}.univer-mr-2{margin-right:.5rem}.univer-flex{display:flex}.univer-inline-flex{display:inline-flex}.univer-max-h-\[360px\]{max-height:360px}.univer-w-\[220px\]{width:220px}.univer-items-center{align-items:center}.univer-overflow-y-auto{overflow-y:auto}.univer-rounded-lg{border-radius:.5rem}.univer-border{border-width:1px}.univer-border-solid{border-style:solid}.univer-border-gray-100{--tw-border-opacity: 1;border-color:#eeeff1;border-color:rgba(238,239,241,var(--tw-border-opacity, 1))}.univer-bg-gray-100{--tw-bg-opacity: 1;background-color:#eeeff1;background-color:rgba(238,239,241,var(--tw-bg-opacity, 1))}.univer-bg-transparent{background-color:transparent}.univer-px-1{padding-left:.25rem;padding-right:.25rem}.univer-text-base{font-size:1rem;line-height:1.5rem}.univer-text-sm{font-size:.875rem;line-height:1.25rem}.univer-text-xs{font-size:.75rem;line-height:1rem}.univer-text-gray-400{--tw-text-opacity: 1;color:#979dac;color:rgba(151,157,172,var(--tw-text-opacity, 1))}.univer-shadow-\[0_0_10px_0_rgba\(0\,0\,0\,0\.1\)\]{--tw-shadow: 0 0 10px 0 rgba(0,0,0,.1);--tw-shadow-colored: 0 0 10px 0 var(--tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 0 10px #0000001a;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-transparent:hover{background-color:transparent}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ICommand } from '@univerjs/core';
|
|
2
|
+
import { IDocPopup } from '../../services/doc-quick-insert-popup.service';
|
|
3
|
+
export interface IShowQuickInsertPopupOperationParams {
|
|
4
|
+
unitId: string;
|
|
5
|
+
index: number;
|
|
6
|
+
popup: IDocPopup;
|
|
7
|
+
}
|
|
8
|
+
export declare const ShowQuickInsertPopupOperation: ICommand<IShowQuickInsertPopupOperationParams>;
|
|
9
|
+
export declare const CloseQuickInsertPopupOperation: ICommand;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DocPopupMenu, IDocPopupMenuItem } from '../services/doc-quick-insert-popup.service';
|
|
2
|
+
export declare enum QuickInsertMenuGroup {
|
|
3
|
+
Basic = "quick.insert.group.basic",
|
|
4
|
+
Media = "quick.insert.group.media"
|
|
5
|
+
}
|
|
6
|
+
export declare const textMenu: IDocPopupMenuItem;
|
|
7
|
+
export declare const numberedListMenu: IDocPopupMenuItem;
|
|
8
|
+
export declare const bulletedListMenu: IDocPopupMenuItem;
|
|
9
|
+
export declare const dividerMenu: IDocPopupMenuItem;
|
|
10
|
+
export declare const builtInMenus: DocPopupMenu[];
|
|
11
|
+
export declare const builtInMenuCommandIds: Set<string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Disposable, ICommandService } from '@univerjs/core';
|
|
2
|
+
import { DocSelectionManagerService } from '@univerjs/docs';
|
|
3
|
+
import { IShortcutService } from '@univerjs/ui';
|
|
4
|
+
import { DocQuickInsertPopupService } from '../services/doc-quick-insert-popup.service';
|
|
5
|
+
export declare class DocQuickInsertTriggerController extends Disposable {
|
|
6
|
+
private readonly _commandService;
|
|
7
|
+
private readonly _textSelectionManagerService;
|
|
8
|
+
private readonly _docQuickInsertPopupService;
|
|
9
|
+
private readonly _shortcutService;
|
|
10
|
+
constructor(_commandService: ICommandService, _textSelectionManagerService: DocSelectionManagerService, _docQuickInsertPopupService: DocQuickInsertPopupService, _shortcutService: IShortcutService);
|
|
11
|
+
private _initTrigger;
|
|
12
|
+
private _initMenuHandler;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Disposable, ICommandService } from '@univerjs/core';
|
|
2
|
+
import { ComponentManager, IMenuManagerService } from '@univerjs/ui';
|
|
3
|
+
import { DocQuickInsertPopupService } from '../services/doc-quick-insert-popup.service';
|
|
4
|
+
export declare class DocQuickInsertUIController extends Disposable {
|
|
5
|
+
private readonly _commandService;
|
|
6
|
+
private readonly _docQuickInsertPopupService;
|
|
7
|
+
private readonly _componentManager;
|
|
8
|
+
private readonly _menuManagerService;
|
|
9
|
+
constructor(_commandService: ICommandService, _docQuickInsertPopupService: DocQuickInsertPopupService, _componentManager: ComponentManager, _menuManagerService: IMenuManagerService);
|
|
10
|
+
private _initCommands;
|
|
11
|
+
private _initComponents;
|
|
12
|
+
private _initMenus;
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
import './global.css';
|
|
17
|
+
export { UniverDocsQuickInsertUIPlugin } from './plugin';
|
|
18
|
+
export type { DocPopupMenu, IDocPopup, IDocPopupGroupItem, IDocPopupMenuItem, } from './services/doc-quick-insert-popup.service';
|
|
19
|
+
export { DocQuickInsertPopupService } from './services/doc-quick-insert-popup.service';
|
|
20
|
+
export { DocQuickInsertTriggerController } from './controllers/doc-quick-insert-trigger.controller';
|
|
21
|
+
export { DocQuickInsertUIController } from './controllers/doc-quick-insert-ui.controller';
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
};
|
|
24
|
+
group: {
|
|
25
|
+
basics: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export default locale;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
2
|
+
export declare class UniverDocsQuickInsertUIPlugin extends Plugin {
|
|
3
|
+
protected _injector: Injector;
|
|
4
|
+
static type: UniverInstanceType;
|
|
5
|
+
static pluginName: string;
|
|
6
|
+
constructor(_injector: Injector);
|
|
7
|
+
onStarting(): void;
|
|
8
|
+
onRendered(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { IDisposable, Nullable, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
|
|
2
|
+
import { IInsertCommandParams, DocCanvasPopManagerService } from '@univerjs/docs-ui';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
export interface IDocPopupGroupItem {
|
|
5
|
+
id: string;
|
|
6
|
+
icon?: string;
|
|
7
|
+
title: string;
|
|
8
|
+
children?: IDocPopupMenuItem[];
|
|
9
|
+
}
|
|
10
|
+
export interface IDocPopupMenuItem {
|
|
11
|
+
id: string;
|
|
12
|
+
icon?: string;
|
|
13
|
+
title: string;
|
|
14
|
+
keywords?: string[];
|
|
15
|
+
}
|
|
16
|
+
export type DocPopupMenu = IDocPopupGroupItem | IDocPopupMenuItem;
|
|
17
|
+
export interface IDocPopup {
|
|
18
|
+
keyword: string;
|
|
19
|
+
menus$: Observable<DocPopupMenu[]>;
|
|
20
|
+
placeholder?: React.ReactNode;
|
|
21
|
+
preconditions?: (params: IInsertCommandParams) => boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare class DocQuickInsertPopupService extends Disposable {
|
|
24
|
+
private readonly _docCanvasPopupManagerService;
|
|
25
|
+
private readonly _univerInstanceService;
|
|
26
|
+
private readonly _commandService;
|
|
27
|
+
private readonly _popups;
|
|
28
|
+
private readonly _editPopup$;
|
|
29
|
+
readonly editPopup$: Observable<Nullable<{
|
|
30
|
+
popup: IDocPopup;
|
|
31
|
+
anchor: number;
|
|
32
|
+
disposable: IDisposable;
|
|
33
|
+
unitId: string;
|
|
34
|
+
}>>;
|
|
35
|
+
get editPopup(): Nullable<{
|
|
36
|
+
popup: IDocPopup;
|
|
37
|
+
anchor: number;
|
|
38
|
+
disposable: IDisposable;
|
|
39
|
+
unitId: string;
|
|
40
|
+
}>;
|
|
41
|
+
private readonly _inputOffset$;
|
|
42
|
+
readonly inputOffset$: Observable<{
|
|
43
|
+
start: number;
|
|
44
|
+
end: number;
|
|
45
|
+
}>;
|
|
46
|
+
get inputOffset(): {
|
|
47
|
+
start: number;
|
|
48
|
+
end: number;
|
|
49
|
+
};
|
|
50
|
+
setInputOffset(offset: {
|
|
51
|
+
start: number;
|
|
52
|
+
end: number;
|
|
53
|
+
}): void;
|
|
54
|
+
readonly filterKeyword$: Observable<string>;
|
|
55
|
+
private _menuSelectedCallbacks;
|
|
56
|
+
constructor(_docCanvasPopupManagerService: DocCanvasPopManagerService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService);
|
|
57
|
+
resolvePopup(keyword: string): IDocPopup | undefined;
|
|
58
|
+
registerPopup(popup: IDocPopup): () => void;
|
|
59
|
+
showPopup(options: {
|
|
60
|
+
popup: IDocPopup;
|
|
61
|
+
index: number;
|
|
62
|
+
unitId: string;
|
|
63
|
+
}): void;
|
|
64
|
+
closePopup(): void;
|
|
65
|
+
onMenuSelected(callback: (menu: IDocPopupMenuItem) => void): () => void;
|
|
66
|
+
emitMenuSelected(menu: IDocPopupMenuItem): void;
|
|
67
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 QuickInsertPopup: {
|
|
17
|
+
(): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
componentKey: string;
|
|
19
|
+
};
|
|
20
|
+
export { QuickInsertPopup };
|
package/lib/umd/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(function(o,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/docs-drawing"),require("@univerjs/drawing"),require("@univerjs/drawing-ui"),require("@univerjs/ui"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-drawing","@univerjs/drawing","@univerjs/drawing-ui","@univerjs/ui","@univerjs/docs","@univerjs/docs-ui","rxjs","react/jsx-runtime","@univerjs/design","react"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o.UniverDocsQuickInsertUi={},o.UniverCore,o.UniverDocsDrawing,o.UniverDrawing,o.UniverDrawingUi,o.UniverUi,o.UniverDocs,o.UniverDocsUi,o.rxjs,o.React,o.UniverDesign,o.React))})(this,function(o,s,D,te,ne,l,R,C,k,h,b,f){"use strict";var Me=Object.defineProperty;var ke=(o,s,D)=>s in o?Me(o,s,{enumerable:!0,configurable:!0,writable:!0,value:D}):o[s]=D;var _=(o,s,D)=>ke(o,typeof s!="symbol"?s+"":s,D);const H={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(C.CutContentCommand.id,{segmentId:"",textRanges:[{startOffset:t,endOffset:t,collapsed:!0}],selections:[{startOffset:t,endOffset:r,collapsed:!1,direction:s.RANGE_DIRECTION.FORWARD}]})}};function q(i,n){return i.map(e=>({...e})).filter(e=>{if("children"in e)return e.children=q(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 A(i,n){return i.map(e=>{const t={...e};return"children"in t&&(t.children=A(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 ie=[l.KeyCode.ARROW_UP,l.KeyCode.ARROW_DOWN,l.KeyCode.ENTER],x=()=>{const i=l.useDependency(s.LocaleService),n=l.useDependency(o.DocQuickInsertPopupService),e=l.useDependency(l.ComponentManager),t=l.useDependency(l.IShortcutService),r=l.useDependency(s.ICommandService),c=f.useMemo(()=>s.generateRandomId(),[]),[u,a]=f.useState(0),d=f.useRef(null),p=f.useRef(0);p.current=0;const S=l.useObservable(n.filterKeyword$,""),O=l.useObservable(n.editPopup$),J=l.useObservable(O==null?void 0:O.popup.menus$,[]),[N,Pe]=f.useState([]),X=f.useMemo(()=>A(J,i),[J]);f.useEffect(()=>{const v=requestIdleCallback(()=>{Pe(q(X,S.toLowerCase()))});return()=>{cancelIdleCallback(v)}},[X,S]);const Y=v=>{n.emitMenuSelected(v),r.executeCommand(w.id)};f.useEffect(()=>{const v=new s.DisposableCollection;t.getAllShortcuts().filter(m=>m.binding&&ie.includes(m.binding)).forEach(m=>{const P=m.preconditions;m.preconditions=()=>!1,v.add(s.toDisposable(()=>{m.preconditions=P}))});const y={id:`quick.insert.popup.enter.${c}`,type:s.CommandType.OPERATION,handler:()=>{const m=d.current;m&&Y(m)}},j={id:`quick.insert.popup.move.cursor.up.${c}`,type:s.CommandType.OPERATION,handler:()=>{a(m=>{const P=m-1;return P>=0?P:p.current-1})}},M={id:`quick.insert.popup.move.cursor.down.${c}`,type:s.CommandType.OPERATION,handler:()=>{a(m=>{const P=m+1;return P<=p.current-1?P:0})}};return v.add(r.registerCommand(j)),v.add(r.registerCommand(M)),v.add(r.registerCommand(y)),v.add(t.registerShortcut({priority:1e3,id:j.id,binding:l.KeyCode.ARROW_UP,preconditions:()=>!0,staticParameters:{direction:s.Direction.UP}})),v.add(t.registerShortcut({priority:1e3,id:M.id,binding:l.KeyCode.ARROW_DOWN,preconditions:()=>!0,staticParameters:{direction:s.Direction.DOWN}})),v.add(t.registerShortcut({priority:1e3,id:y.id,binding:l.KeyCode.ENTER,preconditions:()=>!0})),()=>{v.dispose()}},[]),f.useEffect(()=>{a(0)},[N]);function ee(v){return v.map(I=>{const $=I.icon,y=$?e.get($):null;if("children"in I)return h.jsx(b.MenuItemGroup,{title:h.jsxs("div",{className:`
|
|
2
|
+
univer-mb-2 univer-flex univer-items-center univer-text-xs univer-text-gray-400
|
|
3
|
+
`,children:[y&&h.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:h.jsx(y,{})}),h.jsx("span",{children:I.title})]}),children:ee(I.children)},I.id);const j=p.current,M=u===j;return M&&(d.current=I),p.current++,h.jsx(b.MenuItem,{onMouseEnter:()=>a(j),onMouseLeave:()=>a(Number.NaN),className:b.clsx("univer-text-sm",{"hover:univer-bg-transparent":!M,"univer-bg-gray-100":M}),onClick:()=>{Y(I)},children:h.jsxs("div",{className:"univer-flex univer-items-center univer-px-1",children:[y&&h.jsx("span",{className:"univer-mr-2 univer-inline-flex univer-text-base",children:h.jsx(y,{})}),h.jsx("span",{children:I.title})]})},I.id)})}const De=N.length>0;return h.jsx("div",{className:b.clsx(`
|
|
4
|
+
univer-rounded-lg univer-border univer-border-solid univer-border-gray-100
|
|
5
|
+
univer-shadow-[0_0_10px_0_rgba(0,0,0,0.1)]
|
|
6
|
+
`),children:De?h.jsx("div",{className:"univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto",children:h.jsx(b.Menu,{children:ee(N)})}):O==null?void 0:O.popup.placeholder})};x.componentKey="doc.quick-insert-popup";var re=Object.getOwnPropertyDescriptor,se=(i,n,e,t)=>{for(var r=t>1?void 0:t?re(n,e):n,c=i.length-1,u;c>=0;c--)(u=i[c])&&(r=u(r)||r);return r},T=(i,n)=>(e,t)=>n(e,t,i);o.DocQuickInsertPopupService=class extends s.Disposable{constructor(e,t,r){super();_(this,"_popups",new Set);_(this,"_editPopup$",new k.BehaviorSubject(void 0));_(this,"editPopup$",this._editPopup$.asObservable());_(this,"_inputOffset$",new k.BehaviorSubject({start:0,end:0}));_(this,"inputOffset$",this._inputOffset$.asObservable());_(this,"filterKeyword$");_(this,"_menuSelectedCallbacks",new Set);this._docCanvasPopupManagerService=e,this._univerInstanceService=t,this._commandService=r,this.disposeWithMe(this._editPopup$);const c=(u,a)=>{var d,p;return(p=(d=this._univerInstanceService.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_DOC))==null?void 0:d.getBody())==null?void 0:p.dataStream.slice(u,a)};this.filterKeyword$=this._inputOffset$.pipe(k.map(u=>{var d;const a=c(u.start,u.end);return(d=a==null?void 0:a.slice(1))!=null?d:""}),k.distinctUntilChanged())}get editPopup(){return this._editPopup$.value}get inputOffset(){return this._inputOffset$.value}setInputOffset(e){this._inputOffset$.next(e)}resolvePopup(e){return Array.from(this._popups).find(t=>t.keyword===e)}registerPopup(e){return this._popups.add(e),()=>{this._popups.delete(e)}}showPopup(e){const{popup:t,index:r,unitId:c}=e;this.closePopup();const u=this._docCanvasPopupManagerService.attachPopupToRange({startOffset:r,endOffset:r,collapsed:!0},{componentKey:x.componentKey,onClickOutside:()=>{this.closePopup()},direction:"bottom"},c);this._editPopup$.next({disposable:u,popup:t,anchor:r,unitId:c})}closePopup(){this.editPopup&&(this.editPopup.disposable.dispose(),this._editPopup$.next(null))}onMenuSelected(e){return this._menuSelectedCallbacks.add(e),()=>{this._menuSelectedCallbacks.delete(e)}}emitMenuSelected(e){const{start:t,end:r}=this.inputOffset;this._commandService.syncExecuteCommand(H.id,{start:t,end:r}),setTimeout(()=>{this._menuSelectedCallbacks.forEach(c=>c(e))},0)}},o.DocQuickInsertPopupService=se([T(0,s.Inject(C.DocCanvasPopManagerService)),T(1,s.Inject(s.IUniverInstanceService)),T(2,s.Inject(s.ICommandService))],o.DocQuickInsertPopupService);const K={type:s.CommandType.OPERATION,id:"doc.operation.show-quick-insert-popup",handler(i,n){const e=i.get(o.DocQuickInsertPopupService);return n?(e.showPopup(n),!0):!1}},w={type:s.CommandType.OPERATION,id:"doc.operation.close-quick-insert-popup",handler(i){return i.get(o.DocQuickInsertPopupService).closePopup(),!0}},L={id:"quick-insert.text.menu",title:"docQuickInsert.menu.text",icon:"TextSingle",keywords:["text"]},W={id:C.OrderListCommand.id,title:"docQuickInsert.menu.numberedList",icon:"OrderSingle",keywords:["numbered","list","ordered"]},z={id:C.BulletListCommand.id,title:"docQuickInsert.menu.bulletedList",icon:"UnorderSingle",keywords:["bulleted","list","unordered"]},B={id:C.HorizontalLineCommand.id,title:"docQuickInsert.menu.divider",icon:"DividerSingle",keywords:["divider","line","separate"]},oe=[{title:"docQuickInsert.group.basics",id:"quick.insert.group.basic",children:[L,W,z,B]}],ce=new Set([W.id,z.id,B.id]);var ue=Object.getOwnPropertyDescriptor,de=(i,n,e,t)=>{for(var r=t>1?void 0:t?ue(n,e):n,c=i.length-1,u;c>=0;c--)(u=i[c])&&(r=u(r)||r);return r},Q=(i,n)=>(e,t)=>n(e,t,i);o.DocQuickInsertTriggerController=class extends s.Disposable{constructor(n,e,t,r){super(),this._commandService=n,this._textSelectionManagerService=e,this._docQuickInsertPopupService=t,this._shortcutService=r,this.disposeWithMe(this._shortcutService.registerShortcut({id:w.id,binding:l.KeyCode.ESC,preconditions:()=>!!this._docQuickInsertPopupService.editPopup,priority:1e3})),this._initTrigger(),this._initMenuHandler()}_initTrigger(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var c,u,a;const{_docQuickInsertPopupService:e,_textSelectionManagerService:t,_commandService:r}=this;if(n.id===C.InsertCommand.id){const d=n.params;if(e.editPopup){e.setInputOffset({start:e.inputOffset.start,end:d.range.endOffset+1});return}const p=t.getActiveTextRange();if(!p)return;const S=e.resolvePopup(d.body.dataStream);if(!S||!(S.preconditions?S.preconditions(d):!0))return;e.setInputOffset({start:p.startOffset-1,end:p.startOffset}),setTimeout(()=>{r.executeCommand(K.id,{index:p.startOffset-1,unitId:d.unitId,popup:S})},100)}if(n.id===R.RichTextEditingMutation.id){const d=n.params;if(d.isCompositionEnd){const p=(u=(c=d.textRanges)==null?void 0:c[0])==null?void 0:u.endOffset;p&&e.setInputOffset({start:e.inputOffset.start,end:p})}}if(n.id===C.DeleteCommand.id){const d=n.params;if(e.editPopup&&d.direction===s.DeleteDirection.LEFT){const p=(a=d.len)!=null?a:0;e.setInputOffset({start:e.inputOffset.start,end:d.range.endOffset-p})}}if(n.id===C.MoveCursorOperation.id){const d=n.params;(d.direction===s.Direction.LEFT||d.direction===s.Direction.RIGHT)&&e.editPopup&&r.executeCommand(w.id)}if(n.id===C.DeleteLeftCommand.id){const d=t.getActiveTextRange();if(!e.editPopup||!d)return;d.endOffset<=e.editPopup.anchor&&r.executeCommand(w.id)}}))}_initMenuHandler(){this.disposeWithMe(this._docQuickInsertPopupService.onMenuSelected(n=>{n.id!==L.id&&ce.has(n.id)&&this._commandService.executeCommand(n.id)}))}},o.DocQuickInsertTriggerController=de([Q(0,s.ICommandService),Q(1,s.Inject(R.DocSelectionManagerService)),Q(2,s.Inject(o.DocQuickInsertPopupService)),Q(3,s.Inject(l.IShortcutService))],o.DocQuickInsertTriggerController);var g=function(){return g=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},g.apply(this,arguments)},ae=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},E=f.forwardRef(function(i,n){var e=i.icon,t=i.id,r=i.className,c=i.extend,u=ae(i,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),d=f.useRef("_".concat(fe()));return V(e,"".concat(t),{defIds:e.defIds,idSuffix:d.current},g({ref:n,className:a},u),c)});function V(i,n,e,t,r){return f.createElement(i.tag,g(g({key:n},le(i,e,r)),t),(pe(i,e).children||[]).map(function(c,u){return V(c,"".concat(n,"-").concat(i.tag,"-").concat(u),e,void 0,r)}))}function le(i,n,e){var t=g({},i.attrs);e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1),i.tag==="mask"&&t.id&&(t.id=t.id+n.idSuffix),Object.entries(t).forEach(function(c){var u=c[0],a=c[1];u==="mask"&&typeof a=="string"&&(t[u]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))});var r=n.defIds;return!r||r.length===0||(i.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+n.idSuffix),Object.entries(t).forEach(function(c){var u=c[0],a=c[1];typeof a=="string"&&(t[u]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),t}function pe(i,n){var e,t=n.defIds;return!t||t.length===0?i:i.tag==="defs"&&(!((e=i.children)===null||e===void 0)&&e.length)?g(g({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?g(g({},r),{attrs:g(g({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):i}function fe(){return Math.random().toString(36).substring(2,8)}E.displayName="UniverIcon";var ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.01953 3.13985C1.01953 2.77258 1.31726 2.47485 1.68453 2.47485H2.73713C3.1044 2.47485 3.40213 2.77258 3.40213 3.13985 3.40213 3.50712 3.1044 3.80485 2.73713 3.80485H1.68453C1.31726 3.80485 1.01953 3.50712 1.01953 3.13985zM4.17734 3.13985C4.17734 2.77258 4.47507 2.47485 4.84234 2.47485H6.94754C7.31481 2.47485 7.61254 2.77258 7.61254 3.13985 7.61254 3.50712 7.31481 3.80485 6.94754 3.80485H4.84234C4.47507 3.80485 4.17734 3.50712 4.17734 3.13985zM8.38775 3.13985C8.38775 2.77258 8.68548 2.47485 9.05275 2.47485H11.158C11.5252 2.47485 11.823 2.77258 11.823 3.13985 11.823 3.50712 11.5252 3.80485 11.158 3.80485H9.05275C8.68548 3.80485 8.38775 3.50712 8.38775 3.13985zM12.5982 3.13985C12.5982 2.77258 12.8959 2.47485 13.2632 2.47485H14.3158C14.683 2.47485 14.9808 2.77258 14.9808 3.13985 14.9808 3.50712 14.683 3.80485 14.3158 3.80485H13.2632C12.8959 3.80485 12.5982 3.50712 12.5982 3.13985zM1.01953 7.99972C1.01953 7.63245 1.31726 7.33472 1.68453 7.33472H14.3158C14.683 7.33472 14.9808 7.63245 14.9808 7.99972 14.9808 8.36699 14.683 8.66472 14.3158 8.66472H1.68453C1.31726 8.66472 1.01953 8.36699 1.01953 7.99972zM1.68453 12.1951C1.31726 12.1951 1.01953 12.4928 1.01953 12.8601 1.01953 13.2273 1.31726 13.5251 1.68453 13.5251H2.73713C3.1044 13.5251 3.40213 13.2273 3.40213 12.8601 3.40213 12.4928 3.1044 12.1951 2.73713 12.1951H1.68453zM4.84234 12.1951C4.47507 12.1951 4.17734 12.4928 4.17734 12.8601 4.17734 13.2273 4.47507 13.5251 4.84234 13.5251H6.94754C7.31481 13.5251 7.61254 13.2273 7.61254 12.8601 7.61254 12.4928 7.31481 12.1951 6.94754 12.1951H4.84234zM9.05275 12.1951C8.68548 12.1951 8.38775 12.4928 8.38775 12.8601 8.38775 13.2273 8.68548 13.5251 9.05275 13.5251H11.158C11.5252 13.5251 11.823 13.2273 11.823 12.8601 11.823 12.4928 11.5252 12.1951 11.158 12.1951H9.05275zM13.2632 12.1951C12.8959 12.1951 12.5982 12.4928 12.5982 12.8601 12.5982 13.2273 12.8959 13.5251 13.2632 13.5251H14.3158C14.683 13.5251 14.9808 13.2273 14.9808 12.8601 14.9808 12.4928 14.683 12.1951 14.3158 12.1951H13.2632z"}}]},F=f.forwardRef(function(i,n){return f.createElement(E,Object.assign({},i,{id:"divider-single",ref:n,icon:ve}))});F.displayName="DividerSingle";var he={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.66695 1.33496C2.29968 1.33496 2.00195 1.63269 2.00195 1.99996V3.64439C2.00195 4.01166 2.29968 4.30939 2.66695 4.30939C3.03422 4.30939 3.33195 4.01166 3.33195 3.64439V2.66496H7.33521V13.335H5.3337C4.96643 13.335 4.6687 13.6327 4.6687 14C4.6687 14.3672 4.96643 14.665 5.3337 14.665H10.667C11.0343 14.665 11.332 14.3672 11.332 14C11.332 13.6327 11.0343 13.335 10.667 13.335H8.66521V2.66496H12.6686V3.64439C12.6686 4.01166 12.9664 4.30939 13.3336 4.30939C13.7009 4.30939 13.9986 4.01166 13.9986 3.64439V1.99996C13.9986 1.63269 13.7009 1.33496 13.3336 1.33496H2.66695Z"}}]},G=f.forwardRef(function(i,n){return f.createElement(E,Object.assign({},i,{id:"text-single",ref:n,icon:he}))});G.displayName="TextSingle";var me=Object.getOwnPropertyDescriptor,ge=(i,n,e,t)=>{for(var r=t>1?void 0:t?me(n,e):n,c=i.length-1,u;c>=0;c--)(u=i[c])&&(r=u(r)||r);return r},U=(i,n)=>(e,t)=>n(e,t,i);o.DocQuickInsertUIController=class extends s.Disposable{constructor(n,e,t,r){super(),this._commandService=n,this._docQuickInsertPopupService=e,this._componentManager=t,this._menuManagerService=r,this._initCommands(),this._initComponents(),this._initMenus()}_initCommands(){[H,K,w].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initComponents(){this.disposeWithMe(this._componentManager.register(x.componentKey,x)),this.disposeWithMe(this._componentManager.register("DividerSingle",F)),this.disposeWithMe(this._componentManager.register("TextSingle",G)),[{keyword:"/",menus$:k.of(oe),preconditions:e=>{var t;return((t=e.range.startNodePosition)==null?void 0:t.glyph)===0}}].forEach(e=>{this.disposeWithMe(this._docQuickInsertPopupService.registerPopup(e))})}_initMenus(){}},o.DocQuickInsertUIController=ge([U(0,s.ICommandService),U(1,s.Inject(o.DocQuickInsertPopupService)),U(2,s.Inject(l.ComponentManager)),U(3,s.Inject(l.IMenuManagerService))],o.DocQuickInsertUIController);var Ie=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,_e=(i,n,e)=>n in i?Ie(i,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[n]=e,Se=(i,n,e,t)=>{for(var r=t>1?void 0:t?Ce(n,e):n,c=i.length-1,u;c>=0;c--)(u=i[c])&&(r=u(r)||r);return r},Oe=(i,n)=>(e,t)=>n(e,t,i),Z=(i,n,e)=>_e(i,typeof n!="symbol"?n+"":n,e);const ye="DOC_QUICK_INSERT_UI_PLUGIN";o.UniverDocsQuickInsertUIPlugin=class extends s.Plugin{constructor(n){super(),this._injector=n}onStarting(){[[o.DocQuickInsertUIController],[o.DocQuickInsertTriggerController],[o.DocQuickInsertPopupService]].forEach(e=>this._injector.add(e)),this._injector.get(o.DocQuickInsertUIController)}onRendered(){this._injector.get(o.DocQuickInsertTriggerController),this._injector.get(o.DocQuickInsertPopupService)}},Z(o.UniverDocsQuickInsertUIPlugin,"type",s.UniverInstanceType.UNIVER_DOC),Z(o.UniverDocsQuickInsertUIPlugin,"pluginName",ye),o.UniverDocsQuickInsertUIPlugin=Se([s.DependentOn(ne.UniverDrawingUIPlugin,te.UniverDrawingPlugin,D.UniverDocsDrawingPlugin,l.UniverUIPlugin),Oe(0,s.Inject(s.Injector))],o.UniverDocsQuickInsertUIPlugin),Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverDocsQuickInsertUiEnUS=i())})(this,function(){"use strict";return{docQuickInsert:{menu:{numberedList:"Numbered List",bulletedList:"Bulleted List",divider:"Divider",text:"Text"},group:{basics:"Basics"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverDocsQuickInsertUiFaIR=i())})(this,function(){"use strict";return{docQuickInsert:{menu:{numberedList:"لیست شمارهدار",bulletedList:"لیست نقطهدار",divider:"خط تقسیم",text:"متن"},group:{basics:"بنیادی"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverDocsQuickInsertUiFrFR=i())})(this,function(){"use strict";return{docQuickInsert:{menu:{numberedList:"Liste numérotée",bulletedList:"Liste à puces",divider:"Ligne de séparation",text:"Texte"},group:{basics:"Basiques"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverDocsQuickInsertUiRuRU=i())})(this,function(){"use strict";return{docQuickInsert:{menu:{numberedList:"Список с нумерацией",bulletedList:"Маркированный список",divider:"Разделительная линия",text:"Текст"},group:{basics:"Основные"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverDocsQuickInsertUiViVN=n())})(this,function(){"use strict";return{docQuickInsert:{menu:{numberedList:"Danh sách được đánh số",bulletedList:"Danh sách không được đánh số",divider:"Đường phân cách",text:"Văn bản"},group:{basics:"Cơ bản"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverDocsQuickInsertUiZhCN=i())})(this,function(){"use strict";return{docQuickInsert:{menu:{numberedList:"有序列表",bulletedList:"无序列表",divider:"分隔线",text:"文本"},group:{basics:"基础"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverDocsQuickInsertUiZhTW=i())})(this,function(){"use strict";return{docQuickInsert:{menu:{numberedList:"有序列表",bulletedList:"無序列表",divider:"分隔線",text:"文本"},group:{basics:"基礎"}}}});
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@univerjs/docs-quick-insert-ui",
|
|
3
|
+
"version": "0.6.6-nightly.202503151606",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "",
|
|
6
|
+
"author": "DreamNum <developer@univer.ai>",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"funding": {
|
|
9
|
+
"type": "opencollective",
|
|
10
|
+
"url": "https://opencollective.com/univer"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://univer.ai",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/dream-num/univer"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/dream-num/univer/issues"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./lib/es/index.js",
|
|
24
|
+
"require": "./lib/cjs/index.js",
|
|
25
|
+
"types": "./lib/types/index.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./*": {
|
|
28
|
+
"import": "./lib/es/*",
|
|
29
|
+
"require": "./lib/cjs/*",
|
|
30
|
+
"types": "./lib/types/index.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"./locale/*": {
|
|
33
|
+
"import": "./lib/es/locale/*.js",
|
|
34
|
+
"require": "./lib/cjs/locale/*.js",
|
|
35
|
+
"types": "./lib/types/locale/*.d.ts"
|
|
36
|
+
},
|
|
37
|
+
"./lib/*": "./lib/*"
|
|
38
|
+
},
|
|
39
|
+
"main": "./lib/es/index.js",
|
|
40
|
+
"types": "./lib/types/index.d.ts",
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"directories": {
|
|
45
|
+
"lib": "lib"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"lib"
|
|
49
|
+
],
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"react": ">=16.9.0",
|
|
52
|
+
"rxjs": ">=7.0.0"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@univerjs/icons": "^0.2.22",
|
|
56
|
+
"@univerjs/core": "0.6.6-nightly.202503151606",
|
|
57
|
+
"@univerjs/docs-ui": "0.6.6-nightly.202503151606",
|
|
58
|
+
"@univerjs/design": "0.6.6-nightly.202503151606",
|
|
59
|
+
"@univerjs/docs": "0.6.6-nightly.202503151606",
|
|
60
|
+
"@univerjs/drawing": "0.6.6-nightly.202503151606",
|
|
61
|
+
"@univerjs/drawing-ui": "0.6.6-nightly.202503151606",
|
|
62
|
+
"@univerjs/ui": "0.6.6-nightly.202503151606",
|
|
63
|
+
"@univerjs/docs-drawing": "0.6.6-nightly.202503151606"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"less": "^4.2.2",
|
|
67
|
+
"postcss": "^8.5.3",
|
|
68
|
+
"react": "18.3.1",
|
|
69
|
+
"rxjs": "^7.8.1",
|
|
70
|
+
"tailwindcss": "^3.4.17",
|
|
71
|
+
"typescript": "^5.8.2",
|
|
72
|
+
"vite": "^6.2.1",
|
|
73
|
+
"vitest": "^3.0.8",
|
|
74
|
+
"@univerjs-infra/shared": "0.6.6"
|
|
75
|
+
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"test": "vitest run",
|
|
78
|
+
"test:watch": "vitest",
|
|
79
|
+
"coverage": "vitest run --coverage",
|
|
80
|
+
"lint:types": "tsc --noEmit",
|
|
81
|
+
"build": "univer-cli build"
|
|
82
|
+
},
|
|
83
|
+
"module": "./lib/es/index.js"
|
|
84
|
+
}
|