@univerjs/sheets-hyper-link-ui 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +22 -0
  3. package/lib/cjs/index.js +9 -0
  4. package/lib/es/index.js +1717 -0
  5. package/lib/index.css +1 -0
  6. package/lib/locale/en-US.json +35 -0
  7. package/lib/locale/ru-RU.json +35 -0
  8. package/lib/locale/zh-CN.json +35 -0
  9. package/lib/types/commands/operations/sidebar.operations.d.ts +11 -0
  10. package/lib/types/common/util.d.ts +19 -0
  11. package/lib/types/controllers/auto-fill.controller.d.ts +10 -0
  12. package/lib/types/controllers/copy-paste.controller.d.ts +17 -0
  13. package/lib/types/controllers/hyper-link-permission.controller.d.ts +10 -0
  14. package/lib/types/controllers/menu.d.ts +15 -0
  15. package/lib/types/controllers/popup.controller.d.ts +10 -0
  16. package/lib/types/controllers/ref-range.controller.d.ts +20 -0
  17. package/lib/types/controllers/remove-sheet.controller.d.ts +11 -0
  18. package/lib/types/controllers/render-controllers/render.controller.d.ts +17 -0
  19. package/lib/types/controllers/set-range.controller.d.ts +18 -0
  20. package/lib/types/controllers/ui.controller.d.ts +21 -0
  21. package/lib/types/controllers/url.controller.d.ts +8 -0
  22. package/lib/types/index.d.ts +30 -0
  23. package/lib/types/locale/en-US.d.ts +4 -0
  24. package/lib/types/locale/ru-RU.d.ts +4 -0
  25. package/lib/types/locale/zh-CN.d.ts +51 -0
  26. package/lib/types/plugin.d.ts +13 -0
  27. package/lib/types/services/popup.service.d.ts +34 -0
  28. package/lib/types/services/resolver.service.d.ts +38 -0
  29. package/lib/types/types/const.d.ts +17 -0
  30. package/lib/types/views/CellLinkEdit/index.d.ts +6 -0
  31. package/lib/types/views/CellLinkPopup/index.d.ts +6 -0
  32. package/lib/umd/index.js +9 -0
  33. package/package.json +94 -0
