@univerjs/docs-hyper-link-ui 0.5.5-experimental.20250122-3362a4a → 0.5.5-nightly.202501201606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +9 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/index.js +539 -521
- package/lib/es/locale/en-US.js +2 -2
- package/lib/es/locale/fa-IR.js +2 -2
- package/lib/es/locale/fr-FR.js +2 -2
- package/lib/es/locale/ru-RU.js +2 -2
- package/lib/es/locale/vi-VN.js +2 -2
- package/lib/es/locale/zh-CN.js +2 -2
- package/lib/es/locale/zh-TW.js +2 -2
- package/lib/types/views/hyper-link-edit/index.d.ts +2 -16
- package/lib/types/views/hyper-link-popup/index.d.ts +2 -16
- package/lib/umd/index.js +9 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +9 -9
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@univerjs/core"),docsHyperLink=require("@univerjs/docs-hyper-link"),engineRender=require("@univerjs/engine-render"),docs=require("@univerjs/docs"),docsUi=require("@univerjs/docs-ui"),rxjs=require("rxjs"),jsxRuntime=require("react/jsx-runtime"),design=require("@univerjs/design"),ui=require("@univerjs/ui"),react=require("react"),DOCS_HYPER_LINK_UI_PLUGIN_CONFIG_KEY="docs-hyper-link-ui.config",defaultPluginConfig={},AddDocHyperLinkCommand={type:core.CommandType.COMMAND,id:"docs.command.add-hyper-link",async handler(accessor,params){if(!params)return!1;const{payload,unitId,selections}=params,commandService=accessor.get(core.ICommandService),id=core.generateRandomId(),doMutation=docs.addCustomRangeBySelectionFactory(accessor,{rangeId:id,rangeType:core.CustomRangeType.HYPERLINK,properties:{url:payload},unitId,selections});return doMutation?commandService.syncExecuteCommand(doMutation.id,doMutation.params):!1}},UpdateDocHyperLinkCommand={id:"docs.command.update-hyper-link",type:core.CommandType.COMMAND,handler(accessor,params){var _a7;if(!params)return!1;const{unitId,payload,segmentId,linkId}=params,commandService=accessor.get(core.ICommandService),univerInstanceService=accessor.get(core.IUniverInstanceService),currentSelection=accessor.get(docs.DocSelectionManagerService).getActiveTextRange(),doc=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC);if(!currentSelection||!doc)return!1;const textRun=(_a7=core.getBodySlice(doc.getSelfOrHeaderFooterModel(segmentId).getBody(),currentSelection.startOffset,currentSelection.endOffset).textRuns)==null?void 0:_a7[0];textRun&&(textRun.ed=params.label.length+1);const replaceSelection=docs.replaceSelectionFactory(accessor,{unitId,body:{dataStream:`${params.label}`,customRanges:[{rangeId:linkId,rangeType:core.CustomRangeType.HYPERLINK,startIndex:0,endIndex:params.label.length+1,properties:{url:payload}}],textRuns:textRun?[textRun]:void 0},selection:{startOffset:currentSelection.startOffset,endOffset:currentSelection.endOffset,collapsed:!1,segmentId}});return replaceSelection?commandService.syncExecuteCommand(replaceSelection.id,replaceSelection.params):!1}},docsLinkEdit="univer-docs-link-edit",docsLinkEditTitle="univer-docs-link-edit-title",docsLinkEditClose="univer-docs-link-edit-close",docsLinkEditButtons="univer-docs-link-edit-buttons",docsLinkEditButton="univer-docs-link-edit-button",styles$1={docsLinkEdit,docsLinkEditTitle,docsLinkEditClose,docsLinkEditButtons,docsLinkEditButton};function hasProtocol(urlString){return/^[a-zA-Z]+:\/\//.test(urlString)}__name(hasProtocol,"hasProtocol");function isEmail(url){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url)}__name(isEmail,"isEmail");function transformUrl(urlStr){return hasProtocol(urlStr)?urlStr:isEmail(urlStr)?`mailto://${urlStr}`:`https://${urlStr}`}__name(transformUrl,"transformUrl");const DocHyperLinkEdit=__name(()=>{const hyperLinkService=core.useDependency(DocHyperLinkPopupService),localeService=core.useDependency(core.LocaleService),editing=core.useObservable(hyperLinkService.editingLink$),commandService=core.useDependency(core.ICommandService),univerInstanceService=core.useDependency(core.IUniverInstanceService),docSelectionManagerService=core.useDependency(docs.DocSelectionManagerService),[link,setLink]=react.useState(""),[label,setLabel]=react.useState(""),[showError,setShowError]=react.useState(!1),isLegal=core.Tools.isLegalUrl(link),doc=editing?univerInstanceService.getUnit(editing.unitId,core.UniverInstanceType.UNIVER_DOC):univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC);react.useEffect(()=>{var _a7,_b,_c,_d,_e,_f,_g,_h,_i;const activeRange=docSelectionManagerService.getActiveTextRange();if(!activeRange)return;if(editing){const body2=(_a7=doc==null?void 0:doc.getSelfOrHeaderFooterModel(editing.segmentId))==null?void 0:_a7.getBody(),matchedRange2=(_b=body2==null?void 0:body2.customRanges)==null?void 0:_b.find(i=>(editing==null?void 0:editing.linkId)===i.rangeId&&i.startIndex===editing.startIndex&&i.endIndex===editing.endIndex);doc&&matchedRange2&&(setLink((_d=(_c=matchedRange2.properties)==null?void 0:_c.url)!=null?_d:""),setLabel(core.BuildTextUtils.transform.getPlainText(core.getBodySlice(body2,matchedRange2.startIndex,matchedRange2.endIndex+1).dataStream)));return}const body=(_e=doc==null?void 0:doc.getSelfOrHeaderFooterModel(activeRange.segmentId))==null?void 0:_e.getBody(),selection=body?activeRange:null,matchedRange=selection&&((_g=core.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(selection,(_f=body==null?void 0:body.customRanges)!=null?_f:[]))==null?void 0:_g[0]);doc&&matchedRange&&setLink((_i=(_h=matchedRange==null?void 0:matchedRange.properties)==null?void 0:_h.url)!=null?_i:"")},[doc,editing,docSelectionManagerService,univerInstanceService]);const handleCancel=__name(()=>{hyperLinkService.hideEditPopup()},"handleCancel"),handleConfirm=__name(()=>{if(setShowError(!0),!isLegal||!doc)return;const linkFinal=transformUrl(link);if(!editing)commandService.executeCommand(AddDocHyperLinkCommand.id,{unitId:doc.getUnitId(),payload:linkFinal});else{if(!label)return;commandService.executeCommand(UpdateDocHyperLinkCommand.id,{unitId:doc.getUnitId(),payload:linkFinal,linkId:editing.linkId,label,segmentId:editing.segmentId})}hyperLinkService.hideEditPopup()},"handleConfirm");if(doc)return jsxRuntime.jsxs("div",{className:styles$1.docsLinkEdit,children:[jsxRuntime.jsxs("div",{children:[editing?jsxRuntime.jsx(design.FormLayout,{label:localeService.t("docLink.edit.label"),error:showError&&!label?localeService.t("docLink.edit.labelError"):"",children:jsxRuntime.jsx(design.Input,{value:label,onChange:setLabel,autoFocus:!0,onKeyDown:__name(evt=>{evt.keyCode===ui.KeyCode.ENTER&&handleConfirm()},"onKeyDown")})}):null,jsxRuntime.jsx(design.FormLayout,{label:localeService.t("docLink.edit.address"),error:showError&&!isLegal?localeService.t("docLink.edit.addressError"):"",children:jsxRuntime.jsx(design.Input,{value:link,onChange:setLink,autoFocus:!0,onKeyDown:__name(evt=>{evt.keyCode===ui.KeyCode.ENTER&&handleConfirm()},"onKeyDown")})})]}),jsxRuntime.jsxs("div",{className:styles$1.docsLinkEditButtons,children:[jsxRuntime.jsx(design.Button,{className:styles$1.docsLinkEditButton,onClick:handleCancel,children:localeService.t("docLink.edit.cancel")}),jsxRuntime.jsx(design.Button,{disabled:!link,className:styles$1.docsLinkEditButton,type:"primary",onClick:handleConfirm,children:localeService.t("docLink.edit.confirm")})]})]})},"DocHyperLinkEdit");DocHyperLinkEdit.componentKey="docs-hyper-link-edit";var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=react.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=react.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return react.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a7){var key=_a7[0],value=_a7[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a7,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a7=node.children)===null||_a7===void 0)&&_a7.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid");IconBase.displayName="UniverIcon";var element$3={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},CopySingle=react.forwardRef(function(props,ref){return react.createElement(IconBase,Object.assign({},props,{id:"copy-single",ref,icon:element$3}))});CopySingle.displayName="CopySingle";var element$2={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},LinkSingle=react.forwardRef(function(props,ref){return react.createElement(IconBase,Object.assign({},props,{id:"link-single",ref,icon:element$2}))});LinkSingle.displayName="LinkSingle";var element$1={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"}}]},UnlinkSingle=react.forwardRef(function(props,ref){return react.createElement(IconBase,Object.assign({},props,{id:"unlink-single",ref,icon:element$1}))});UnlinkSingle.displayName="UnlinkSingle";var element={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"}}]},WriteSingle=react.forwardRef(function(props,ref){return react.createElement(IconBase,Object.assign({},props,{id:"write-single",ref,icon:element}))});WriteSingle.displayName="WriteSingle";function r(e){var t,f,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}__name(r,"r");function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}__name(clsx,"clsx");const DeleteDocHyperLinkCommand={type:core.CommandType.COMMAND,id:"docs.command.delete-hyper-link",async handler(accessor,params){if(!params)return!1;const{unitId,linkId,segmentId}=params,commandService=accessor.get(core.ICommandService),doMutation=docs.deleteCustomRangeFactory(accessor,{unitId,rangeId:linkId,segmentId});return doMutation?await commandService.syncExecuteCommand(doMutation.id,doMutation.params):!1}},shouldDisableAddLink=__name(accessor=>{const textSelectionService=accessor.get(docs.DocSelectionManagerService),univerInstanceService=accessor.get(core.IUniverInstanceService),textRanges=textSelectionService.getTextRanges();if(!(textRanges!=null&&textRanges.length))return!0;const activeRange=textRanges[0];return!!(!univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC)||!activeRange||activeRange.collapsed)},"shouldDisableAddLink"),ShowDocHyperLinkEditPopupOperation={type:core.CommandType.OPERATION,id:"doc.operation.show-hyper-link-edit-popup",handler(accessor,params){var _a7;const linkInfo=params==null?void 0:params.link,univerInstanceService=accessor.get(core.IUniverInstanceService);if(shouldDisableAddLink(accessor)&&!linkInfo)return!1;const hyperLinkService=accessor.get(DocHyperLinkPopupService),unitId=(linkInfo==null?void 0:linkInfo.unitId)||((_a7=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_DOC))==null?void 0:_a7.getUnitId());return unitId?(hyperLinkService.showEditPopup(unitId,linkInfo),!0):!1}},ToggleDocHyperLinkInfoPopupOperation={type:core.CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(accessor,params){const hyperLinkService=accessor.get(DocHyperLinkPopupService);return params?(hyperLinkService.showInfoPopup(params),!0):(hyperLinkService.hideInfoPopup(),!0)}},ClickDocHyperLinkOperation={type:core.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(accessor,params){var _a7,_b,_c;if(!params)return!1;const{unitId,linkId,segmentId}=params,doc=accessor.get(core.IUniverInstanceService).getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),body=doc==null?void 0:doc.getSelfOrHeaderFooterModel(segmentId).getBody(),link=(_c=(_b=(_a7=body==null?void 0:body.customRanges)==null?void 0:_a7.find(range=>range.rangeId===linkId&&range.rangeType===core.CustomRangeType.HYPERLINK))==null?void 0:_b.properties)==null?void 0:_c.url;return link&&window.open(link,"_blank","noopener noreferrer"),!0}},docLink="univer-doc-link",docLinkType="univer-doc-link-type",docLinkContent="univer-doc-link-content",docLinkContentError="univer-doc-link-content-error",docLinkUrl="univer-doc-link-url",docLinkOperations="univer-doc-link-operations",docLinkOperation="univer-doc-link-operation",docLinkOperationError="univer-doc-link-operation-error",styles={docLink,docLinkType,docLinkContent,docLinkContentError,docLinkUrl,docLinkOperations,docLinkOperation,docLinkOperationError},DocLinkPopup=__name(()=>{var _a7,_b;const hyperLinkService=core.useDependency(DocHyperLinkPopupService),commandService=core.useDependency(core.ICommandService),messageService=core.useDependency(ui.IMessageService),localeService=core.useDependency(core.LocaleService),currentPopup=ui.useObservable(hyperLinkService.showingLink$),univerInstanceService=core.useDependency(core.IUniverInstanceService);if(!currentPopup)return null;const{unitId,linkId,segmentId,startIndex,endIndex}=currentPopup,doc=univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),body=doc==null?void 0:doc.getSelfOrHeaderFooterModel(segmentId).getBody(),link=(_a7=body==null?void 0:body.customRanges)==null?void 0:_a7.find(range=>range.rangeId===linkId&&range.rangeType===core.CustomRangeType.HYPERLINK&&range.startIndex===startIndex&&range.endIndex===endIndex);if(!link)return null;const url=(_b=link.properties)==null?void 0:_b.url;return jsxRuntime.jsxs("div",{className:styles.docLink,onClick:__name(()=>{hyperLinkService.hideInfoPopup()},"onClick"),children:[jsxRuntime.jsxs("div",{className:clsx(styles.docLinkContent),onClick:__name(()=>window.open(url),"onClick"),children:[jsxRuntime.jsx("div",{className:styles.docLinkType,children:jsxRuntime.jsx(LinkSingle,{})}),jsxRuntime.jsx(design.Tooltip,{showIfEllipsis:!0,title:url,children:jsxRuntime.jsx("span",{className:styles.docLinkUrl,children:url})})]}),jsxRuntime.jsxs("div",{className:styles.docLinkOperations,children:[jsxRuntime.jsx("div",{className:clsx(styles.docLinkOperation),onClick:__name(()=>{navigator.clipboard.writeText(url),messageService.show({content:localeService.t("docLink.info.coped"),type:design.MessageType.Info})},"onClick"),children:jsxRuntime.jsx(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.copy"),children:jsxRuntime.jsx(CopySingle,{})})}),jsxRuntime.jsx("div",{className:styles.docLinkOperation,onClick:__name(()=>{commandService.executeCommand(ShowDocHyperLinkEditPopupOperation.id,{link:currentPopup})},"onClick"),children:jsxRuntime.jsx(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.edit"),children:jsxRuntime.jsx(WriteSingle,{})})}),jsxRuntime.jsx("div",{className:styles.docLinkOperation,onClick:__name(()=>{commandService.executeCommand(DeleteDocHyperLinkCommand.id,{unitId,linkId:link.rangeId,segmentId})},"onClick"),children:jsxRuntime.jsx(design.Tooltip,{placement:"bottom",title:localeService.t("docLink.info.cancel"),children:jsxRuntime.jsx(UnlinkSingle,{})})})]})]})},"DocLinkPopup");DocLinkPopup.componentKey="univer.doc.link-info-popup";var __defProp$5=Object.defineProperty,__getOwnPropDesc$5=Object.getOwnPropertyDescriptor,__decorateClass$5=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$5(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$5(target,key,result),result},"__decorateClass$5"),__decorateParam$5=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$5"),_a;let DocHyperLinkPopupService=(_a=class extends core.Disposable{constructor(_docCanvasPopupManagerService,_textSelectionManagerService,_univerInstanceService){super();__publicField(this,"_editingLink$",new rxjs.BehaviorSubject(null));__publicField(this,"_showingLink$",new rxjs.BehaviorSubject(null));__publicField(this,"editingLink$",this._editingLink$.asObservable());__publicField(this,"showingLink$",this._showingLink$.asObservable());__publicField(this,"_editPopup",null);__publicField(this,"_infoPopup",null);this._docCanvasPopupManagerService=_docCanvasPopupManagerService,this._textSelectionManagerService=_textSelectionManagerService,this._univerInstanceService=_univerInstanceService,this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(unitId,linkInfo){this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(linkInfo);const textRanges=this._textSelectionManagerService.getTextRanges({unitId,subUnitId:unitId});let activeRange=textRanges==null?void 0:textRanges[textRanges.length-1];if(linkInfo){const{segmentId,segmentPage,startIndex,endIndex}=linkInfo;activeRange={collapsed:!1,startOffset:startIndex,endOffset:endIndex+1,segmentId,segmentPage},this._textSelectionManagerService.replaceDocRanges([{startOffset:startIndex,endOffset:endIndex+1}])}return activeRange?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(activeRange,{componentKey:DocHyperLinkEdit.componentKey,direction:"bottom"},unitId),this._editPopup):null}hideEditPopup(){var _a7;this._editingLink$.next(null),(_a7=this._editPopup)==null||_a7.dispose()}showInfoPopup(info){var _a7,_b,_c,_d,_e,_f;const{linkId,unitId,segmentId,segmentPage,startIndex,endIndex}=info;if(!(((_a7=this.showing)==null?void 0:_a7.linkId)===linkId&&((_b=this.showing)==null?void 0:_b.unitId)===unitId&&((_c=this.showing)==null?void 0:_c.segmentId)===segmentId&&((_d=this.showing)==null?void 0:_d.segmentPage)===segmentPage&&((_e=this.showing)==null?void 0:_e.startIndex)===startIndex&&((_f=this.showing)==null?void 0:_f.endIndex)===endIndex||(this._infoPopup&&this._infoPopup.dispose(),!this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC))))return this._showingLink$.next({unitId,linkId,segmentId,segmentPage,startIndex,endIndex}),this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:startIndex,endOffset:endIndex+1,segmentId,segmentPage},{componentKey:DocLinkPopup.componentKey,direction:"top-center",multipleDirection:"top",onClickOutside:__name(()=>{this.hideInfoPopup()},"onClickOutside")},unitId),this._infoPopup}hideInfoPopup(){var _a7;this._showingLink$.next(null),(_a7=this._infoPopup)==null||_a7.dispose()}},__name(_a,"DocHyperLinkPopupService"),_a);DocHyperLinkPopupService=__decorateClass$5([__decorateParam$5(0,core.Inject(docsUi.DocCanvasPopManagerService)),__decorateParam$5(1,core.Inject(docs.DocSelectionManagerService)),__decorateParam$5(2,core.IUniverInstanceService)],DocHyperLinkPopupService);var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4"),_a2;let DocHyperLinkSelectionController=(_a2=class extends core.Disposable{constructor(_commandService,_univerInstanceService,_docHyperLinkService){super(),this._commandService=_commandService,this._univerInstanceService=_univerInstanceService,this._docHyperLinkService=_docHyperLinkService,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(commandInfo=>{var _a7,_b,_c;if(commandInfo.id===docs.SetTextSelectionsOperation.id){const params=commandInfo.params,{unitId,ranges,segmentId}=params,doc=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_DOC),primary=ranges[0];if(primary&&doc){const{startOffset,endOffset,collapsed,segmentPage}=primary,customRanges=(_b=(_a7=doc.getSelfOrHeaderFooterModel(segmentId))==null?void 0:_a7.getBody())==null?void 0:_b.customRanges;if(collapsed){const index=(_c=customRanges==null?void 0:customRanges.findIndex(value=>value.startIndex<startOffset&&value.endIndex>endOffset-1))!=null?_c:-1;if(index>-1){const customRange=customRanges[index];this._docHyperLinkService.showInfoPopup({unitId,linkId:customRange.rangeId,segmentId,segmentPage,startIndex:customRange.startIndex,endIndex:customRange.endIndex});return}}else if(customRanges==null?void 0:customRanges.find(value=>value.startIndex<=startOffset&&value.endIndex>=endOffset-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}},__name(_a2,"DocHyperLinkSelectionController"),_a2);DocHyperLinkSelectionController=__decorateClass$4([__decorateParam$4(0,core.ICommandService),__decorateParam$4(1,core.IUniverInstanceService),__decorateParam$4(2,core.Inject(DocHyperLinkPopupService))],DocHyperLinkSelectionController);var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3"),_a3;let DocHyperLinkEventRenderController=(_a3=class extends core.Disposable{constructor(_context,_docEventManagerService,_commandService,_hyperLinkPopupService,_docSkeletonManagerService,_docSelectionManagerService){super(),this._context=_context,this._docEventManagerService=_docEventManagerService,this._commandService=_commandService,this._hyperLinkPopupService=_hyperLinkPopupService,this._docSkeletonManagerService=_docSkeletonManagerService,this._docSelectionManagerService=_docSelectionManagerService,!(this._context.unitId===core.DOCS_ZEN_EDITOR_UNIT_ID_KEY||this._context.unitId===core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)&&(this._initHover(),this._initClick())}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(ToggleDocHyperLinkInfoPopupOperation.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(ranges=>{var _a7;const link=ranges.find(range=>range.range.rangeType===core.CustomRangeType.HYPERLINK),activeRanges=this._docSelectionManagerService.getTextRanges(),currentSegmentId=activeRanges==null?void 0:activeRanges[0].segmentId;if(((_a7=link==null?void 0:link.segmentId)!=null?_a7:"")!==currentSegmentId){this._hideInfoPopup();return}link?this._commandService.executeCommand(ToggleDocHyperLinkInfoPopupOperation.id,{unitId:this._context.unitId,linkId:link.range.rangeId,segmentId:link.segmentId,segmentPage:link.segmentPageIndex,rangeId:link.range.rangeId,startIndex:link.range.startIndex,endIndex:link.range.endIndex}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(range=>{const link=range.range;link&&this._commandService.executeCommand(ClickDocHyperLinkOperation.id,{unitId:this._context.unitId,linkId:link.rangeId,segmentId:range.segmentId})}))}},__name(_a3,"DocHyperLinkEventRenderController"),_a3);DocHyperLinkEventRenderController=__decorateClass$3([__decorateParam$3(1,core.Inject(docsUi.DocEventManagerService)),__decorateParam$3(2,core.ICommandService),__decorateParam$3(3,core.Inject(DocHyperLinkPopupService)),__decorateParam$3(4,core.Inject(docs.DocSkeletonManagerService)),__decorateParam$3(5,core.Inject(docs.DocSelectionManagerService))],DocHyperLinkEventRenderController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2"),_a4;let DocHyperLinkRenderController=(_a4=class extends core.Disposable{constructor(_context,_docInterceptorService,_hyperLinkService,_docRenderController){super(),this._context=_context,this._docInterceptorService=_docInterceptorService,this._hyperLinkService=_hyperLinkService,this._docRenderController=_docRenderController,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(docs.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:__name((data,pos,next)=>{if(!data)return next(data);const{unitId,index}=pos,activeLink=this._hyperLinkService.showing;if(!activeLink)return next({...data,active:!1});const{linkId,unitId:linkUnitId,startIndex,endIndex}=activeLink,isActive=linkUnitId===unitId&&data.rangeId===linkId&&index>=startIndex&&index<=endIndex;return next({...data,active:isActive})},"handler")})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(rxjs.distinctUntilChanged((prev,aft)=>(prev==null?void 0:prev.linkId)===(aft==null?void 0:aft.linkId)&&(prev==null?void 0:prev.unitId)===(aft==null?void 0:aft.unitId)&&(prev==null?void 0:prev.startIndex)===(aft==null?void 0:aft.startIndex)),rxjs.pairwise()).subscribe(([preLink,link])=>{link?link.unitId===this._context.unitId&&this._docRenderController.reRender(link.unitId):preLink&&preLink.unitId===this._context.unitId&&this._docRenderController.reRender(preLink.unitId)}))}},__name(_a4,"DocHyperLinkRenderController"),_a4);DocHyperLinkRenderController=__decorateClass$2([__decorateParam$2(1,core.Inject(docs.DocInterceptorService)),__decorateParam$2(2,core.Inject(DocHyperLinkPopupService)),__decorateParam$2(3,core.Inject(docsUi.DocRenderController))],DocHyperLinkRenderController);const DOC_LINK_ICON="doc-hyper-link-icon";function AddHyperLinkMenuItemFactory(accessor){return{id:ShowDocHyperLinkEditPopupOperation.id,type:ui.MenuItemType.BUTTON,icon:DOC_LINK_ICON,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_DOC),disabled$:new rxjs.Observable(function(subscribe){const observer=accessor.get(docs.DocSelectionManagerService).textSelection$.pipe(rxjs.debounceTime(16)).subscribe(()=>{subscribe.next(shouldDisableAddLink(accessor))});return()=>{observer.unsubscribe()}})}}__name(AddHyperLinkMenuItemFactory,"AddHyperLinkMenuItemFactory");const addLinkShortcut={id:ShowDocHyperLinkEditPopupOperation.id,binding:ui.MetaKeys.CTRL_COMMAND|ui.KeyCode.K,description:"docLink.menu.tooltip",preconditions:docsUi.whenDocAndEditorFocused},menuSchema={[ui.RibbonStartGroup.OTHERS]:{[ShowDocHyperLinkEditPopupOperation.id]:{order:0,menuItemFactory:AddHyperLinkMenuItemFactory}},[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.DATA]:{[ShowDocHyperLinkEditPopupOperation.id]:{order:0,menuItemFactory:AddHyperLinkMenuItemFactory}}}};var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1"),_a5;let DocHyperLinkUIController=(_a5=class extends core.Disposable{constructor(_componentManager,_commandService,_menuManagerService,_shortcutService){super(),this._componentManager=_componentManager,this._commandService=_commandService,this._menuManagerService=_menuManagerService,this._shortcutService=_shortcutService,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[DocHyperLinkEdit,DocHyperLinkEdit.componentKey],[DocLinkPopup,DocLinkPopup.componentKey],[LinkSingle,DOC_LINK_ICON]].forEach(([comp,key])=>{this._componentManager.register(key,comp)})}_initCommands(){[AddDocHyperLinkCommand,UpdateDocHyperLinkCommand,DeleteDocHyperLinkCommand,ShowDocHyperLinkEditPopupOperation,ToggleDocHyperLinkInfoPopupOperation,ClickDocHyperLinkOperation].forEach(command=>{this._commandService.registerCommand(command)})}_initShortcut(){[addLinkShortcut].forEach(shortcut=>{this._shortcutService.registerShortcut(shortcut)})}_initMenus(){this._menuManagerService.mergeMenu(menuSchema)}},__name(_a5,"DocHyperLinkUIController"),_a5);DocHyperLinkUIController=__decorateClass$1([__decorateParam$1(0,core.Inject(ui.ComponentManager)),__decorateParam$1(1,core.ICommandService),__decorateParam$1(2,ui.IMenuManagerService),__decorateParam$1(3,ui.IShortcutService)],DocHyperLinkUIController);const DOC_HYPER_LINK_UI_PLUGIN="DOC_HYPER_LINK_UI_PLUGIN";var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField"),_a6;exports.UniverDocsHyperLinkUIPlugin=(_a6=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_renderManagerSrv,_configService){super(),this._config=_config,this._injector=_injector,this._renderManagerSrv=_renderManagerSrv,this._configService=_configService;const{menu,...rest}=core.merge({},defaultPluginConfig,this._config);menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(DOCS_HYPER_LINK_UI_PLUGIN_CONFIG_KEY,rest)}onStarting(){[[DocHyperLinkPopupService],[DocHyperLinkUIController],[DocHyperLinkSelectionController]].forEach(dep=>{this._injector.add(dep)}),this._injector.get(DocHyperLinkUIController)}onReady(){this._injector.get(DocHyperLinkSelectionController)}onRendered(){this._initRenderModule()}_initRenderModule(){[[DocHyperLinkRenderController],[DocHyperLinkEventRenderController]].forEach(dep=>{this._renderManagerSrv.registerRenderModule(core.UniverInstanceType.UNIVER_DOC,dep)})}},__name(_a6,"UniverDocsHyperLinkUIPlugin"),_a6);__publicField2(exports.UniverDocsHyperLinkUIPlugin,"pluginName",DOC_HYPER_LINK_UI_PLUGIN);__publicField2(exports.UniverDocsHyperLinkUIPlugin,"type",core.UniverInstanceType.UNIVER_DOC);exports.UniverDocsHyperLinkUIPlugin=__decorateClass([core.DependentOn(docsHyperLink.UniverDocsHyperLinkPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,engineRender.IRenderManagerService),__decorateParam(3,core.IConfigService)],exports.UniverDocsHyperLinkUIPlugin);
|
|
1
|
+
"use strict";var Pe=Object.defineProperty;var Re=(n,e,t)=>e in n?Pe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var P=(n,e,t)=>Re(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),Ee=require("@univerjs/docs-hyper-link"),De=require("@univerjs/engine-render"),C=require("@univerjs/docs"),K=require("@univerjs/docs-ui"),R=require("rxjs"),m=require("react"),S=require("@univerjs/design"),_=require("@univerjs/ui"),be="docs-hyper-link-ui.config",ae={};var V={exports:{}},D={};/**
|
|
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 le;function Me(){if(le)return D;le=1;var n=m,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function c(d,a,f){var u,v={},g=null,l=null;f!==void 0&&(g=""+f),a.key!==void 0&&(g=""+a.key),a.ref!==void 0&&(l=a.ref);for(u in a)i.call(a,u)&&!s.hasOwnProperty(u)&&(v[u]=a[u]);if(d&&d.defaultProps)for(u in a=d.defaultProps,a)v[u]===void 0&&(v[u]=a[u]);return{$$typeof:e,type:d,key:g,ref:l,props:v,_owner:r.current}}return D.Fragment=t,D.jsx=c,D.jsxs=c,D}var ue;function Ue(){return ue||(ue=1,V.exports=Me()),V.exports}var p=Ue();const ge={type:o.CommandType.COMMAND,id:"docs.command.add-hyper-link",async handler(n,e){if(!e)return!1;const{payload:t,unitId:i,selections:r}=e,s=n.get(o.ICommandService),c=o.generateRandomId(),d=C.addCustomRangeBySelectionFactory(n,{rangeId:c,rangeType:o.CustomRangeType.HYPERLINK,properties:{url:t},unitId:i,selections:r});return d?s.syncExecuteCommand(d.id,d.params):!1}},he={id:"docs.command.update-hyper-link",type:o.CommandType.COMMAND,handler(n,e){var I;if(!e)return!1;const{unitId:t,payload:i,segmentId:r,linkId:s}=e,c=n.get(o.ICommandService),d=n.get(o.IUniverInstanceService),f=n.get(C.DocSelectionManagerService).getActiveTextRange(),u=d.getUnit(t,o.UniverInstanceType.UNIVER_DOC);if(!f||!u)return!1;const g=(I=o.getBodySlice(u.getSelfOrHeaderFooterModel(r).getBody(),f.startOffset,f.endOffset).textRuns)==null?void 0:I[0];g&&(g.ed=e.label.length+1);const l=C.replaceSelectionFactory(n,{unitId:t,body:{dataStream:`${e.label}`,customRanges:[{rangeId:s,rangeType:o.CustomRangeType.HYPERLINK,startIndex:0,endIndex:e.label.length+1,properties:{url:i}}],textRuns:g?[g]:void 0},selection:{startOffset:f.startOffset,endOffset:f.endOffset,collapsed:!1,segmentId:r}});return l?c.syncExecuteCommand(l.id,l.params):!1}},we="univer-docs-link-edit",Te="univer-docs-link-edit-title",je="univer-docs-link-edit-close",Ne="univer-docs-link-edit-buttons",$e="univer-docs-link-edit-button",j={docsLinkEdit:we,docsLinkEditTitle:Te,docsLinkEditClose:je,docsLinkEditButtons:Ne,docsLinkEditButton:$e};function He(n){return/^[a-zA-Z]+:\/\//.test(n)}function Be(n){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(n)}function Ae(n){return He(n)?n:Be(n)?`mailto://${n}`:`https://${n}`}const $=()=>{const n=o.useDependency(k),e=o.useDependency(o.LocaleService),t=o.useObservable(n.editingLink$),i=o.useDependency(o.ICommandService),r=o.useDependency(o.IUniverInstanceService),s=o.useDependency(C.DocSelectionManagerService),[c,d]=m.useState(""),[a,f]=m.useState(""),[u,v]=m.useState(!1),g=o.Tools.isLegalUrl(c),l=t?r.getUnit(t.unitId,o.UniverInstanceType.UNIVER_DOC):r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);m.useEffect(()=>{var ee,ne,te,ie,re,oe,se,ce,de;const h=s.getActiveTextRange();if(!h)return;if(t){const w=(ee=l==null?void 0:l.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:ee.getBody(),T=(ne=w==null?void 0:w.customRanges)==null?void 0:ne.find(F=>(t==null?void 0:t.linkId)===F.rangeId&&F.startIndex===t.startIndex&&F.endIndex===t.endIndex);l&&T&&(d((ie=(te=T.properties)==null?void 0:te.url)!=null?ie:""),f(o.BuildTextUtils.transform.getPlainText(o.getBodySlice(w,T.startIndex,T.endIndex+1).dataStream)));return}const x=(re=l==null?void 0:l.getSelfOrHeaderFooterModel(h.segmentId))==null?void 0:re.getBody(),X=x?h:null,U=X&&((se=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(X,(oe=x==null?void 0:x.customRanges)!=null?oe:[]))==null?void 0:se[0]);l&&U&&d((de=(ce=U==null?void 0:U.properties)==null?void 0:ce.url)!=null?de:"")},[l,t,s,r]);const I=()=>{n.hideEditPopup()},L=()=>{if(v(!0),!g||!l)return;const h=Ae(c);if(!t)i.executeCommand(ge.id,{unitId:l.getUnitId(),payload:h});else{if(!a)return;i.executeCommand(he.id,{unitId:l.getUnitId(),payload:h,linkId:t.linkId,label:a,segmentId:t.segmentId})}n.hideEditPopup()};if(l)return p.jsxs("div",{className:j.docsLinkEdit,children:[p.jsxs("div",{children:[t?p.jsx(S.FormLayout,{label:e.t("docLink.edit.label"),error:u&&!a?e.t("docLink.edit.labelError"):"",children:p.jsx(S.Input,{value:a,onChange:f,autoFocus:!0,onKeyDown:h=>{h.keyCode===_.KeyCode.ENTER&&L()}})}):null,p.jsx(S.FormLayout,{label:e.t("docLink.edit.address"),error:u&&!g?e.t("docLink.edit.addressError"):"",children:p.jsx(S.Input,{value:c,onChange:d,autoFocus:!0,onKeyDown:h=>{h.keyCode===_.KeyCode.ENTER&&L()}})})]}),p.jsxs("div",{className:j.docsLinkEditButtons,children:[p.jsx(S.Button,{className:j.docsLinkEditButton,onClick:I,children:e.t("docLink.edit.cancel")}),p.jsx(S.Button,{disabled:!c,className:j.docsLinkEditButton,type:"primary",onClick:L,children:e.t("docLink.edit.confirm")})]})]})};$.componentKey="docs-hyper-link-edit";var y=function(){return y=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},y.apply(this,arguments)},Ke=function(n,e){var t={};for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(n);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(n,i[r])&&(t[i[r]]=n[i[r]]);return t},M=m.forwardRef(function(n,e){var t=n.icon,i=n.id,r=n.className,s=n.extend,c=Ke(n,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),a=m.useRef("_".concat(qe()));return ve(t,"".concat(i),{defIds:t.defIds,idSuffix:a.current},y({ref:e,className:d},c),s)});function ve(n,e,t,i,r){return m.createElement(n.tag,y(y({key:e},Fe(n,t,r)),i),(Ve(n,t).children||[]).map(function(s,c){return ve(s,"".concat(e,"-").concat(n.tag,"-").concat(c),t,void 0,r)}))}function Fe(n,e,t){var i=y({},n.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1);var r=e.defIds;return!r||r.length===0||(n.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(s){var c=s[0],d=s[1];typeof d=="string"&&(i[c]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function Ve(n,e){var t,i=e.defIds;return!i||i.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?y(y({},n),{children:n.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?y(y({},r),{attrs:y(y({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):n}function qe(){return Math.random().toString(36).substring(2,8)}M.displayName="UniverIcon";var Ye={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ie=m.forwardRef(function(n,e){return m.createElement(M,Object.assign({},n,{id:"copy-single",ref:e,icon:Ye}))});Ie.displayName="CopySingle";var Ze={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},Q=m.forwardRef(function(n,e){return m.createElement(M,Object.assign({},n,{id:"link-single",ref:e,icon:Ze}))});Q.displayName="LinkSingle";var We={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"}}]},me=m.forwardRef(function(n,e){return m.createElement(M,Object.assign({},n,{id:"unlink-single",ref:e,icon:We}))});me.displayName="UnlinkSingle";var Ge={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"}}]},_e=m.forwardRef(function(n,e){return m.createElement(M,Object.assign({},n,{id:"write-single",ref:e,icon:Ge}))});_e.displayName="WriteSingle";function Ce(n){var e,t,i="";if(typeof n=="string"||typeof n=="number")i+=n;else if(typeof n=="object")if(Array.isArray(n)){var r=n.length;for(e=0;e<r;e++)n[e]&&(t=Ce(n[e]))&&(i&&(i+=" "),i+=t)}else for(t in n)n[t]&&(i&&(i+=" "),i+=t);return i}function pe(){for(var n,e,t=0,i="",r=arguments.length;t<r;t++)(n=arguments[t])&&(e=Ce(n))&&(i&&(i+=" "),i+=e);return i}const ye={type:o.CommandType.COMMAND,id:"docs.command.delete-hyper-link",async handler(n,e){if(!e)return!1;const{unitId:t,linkId:i,segmentId:r}=e,s=n.get(o.ICommandService),c=C.deleteCustomRangeFactory(n,{unitId:t,rangeId:i,segmentId:r});return c?await s.syncExecuteCommand(c.id,c.params):!1}},Se=n=>{const e=n.get(C.DocSelectionManagerService),t=n.get(o.IUniverInstanceService),i=e.getTextRanges();if(!(i!=null&&i.length))return!0;const r=i[0];return!!(!t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC)||!r||r.collapsed)},E={type:o.CommandType.OPERATION,id:"doc.operation.show-hyper-link-edit-popup",handler(n,e){var c;const t=e==null?void 0:e.link,i=n.get(o.IUniverInstanceService);if(Se(n)&&!t)return!1;const r=n.get(k),s=(t==null?void 0:t.unitId)||((c=i.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:c.getUnitId());return s?(r.showEditPopup(s,t),!0):!1}},G={type:o.CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(n,e){const t=n.get(k);return e?(t.showInfoPopup(e),!0):(t.hideInfoPopup(),!0)}},Le={type:o.CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(n,e){var f,u,v;if(!e)return!1;const{unitId:t,linkId:i,segmentId:r}=e,c=n.get(o.IUniverInstanceService).getUnit(t,o.UniverInstanceType.UNIVER_DOC),d=c==null?void 0:c.getSelfOrHeaderFooterModel(r).getBody(),a=(v=(u=(f=d==null?void 0:d.customRanges)==null?void 0:f.find(g=>g.rangeId===i&&g.rangeType===o.CustomRangeType.HYPERLINK))==null?void 0:u.properties)==null?void 0:v.url;return a&&window.open(a,"_blank","noopener noreferrer"),!0}},Je="univer-doc-link",ze="univer-doc-link-type",Qe="univer-doc-link-content",Xe="univer-doc-link-content-error",en="univer-doc-link-url",nn="univer-doc-link-operations",tn="univer-doc-link-operation",rn="univer-doc-link-operation-error",O={docLink:Je,docLinkType:ze,docLinkContent:Qe,docLinkContentError:Xe,docLinkUrl:en,docLinkOperations:nn,docLinkOperation:tn,docLinkOperationError:rn},H=()=>{var L,h;const n=o.useDependency(k),e=o.useDependency(o.ICommandService),t=o.useDependency(_.IMessageService),i=o.useDependency(o.LocaleService),r=_.useObservable(n.showingLink$),s=o.useDependency(o.IUniverInstanceService);if(!r)return null;const{unitId:c,linkId:d,segmentId:a,startIndex:f,endIndex:u}=r,v=s.getUnit(c,o.UniverInstanceType.UNIVER_DOC),g=v==null?void 0:v.getSelfOrHeaderFooterModel(a).getBody(),l=(L=g==null?void 0:g.customRanges)==null?void 0:L.find(x=>x.rangeId===d&&x.rangeType===o.CustomRangeType.HYPERLINK&&x.startIndex===f&&x.endIndex===u);if(!l)return null;const I=(h=l.properties)==null?void 0:h.url;return p.jsxs("div",{className:O.docLink,onClick:()=>{n.hideInfoPopup()},children:[p.jsxs("div",{className:pe(O.docLinkContent),onClick:()=>window.open(I),children:[p.jsx("div",{className:O.docLinkType,children:p.jsx(Q,{})}),p.jsx(S.Tooltip,{showIfEllipsis:!0,title:I,children:p.jsx("span",{className:O.docLinkUrl,children:I})})]}),p.jsxs("div",{className:O.docLinkOperations,children:[p.jsx("div",{className:pe(O.docLinkOperation),onClick:()=>{navigator.clipboard.writeText(I),t.show({content:i.t("docLink.info.coped"),type:S.MessageType.Info})},children:p.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.copy"),children:p.jsx(Ie,{})})}),p.jsx("div",{className:O.docLinkOperation,onClick:()=>{e.executeCommand(E.id,{link:r})},children:p.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.edit"),children:p.jsx(_e,{})})}),p.jsx("div",{className:O.docLinkOperation,onClick:()=>{e.executeCommand(ye.id,{unitId:c,linkId:l.rangeId,segmentId:a})},children:p.jsx(S.Tooltip,{placement:"bottom",title:i.t("docLink.info.cancel"),children:p.jsx(me,{})})})]})]})};H.componentKey="univer.doc.link-info-popup";var on=Object.defineProperty,sn=Object.getOwnPropertyDescriptor,cn=(n,e,t,i)=>{for(var r=i>1?void 0:i?sn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&on(e,t,r),r},q=(n,e)=>(t,i)=>e(t,i,n);let k=class extends o.Disposable{constructor(e,t,i){super();P(this,"_editingLink$",new R.BehaviorSubject(null));P(this,"_showingLink$",new R.BehaviorSubject(null));P(this,"editingLink$",this._editingLink$.asObservable());P(this,"showingLink$",this._showingLink$.asObservable());P(this,"_editPopup",null);P(this,"_infoPopup",null);this._docCanvasPopupManagerService=e,this._textSelectionManagerService=t,this._univerInstanceService=i,this.disposeWithMe(()=>{this._editingLink$.complete(),this._showingLink$.complete()})}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(e,t){this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(t);const i=this._textSelectionManagerService.getTextRanges({unitId:e,subUnitId:e});let r=i==null?void 0:i[i.length-1];if(t){const{segmentId:s,segmentPage:c,startIndex:d,endIndex:a}=t;r={collapsed:!1,startOffset:d,endOffset:a+1,segmentId:s,segmentPage:c},this._textSelectionManagerService.replaceDocRanges([{startOffset:d,endOffset:a+1}])}return r?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(r,{componentKey:$.componentKey,direction:"bottom"},e),this._editPopup):null}hideEditPopup(){var e;this._editingLink$.next(null),(e=this._editPopup)==null||e.dispose()}showInfoPopup(e){var f,u,v,g,l,I;const{linkId:t,unitId:i,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}=e;if(!(((f=this.showing)==null?void 0:f.linkId)===t&&((u=this.showing)==null?void 0:u.unitId)===i&&((v=this.showing)==null?void 0:v.segmentId)===r&&((g=this.showing)==null?void 0:g.segmentPage)===s&&((l=this.showing)==null?void 0:l.startIndex)===c&&((I=this.showing)==null?void 0:I.endIndex)===d||(this._infoPopup&&this._infoPopup.dispose(),!this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_DOC))))return this._showingLink$.next({unitId:i,linkId:t,segmentId:r,segmentPage:s,startIndex:c,endIndex:d}),this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:c,endOffset:d+1,segmentId:r,segmentPage:s},{componentKey:H.componentKey,direction:"top-center",multipleDirection:"top",onClickOutside:()=>{this.hideInfoPopup()}},i),this._infoPopup}hideInfoPopup(){var e;this._showingLink$.next(null),(e=this._infoPopup)==null||e.dispose()}};k=cn([q(0,o.Inject(K.DocCanvasPopManagerService)),q(1,o.Inject(C.DocSelectionManagerService)),q(2,o.IUniverInstanceService)],k);var dn=Object.defineProperty,an=Object.getOwnPropertyDescriptor,ln=(n,e,t,i)=>{for(var r=i>1?void 0:i?an(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&dn(e,t,r),r},Y=(n,e)=>(t,i)=>e(t,i,n);let B=class extends o.Disposable{constructor(n,e,t){super(),this._commandService=n,this._univerInstanceService=e,this._docHyperLinkService=t,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var e,t,i;if(n.id===C.SetTextSelectionsOperation.id){const r=n.params,{unitId:s,ranges:c,segmentId:d}=r,a=this._univerInstanceService.getUnit(s,o.UniverInstanceType.UNIVER_DOC),f=c[0];if(f&&a){const{startOffset:u,endOffset:v,collapsed:g,segmentPage:l}=f,I=(t=(e=a.getSelfOrHeaderFooterModel(d))==null?void 0:e.getBody())==null?void 0:t.customRanges;if(g){const L=(i=I==null?void 0:I.findIndex(h=>h.startIndex<u&&h.endIndex>v-1))!=null?i:-1;if(L>-1){const h=I[L];this._docHyperLinkService.showInfoPopup({unitId:s,linkId:h.rangeId,segmentId:d,segmentPage:l,startIndex:h.startIndex,endIndex:h.endIndex});return}}else if(I==null?void 0:I.find(h=>h.startIndex<=u&&h.endIndex>=v-1))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};B=ln([Y(0,o.ICommandService),Y(1,o.IUniverInstanceService),Y(2,o.Inject(k))],B);var un=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,fn=(n,e,t,i)=>{for(var r=i>1?void 0:i?pn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&un(e,t,r),r},b=(n,e)=>(t,i)=>e(t,i,n);let J=class extends o.Disposable{constructor(n,e,t,i,r,s){super(),this._context=n,this._docEventManagerService=e,this._commandService=t,this._hyperLinkPopupService=i,this._docSkeletonManagerService=r,this._docSelectionManagerService=s,!(this._context.unitId===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY||this._context.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)&&(this._initHover(),this._initClick())}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(G.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(n=>{var r;const e=n.find(s=>s.range.rangeType===o.CustomRangeType.HYPERLINK),t=this._docSelectionManagerService.getTextRanges(),i=t==null?void 0:t[0].segmentId;if(((r=e==null?void 0:e.segmentId)!=null?r:"")!==i){this._hideInfoPopup();return}e?this._commandService.executeCommand(G.id,{unitId:this._context.unitId,linkId:e.range.rangeId,segmentId:e.segmentId,segmentPage:e.segmentPageIndex,rangeId:e.range.rangeId,startIndex:e.range.startIndex,endIndex:e.range.endIndex}):this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(n=>{const e=n.range;e&&this._commandService.executeCommand(Le.id,{unitId:this._context.unitId,linkId:e.rangeId,segmentId:n.segmentId})}))}};J=fn([b(1,o.Inject(K.DocEventManagerService)),b(2,o.ICommandService),b(3,o.Inject(k)),b(4,o.Inject(C.DocSkeletonManagerService)),b(5,o.Inject(C.DocSelectionManagerService))],J);var gn=Object.defineProperty,hn=Object.getOwnPropertyDescriptor,vn=(n,e,t,i)=>{for(var r=i>1?void 0:i?hn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&gn(e,t,r),r},Z=(n,e)=>(t,i)=>e(t,i,n);let z=class extends o.Disposable{constructor(n,e,t,i){super(),this._context=n,this._docInterceptorService=e,this._hyperLinkService=t,this._docRenderController=i,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(C.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:(n,e,t)=>{if(!n)return t(n);const{unitId:i,index:r}=e,s=this._hyperLinkService.showing;if(!s)return t({...n,active:!1});const{linkId:c,unitId:d,startIndex:a,endIndex:f}=s,u=d===i&&n.rangeId===c&&r>=a&&r<=f;return t({...n,active:u})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(R.distinctUntilChanged((n,e)=>(n==null?void 0:n.linkId)===(e==null?void 0:e.linkId)&&(n==null?void 0:n.unitId)===(e==null?void 0:e.unitId)&&(n==null?void 0:n.startIndex)===(e==null?void 0:e.startIndex)),R.pairwise()).subscribe(([n,e])=>{e?e.unitId===this._context.unitId&&this._docRenderController.reRender(e.unitId):n&&n.unitId===this._context.unitId&&this._docRenderController.reRender(n.unitId)}))}};z=vn([Z(1,o.Inject(C.DocInterceptorService)),Z(2,o.Inject(k)),Z(3,o.Inject(K.DocRenderController))],z);const ke="doc-hyper-link-icon";function fe(n){return{id:E.id,type:_.MenuItemType.BUTTON,icon:ke,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:_.getMenuHiddenObservable(n,o.UniverInstanceType.UNIVER_DOC),disabled$:new R.Observable(function(e){const i=n.get(C.DocSelectionManagerService).textSelection$.pipe(R.debounceTime(16)).subscribe(()=>{e.next(Se(n))});return()=>{i.unsubscribe()}})}}const In={id:E.id,binding:_.MetaKeys.CTRL_COMMAND|_.KeyCode.K,description:"docLink.menu.tooltip",preconditions:K.whenDocAndEditorFocused},mn={[_.RibbonStartGroup.OTHERS]:{[E.id]:{order:0,menuItemFactory:fe}},[_.ContextMenuPosition.MAIN_AREA]:{[_.ContextMenuGroup.DATA]:{[E.id]:{order:0,menuItemFactory:fe}}}};var _n=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,yn=(n,e,t,i)=>{for(var r=i>1?void 0:i?Cn(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&_n(e,t,r),r},N=(n,e)=>(t,i)=>e(t,i,n);let A=class extends o.Disposable{constructor(n,e,t,i){super(),this._componentManager=n,this._commandService=e,this._menuManagerService=t,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[$,$.componentKey],[H,H.componentKey],[Q,ke]].forEach(([n,e])=>{this._componentManager.register(e,n)})}_initCommands(){[ge,he,ye,E,G,Le].forEach(n=>{this._commandService.registerCommand(n)})}_initShortcut(){[In].forEach(n=>{this._shortcutService.registerShortcut(n)})}_initMenus(){this._menuManagerService.mergeMenu(mn)}};A=yn([N(0,o.Inject(_.ComponentManager)),N(1,o.ICommandService),N(2,_.IMenuManagerService),N(3,_.IShortcutService)],A);const Sn="DOC_HYPER_LINK_UI_PLUGIN";var xe=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,kn=(n,e,t)=>e in n?xe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,xn=(n,e,t,i)=>{for(var r=i>1?void 0:i?Ln(e,t):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(r=(i?c(e,t,r):c(r))||r);return i&&r&&xe(e,t,r),r},W=(n,e)=>(t,i)=>e(t,i,n),Oe=(n,e,t)=>kn(n,typeof e!="symbol"?e+"":e,t);exports.UniverDocsHyperLinkUIPlugin=class extends o.Plugin{constructor(e=ae,t,i,r){super(),this._config=e,this._injector=t,this._renderManagerSrv=i,this._configService=r;const{menu:s,...c}=o.merge({},ae,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(be,c)}onStarting(){[[k],[A],[B]].forEach(t=>{this._injector.add(t)}),this._injector.get(A)}onReady(){this._injector.get(B)}onRendered(){this._initRenderModule()}_initRenderModule(){[[z],[J]].forEach(e=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,e)})}};Oe(exports.UniverDocsHyperLinkUIPlugin,"pluginName",Sn);Oe(exports.UniverDocsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC);exports.UniverDocsHyperLinkUIPlugin=xn([o.DependentOn(Ee.UniverDocsHyperLinkPlugin),W(1,o.Inject(o.Injector)),W(2,De.IRenderManagerService),W(3,o.IConfigService)],exports.UniverDocsHyperLinkUIPlugin);
|
package/lib/cjs/locale/en-US.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const l={docLink:{edit:{confirm:"Confirm",cancel:"Cancel",title:"Link",address:"Link",placeholder:"Please input a link url",addressError:"Url is illegal!",label:"Label",labelError:"Please input label of link"},info:{copy:"Copy",edit:"Edit",cancel:"Cancel link",coped:"Link copied to clipboard"},menu:{tooltip:"Add link"}}};module.exports=l;
|
package/lib/cjs/locale/fa-IR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const e={docLink:{edit:{confirm:"تایید",cancel:"انصراف",title:"لینک",address:"لینک",placeholder:"لطفا یک آدرس لینک وارد کنید",addressError:"آدرس غیرمجاز است!",label:"برچسب",labelError:"لطفا برچسب لینک را وارد کنید"},info:{copy:"کپی",edit:"ویرایش",cancel:"لینک را لغو کنید",coped:"لینک به کلیپ بورد کپی شد"},menu:{tooltip:"افزودن لینک"}}};module.exports=e;
|
package/lib/cjs/locale/fr-FR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const e={docLink:{edit:{confirm:"Confirmer",cancel:"Annuler",title:"Lien",address:"Link",placeholder:"Veuillez entrer un lien",addressError:"L'url est illégal!",label:"Label",labelError:"Veuillez entrer le label du lien"},info:{copy:"Copy",edit:"Edit",cancel:"Cancel link",coped:"Link copied to clipboard"},menu:{tooltip:"Add link"}}};module.exports=e;
|
package/lib/cjs/locale/ru-RU.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const e={docLink:{edit:{confirm:"Подтвердить",cancel:"Отменить",title:"Ссылка",address:"Cсылки",label:"Текст",labelError:"Введите текст ссылки",placeholder:"Пожалуйста, введите URL ссылки",addressError:"URL некорректен!"},info:{copy:"Копировать",edit:"Редактировать",cancel:"Отменить ссылку",coped:"Link copied to clipboard"},menu:{tooltip:"Добавить ссылку"}}};module.exports=e;
|
package/lib/cjs/locale/vi-VN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const n={docLink:{edit:{confirm:"Xác nhận",cancel:"Hủy",title:"Liên kết",address:"Liên kết",label:"Nhãn",labelError:"Vui lòng nhập nhãn liên kết",placeholder:"Vui lòng nhập liên kết hợp lệ",addressError:"Vui lòng nhập liên kết hợp lệ"},info:{copy:"Sao chép",edit:"Chỉnh sửa",cancel:"Hủy liên kết",coped:"Liên kết đã được sao chép vào clipboard"},menu:{tooltip:"Thêm liên kết"}}};module.exports=n;
|
package/lib/cjs/locale/zh-CN.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const e={docLink:{edit:{confirm:"确认",cancel:"取消",title:"链接",address:"链接",label:"文本",labelError:"请输入链接文本",placeholder:"请输入合法的链接",addressError:"请输入合法的链接"},info:{copy:"复制",edit:"编辑",cancel:"取消链接",coped:"链接已被复制到剪贴板"},menu:{tooltip:"添加链接"}}};module.exports=e;
|
package/lib/cjs/locale/zh-TW.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const e={docLink:{edit:{confirm:"確認",cancel:"取消",title:"連結",address:"連結",label:"文本",labelError:"请输入链接文本",placeholder:"請輸入合法的連結",addressError:"請輸入合法的連結"},info:{copy:"複製",edit:"編輯",cancel:"取消連結",coped:"連結已複製到剪貼板"},menu:{tooltip:"新增連結"}}};module.exports=e;
|