@@ -0,0 +1,9 @@
1
+ (function(l,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@wendellhu/redi"),require("@univerjs/sheets-hyper-link"),require("@univerjs/engine-formula"),require("@univerjs/design"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/engine-render"),require("rxjs"),require("react"),require("@wendellhu/redi/react-bindings"),require("clsx"),require("@univerjs/sheets-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@wendellhu/redi","@univerjs/sheets-hyper-link","@univerjs/engine-formula","@univerjs/design","@univerjs/sheets-ui","@univerjs/ui","@univerjs/engine-render","rxjs","react","@wendellhu/redi/react-bindings","clsx","@univerjs/sheets-formula"],s):(l=typeof globalThis<"u"?globalThis:l||self,s(l.UniverSheetsHyperLinkUi={},l.UniverCore,l.UniverSheets,l["@wendellhu/redi"],l.UniverSheetsHyperLink,l.UniverEngineFormula,l.UniverDesign,l.UniverSheetsUi,l.UniverUi,l.UniverEngineRender,l.rxjs,l.React,l["@wendellhu/redi/react-bindings"],l.clsx,l.UniverSheetsFormula))})(this,function(l,s,p,S,v,H,I,_,O,Ae,pe,C,w,Le,Ve){"use strict";var rn=Object.defineProperty;var on=(l,s,p)=>s in l?rn(l,s,{enumerable:!0,configurable:!0,writable:!0,value:p}):l[s]=p;var A=(l,s,p)=>(on(l,typeof s!="symbol"?s+"":s,p),p);var de;var We=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,$e=(i,n,t,e)=>{for(var r=e>1?void 0:e?xe(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&We(n,t,r),r},he=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkRemoveSheetController=class extends s.Disposable{constructor(n,t,e){super(),this._sheetInterceptorService=n,this._univerInstanceService=t,this._hyperLinkModel=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{if(n.id===p.RemoveSheetCommand.id){const t=n.params,e=t.unitId?this._univerInstanceService.getUnit(t.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),o=t.subUnitId||e.getActiveSheet().getSheetId(),a=this._hyperLinkModel.getSubUnit(r,o),c=a.map(u=>({id:v.RemoveHyperLinkCommand.id,params:{unitId:r,subUnitId:o,id:u.id}})),d=a.map(u=>({id:v.AddHyperLinkCommand.id,params:{unitId:r,subUnitId:o,link:u}}));return{redos:c,undos:d}}return{redos:[],undos:[]}}}))}},l.SheetsHyperLinkRemoveSheetController=$e([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkRemoveSheetController),he(0,S.Inject(p.SheetInterceptorService)),he(1,s.IUniverInstanceService),he(2,S.Inject(v.HyperLinkModel))],l.SheetsHyperLinkRemoveSheetController);const ve="SHEETS_HYPER_LINK_UI_PLUGIN",me="err";var Be=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,ze=(i,n,t,e)=>{for(var r=e>1?void 0:e?Fe(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Be(n,t,r),r},X=(i,n)=>(t,e)=>n(t,e,i);function Ye(i,n){const t=[];return n.forEach(e=>{s.Rectangle.intersects(i,e)&&t.push(e)}),s.Rectangle.realUnion(i,...t)}l.SheetsHyperLinkResolverService=class{constructor(n,t,e,r,o){this._univerInstanceService=n,this._commandService=t,this._definedNamesService=e,this._messageService=r,this._localeService=o}_getURLName(n){var d;const{gid:t,range:e,rangeid:r}=n,o=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return null;const a=t?o.getSheetBySheetId(t):o.getActiveSheet(),c=(d=a==null?void 0:a.getName())!=null?d:"";if(e){const u=H.deserializeRangeWithSheet(e).range;return s.isValidRange(u)&&e!==me?{type:"range",name:H.serializeRangeWithSheet(c,u)}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(r){const u=this._definedNamesService.getValueById(o.getUnitId(),r);return u?{type:"defineName",name:u.formulaOrRefString}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(t){const u=o.getSheetBySheetId(t);return u?{type:"sheet",name:u.getName()}:{type:"sheet-error",name:this._localeService.t("hyperLink.message.refError")}}return null}navigateTo(n){const{gid:t,range:e,rangeid:r}=n,o=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return;const a=o.getUnitId();if(r&&this.navigateToDefineName(a,r),!!t){if(e){const c=H.deserializeRangeWithSheet(e);s.isValidRange(c.range)&&e!==me&&this.navigateToRange(a,t,c.range);return}this.navigateToSheetById(a,t)}}parseHyperLink(n){var t,e,r;if(n!=null&&n.startsWith("#")){const o=new URLSearchParams(n.slice(1)),a={gid:(t=o.get("gid"))!=null?t:"",range:(e=o.get("range"))!=null?e:"",rangeid:(r=o.get("rangeid"))!=null?r:""},c=this._getURLName(a);return{type:(c==null?void 0:c.type)||"link",name:(c==null?void 0:c.name)||n,url:n,searchObj:a,handler:()=>{this.navigateTo(a)}}}else return{type:"outer",name:n,url:n,handler:()=>{this.navigateToOtherWebsite(n)}}}async navigateToRange(n,t,e){const r=await this.navigateToSheetById(n,t);if(r){const o=Ye(e,r.getMergeData());await this._commandService.executeCommand(p.SetSelectionsOperation.id,{unitId:n,subUnitId:t,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:o}]}),await this._commandService.executeCommand(_.ScrollToCellCommand.id,{range:o})}}async navigateToSheet(n,t){const e=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET);if(!e)return!1;const r=e.getActiveSheet();if((r==null?void 0:r.getName())===t)return!0;const o=e.getSheetBySheetName(t);if(!o){this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error});return}const a=o.getSheetId();return e.getHiddenWorksheets().indexOf(a)>-1&&this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:a})}async navigateToSheetById(n,t){const e=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET);if(!e)return!1;const r=e.getActiveSheet();if(r.getSheetId()===t)return r;const o=e.getSheetBySheetId(t);return o?e.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),!1):await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:t})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error}),!1)}async navigateToDefineName(n,t){return this._definedNamesService.focusRange(n,t),!0}async navigateToOtherWebsite(n){window.open(n,"_blank","noopener noreferrer")}},l.SheetsHyperLinkResolverService=ze([X(0,s.IUniverInstanceService),X(1,s.ICommandService),X(2,H.IDefinedNamesService),X(3,O.IMessageService),X(4,S.Inject(s.LocaleService))],l.SheetsHyperLinkResolverService);var Ze=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ge=(i,n,t,e)=>{for(var r=e>1?void 0:e?Ke(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Ze(n,t,r),r},ne=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkRefRangeController=class extends s.Disposable{constructor(t,e,r,o){super();A(this,"_disposableMap",new Map);A(this,"_rangeDisableMap",new Map);this._refRangeService=t,this._hyperLinkModel=e,this._resolverService=r,this._univerInstanceService=o,this._initData(),this._initRefRange()}_register(t,e,r){const o=r.id,a={startColumn:r.column,endColumn:r.column,startRow:r.row,endRow:r.row},c=d=>{const u=p.handleDefaultRangeChangeWithEffectRefCommands(a,d);return u&&u.startColumn===a.startColumn&&u.startRow===a.startRow?{undos:[],redos:[]}:u?{redos:[{id:v.UpdateHyperLinkRefMutation.id,params:{unitId:t,subUnitId:e,id:r.id,row:u.startRow,column:u.startColumn}}],undos:[{id:v.UpdateHyperLinkRefMutation.id,params:{unitId:t,subUnitId:e,id:r.id,row:a.startRow,column:a.startColumn}}]}:{redos:[{id:v.RemoveHyperLinkMutation.id,params:{unitId:t,subUnitId:e,id:r.id}}],undos:[{id:v.AddHyperLinkMutation.id,params:{unitId:t,subUnitId:e,link:r}}]}};this._disposableMap.set(o,this._refRangeService.registerRefRange(a,c,t,e))}_unregister(t){const e=this._disposableMap.get(t);e==null||e.dispose(),this._disposableMap.delete(t)}_registerRange(t,e,r){const o=this._resolverService.parseHyperLink(r);if(o.searchObj&&o.searchObj.range&&o.searchObj.gid){const a=o.searchObj.gid,c=H.deserializeRangeWithSheet(o.searchObj.range).range;if(s.isValidRange(c)&&o.searchObj.range!==me){const d=u=>{const g=p.handleDefaultRangeChangeWithEffectRefCommands(c,u);return g&&H.serializeRange(g)===H.serializeRange(c)?{redos:[],undos:[]}:{redos:[{id:v.UpdateHyperLinkMutation.id,params:{unitId:t,subUnitId:a,id:e,payload:{payload:`#gid=${a}&range=${g?H.serializeRange(g):"err"}`}}}],undos:[{id:v.UpdateHyperLinkMutation.id,params:{unitId:t,subUnitId:a,id:e,payload:{payload:r}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(c,d,t,a))}}}_unregisterRange(t){const e=this._rangeDisableMap.get(t);e==null||e.dispose(),this._rangeDisableMap.delete(t)}_initData(){this._hyperLinkModel.getAll().forEach(e=>{e.forEach(r=>{const{unitId:o,subUnitId:a,links:c}=r;c.forEach(d=>{this._register(o,a,d)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(t=>{switch(t.type){case"add":{this._register(t.unitId,t.subUnitId,t.payload),this._registerRange(t.unitId,t.payload.id,t.payload.payload);break}case"remove":{this._unregister(t.payload.id),this._unregisterRange(t.payload.id);break}case"updateRef":{const{unitId:e,subUnitId:r,id:o}=t,a=this._hyperLinkModel.getHyperLink(e,r,o);if(!a)return;this._unregister(o),this._register(e,r,a);break}case"unload":{const{unitLinks:e}=t;e.forEach(r=>{const{links:o}=r;o.forEach(a=>{this._unregister(a.id),this._unregisterRange(a.id)})});break}case"update":{this._unregisterRange(t.id),this._registerRange(t.unitId,t.id,t.payload.payload);break}}})),this.disposeWithMe(s.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}},l.SheetsHyperLinkRefRangeController=Ge([s.OnLifecycle(s.LifecycleStages.Starting,l.SheetsHyperLinkRefRangeController),ne(0,S.Inject(p.RefRangeService)),ne(1,S.Inject(v.HyperLinkModel)),ne(2,S.Inject(l.SheetsHyperLinkResolverService)),ne(3,s.IUniverInstanceService)],l.SheetsHyperLinkRefRangeController);var Xe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(i,n,t,e)=>{for(var r=e>1?void 0:e?Je(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Xe(n,t,r),r},z=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkRenderController=class extends s.Disposable{constructor(n,t,e,r,o,a){super(),this._sheetInterceptorService=n,this._hyperLinkModel=t,this._univerInstanceService=e,this._sheetSkeletonManagerService=r,this._renderManagerService=o,this._themeService=a,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(p.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(n,t,e)=>{const{row:r,col:o,unitId:a,subUnitId:c}=t,d=this._hyperLinkModel.getHyperLinkByLocation(a,c,r,o),u=this._themeService.getCurrentTheme();return e(d?{...n,interceptorStyle:{ul:{s:s.BooleanNumber.TRUE},cl:{rgb:u.blue500}}}:n)},priority:100}))}_initSkeletonChange(){const n=()=>{const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return;const e=t.getUnitId(),r=t.getActiveSheet().getSheetId(),o=this._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:e,sheetId:r}),a=this._renderManagerService.getRenderById(e);o==null||o.makeDirty(!0),o==null||o.calculate(),a&&a.mainComponent.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(()=>{n()}))}},l.SheetsHyperLinkRenderController=Qe([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkRenderController),z(0,S.Inject(p.SheetInterceptorService)),z(1,S.Inject(v.HyperLinkModel)),z(2,s.IUniverInstanceService),z(3,S.Inject(_.SheetSkeletonManagerService)),z(4,Ae.IRenderManagerService),z(5,S.Inject(s.ThemeService))],l.SheetsHyperLinkRenderController);var ke={exports:{}},re={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var qe=C,et=Symbol.for("react.element"),tt=Symbol.for("react.fragment"),nt=Object.prototype.hasOwnProperty,rt=qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,it={key:!0,ref:!0,__self:!0,__source:!0};function Ie(i,n,t){var e,r={},o=null,a=null;t!==void 0&&(o=""+t),n.key!==void 0&&(o=""+n.key),n.ref!==void 0&&(a=n.ref);for(e in n)nt.call(n,e)&&!it.hasOwnProperty(e)&&(r[e]=n[e]);if(i&&i.defaultProps)for(e in n=i.defaultProps,n)r[e]===void 0&&(r[e]=n[e]);return{$$typeof:et,type:i,key:o,ref:a,props:r,_owner:rt.current}}re.Fragment=tt,re.jsx=Ie,re.jsxs=Ie,ke.exports=re;var m=ke.exports,N=function(){return N=Object.assign||function(i){for(var n,t=1,e=arguments.length;t<e;t++){n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])}return i},N.apply(this,arguments)},ot=function(i,n){var t={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&n.indexOf(e)<0&&(t[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)n.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(t[e[r]]=i[e[r]]);return t},$=C.forwardRef(function(i,n){var t=i.icon,e=i.id,r=i.className,o=i.extend,a=ot(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),d=C.useRef("_".concat(lt()));return Re(t,"".concat(e),{defIds:t.defIds,idSuffix:d.current},N({ref:n,className:c},a),o)});function Re(i,n,t,e,r){return C.createElement(i.tag,N(N({key:n},at(i,t,r)),e),(st(i,t).children||[]).map(function(o,a){return Re(o,"".concat(n,"-").concat(i.tag,"-").concat(a),t,void 0,r)}))}function at(i,n,t){var e=N({},i.attrs);t!=null&&t.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=t.colorChannel1);var r=n.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+n.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),e}function st(i,n){var t,e=n.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?N(N({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?N(N({},r),{attrs:N(N({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):i}function lt(){return Math.random().toString(36).substring(2,8)}$.displayName="UniverIcon";var ct={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Pe=C.forwardRef(function(i,n){return C.createElement($,Object.assign({},i,{id:"all-border-single",ref:n,icon:ct}))});Pe.displayName="AllBorderSingle";const ge=Pe;var dt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.02547 12.4251C5.15328 13.7417 6.26305 14.7708 7.61318 14.7708H12.6132C14.0491 14.7708 15.2132 13.6067 15.2132 12.1708V6.1708C15.2132 4.78586 14.1303 3.65383 12.7651 3.57517C12.6373 2.25858 11.5275 1.22949 10.1774 1.22949H5.17739C3.74145 1.22949 2.57739 2.39355 2.57739 3.82949V9.82949C2.57739 11.2144 3.66024 12.3465 5.02547 12.4251ZM11.5535 3.5708H7.61318C6.17724 3.5708 5.01318 4.73486 5.01318 6.1708V11.22C4.31736 11.1387 3.77739 10.5471 3.77739 9.82949V3.82949C3.77739 3.05629 4.40419 2.42949 5.17739 2.42949H10.1774C10.8622 2.42949 11.4322 2.92119 11.5535 3.5708ZM14.0132 6.1708C14.0132 5.3976 13.3864 4.7708 12.6132 4.7708H7.61318C6.83998 4.7708 6.21318 5.3976 6.21318 6.1708V12.1708C6.21318 12.944 6.83998 13.5708 7.61318 13.5708H12.6132C13.3864 13.5708 14.0132 12.944 14.0132 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},be=C.forwardRef(function(i,n){return C.createElement($,Object.assign({},i,{id:"copy-single",ref:n,icon:dt}))});be.displayName="CopySingle";const ut=be;var pt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=C.forwardRef(function(i,n){return C.createElement($,Object.assign({},i,{id:"link-single",ref:n,icon:pt}))});ie.displayName="LinkSingle";var ht={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},Oe=C.forwardRef(function(i,n){return C.createElement($,Object.assign({},i,{id:"unlink-single",ref:n,icon:ht}))});Oe.displayName="UnlinkSingle";const vt=Oe;var mt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},Me=C.forwardRef(function(i,n){return C.createElement($,Object.assign({},i,{id:"write-single",ref:n,icon:mt}))});Me.displayName="WriteSingle";const gt=Me;var St={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.36396 1.12549C2.61066 1.12549 2 1.73615 2 2.48945V13.5104C2 14.2637 2.61066 14.8744 3.36396 14.8744H12.457C13.2103 14.8744 13.821 14.2637 13.821 13.5104V5.0992L9.91954 1.12549H3.36396Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M9.91797 1.12549L13.8209 5.09842H10.5846C10.2164 5.09842 9.91797 4.79994 9.91797 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.71926 10.2949L6.28687 12.403C6.17306 12.5705 5.94501 12.614 5.77751 12.5002C5.61002 12.3864 5.56649 12.1584 5.6803 11.9909L7.27596 9.64252L5.85088 7.54519C5.73707 7.37769 5.78059 7.14964 5.94809 7.03583C6.11558 6.92202 6.34363 6.96555 6.45744 7.13304L7.71926 8.9901L8.98108 7.13304C9.09489 6.96555 9.32294 6.92202 9.49044 7.03583C9.65793 7.14964 9.70146 7.37769 9.58765 7.54519L8.16256 9.64252L9.75822 11.9909C9.87203 12.1584 9.82851 12.3864 9.66101 12.5002C9.49351 12.614 9.26547 12.5705 9.15166 12.403L7.71926 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ee=C.forwardRef(function(i,n){return C.createElement($,Object.assign({},i,{id:"xlsx",ref:n,icon:St}))});Ee.displayName="Xlsx";const He=Ee,ft=/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi,yt=new RegExp(ft);function J(i){return i.startsWith("http://localhost:3002")||i.startsWith("localhost:3002")?!0:!!i.match(yt)}function we(i){return/^[a-zA-Z]+:\/\//.test(i)}function _t(i){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(i)}function je(i){return J(i)?we(i)?i:_t(i)?`mailto://${i}`:`http://${i}`:i}const Ct={cellLinkEditButtons:"univer-cell-link-edit-buttons"};function Lt(i){if(i===null)return"";if(i!=null&&i.p){const n=i==null?void 0:i.p.body;if(n==null)return"";const t=n.dataStream;return t.substring(t.length-2,t.length)===s.DEFAULT_EMPTY_DOCUMENT_VALUE?t.substring(0,t.length-2):t}return i==null?void 0:i.v}const oe=()=>{var ue;const[i,n]=C.useState(""),[t,e]=C.useState(""),[r,o]=C.useState("link"),[a,c]=C.useState(""),d=w.useDependency(s.LocaleService),u=w.useDependency(H.IDefinedNamesService),g=w.useDependency(s.IUniverInstanceService),y=w.useDependency(l.SheetsHyperLinkPopupService),h=O.useObservable(y.currentEditing$),P=w.useDependency(v.HyperLinkModel),b=w.useDependency(l.SheetsHyperLinkResolverService),R=w.useDependency(s.ICommandService),[E,j]=C.useState(!1),L=C.useRef(!1);C.useEffect(()=>{var f,k,M;if((h==null?void 0:h.row)!==void 0&&h.column!==void 0){const U=P.getHyperLinkByLocation(h.unitId,h.subUnitId,h.row,h.column);if(U){const Ce=b.parseHyperLink(U.payload);if(n(U.id),e(U.display),Ce.type==="outer"){o("link"),c(Ce.url);return}else{const x=Ce.searchObj;if(x.rangeid){o("rangeid"),c(x.rangeid);return}if(x.range){const nn=x.gid&&(M=(k=(f=g.getUnit(h.unitId))==null?void 0:f.getSheetBySheetId(x.gid))==null?void 0:k.getName())!=null?M:"";o("range"),c(H.serializeRangeWithSheet(nn,H.deserializeRangeWithSheet(x.range).range));return}if(x.gid){o("gid"),c(x.gid);return}}}const G=g.getUnit(h.unitId),W=G==null?void 0:G.getSheetBySheetId(h.subUnitId),tn=W==null?void 0:W.getCellRaw(h.row,h.column),_e=Lt(tn);o("link"),c(""),e((_e!=null?_e:"").toString()),n("");return}o("link"),c(""),e(""),n("")},[h,P,b,g]);const D=C.useMemo(()=>a,[r]),Z=[{label:d.t("hyperLink.form.link"),value:"link"},{label:d.t("hyperLink.form.range"),value:"range"},{label:d.t("hyperLink.form.worksheet"),value:"gid"},{label:d.t("hyperLink.form.definedName"),value:"rangeid"}],T=g.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!T)return;const K=T.getHiddenWorksheets(),B=T.getSheets().map(f=>({label:f.getName(),value:f.getSheetId()})).filter(f=>K.indexOf(f.value)===-1),F=Object.values((ue=u.getDefinedNameMap(T.getUnitId()))!=null?ue:{}).map(f=>({label:f.name,value:f.id})),te=(f,k)=>{if(f==="link")return we(k)?k:`http://${k}`;if(f==="range"){const M=H.deserializeRangeWithSheet(k),U=T.getSheetBySheetName(M.sheetName);if(U)return`#gid=${U.getSheetId()}&range=${H.serializeRange(M.range)}`}return`#${f}=${k}`},ye=async()=>{h&&(i?await R.executeCommand(v.UpdateHyperLinkCommand.id,{unitId:h.unitId,subUnitId:h.subUnitId,id:i,payload:{display:t,payload:te(r,a)}}):await R.executeCommand(v.AddHyperLinkCommand.id,{unitId:h.unitId,subUnitId:h.subUnitId,link:{id:s.Tools.generateRandomId(),row:h.row,column:h.column,payload:te(r,a),display:t}})),h&&(await R.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:h.unitId,subUnitId:h.subUnitId}),await R.executeCommand(_.ScrollToCellCommand.id,{range:{startRow:h.row,endRow:h.row,startColumn:h.column,endColumn:h.column}})),R.executeCommand(Q.id)};return m.jsxs("div",{children:[m.jsx(I.FormLayout,{label:d.t("hyperLink.form.label"),error:E&&!t?d.t("hyperLink.form.inputError"):"",children:m.jsx(I.Input,{value:t,onChange:f=>{e(f),L.current=!1},placeholder:d.t("hyperLink.form.labelPlaceholder")})}),m.jsx(I.FormLayout,{label:d.t("hyperLink.form.type"),children:m.jsx(I.Select,{options:Z,value:r,onChange:f=>{o(f),c("")}})}),r==="link"&&m.jsx(I.FormLayout,{error:E?a?J(a)?"":d.t("hyperLink.form.linkError"):d.t("hyperLink.form.inputError"):"",children:m.jsx(I.Input,{value:a,onChange:f=>{c(f),f&&(L.current||!t)&&(e(f),L.current=!0)},placeholder:d.t("hyperLink.form.linkPlaceholder")})}),r==="range"&&m.jsx(I.FormLayout,{error:E&&!a?d.t("hyperLink.form.inputError"):"",children:m.jsx(O.RangeSelector,{openForSheetUnitId:T.getUnitId(),id:s.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:D,onChange:f=>{const k=f[0];if(!k||!s.isValidRange(k.range))return;k.sheetName||(k.sheetName=T.getActiveSheet().getName());const M=H.serializeRangeToRefString(k);c(M),M&&(L.current||!t)&&(e(M),L.current=!0)}})}),r==="gid"&&m.jsx(I.FormLayout,{error:E&&!a?d.t("hyperLink.form.selectError"):"",children:m.jsx(I.Select,{options:B,value:a,onChange:f=>{var M;c(f);const k=(M=B.find(U=>U.value===f))==null?void 0:M.label;k&&(L.current||!t)&&(e(k),L.current=!0)}})}),r==="rangeid"&&m.jsx(I.FormLayout,{error:E&&!a?d.t("hyperLink.form.selectError"):"",children:m.jsx(I.Select,{options:F,value:a,onChange:f=>{var M;c(f);const k=(M=F.find(U=>U.value===f))==null?void 0:M.label;k&&(L.current||!t)&&(e(k),L.current=!0)}})}),m.jsxs("div",{className:Ct.cellLinkEditButtons,children:[m.jsx(I.Button,{onClick:()=>{h&&R.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:h.unitId,subUnitId:h.subUnitId}),R.executeCommand(Q.id)},children:d.t("hyperLink.form.cancel")}),m.jsx(I.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{if(!t||!a||r==="link"&&!J(a)){j(!0);return}ye()},children:d.t("hyperLink.form.ok")})]})]})};oe.componentKey="univer.sheet.cell-link-edit";const ae={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-sidebar",handler(i,n){if(!n)return!1;const{unitId:t,subUnitId:e,row:r,column:o}=n,a=i.get(v.HyperLinkModel),c=i.get(O.ISidebarService),d=i.get(l.SheetsHyperLinkPopupService),u=a.getHyperLinkByLocation(t,e,r,o);return d.startEditing(n),c.open({header:{title:u?"hyperLink.form.editTitle":"hyperLink.form.addTitle"},children:{label:oe.componentKey}}),!0}},Q={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-sidebar",handler(i){const n=i.get(O.ISidebarService),t=i.get(l.SheetsHyperLinkPopupService);return n.close(),t.endEditing(),!0}},q={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(i){const n=i.get(s.IUniverInstanceService),t=p.getSheetCommandTarget(n);if(!t)return!1;const e=i.get(s.ICommandService),o=i.get(p.SelectionManagerService).getFirst();if(!(o!=null&&o.primary))return!1;const a=o.primary.actualRow,c=o.primary.actualColumn;return e.executeCommand(ae.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:a,column:c})}},Te={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(i){const n=i.get(s.ICommandService);return i.get(l.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(Q.id):n.executeCommand(q.id)}},V={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},kt={outer:m.jsx(ie,{}),link:m.jsx(ie,{}),sheet:m.jsx(He,{}),range:m.jsx(ge,{}),defineName:m.jsx(ge,{}),"range-error":m.jsx(ge,{}),"sheet-error":m.jsx(He,{})},se=()=>{const i=w.useDependency(l.SheetsHyperLinkPopupService),n=w.useDependency(v.HyperLinkModel),t=w.useDependency(s.ICommandService),e=w.useDependency(O.IMessageService),r=w.useDependency(s.LocaleService),o=w.useObservable(i.currentPopup$,i.currentPopup),a=w.useDependency(l.SheetsHyperLinkResolverService);if(!o)return null;const{unitId:c,subUnitId:d,id:u}=o,g=n.getHyperLink(c,d,u);if(!g)return null;const y=a.parseHyperLink(g.payload),h=y.type.indexOf("error")>-1;return m.jsxs("div",{className:V.cellLink,onClick:()=>i.hideCurrentPopup(),children:[m.jsxs("div",{className:Le(V.cellLinkContent,{[V.cellLinkContentError]:h}),onClick:y.handler,children:[m.jsx("div",{className:V.cellLinkType,children:kt[y.type]}),m.jsx("div",{className:V.cellLinkUrl,children:y.name})]}),m.jsxs("div",{className:V.cellLinkOperations,children:[m.jsx("div",{className:Le(V.cellLinkOperation,{[V.cellLinkOperationError]:h}),onClick:()=>{if(!h){if(y.type!=="outer"){const P=new URL(window.location.href);P.hash=y.url.slice(1),navigator.clipboard.writeText(P.href)}else navigator.clipboard.writeText(y.url);e.show({content:r.t("hyperLink.message.coped"),type:I.MessageType.Info})}},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:m.jsx(ut,{})})}),m.jsx("div",{className:V.cellLinkOperation,onClick:()=>{t.executeCommand(ae.id,{unitId:c,subUnitId:d,row:g.row,column:g.column})},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:m.jsx(gt,{})})}),m.jsx("div",{className:V.cellLinkOperation,onClick:()=>{t.executeCommand(v.CancelHyperLinkCommand.id,{unitId:c,subUnitId:d,id:g.id})},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:m.jsx(vt,{})})})]})]})};se.componentKey="univer.sheet.cell-link-popup";var It=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,Pt=(i,n,t,e)=>{for(var r=e>1?void 0:e?Rt(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&It(n,t,r),r},Ue=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkPopupService=class{constructor(n,t){A(this,"_currentPopup",null);A(this,"_currentPopup$",new pe.Subject);A(this,"currentPopup$",this._currentPopup$.asObservable());A(this,"_currentEditing$",new pe.BehaviorSubject(null));A(this,"currentEditing$",this._currentEditing$.asObservable());this._hyperLinkModel=n,this._sheetCanvasPopManagerService=t}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}showPopup(n){this.hideCurrentPopup();const{unitId:t,subUnitId:e,row:r,col:o}=n,a=this._hyperLinkModel.getHyperLinkByLocation(t,e,r,o);if(!a)return;const c=this._sheetCanvasPopManagerService.attachPopupToCell(r,o,{componentKey:se.componentKey,direction:"bottom",closeOnSelfTarget:!0});c&&(this._currentPopup={unitId:t,subUnitId:e,id:a.id,disposable:c},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(){var n;this._currentPopup&&((n=this._currentPopup.disposable)==null||n.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}startEditing(n){this._currentEditing$.next(n)}endEditing(){this._currentEditing$.next(null)}},l.SheetsHyperLinkPopupService=Pt([Ue(0,S.Inject(v.HyperLinkModel)),Ue(1,S.Inject(_.SheetCanvasPopManagerService))],l.SheetsHyperLinkPopupService);var bt=Object.defineProperty,Ot=Object.getOwnPropertyDescriptor,Mt=(i,n,t,e)=>{for(var r=e>1?void 0:e?Ot(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&bt(n,t,r),r},ee=(i,n)=>(t,e)=>n(t,e,i);l.SheetHyperLinkSetRangeController=class extends s.Disposable{constructor(n,t,e,r,o){super(),this._sheetInterceptorService=n,this._injector=t,this._hyperLinkModel=e,this._selectionManagerService=r,this._univerInstanceService=o,this._initCommandInterceptor()}_initCommandInterceptor(){this._initAddHyperLinkCommandInterceptor(),this._initSetRangeValuesCommandInterceptor(),this._initUpdateHyperLinkCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initAddHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{if(n.id===v.AddHyperLinkCommand.id){const t=n.params,{unitId:e,subUnitId:r,link:o}=t,a={unitId:e,subUnitId:r,cellValue:{[o.row]:{[o.column]:{v:o.display,t:s.CellValueType.STRING,p:null}}}};return{redos:[{id:p.SetRangeValuesMutation.id,params:a}],undos:[{id:p.SetRangeValuesMutation.id,params:p.SetRangeValuesUndoMutationFactory(this._injector,a)}]}}return{redos:[],undos:[]}}}))}_initUpdateHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{if(n.id===v.UpdateHyperLinkCommand.id){const t=n.params,{unitId:e,subUnitId:r,id:o,payload:a}=t,c=this._hyperLinkModel.getHyperLink(e,r,o);if(c&&c.display!==a.display){const d={unitId:e,subUnitId:r,cellValue:{[c.row]:{[c.column]:{v:a.display,t:s.CellValueType.STRING,p:null}}}};return{redos:[{id:p.SetRangeValuesMutation.id,params:d}],undos:[{id:p.SetRangeValuesMutation.id,params:p.SetRangeValuesUndoMutationFactory(this._injector,d)}]}}}return{redos:[],undos:[]}}}))}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{if(n.id===p.SetRangeValuesCommand.id){const t=n.params,{unitId:e,subUnitId:r}=t,o=[],a=[];return t.cellValue&&new s.ObjectMatrix(t.cellValue).forValue((c,d,u)=>{var b,R,E,j;const g=((j=(E=u==null?void 0:u.v)!=null?E:(R=(b=u==null?void 0:u.p)==null?void 0:b.body)==null?void 0:R.dataStream.slice(0,-2))!=null?j:"").toString(),y=this._hyperLinkModel.getHyperLinkByLocation(e,r,c,d);if(!y){if(J(g)){const L=s.Tools.generateRandomId();a.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:e,subUnitId:r,id:L}}),o.push({id:v.AddHyperLinkMutation.id,params:{unitId:e,subUnitId:r,link:{id:L,row:c,column:d,display:g,payload:je(g)}}})}return}if(y.display===g)return;g||(o.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:e,subUnitId:r,id:y.id}}),a.push({id:v.AddHyperLinkMutation.id,params:{unitId:e,subUnitId:r,link:y}}));const h={unitId:e,subUnitId:r,id:y.id,payload:{payload:y.payload,display:g}},P={unitId:e,subUnitId:r,id:y.id,payload:{payload:y.payload,display:y.display}};o.push({id:v.UpdateHyperLinkMutation.id,params:h}),a.push({id:v.UpdateHyperLinkMutation.id,params:P})}),{undos:a,redos:o}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{if(n.id===p.ClearSelectionContentCommand.id||n.id===p.ClearSelectionAllCommand.id){const t=[],e=[],r=this._selectionManagerService.getFirst(),o=p.getSheetCommandTarget(this._univerInstanceService);if(r&&o){const{unitId:a,subUnitId:c}=o;s.Range.foreach(r.range,(d,u)=>{const g=this._hyperLinkModel.getHyperLinkByLocation(a,c,d,u);g&&(t.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:c,id:g.id}}),e.push({id:v.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:c,link:g}}))})}return{redos:t,undos:e}}return{redos:[],undos:[]}}}))}},l.SheetHyperLinkSetRangeController=Mt([s.OnLifecycle(s.LifecycleStages.Starting,l.SheetHyperLinkSetRangeController),ee(0,S.Inject(p.SheetInterceptorService)),ee(1,S.Inject(S.Injector)),ee(2,S.Inject(v.HyperLinkModel)),ee(3,S.Inject(p.SelectionManagerService)),ee(4,s.IUniverInstanceService)],l.SheetHyperLinkSetRangeController);var Et=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,wt=(i,n,t,e)=>{for(var r=e>1?void 0:e?Ht(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Et(n,t,r),r},Ne=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkPopupController=class extends s.Disposable{constructor(n,t){super(),this._hoverManagerService=n,this._sheetsHyperLinkPopupService=t,this._initHoverListener()}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(pe.debounceTime(100)).subscribe(n=>{if(!n){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup(n.location)}))}},l.SheetsHyperLinkPopupController=wt([s.OnLifecycle(s.LifecycleStages.Rendered,l.SheetsHyperLinkPopupController),Ne(0,S.Inject(_.HoverManagerService)),Ne(1,S.Inject(l.SheetsHyperLinkPopupService))],l.SheetsHyperLinkPopupController);const jt=i=>({id:q.id,type:O.MenuItemType.BUTTON,positions:[O.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",hidden$:O.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET),icon:"LinkSingle",disabled$:_.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]})}),Tt=i=>({tooltip:"hyperLink.form.addTitle",positions:O.MenuPosition.TOOLBAR_START,group:O.MenuGroup.TOOLBAR_OTHERS,id:Te.id,type:O.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:O.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]})}),Se={id:q.id,binding:O.KeyCode.K|O.MetaKeys.CTRL_COMMAND,preconditions:_.whenSheetEditorFocused};var Ut=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,Dt=(i,n,t,e)=>{for(var r=e>1?void 0:e?Nt(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Ut(n,t,r),r},Y=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkUIController=class extends s.Disposable{constructor(n,t,e,r,o,a,c){super(),this._config=n,this._componentManager=t,this._commandService=e,this._localeService=r,this._menuService=o,this._injector=a,this._shortcutService=c,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[se,se.componentKey],[oe,oe.componentKey],[ie,"LinkSingle"]].forEach(([n,t])=>{this._componentManager.register(t,n)})}_initCommands(){[ae,Q,q,Te].forEach(n=>{this._commandService.registerCommand(n)})}_initMenus(){var n,t,e,r;this._menuService.addMenuItem(jt(this._injector),(t=(n=this._config)==null?void 0:n.menu)!=null?t:{}),this._menuService.addMenuItem(Tt(this._injector),(r=(e=this._config)==null?void 0:e.menu)!=null?r:{})}_initShortCut(){this._shortcutService.registerShortcut(Se)}},l.SheetsHyperLinkUIController=Dt([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkUIController),Y(1,S.Inject(O.ComponentManager)),Y(2,s.ICommandService),Y(3,S.Inject(s.LocaleService)),Y(4,O.IMenuService),Y(5,S.Inject(S.Injector)),Y(6,S.Inject(O.IShortcutService))],l.SheetsHyperLinkUIController);var At=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,Wt=(i,n,t,e)=>{for(var r=e>1?void 0:e?Vt(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&At(n,t,r),r},De=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkAutoFillController=class extends s.Disposable{constructor(n,t){super(),this._autoFillService=n,this._hyperLinkModel=t,this._initAutoFill()}_initAutoFill(){const n=()=>({redos:[],undos:[]}),t=(r,o)=>{const{source:a,target:c,unitId:d,subUnitId:u}=r,g=_.virtualizeDiscreteRanges([a,c]),[y,h]=g.ranges,{mapFunc:P}=g,b={row:y.startRow,col:y.startColumn},R=_.getAutoFillRepeatRange(y,h),E=[],j=[];return R.forEach(L=>{const D=L.repeatStartCell,Z=L.relativeRange,T={startRow:b.row,startColumn:b.col,endColumn:b.col,endRow:b.row},K={startRow:D.row,startColumn:D.col,endColumn:D.col,endRow:D.row};s.Range.foreach(Z,(B,F)=>{const te=s.Rectangle.getPositionRange({startRow:B,startColumn:F,endColumn:F,endRow:B},T),{row:ye,col:ue}=P(te.startRow,te.startColumn),f=this._hyperLinkModel.getHyperLinkByLocation(d,u,ye,ue);if(f){const k=s.Rectangle.getPositionRange({startRow:B,startColumn:F,endColumn:F,endRow:B},K),{row:M,col:U}=P(k.startRow,k.startColumn),G=s.Tools.generateRandomId(),W=this._hyperLinkModel.getHyperLinkByLocation(d,u,M,U);W&&E.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:u,id:W.id}}),_.APPLY_TYPE.COPY===o&&(E.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:u,link:{...f,id:G,row:M,column:U}}}),j.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:u,id:G}})),W&&j.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:u,link:W}})}})}),{undos:j,redos:E}},e={id:ve,onFillData:(r,o,a)=>a===_.APPLY_TYPE.COPY||a===_.APPLY_TYPE.ONLY_FORMAT||a===_.APPLY_TYPE.SERIES?t(r,a):n()};this.disposeWithMe(this._autoFillService.addHook(e))}},l.SheetsHyperLinkAutoFillController=Wt([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkAutoFillController),De(0,_.IAutoFillService),De(1,S.Inject(v.HyperLinkModel))],l.SheetsHyperLinkAutoFillController);var xt=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,Bt=(i,n,t,e)=>{for(var r=e>1?void 0:e?$t(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&xt(n,t,r),r},le=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(t,e,r,o){super();A(this,"_copyInfo");this._sheetClipboardService=t,this._hyperLinkModel=e,this._injector=r,this._resolverService=o,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:ve,onBeforeCopy:(t,e,r)=>this._collect(t,e,r),onPasteCells:(t,e,r,o)=>{const{copyType:a=_.COPY_TYPE.COPY,pasteType:c}=o,{range:d}=t||{},{range:u,unitId:g,subUnitId:y}=e;return this._generateMutations(u,{copyType:a,pasteType:c,copyRange:d,unitId:g,subUnitId:y})},onPastePlainText:(t,e)=>{if(J(e)){let r=je(e);const o=new URL(r),a=e;o.hostname===location.hostname&&o.port===location.port&&o.protocol===location.protocol&&o.pathname===location.pathname&&o.hash&&(r=o.hash);const{range:c,unitId:d,subUnitId:u}=t,{ranges:[g],mapFunc:y}=_.virtualizeDiscreteRanges([c]),h=[],P=[];return s.Range.foreach(g,(b,R)=>{const{row:E,col:j}=y(b,R),L=this._hyperLinkModel.getHyperLinkByLocation(d,u,E,j);L&&h.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:u,id:L.id}});const D=s.Tools.generateRandomId();h.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:u,link:{id:D,row:E,column:j,display:a,payload:r}}}),P.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:u,id:D}}),L&&P.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:u,link:L}})}),{redos:h,undos:P}}return{undos:[],redos:[]}}})}_collect(t,e,r){const o=new s.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:e,matrix:o};const a={get:this._injector.get.bind(this._injector)},c=_.rangeToDiscreteRange(r,a,t,e);if(!c)return;const{rows:d,cols:u}=c;d.forEach((g,y)=>{u.forEach((h,P)=>{var R;const b=this._hyperLinkModel.getHyperLinkByLocation(t,e,g,h);o.setValue(y,P,(R=b==null?void 0:b.id)!=null?R:"")})})}_generateMutations(t,e){if(!this._copyInfo)return{redos:[],undos:[]};if(e.copyType===_.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!e.copyRange)return{redos:[],undos:[]};if([_.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,_.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,_.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,Ve.SPECIAL_PASTE_FORMULA].includes(e.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:o}=this._copyInfo,a=[],c=[],{ranges:[d,u],mapFunc:g}=_.virtualizeDiscreteRanges([e.copyRange,t]);return _.getRepeatRange(d,u,!0).forEach(({startRange:h})=>{var P;(P=this._copyInfo)==null||P.matrix.forValue((b,R,E)=>{const j=s.Rectangle.getPositionRange({startRow:b,endRow:b,startColumn:R,endColumn:R},h),L=this._hyperLinkModel.getHyperLink(r,o,E),{row:D,col:Z}=g(j.startRow,j.startColumn),T=this._hyperLinkModel.getHyperLinkByLocation(e.unitId,e.subUnitId,D,Z),K=s.Tools.generateRandomId();T&&a.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:e.unitId,subUnitId:e.subUnitId,id:T.id}}),L&&(a.push({id:v.AddHyperLinkMutation.id,params:{unitId:e.unitId,subUnitId:e.subUnitId,link:{...L,id:K,row:D,column:Z}}}),c.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:e.unitId,subUnitId:e.subUnitId,id:K}})),T&&c.push({id:v.AddHyperLinkMutation.id,params:{unitId:e.unitId,subUnitId:e.subUnitId,link:T}})})}),{redos:a,undos:c}}},l.SheetsHyperLinkCopyPasteController=Bt([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkCopyPasteController),le(0,_.ISheetClipboardService),le(1,S.Inject(v.HyperLinkModel)),le(2,S.Inject(S.Injector)),le(3,S.Inject(l.SheetsHyperLinkResolverService))],l.SheetsHyperLinkCopyPasteController);var Ft=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,Yt=(i,n,t,e)=>{for(var r=e>1?void 0:e?zt(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Ft(n,t,r),r},Zt=(i,n)=>(t,e)=>n(t,e,i);l.SheetHyperLinkUrlController=class extends s.Disposable{constructor(n){super(),this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const n=location.hash;n&&this._resolverService.parseHyperLink(n).handler()}},l.SheetHyperLinkUrlController=Yt([s.OnLifecycle(s.LifecycleStages.Rendered,l.SheetHyperLinkUrlController),Zt(0,S.Inject(l.SheetsHyperLinkResolverService))],l.SheetHyperLinkUrlController);var Kt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Xt=(i,n,t,e)=>{for(var r=e>1?void 0:e?Gt(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Kt(n,t,r),r},fe=(i,n)=>(t,e)=>n(t,e,i);let ce=class extends s.Disposable{constructor(i,n,t){super(),this._localeService=i,this._commandService=n,this._sheetPermissionInterceptorBaseController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{i.id===Se.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookEditablePermission],rangeTypes:[p.RangeProtectionPermissionEditPoint],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};ce=Xt([s.OnLifecycle(s.LifecycleStages.Rendered,ce),fe(0,S.Inject(s.LocaleService)),fe(1,s.ICommandService),fe(2,S.Inject(_.SheetPermissionInterceptorBaseController))],ce);var Jt=Object.defineProperty,Qt=Object.getOwnPropertyDescriptor,qt=(i,n,t,e)=>{for(var r=e>1?void 0:e?Qt(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Jt(n,t,r),r},en=(i,n)=>(t,e)=>n(t,e,i);l.UniverSheetsHyperLinkUIPlugin=(de=class extends v.UniverSheetsHyperLinkPlugin{constructor(n,t){super(n,t),this._config=n,this._injector=t}onStarting(n){super.onStarting(n),[[l.SheetsHyperLinkResolverService],[l.SheetsHyperLinkPopupService],[l.SheetsHyperLinkRemoveSheetController],[l.SheetsHyperLinkRefRangeController],[l.SheetsHyperLinkRenderController],[l.SheetHyperLinkSetRangeController],[l.SheetsHyperLinkPopupController],[l.SheetsHyperLinkUIController,{useFactory:()=>this._injector.createInstance(l.SheetsHyperLinkUIController,this._config)}],[l.SheetsHyperLinkAutoFillController],[l.SheetsHyperLinkCopyPasteController],[ce],[l.SheetHyperLinkUrlController]].forEach(e=>{n.add(e)})}},A(de,"pluginName",ve),A(de,"type",s.UniverInstanceType.UNIVER_SHEET),de),l.UniverSheetsHyperLinkUIPlugin=qt([en(1,S.Inject(S.Injector))],l.UniverSheetsHyperLinkUIPlugin),l.CloseHyperLinkSidebarOperation=Q,l.InsertHyperLinkOperation=q,l.InsertLinkShortcut=Se,l.OpenHyperLinkSidebarOperation=ae,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
package/package.json ADDED
@@ -0,0 +1,94 @@
1
+ {
2
+ "name": "@univerjs/sheets-hyper-link-ui",
3
+ "version": "0.1.13",
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
+ "univer"
22
+ ],
23
+ "sideEffects": [
24
+ "**/*.css"
25
+ ],
26
+ "exports": {
27
+ ".": {
28
+ "import": "./lib/es/index.js",
29
+ "require": "./lib/cjs/index.js",
30
+ "types": "./lib/types/index.d.ts"
31
+ },
32
+ "./*": {
33
+ "import": "./lib/es/*",
34
+ "require": "./lib/cjs/*",
35
+ "types": "./lib/types/index.d.ts"
36
+ },
37
+ "./locale/*": "./lib/locale/*.json",
38
+ "./lib/*": "./lib/*"
39
+ },
40
+ "main": "./lib/cjs/index.js",
41
+ "module": "./lib/es/index.js",
42
+ "types": "./lib/types/index.d.ts",
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "directories": {
47
+ "lib": "lib"
48
+ },
49
+ "files": [
50
+ "lib"
51
+ ],
52
+ "peerDependencies": {
53
+ "@wendellhu/redi": "0.15.2",
54
+ "clsx": ">=2.0.0",
55
+ "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
56
+ "rxjs": ">=7.0.0",
57
+ "@univerjs/design": "0.1.13",
58
+ "@univerjs/engine-formula": "0.1.13",
59
+ "@univerjs/core": "0.1.13",
60
+ "@univerjs/engine-render": "0.1.13",
61
+ "@univerjs/sheets-formula": "0.1.13",
62
+ "@univerjs/sheets": "0.1.13",
63
+ "@univerjs/sheets-hyper-link": "0.1.13",
64
+ "@univerjs/sheets-ui": "0.1.13",
65
+ "@univerjs/ui": "0.1.13"
66
+ },
67
+ "dependencies": {
68
+ "@univerjs/icons": "^0.1.55",
69
+ "@univerjs/sheets-hyper-link": "0.1.13"
70
+ },
71
+ "devDependencies": {
72
+ "@wendellhu/redi": "^0.15.2",
73
+ "clsx": "^2.1.1",
74
+ "rxjs": "^7.8.1",
75
+ "typescript": "^5.4.5",
76
+ "vite": "^5.2.12",
77
+ "vitest": "^1.6.0",
78
+ "@univerjs/engine-formula": "0.1.13",
79
+ "@univerjs/engine-render": "0.1.13",
80
+ "@univerjs/shared": "0.1.13",
81
+ "@univerjs/sheets": "0.1.13",
82
+ "@univerjs/core": "0.1.13",
83
+ "@univerjs/sheets-formula": "0.1.13",
84
+ "@univerjs/sheets-ui": "0.1.13",
85
+ "@univerjs/ui": "0.1.13"
86
+ },
87
+ "scripts": {
88
+ "test": "vitest run",
89
+ "test:watch": "vitest",
90
+ "coverage": "vitest run --coverage",
91
+ "lint:types": "tsc --noEmit",
92
+ "build": "tsc && vite build"
93
+ }
94
+ }