@univerjs/docs-hyper-link-ui 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -470,6 +470,9 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends _univerjs_
470
470
  return this._infoPopupPinned;
471
471
  }
472
472
  showEditPopup(unitId, linkInfo) {
473
+ var _getEditorRuntimeConf;
474
+ const doc = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
475
+ if (doc && ((_getEditorRuntimeConf = (0, _univerjs_docs_ui.getEditorRuntimeConfig)(doc)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.customHyperLinkUI)) return null;
473
476
  if (!this.canEditLink(unitId, linkInfo)) return null;
474
477
  if (this._editPopup) {
475
478
  this._editPopup.dispose();
@@ -511,6 +514,9 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends _univerjs_
511
514
  this._editPopupUnitId = null;
512
515
  }
513
516
  showInfoPopup(info, options) {
517
+ var _getEditorRuntimeConf2;
518
+ const doc = this._univerInstanceService.getUnit(info.unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
519
+ if (!(doc instanceof _univerjs_core.DocumentDataModel) || ((_getEditorRuntimeConf2 = (0, _univerjs_docs_ui.getEditorRuntimeConfig)(doc)) === null || _getEditorRuntimeConf2 === void 0 ? void 0 : _getEditorRuntimeConf2.customHyperLinkUI)) return;
514
520
  this.cancelScheduledHideInfoPopup();
515
521
  if (this._infoPopupSuppressed) return;
516
522
  const { linkId, unitId, segmentId, segmentPage, startIndex, endIndex } = info;
@@ -522,7 +528,6 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends _univerjs_
522
528
  this._infoPopup.dispose();
523
529
  this._infoPopup = null;
524
530
  }
525
- if (!(this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC) instanceof _univerjs_core.DocumentDataModel)) return;
526
531
  this._infoPopupPinned = (options === null || options === void 0 ? void 0 : options.pinned) ?? false;
527
532
  this._showingLink$.next({
528
533
  unitId,
@@ -785,7 +790,7 @@ const menuSchema = {
785
790
  //#endregion
786
791
  //#region package.json
787
792
  var name = "@univerjs/docs-hyper-link-ui";
788
- var version = "1.0.2";
793
+ var version = "1.0.3";
789
794
 
790
795
  //#endregion
791
796
  //#region src/config/config.ts
@@ -1291,6 +1296,7 @@ let DocHyperLinkEventRenderController = class DocHyperLinkEventRenderController
1291
1296
  return this._docSkeletonManagerService.getSkeleton();
1292
1297
  }
1293
1298
  constructor(_context, _docEventManagerService, _commandService, _hyperLinkPopupService, _docSkeletonManagerService, _docSelectionManagerService) {
1299
+ var _getEditorRuntimeConf;
1294
1300
  super();
1295
1301
  this._context = _context;
1296
1302
  this._docEventManagerService = _docEventManagerService;
@@ -1298,7 +1304,7 @@ let DocHyperLinkEventRenderController = class DocHyperLinkEventRenderController
1298
1304
  this._hyperLinkPopupService = _hyperLinkPopupService;
1299
1305
  this._docSkeletonManagerService = _docSkeletonManagerService;
1300
1306
  this._docSelectionManagerService = _docSelectionManagerService;
1301
- if (this._context.unitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY) return;
1307
+ if (this._context.unitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY || ((_getEditorRuntimeConf = (0, _univerjs_docs_ui.getEditorRuntimeConfig)(this._context.unit)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.customHyperLinkUI)) return;
1302
1308
  this._initPointerDown();
1303
1309
  this._initHover();
1304
1310
  this._initClick();
package/lib/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DocBackScrollRenderController, DocCanvasPopManagerService, DocEventManagerService, DocMobileElementMenuService, EMPTY_PARAGRAPH_MENU_ID, FLOAT_TOOLBAR_MENU_POSITION, INSERT_BELLOW_MENU_ID, MOBILE_DOC_ELEMENT_MENU, UniverDocsMobileUIPlugin, UniverDocsUIPlugin, whenDocAndEditorFocused } from "@univerjs/docs-ui";
1
+ import { DocBackScrollRenderController, DocCanvasPopManagerService, DocEventManagerService, DocMobileElementMenuService, EMPTY_PARAGRAPH_MENU_ID, FLOAT_TOOLBAR_MENU_POSITION, INSERT_BELLOW_MENU_ID, MOBILE_DOC_ELEMENT_MENU, UniverDocsMobileUIPlugin, UniverDocsUIPlugin, getEditorRuntimeConfig, whenDocAndEditorFocused } from "@univerjs/docs-ui";
2
2
  import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IDialogService, IMenuManagerService, IMessageService, IShortcutService, IconManager, KeyCode, MenuItemType, MetaKeys, RibbonInsertGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
3
3
  import { BuildTextUtils, CommandType, CustomRangeType, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Disposable, DocumentDataModel, ICommandService, IConfigService, IPermissionService, IUniverInstanceService, Inject, Injector, LocaleService, Plugin, Tools, UniverInstanceType, generateRandomId, getBodySlice, isSafeUrl, merge } from "@univerjs/core";
4
4
  import { DOC_INTERCEPTOR_POINT, DOC_SELECTION_OPTION_PRESERVE_CARET, DocInterceptorService, DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation, SetTextSelectionsOperation, UniverDocsPlugin, addCustomRangeBySelectionFactory, canEditDocumentTargets, deleteCustomRangeFactory, getDocumentEntityParentPermissionObjectIds, getDocumentEntityPermissionObjectId, getDocumentPermissionValue, replaceSelectionFactory } from "@univerjs/docs";
@@ -469,6 +469,9 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
469
469
  return this._infoPopupPinned;
470
470
  }
471
471
  showEditPopup(unitId, linkInfo) {
472
+ var _getEditorRuntimeConf;
473
+ const doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
474
+ if (doc && ((_getEditorRuntimeConf = getEditorRuntimeConfig(doc)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.customHyperLinkUI)) return null;
472
475
  if (!this.canEditLink(unitId, linkInfo)) return null;
473
476
  if (this._editPopup) {
474
477
  this._editPopup.dispose();
@@ -510,6 +513,9 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
510
513
  this._editPopupUnitId = null;
511
514
  }
512
515
  showInfoPopup(info, options) {
516
+ var _getEditorRuntimeConf2;
517
+ const doc = this._univerInstanceService.getUnit(info.unitId, UniverInstanceType.UNIVER_DOC);
518
+ if (!(doc instanceof DocumentDataModel) || ((_getEditorRuntimeConf2 = getEditorRuntimeConfig(doc)) === null || _getEditorRuntimeConf2 === void 0 ? void 0 : _getEditorRuntimeConf2.customHyperLinkUI)) return;
513
519
  this.cancelScheduledHideInfoPopup();
514
520
  if (this._infoPopupSuppressed) return;
515
521
  const { linkId, unitId, segmentId, segmentPage, startIndex, endIndex } = info;
@@ -521,7 +527,6 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
521
527
  this._infoPopup.dispose();
522
528
  this._infoPopup = null;
523
529
  }
524
- if (!(this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC) instanceof DocumentDataModel)) return;
525
530
  this._infoPopupPinned = (options === null || options === void 0 ? void 0 : options.pinned) ?? false;
526
531
  this._showingLink$.next({
527
532
  unitId,
@@ -784,7 +789,7 @@ const menuSchema = {
784
789
  //#endregion
785
790
  //#region package.json
786
791
  var name = "@univerjs/docs-hyper-link-ui";
787
- var version = "1.0.2";
792
+ var version = "1.0.3";
788
793
 
789
794
  //#endregion
790
795
  //#region src/config/config.ts
@@ -1290,6 +1295,7 @@ let DocHyperLinkEventRenderController = class DocHyperLinkEventRenderController
1290
1295
  return this._docSkeletonManagerService.getSkeleton();
1291
1296
  }
1292
1297
  constructor(_context, _docEventManagerService, _commandService, _hyperLinkPopupService, _docSkeletonManagerService, _docSelectionManagerService) {
1298
+ var _getEditorRuntimeConf;
1293
1299
  super();
1294
1300
  this._context = _context;
1295
1301
  this._docEventManagerService = _docEventManagerService;
@@ -1297,7 +1303,7 @@ let DocHyperLinkEventRenderController = class DocHyperLinkEventRenderController
1297
1303
  this._hyperLinkPopupService = _hyperLinkPopupService;
1298
1304
  this._docSkeletonManagerService = _docSkeletonManagerService;
1299
1305
  this._docSelectionManagerService = _docSelectionManagerService;
1300
- if (this._context.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY) return;
1306
+ if (this._context.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY || ((_getEditorRuntimeConf = getEditorRuntimeConfig(this._context.unit)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.customHyperLinkUI)) return;
1301
1307
  this._initPointerDown();
1302
1308
  this._initHover();
1303
1309
  this._initClick();
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DocBackScrollRenderController, DocCanvasPopManagerService, DocEventManagerService, DocMobileElementMenuService, EMPTY_PARAGRAPH_MENU_ID, FLOAT_TOOLBAR_MENU_POSITION, INSERT_BELLOW_MENU_ID, MOBILE_DOC_ELEMENT_MENU, UniverDocsMobileUIPlugin, UniverDocsUIPlugin, whenDocAndEditorFocused } from "@univerjs/docs-ui";
1
+ import { DocBackScrollRenderController, DocCanvasPopManagerService, DocEventManagerService, DocMobileElementMenuService, EMPTY_PARAGRAPH_MENU_ID, FLOAT_TOOLBAR_MENU_POSITION, INSERT_BELLOW_MENU_ID, MOBILE_DOC_ELEMENT_MENU, UniverDocsMobileUIPlugin, UniverDocsUIPlugin, getEditorRuntimeConfig, whenDocAndEditorFocused } from "@univerjs/docs-ui";
2
2
  import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IDialogService, IMenuManagerService, IMessageService, IShortcutService, IconManager, KeyCode, MenuItemType, MetaKeys, RibbonInsertGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
3
3
  import { BuildTextUtils, CommandType, CustomRangeType, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Disposable, DocumentDataModel, ICommandService, IConfigService, IPermissionService, IUniverInstanceService, Inject, Injector, LocaleService, Plugin, Tools, UniverInstanceType, generateRandomId, getBodySlice, isSafeUrl, merge } from "@univerjs/core";
4
4
  import { DOC_INTERCEPTOR_POINT, DOC_SELECTION_OPTION_PRESERVE_CARET, DocInterceptorService, DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation, SetTextSelectionsOperation, UniverDocsPlugin, addCustomRangeBySelectionFactory, canEditDocumentTargets, deleteCustomRangeFactory, getDocumentEntityParentPermissionObjectIds, getDocumentEntityPermissionObjectId, getDocumentPermissionValue, replaceSelectionFactory } from "@univerjs/docs";
@@ -469,6 +469,9 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
469
469
  return this._infoPopupPinned;
470
470
  }
471
471
  showEditPopup(unitId, linkInfo) {
472
+ var _getEditorRuntimeConf;
473
+ const doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC);
474
+ if (doc && ((_getEditorRuntimeConf = getEditorRuntimeConfig(doc)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.customHyperLinkUI)) return null;
472
475
  if (!this.canEditLink(unitId, linkInfo)) return null;
473
476
  if (this._editPopup) {
474
477
  this._editPopup.dispose();
@@ -510,6 +513,9 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
510
513
  this._editPopupUnitId = null;
511
514
  }
512
515
  showInfoPopup(info, options) {
516
+ var _getEditorRuntimeConf2;
517
+ const doc = this._univerInstanceService.getUnit(info.unitId, UniverInstanceType.UNIVER_DOC);
518
+ if (!(doc instanceof DocumentDataModel) || ((_getEditorRuntimeConf2 = getEditorRuntimeConfig(doc)) === null || _getEditorRuntimeConf2 === void 0 ? void 0 : _getEditorRuntimeConf2.customHyperLinkUI)) return;
513
519
  this.cancelScheduledHideInfoPopup();
514
520
  if (this._infoPopupSuppressed) return;
515
521
  const { linkId, unitId, segmentId, segmentPage, startIndex, endIndex } = info;
@@ -521,7 +527,6 @@ let DocHyperLinkPopupService = class DocHyperLinkPopupService extends Disposable
521
527
  this._infoPopup.dispose();
522
528
  this._infoPopup = null;
523
529
  }
524
- if (!(this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC) instanceof DocumentDataModel)) return;
525
530
  this._infoPopupPinned = (options === null || options === void 0 ? void 0 : options.pinned) ?? false;
526
531
  this._showingLink$.next({
527
532
  unitId,
@@ -784,7 +789,7 @@ const menuSchema = {
784
789
  //#endregion
785
790
  //#region package.json
786
791
  var name = "@univerjs/docs-hyper-link-ui";
787
- var version = "1.0.2";
792
+ var version = "1.0.3";
788
793
 
789
794
  //#endregion
790
795
  //#region src/config/config.ts
@@ -1290,6 +1295,7 @@ let DocHyperLinkEventRenderController = class DocHyperLinkEventRenderController
1290
1295
  return this._docSkeletonManagerService.getSkeleton();
1291
1296
  }
1292
1297
  constructor(_context, _docEventManagerService, _commandService, _hyperLinkPopupService, _docSkeletonManagerService, _docSelectionManagerService) {
1298
+ var _getEditorRuntimeConf;
1293
1299
  super();
1294
1300
  this._context = _context;
1295
1301
  this._docEventManagerService = _docEventManagerService;
@@ -1297,7 +1303,7 @@ let DocHyperLinkEventRenderController = class DocHyperLinkEventRenderController
1297
1303
  this._hyperLinkPopupService = _hyperLinkPopupService;
1298
1304
  this._docSkeletonManagerService = _docSkeletonManagerService;
1299
1305
  this._docSelectionManagerService = _docSelectionManagerService;
1300
- if (this._context.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY) return;
1306
+ if (this._context.unitId === DOCS_NORMAL_EDITOR_UNIT_ID_KEY || ((_getEditorRuntimeConf = getEditorRuntimeConfig(this._context.unit)) === null || _getEditorRuntimeConf === void 0 ? void 0 : _getEditorRuntimeConf.customHyperLinkUI)) return;
1301
1307
  this._initPointerDown();
1302
1308
  this._initHover();
1303
1309
  this._initClick();
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/docs-ui"),require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs-hyper-link"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/protocol")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/docs-ui`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/docs`,`@univerjs/engine-render`,`rxjs`,`@univerjs/docs-hyper-link`,`@univerjs/design`,`react`,`react/jsx-runtime`,`@univerjs/protocol`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsHyperLinkUi={},e.UniverDocsUi,e.UniverUi,e.UniverCore,e.UniverDocs,e.UniverEngineRender,e.rxjs,e.UniverDocsHyperLink,e.UniverDesign,e.React,e.React,e.UniverProtocol))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let f={type:r.CommandType.COMMAND,id:s.DocHyperLinkCommandId.Delete,async handler(e,t){if(!t)return!1;let{unitId:n,linkId:a,segmentId:o}=t,s=e.get(r.ICommandService),c=(0,i.deleteCustomRangeFactory)(e,{unitId:n,rangeId:a,segmentId:o});return c?await s.syncExecuteCommand(c.id,c.params):!1}},p={type:r.CommandType.COMMAND,id:s.DocHyperLinkCommandId.Add,async handler(e,t){if(!t)return!1;let{payload:n,unitId:a,selections:o}=t,s=e.get(r.ICommandService),c=(0,r.generateRandomId)(),l=(0,i.addCustomRangeBySelectionFactory)(e,{rangeId:c,rangeType:r.CustomRangeType.HYPERLINK,properties:{url:n},unitId:a,selections:o});return l?s.syncExecuteCommand(l.id,l.params):!1}},m={id:s.DocHyperLinkCommandId.Update,type:r.CommandType.COMMAND,handler(e,t){var n,a,o,s,c;if(!t)return!1;let{unitId:l,payload:u,segmentId:d,linkId:f}=t,p=e.get(r.ICommandService),m=e.get(r.IUniverInstanceService),h=e.get(i.DocSelectionManagerService).getActiveTextRange(),g=m.getUnit(l,r.UniverInstanceType.UNIVER_DOC);if(!h||!g)return!1;let _=(n=g.getSelfOrHeaderFooterModel(d))==null?void 0:n.getBody();if(!_)return!1;let v=(a=_.customRanges)==null?void 0:a.find(e=>e.rangeId===f&&e.rangeType===r.CustomRangeType.HYPERLINK),y=(o=(0,r.getBodySlice)(_,h.startOffset,h.endOffset).textRuns)==null?void 0:o[0];y&&(y.ed=t.label.length+1);let b=(0,i.replaceSelectionFactory)(e,{unitId:l,body:{dataStream:`${t.label}`,customRanges:[{rangeId:f,rangeType:r.CustomRangeType.HYPERLINK,startIndex:0,endIndex:t.label.length+1,properties:{url:u,...v!=null&&(s=v.properties)!=null&&s.textStyleMode?{textStyleMode:v.properties.textStyleMode}:null,...v!=null&&(c=v.properties)!=null&&c.textColorMode?{textColorMode:v.properties.textColorMode}:null}}],textRuns:y?[y]:void 0},selection:{startOffset:h.startOffset,endOffset:h.endOffset,collapsed:!1,segmentId:d}});return b?p.syncExecuteCommand(b.id,b.params):!1}};function h(e){return e.trim().length===0}function g(e){return/^[a-zA-Z]+:\/\//.test(e)}function _(e){return/^[\w.-]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function v(e){return g(e)?e:_(e)?`mailto://${e}`:`https://${e}`}function y(){let e=(0,n.useDependency)(L),t=(0,n.useObservable)(e.editingLink$,e.editing),a=(0,n.useDependency)(r.ICommandService),o=(0,n.useDependency)(r.IUniverInstanceService),s=(0,n.useDependency)(i.DocSelectionManagerService),[c,u]=(0,l.useState)(``),[d,f]=(0,l.useState)(``),[g,_]=(0,l.useState)(!1),y=r.Tools.isLegalUrl(c),b=t?o.getUnit(t.unitId,r.UniverInstanceType.UNIVER_DOC):o.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_DOC);return(0,l.useEffect)(()=>{var e,n;let i=s.getActiveTextRange();if(!i)return;if(t){var a,o;let e=b==null||(a=b.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:a.getBody(),n=e==null||(o=e.customRanges)==null?void 0:o.find(e=>t.linkId===e.rangeId&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex);if(b&&n){var c;u(((c=n.properties)==null?void 0:c.url)??``),f(r.BuildTextUtils.transform.getPlainText((0,r.getBodySlice)(e,n.startIndex,n.endIndex+1).dataStream))}return}let l=b==null||(e=b.getSelfOrHeaderFooterModel(i.segmentId))==null?void 0:e.getBody(),d=l?i:null,p=d&&((n=r.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(d,(l==null?void 0:l.customRanges)??[]))==null?void 0:n[0]);if(b&&p){var m;u(((m=p.properties)==null?void 0:m.url)??``)}},[b,s,t]),{doc:b,editing:t,handleCancel:()=>e.hideEditPopup(),handleConfirm:()=>{if(_(!0),!y||!b)return;let n=v(c);if(t){if(h(d))return;a.executeCommand(m.id,{unitId:b.getUnitId(),payload:n,linkId:t.linkId,label:d,segmentId:t.segmentId}).catch(()=>void 0)}else a.executeCommand(p.id,{unitId:b.getUnitId(),payload:n}).catch(()=>void 0);e.hideEditPopup()},isLegal:y,label:d,link:c,setLabel:f,setLink:u,showError:g}}let b=()=>{let e=(0,n.useDependency)(r.LocaleService),{doc:t,editing:i,handleCancel:a,handleConfirm:o,isLegal:s,label:l,link:d,setLabel:f,setLink:p,showError:m}=y();if(t)return(0,u.jsxs)(`div`,{className:(0,c.clsx)(`univer-box-border univer-w-[328px] univer-rounded-xl univer-bg-gray-0 univer-px-6 univer-py-5 univer-shadow dark:!univer-bg-gray-900`,c.borderClassName),children:[(0,u.jsxs)(`div`,{children:[i?(0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.label`),error:m&&h(l)?e.t(`docs-hyper-link-ui.edit.labelError`):``,children:(0,u.jsx)(c.Input,{value:l,onChange:f,autoFocus:!0,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()}})}):null,(0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.address`),error:m&&!s?e.t(`docs-hyper-link-ui.edit.addressError`):``,children:(0,u.jsx)(c.Input,{value:d,onChange:p,autoFocus:!0,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()}})})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-justify-end univer-gap-3`,children:[(0,u.jsx)(c.Button,{onClick:a,children:e.t(`docs-hyper-link-ui.edit.cancel`)}),(0,u.jsx)(c.Button,{variant:`primary`,disabled:h(d),onClick:o,children:e.t(`docs-hyper-link-ui.edit.confirm`)})]})]})};b.componentKey=`docs-hyper-link-edit`;function x({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,l.useId)()}`,d=(0,l.useRef)(null);return(0,l.useImperativeHandle)(e,()=>d.current),(0,l.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return T(d.current)},[n,r]),S(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:c,...s},o)}function S(e,t,n,r,i){return(0,l.createElement)(e.tag,{key:t,...C(e,n,i),...r},(w(e,n).children||[]).map((r,a)=>S(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function C(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function w(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function T(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:E(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(D(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function E(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function D(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}x.displayName=`UniverIcon`;let O={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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`}}]},k=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`copy-icon`,ref:t,icon:O}))});k.displayName=`CopyIcon`;let A={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M7.30999 8.71386C6.39955 7.80343 6.37922 6.34731 7.26629 5.45772L10.313 2.41112C11.2111 1.51303 12.6799 1.51258 13.5691 2.45476C14.4811 3.36679 14.4798 4.84384 13.6128 5.71094L10.9677 8.35604`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.22}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5.0456 7.66774L2.4005 10.3128C1.50242 11.2109 1.50197 12.6798 2.44413 13.5691C3.35615 14.4811 4.8332 14.4798 5.70033 13.6127L8.747 10.566C9.65743 9.65558 9.67776 8.19945 8.7905 7.30999`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.22}}]},j=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`link-icon`,ref:t,icon:A}))});j.displayName=`LinkIcon`;let ee={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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.76157C6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449C14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797C11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.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.05395C4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092C3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721C8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332C2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302C13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332Z`}}]},te=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`unlink-icon`,ref:t,icon:ee}))});te.displayName=`UnlinkIcon`;let ne={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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`}}]},re=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`write-icon`,ref:t,icon:ne}))});re.displayName=`WriteIcon`;let M=()=>{var e,t,a,o,s;let l=(0,n.useDependency)(L),p=(0,n.useDependency)(r.ICommandService),m=(0,n.useDependency)(n.IMessageService),h=(0,n.useDependency)(r.LocaleService),g=(0,n.useObservable)(l.showingLink$,l.showing),_=(0,n.useDependency)(r.IUniverInstanceService),v=(0,n.useDependency)(r.IPermissionService);if(!g)return null;let{unitId:y,linkId:b,segmentId:x,startIndex:S,endIndex:C}=g,w=_.getUnit(y,r.UniverInstanceType.UNIVER_DOC),T=w instanceof r.DocumentDataModel?(e=w.getSelfOrHeaderFooterModel(x))==null?void 0:e.getBody():void 0,E=T==null||(t=T.customRanges)==null?void 0:t.find(e=>e.rangeId===b&&e.rangeType===r.CustomRangeType.HYPERLINK&&e.startIndex===S&&e.endIndex===C);if(!E)return null;let D=((a=E.properties)==null?void 0:a.url)??`#${((o=E.properties)==null?void 0:o.bookmarkId)??((s=E.properties)==null?void 0:s.headingId)??``}`,O=l.canEditLink(y,g),A=(0,i.getDocumentPermissionValue)(v,y,y,d.UnitAction.Copy);return(0,u.jsxs)(`div`,{className:(0,c.clsx)(`univer-box-border univer-flex univer-max-w-80 univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-gray-0 univer-p-3 univer-shadow dark:!univer-bg-gray-900`,c.borderClassName),onPointerEnter:()=>{l.cancelScheduledHideInfoPopup()},onPointerLeave:()=>{l.scheduleHideInfoPopup()},onClick:()=>{l.hideInfoPopup()},children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-500`,onClick:()=>p.executeCommand(B.id,{unitId:y,linkId:b,segmentId:x}),children:[(0,u.jsx)(`div`,{className:`univer-mr-2 univer-flex univer-size-5 univer-flex-[0_0_auto] univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-gray-0`,children:(0,u.jsx)(j,{})}),(0,u.jsx)(c.Tooltip,{showIfEllipsis:!0,title:D,children:(0,u.jsx)(`span`,{className:`univer-flex-1 univer-truncate`,children:D})})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-[0_0_auto] univer-items-center univer-justify-center`,children:[(0,u.jsx)(c.Button,{type:`button`,variant:`text`,size:`small`,"aria-label":h.t(`docs-hyper-link-ui.info.copy`),className:`univer-ml-2 !univer-flex univer-size-6 !univer-rounded !univer-border-0 !univer-bg-transparent !univer-p-0 !univer-text-base !univer-font-normal hover:!univer-bg-transparent active:!univer-bg-transparent disabled:!univer-pointer-events-auto disabled:!univer-opacity-40`,disabled:!A,onClick:()=>{navigator.clipboard.writeText(D),m.show({content:h.t(`docs-hyper-link-ui.info.coped`),type:c.MessageType.Info})},children:(0,u.jsx)(c.Tooltip,{placement:`bottom`,title:h.t(`docs-hyper-link-ui.info.copy`),children:(0,u.jsx)(k,{})})}),O&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base`,onClick:()=>{p.executeCommand(z.id,{link:g})},children:(0,u.jsx)(c.Tooltip,{placement:`bottom`,title:h.t(`docs-hyper-link-ui.info.edit`),children:(0,u.jsx)(re,{})})}),(0,u.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base`,onClick:()=>{p.executeCommand(f.id,{unitId:y,linkId:E.rangeId,segmentId:x})},children:(0,u.jsx)(c.Tooltip,{placement:`bottom`,title:h.t(`docs-hyper-link-ui.info.cancel`),children:(0,u.jsx)(te,{})})})]})]})]})};M.componentKey=`univer.doc.link-info-popup`;function N(e){"@babel/helpers - typeof";return N=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},N(e)}function ie(e,t){if(N(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(N(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ae(e){var t=ie(e,`string`);return N(t)==`symbol`?t:t+``}function P(e,t,n){return(t=ae(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F(e,t){return function(n,r){t(n,r,e)}}function I(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function oe(e,t){return(e==null?void 0:e.linkId)===t.linkId&&e.unitId===t.unitId&&(e.segmentId??``)===(t.segmentId??``)&&e.segmentPage===t.segmentPage&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex}let L=class extends r.Disposable{constructor(e,t,n,r,i,a,s,c){super(),this._docCanvasPopupManagerService=e,this._textSelectionManagerService=t,this._univerInstanceService=n,this._permissionService=r,this._renderManagerService=i,this._dialogService=a,this._localeService=s,this._commandService=c,P(this,`_editingLink$`,new o.BehaviorSubject(null)),P(this,`_showingLink$`,new o.BehaviorSubject(null)),P(this,`editingLink$`,this._editingLink$.asObservable()),P(this,`showingLink$`,this._showingLink$.asObservable()),P(this,`_editPopup`,null),P(this,`_editPopupUnitId`,null),P(this,`_infoPopup`,null),P(this,`_infoPopupPinned`,!1),P(this,`_infoPopupHideTimer`,null),P(this,`_infoPopupSuppressed`,!1),P(this,`_infoPopupSuppressionTimer`,null),this.disposeWithMe(()=>{this.cancelScheduledHideInfoPopup(),this._infoPopupSuppressionTimer!==null&&clearTimeout(this._infoPopupSuppressionTimer),this._editingLink$.complete(),this._showingLink$.complete()}),this.disposeWithMe(this._permissionService.permissionPointUpdate$.subscribe(()=>{let e=this.editing;e&&!this.canEditLink(e.unitId,e)&&this.hideEditPopup();let t=this.showing;t&&this._showingLink$.next({...t})})),this.disposeWithMe(this._renderManagerService.disposed$.subscribe(e=>{var t;this._editPopupUnitId===e&&this.hideEditPopup(),((t=this.showing)==null?void 0:t.unitId)===e&&this.hideInfoPopup()}))}dispose(){this.hideEditPopup(),this.hideInfoPopup(),super.dispose()}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}get infoPopupPinned(){return this._infoPopupPinned}showEditPopup(e,t){if(!this.canEditLink(e,t))return null;this._editPopup&&(this._editPopup.dispose(),this._editPopup=null,this._editPopupUnitId=null),this._editingLink$.next(t);let n=this._textSelectionManagerService.getTextRanges({unitId:e,subUnitId:e}),r=n==null?void 0:n[n.length-1];if(t){let{segmentId:e,segmentPage:n,startIndex:i,endIndex:a}=t;r={collapsed:!1,startOffset:i,endOffset:a+1,segmentId:e,segmentPage:n},this._textSelectionManagerService.replaceDocRanges([{startOffset:i,endOffset:a+1}])}return r?(this._editPopup=this._openEditSurface(r,e),this._editPopupUnitId=e,this._editPopup):null}hideEditPopup(){this._editingLink$.next(null);let e=this._editPopup;this._editPopup=null,e==null||e.dispose(),this._editPopupUnitId=null}showInfoPopup(e,t){if(this.cancelScheduledHideInfoPopup(),this._infoPopupSuppressed)return;let{linkId:n,unitId:i,segmentId:a,segmentPage:o,startIndex:s,endIndex:c}=e;if(oe(this.showing,e)){t!=null&&t.pinned&&(this._infoPopupPinned=!0);return}if(this._infoPopup&&=(this._infoPopup.dispose(),null),this._univerInstanceService.getUnit(i,r.UniverInstanceType.UNIVER_DOC)instanceof r.DocumentDataModel)return this._infoPopupPinned=(t==null?void 0:t.pinned)??!1,this._showingLink$.next({unitId:i,linkId:n,segmentId:a,segmentPage:o,startIndex:s,endIndex:c}),this._infoPopup=this._openInfoSurface(e),this._infoPopup}_openEditSurface(e,t){return this._docCanvasPopupManagerService.attachPopupToRange(e,{componentKey:b.componentKey,direction:`bottom`,offset:[0,10]},t)}_openInfoSurface(e,t=M.componentKey){let{unitId:n,linkId:r,segmentId:i,segmentPage:a,startIndex:o,endIndex:s}=e;return this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:o,endOffset:s+1,segmentId:i,segmentPage:a},{componentKey:t,extraProps:{onEdit:()=>{this.hideInfoPopup(),this.showEditPopup(n,e)},onDelete:async()=>{await this._commandService.executeCommand(f.id,{unitId:n,linkId:r,segmentId:i})&&this.hideInfoPopup()}},direction:`top-center`,multipleDirection:`top`,offset:[0,10],onClickOutside:()=>{this.hideInfoPopup()}},n)}showInfoPopupFromHover(e){this.cancelScheduledHideInfoPopup(),!(this._infoPopupPinned||this._infoPopupSuppressed)&&(this.showing||this.showInfoPopup(e))}hideInfoPopup(){this.cancelScheduledHideInfoPopup(),this._infoPopupPinned=!1,this._showingLink$.next(null);let e=this._infoPopup;this._infoPopup=null,e==null||e.dispose()}scheduleHideInfoPopup(){!this._infoPopupPinned&&this.showing&&(this.cancelScheduledHideInfoPopup(),this._infoPopupHideTimer=setTimeout(()=>{this._infoPopupHideTimer=null,this._infoPopupPinned||this.hideInfoPopup()},150))}cancelScheduledHideInfoPopup(){this._infoPopupHideTimer!==null&&(clearTimeout(this._infoPopupHideTimer),this._infoPopupHideTimer=null)}hideInfoPopupOnPointerDown(){this._infoPopupSuppressed=!0,this._infoPopupSuppressionTimer!==null&&clearTimeout(this._infoPopupSuppressionTimer),this.hideInfoPopup(),this._infoPopupSuppressionTimer=setTimeout(()=>{this._infoPopupSuppressed=!1,this._infoPopupSuppressionTimer=null},0)}canEditLink(e,t){let n=this._univerInstanceService.getUnit(e,r.UniverInstanceType.UNIVER_DOC);if(!(n instanceof r.DocumentDataModel))return!1;if(!t)return(0,i.canEditDocumentTargets)(this._permissionService,e,[]);let a=t.segmentId??``;return(0,i.canEditDocumentTargets)(this._permissionService,e,[...(0,i.getDocumentEntityParentPermissionObjectIds)(n,a,`custom-range`,t.linkId),(0,i.getDocumentEntityPermissionObjectId)(a,`custom-range`,t.linkId)])}};L=I([F(0,(0,r.Inject)(t.DocCanvasPopManagerService)),F(1,(0,r.Inject)(i.DocSelectionManagerService)),F(2,r.IUniverInstanceService),F(3,r.IPermissionService),F(4,a.IRenderManagerService),F(5,n.IDialogService),F(6,(0,r.Inject)(r.LocaleService)),F(7,r.ICommandService)],L);let R=e=>{let t=e.get(i.DocSelectionManagerService),n=e.get(r.IUniverInstanceService),a=t.getTextRanges();if(!(a!=null&&a.length))return!0;let o=a[0];return!(n.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_DOC)&&o&&!o.collapsed)},z={type:r.CommandType.OPERATION,id:`doc.operation.show-hyper-link-edit-popup`,handler(e,t){var n;let i=t==null?void 0:t.link,a=e.get(r.IUniverInstanceService);if(R(e)&&!i)return!1;let o=e.get(L),s=(i==null?void 0:i.unitId)||((n=a.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_DOC))==null?void 0:n.getUnitId());return s?(o.showEditPopup(s,i??null),!0):!1}},se={type:r.CommandType.OPERATION,id:`doc.operation.toggle-hyper-link-info-popup`,handler(e,t){let n=e.get(L);return t?(t.fromHover?n.showInfoPopupFromHover(t):n.showInfoPopup(t),!0):(n.hideInfoPopup(),!0)}},B={type:r.CommandType.OPERATION,id:`doc.operation.click-hyper-link`,handler(e,n){var o,s;if(!n)return!1;let{unitId:c,linkId:l,segmentId:u}=n,d=e.get(r.IUniverInstanceService).getUnit(c,r.UniverInstanceType.UNIVER_DOC),f=d==null||(o=d.getSelfOrHeaderFooterModel(u))==null?void 0:o.getBody(),p=f==null||(s=f.customRanges)==null||(s=s.find(e=>e.rangeId===l&&e.rangeType===r.CustomRangeType.HYPERLINK))==null?void 0:s.properties;if(p!=null&&p.bookmarkId||p!=null&&p.headingId){var m;let n=ce(d==null?void 0:d.getBody(),p.bookmarkId,p.headingId);if(n==null)return!1;let r={startOffset:n,endOffset:n,collapsed:!0},o=e.get(i.DocSelectionManagerService),s=()=>o.replaceDocRanges([r],{unitId:c,subUnitId:c},!1,{[i.DOC_SELECTION_OPTION_PRESERVE_CARET]:!0}),l=e.get(a.IRenderManagerService).getRenderUnitById(c),u=l==null||(m=l.getInjector)==null?void 0:m.call(l),f=u!=null&&u.has(t.DocBackScrollRenderController)?l==null?void 0:l.with(t.DocBackScrollRenderController):null;return f?f.scrollToRange(r,s):s(),!0}return!(p!=null&&p.url)||!(0,r.isSafeUrl)(p.url)?!1:(window.open(p.url,`_blank`,`noopener noreferrer`),!0)}};function ce(e,t,n){if(e){if(t){var i;let n=(i=e.customRanges)==null?void 0:i.find(e=>{var n;return e.rangeType===r.CustomRangeType.BOOKMARK&&(e.rangeId===t||((n=e.properties)==null?void 0:n.bookmarkId)===t)});if(n)return n.startIndex}if(n){var a;let t=((a=e.paragraphs)==null?void 0:a.findIndex(e=>{var t;return((t=e.paragraphStyle)==null?void 0:t.headingId)===n}))??-1;if(t>=0)return t===0?0:e.paragraphs[t-1].startIndex+1}}}function V(e){return{id:z.id,type:n.MenuItemType.BUTTON,icon:`LinkIcon`,title:`docs-hyper-link-ui.menu.tooltip`,tooltip:`docs-hyper-link-ui.menu.tooltip`,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_DOC),disabled$:new o.Observable(function(t){let n=e.get(i.DocSelectionManagerService).textSelection$.pipe((0,o.debounceTime)(16)).subscribe(()=>{t.next(R(e))});return()=>{n.unsubscribe()}})}}let le={id:z.id,binding:n.MetaKeys.CTRL_COMMAND|n.KeyCode.K,description:`docs-hyper-link-ui.menu.tooltip`,preconditions:t.whenDocAndEditorFocused},ue={[n.RibbonInsertGroup.MEDIA]:{[z.id]:{order:1,gridLayout:{row:1,column:5},menuItemFactory:V}},[t.FLOAT_TOOLBAR_MENU_POSITION]:{[z.id]:{order:20,menuItemFactory:V}},[n.ContextMenuPosition.MAIN_AREA]:{[n.ContextMenuGroup.DATA]:{[z.id]:{order:0,menuItemFactory:V}}},[n.ContextMenuPosition.PARAGRAPH]:{[n.ContextMenuGroup.LAYOUT]:{[t.INSERT_BELLOW_MENU_ID]:{[z.id]:{order:6,menuItemFactory:V}}},[t.EMPTY_PARAGRAPH_MENU_ID]:{[n.ContextMenuGroup.LAYOUT]:{[z.id]:{order:6,menuItemFactory:V}}}}};var de=`@univerjs/docs-hyper-link-ui`,fe=`1.0.2`;let pe=`docs-hyper-link-ui.config`,H={},U=class extends r.Disposable{constructor(e,t,n){super(),this._commandService=e,this._univerInstanceService=t,this._docHyperLinkService=n,P(this,`_selection`,null),this._initSelectionChange(),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(e=>{var t;((t=this._selection)==null?void 0:t.unitId)===e.getUnitId()&&(this._selection=null)}))}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===i.RichTextEditingMutation.id){var t;e.params.unitId===((t=this._docHyperLinkService.showing)==null?void 0:t.unitId)&&this._docHyperLinkService.hideInfoPopup();return}if(e.id===i.SetTextSelectionsOperation.id){var n;let t=e.params,{unitId:i,ranges:o,segmentId:s}=t,c=this._univerInstanceService.getUnit(i,r.UniverInstanceType.UNIVER_DOC),l=o[0],u=JSON.stringify([i,s??``,l==null?void 0:l.startOffset,l==null?void 0:l.endOffset,l==null?void 0:l.segmentPage]),d=u===((n=this._selection)==null?void 0:n.key);this._selection={unitId:i,key:u};let f=this._docHyperLinkService.editing;if((f==null?void 0:f.unitId)===i&&(f.segmentId??``)===(s??``)&&(l==null?void 0:l.startOffset)===f.startIndex&&l.endOffset===f.endIndex+1)return;if(t.isEditing){this._docHyperLinkService.hideInfoPopup();return}if(d)return;if(l!=null&&l.collapsed&&c){var a;let{startOffset:e,endOffset:t,segmentPage:n}=l,o=(a=c.getSelfOrHeaderFooterModel(s))==null||(a=a.getBody())==null?void 0:a.customRanges,u=this._docHyperLinkService.showing,d=((u==null?void 0:u.unitId)===i&&(u.segmentId??``)===s&&u.segmentPage===n&&u.endIndex===t-1?o==null?void 0:o.find(n=>n.rangeId===u.linkId&&n.rangeType===r.CustomRangeType.HYPERLINK&&n.startIndex<=e&&n.endIndex===t-1):void 0)??(o==null?void 0:o.find(n=>n.rangeType===r.CustomRangeType.HYPERLINK&&n.startIndex<=e&&n.endIndex>t-1));if(d){this._docHyperLinkService.showInfoPopup({unitId:i,linkId:d.rangeId,segmentId:s,segmentPage:n,startIndex:d.startIndex,endIndex:d.endIndex});return}}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};U=I([F(0,r.ICommandService),F(1,r.IUniverInstanceService),F(2,(0,r.Inject)(L))],U);function W(){let e=(0,n.useDependency)(r.LocaleService),{doc:t,editing:i,handleCancel:a,handleConfirm:o,isLegal:s,label:l,link:d,setLabel:f,setLink:p,showError:m}=y();if(t)return(0,u.jsxs)(`div`,{className:`univer-box-border univer-w-full univer-bg-gray-0 univer-py-2 dark:!univer-bg-gray-900`,children:[(0,u.jsxs)(`div`,{children:[i?(0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.label`),error:m&&h(l)?e.t(`docs-hyper-link-ui.edit.labelError`):``,children:(0,u.jsx)(c.Input,{value:l,onChange:f,autoFocus:!0,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()}})}):null,(0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.address`),error:m&&!s?e.t(`docs-hyper-link-ui.edit.addressError`):``,children:(0,u.jsx)(c.Input,{value:d,onChange:p,autoFocus:!i,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()}})})]}),(0,u.jsxs)(`div`,{className:`univer-mt-5 univer-flex univer-gap-3`,children:[(0,u.jsx)(c.Button,{className:`univer-h-12 univer-flex-1`,onClick:a,children:e.t(`docs-hyper-link-ui.edit.cancel`)}),(0,u.jsx)(c.Button,{variant:`primary`,className:`univer-h-12 univer-flex-1`,disabled:h(d),onClick:o,children:e.t(`docs-hyper-link-ui.edit.confirm`)})]})]})}W.componentKey=`univer.doc.mobile-hyper-link-edit`;function G(){var e,t,a;let o=(0,n.useDependency)(r.ICommandService),s=(0,n.useDependency)(L),l=(0,n.useDependency)(r.LocaleService),p=(0,n.useDependency)(n.IMessageService),m=(0,n.useDependency)(r.IPermissionService),h=(0,n.useDependency)(r.IUniverInstanceService),g=(0,n.useObservable)(s.showingLink$,s.showing);if(!g)return null;let{unitId:_,linkId:v,segmentId:y,startIndex:b,endIndex:x}=g,S=h.getUnit(_,r.UniverInstanceType.UNIVER_DOC),C=S instanceof r.DocumentDataModel?(e=S.getSelfOrHeaderFooterModel(y))==null?void 0:e.getBody():void 0,w=C==null||(t=C.customRanges)==null?void 0:t.find(e=>e.rangeId===v&&e.rangeType===r.CustomRangeType.HYPERLINK&&e.startIndex===b&&e.endIndex===x);if(!w)return null;let T=(a=w.properties)==null?void 0:a.url,E=s.canEditLink(_,g),D=(0,i.getDocumentPermissionValue)(m,_,_,d.UnitAction.Copy);return(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2 univer-py-2`,children:[(0,u.jsx)(c.MobileActionRow,{title:(0,u.jsx)(`span`,{className:`univer-truncate univer-text-primary-600`,children:T}),"aria-label":T,variant:`subtle`,onClick:()=>window.open(T,void 0,`noopener noreferrer`)}),D&&(0,u.jsx)(c.MobileActionRow,{title:l.t(`docs-hyper-link-ui.info.copy`),"aria-label":l.t(`docs-hyper-link-ui.info.copy`),variant:`subtle`,onClick:()=>navigator.clipboard.writeText(T).then(()=>{p.show({content:l.t(`docs-hyper-link-ui.info.coped`),type:c.MessageType.Info})}).catch(()=>void 0)}),E&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.MobileActionRow,{title:l.t(`docs-hyper-link-ui.info.edit`),"aria-label":l.t(`docs-hyper-link-ui.info.edit`),variant:`subtle`,onClick:()=>{o.executeCommand(z.id,{link:g}).catch(()=>void 0)}}),(0,u.jsx)(c.MobileActionRow,{title:l.t(`docs-hyper-link-ui.info.cancel`),"aria-label":l.t(`docs-hyper-link-ui.info.cancel`),variant:`subtle`,onClick:()=>{o.executeCommand(f.id,{unitId:_,linkId:w.rangeId,segmentId:y}).catch(()=>void 0)}})]})]})}G.componentKey=`univer.doc.mobile-link-info-popup`;let K=class extends r.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[W.componentKey,W],[G.componentKey,G]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({LinkIcon:j}))}};K=I([F(0,(0,r.Inject)(n.ComponentManager)),F(1,(0,r.Inject)(n.IconManager))],K);let q=class extends r.Disposable{get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}constructor(e,t,n,i,a,o){super(),this._context=e,this._docEventManagerService=t,this._commandService=n,this._hyperLinkPopupService=i,this._docSkeletonManagerService=a,this._mobileElementMenuService=o,this._context.unitId!==r.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&(this._initPointerDown(),this._initClick())}_initPointerDown(){this.disposeWithMe(this._docEventManagerService.pointerDownCustomRanges$.subscribe(e=>{let t=e.find(e=>e.range.rangeType===r.CustomRangeType.HYPERLINK);if(!t){this._hyperLinkPopupService.hideInfoPopupOnPointerDown();return}let n={unitId:this._context.unitId,linkId:t.range.rangeId,segmentId:t.segmentId,segmentPage:t.segmentPageIndex,startIndex:t.range.startIndex,endIndex:t.range.endIndex},i=t.rects[0];i&&this._hyperLinkPopupService.canEditLink(n.unitId,n)&&this._mobileElementMenuService.capture({unitId:n.unitId,rect:i,onEdit:()=>this._hyperLinkPopupService.showEditPopup(n.unitId,n),onDelete:()=>this._commandService.executeCommand(f.id,n)})}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(e=>{let t=e.range;if(t.rangeType===r.CustomRangeType.HYPERLINK){if(!e.ctrlKey&&!e.metaKey){this._hyperLinkPopupService.showInfoPopup({unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId,segmentPage:e.segmentPageIndex,startIndex:t.startIndex,endIndex:t.endIndex},{pinned:!0});return}this._commandService.executeCommand(B.id,{unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId})}}))}};q=I([F(1,(0,r.Inject)(t.DocEventManagerService)),F(2,r.ICommandService),F(3,(0,r.Inject)(L)),F(4,(0,r.Inject)(i.DocSkeletonManagerService)),F(5,(0,r.Inject)(t.DocMobileElementMenuService))],q);let J=class extends r.Disposable{constructor(e,t,n){super(),this._docInterceptorService=t,this._hyperLinkService=n,this._init()}_init(){this._docInterceptorService.intercept(i.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:(e,t,n)=>{if(!e)return n(e);let{unitId:r,index:i}=t,a=this._hyperLinkService.showing;if(!a)return n({...e,active:!1});let{linkId:o,unitId:s,startIndex:c,endIndex:l}=a,u=s===r&&e.rangeId===o&&i>=c&&i<=l;return n({...e,active:u})}})}};J=I([F(1,(0,r.Inject)(i.DocInterceptorService)),F(2,(0,r.Inject)(L))],J);let Y=class extends r.Disposable{constructor(e,t,n){super(),this._commandService=e,this._menuManagerService=t,this._shortcutService=n,this._initCommands(),this._initMenus(),this._initShortcut()}_initCommands(){[p,m,f,z,se,B].forEach(e=>{this._commandService.registerCommand(e)})}_initShortcut(){[le].forEach(e=>{this._shortcutService.registerShortcut(e)})}_initMenus(){this._menuManagerService.appendRootMenu({[t.FLOAT_TOOLBAR_MENU_POSITION]:{}}),this._menuManagerService.mergeMenu(ue)}};Y=I([F(0,r.ICommandService),F(1,n.IMenuManagerService),F(2,n.IShortcutService)],Y);var me=class extends L{_openEditSurface(e,t){return this._dialogService.open({id:`doc-mobile-hyper-link-editor`,title:{title:this._localeService.t(`docs-hyper-link-ui.menu.tooltip`)},children:{label:W.componentKey},maskClosable:!1,onClose:()=>this.hideEditPopup()})}_openInfoSurface(e){return this.canEditLink(e.unitId,e)?super._openInfoSurface(e,t.MOBILE_DOC_ELEMENT_MENU):this._dialogService.open({id:`doc-mobile-hyper-link-viewer`,title:{title:this._localeService.t(`docs-hyper-link-ui.menu.tooltip`)},children:{label:G.componentKey},onClose:()=>this.hideInfoPopup()})}};let he=`DOC_HYPER_LINK_UI_PLUGIN`,X=class extends r.Plugin{constructor(e=H,t,n,i){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._configService=i;let{menu:a,...o}=(0,r.merge)({},H,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(pe,o)}onStarting(){[[K],[L,{useClass:me}],[Y],[U]].forEach(e=>this._injector.add(e)),this._injector.get(K),this._injector.get(Y)}onReady(){this._injector.get(U)}onRendered(){[[J],[q]].forEach(e=>{this._renderManagerSrv.registerRenderModule(r.UniverInstanceType.UNIVER_DOC,e)})}};P(X,`pluginName`,he),P(X,`packageName`,de),P(X,`version`,fe),P(X,`type`,r.UniverInstanceType.UNIVER_DOC),X=I([(0,r.DependentOn)(i.UniverDocsPlugin,a.UniverRenderEnginePlugin,s.UniverDocsHyperLinkPlugin,t.UniverDocsMobileUIPlugin),F(1,(0,r.Inject)(r.Injector)),F(2,a.IRenderManagerService),F(3,r.IConfigService)],X);let Z=class extends r.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[b.componentKey,b],[M.componentKey,M]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({LinkIcon:j}))}};Z=I([F(0,(0,r.Inject)(n.ComponentManager)),F(1,(0,r.Inject)(n.IconManager))],Z);let Q=class extends r.Disposable{get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}constructor(e,t,n,i,a,o){super(),this._context=e,this._docEventManagerService=t,this._commandService=n,this._hyperLinkPopupService=i,this._docSkeletonManagerService=a,this._docSelectionManagerService=o,this._context.unitId!==r.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&(this._initPointerDown(),this._initHover(),this._initClick())}_hideInfoPopup(){this._hyperLinkPopupService.infoPopupPinned||this._hyperLinkPopupService.showing&&this._hyperLinkPopupService.scheduleHideInfoPopup()}_normalizeSegmentId(e){var t;return e?(t=this._context.unit.getBody())!=null&&(t=t.tables)!=null&&t.some(t=>t.tableId===e)?``:e:``}_initPointerDown(){this.disposeWithMe(this._docEventManagerService.pointerDownCustomRanges$.subscribe(e=>{e.find(e=>e.range.rangeType===r.CustomRangeType.HYPERLINK)||this._hyperLinkPopupService.hideInfoPopupOnPointerDown()}))}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(e=>{var t;let n=e.find(e=>e.range.rangeType===r.CustomRangeType.HYPERLINK),i=this._docSelectionManagerService.getTextRanges(),a=i==null||(t=i[0])==null?void 0:t.segmentId;if(this._normalizeSegmentId(n==null?void 0:n.segmentId)!==this._normalizeSegmentId(a)){this._hideInfoPopup();return}if(n){let e={unitId:this._context.unitId,linkId:n.range.rangeId,segmentId:n.segmentId,segmentPage:n.segmentPageIndex,startIndex:n.range.startIndex,endIndex:n.range.endIndex};this._commandService.executeCommand(se.id,{...e,fromHover:!0})}else this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(e=>{let t=e.range;if(t.rangeType===r.CustomRangeType.HYPERLINK){if(!e.ctrlKey&&!e.metaKey){this._hyperLinkPopupService.showInfoPopup({unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId,segmentPage:e.segmentPageIndex,startIndex:t.startIndex,endIndex:t.endIndex},{pinned:!0});return}this._commandService.executeCommand(B.id,{unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId})}}))}};Q=I([F(1,(0,r.Inject)(t.DocEventManagerService)),F(2,r.ICommandService),F(3,(0,r.Inject)(L)),F(4,(0,r.Inject)(i.DocSkeletonManagerService)),F(5,(0,r.Inject)(i.DocSelectionManagerService))],Q);let $=class extends r.Plugin{constructor(e=H,t,n,i){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._configService=i;let{menu:a,...o}=(0,r.merge)({},H,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(pe,o)}onStarting(){[[Z],[L],[Y],[U]].forEach(e=>{this._injector.add(e)}),this._injector.get(Z),this._injector.get(Y)}onReady(){this._injector.get(U)}onRendered(){this._initRenderModule()}_initRenderModule(){[[J],[Q]].forEach(e=>{this._renderManagerSrv.registerRenderModule(r.UniverInstanceType.UNIVER_DOC,e)})}};P($,`pluginName`,he),P($,`packageName`,de),P($,`version`,fe),P($,`type`,r.UniverInstanceType.UNIVER_DOC),$=I([(0,r.DependentOn)(i.UniverDocsPlugin,a.UniverRenderEnginePlugin,s.UniverDocsHyperLinkPlugin,t.UniverDocsUIPlugin),F(1,(0,r.Inject)(r.Injector)),F(2,a.IRenderManagerService),F(3,r.IConfigService)],$),e.DocsHyperLinkUIMenuSchema=ue,Object.defineProperty(e,"UniverDocsHyperLinkMobileUIPlugin",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"UniverDocsHyperLinkUIPlugin",{enumerable:!0,get:function(){return $}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/docs-ui"),require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/docs"),require("@univerjs/engine-render"),require("rxjs"),require("@univerjs/docs-hyper-link"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/protocol")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/docs-ui`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/docs`,`@univerjs/engine-render`,`rxjs`,`@univerjs/docs-hyper-link`,`@univerjs/design`,`react`,`react/jsx-runtime`,`@univerjs/protocol`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDocsHyperLinkUi={},e.UniverDocsUi,e.UniverUi,e.UniverCore,e.UniverDocs,e.UniverEngineRender,e.rxjs,e.UniverDocsHyperLink,e.UniverDesign,e.React,e.React,e.UniverProtocol))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let f={type:r.CommandType.COMMAND,id:s.DocHyperLinkCommandId.Delete,async handler(e,t){if(!t)return!1;let{unitId:n,linkId:a,segmentId:o}=t,s=e.get(r.ICommandService),c=(0,i.deleteCustomRangeFactory)(e,{unitId:n,rangeId:a,segmentId:o});return c?await s.syncExecuteCommand(c.id,c.params):!1}},p={type:r.CommandType.COMMAND,id:s.DocHyperLinkCommandId.Add,async handler(e,t){if(!t)return!1;let{payload:n,unitId:a,selections:o}=t,s=e.get(r.ICommandService),c=(0,r.generateRandomId)(),l=(0,i.addCustomRangeBySelectionFactory)(e,{rangeId:c,rangeType:r.CustomRangeType.HYPERLINK,properties:{url:n},unitId:a,selections:o});return l?s.syncExecuteCommand(l.id,l.params):!1}},m={id:s.DocHyperLinkCommandId.Update,type:r.CommandType.COMMAND,handler(e,t){var n,a,o,s,c;if(!t)return!1;let{unitId:l,payload:u,segmentId:d,linkId:f}=t,p=e.get(r.ICommandService),m=e.get(r.IUniverInstanceService),h=e.get(i.DocSelectionManagerService).getActiveTextRange(),g=m.getUnit(l,r.UniverInstanceType.UNIVER_DOC);if(!h||!g)return!1;let _=(n=g.getSelfOrHeaderFooterModel(d))==null?void 0:n.getBody();if(!_)return!1;let v=(a=_.customRanges)==null?void 0:a.find(e=>e.rangeId===f&&e.rangeType===r.CustomRangeType.HYPERLINK),y=(o=(0,r.getBodySlice)(_,h.startOffset,h.endOffset).textRuns)==null?void 0:o[0];y&&(y.ed=t.label.length+1);let b=(0,i.replaceSelectionFactory)(e,{unitId:l,body:{dataStream:`${t.label}`,customRanges:[{rangeId:f,rangeType:r.CustomRangeType.HYPERLINK,startIndex:0,endIndex:t.label.length+1,properties:{url:u,...v!=null&&(s=v.properties)!=null&&s.textStyleMode?{textStyleMode:v.properties.textStyleMode}:null,...v!=null&&(c=v.properties)!=null&&c.textColorMode?{textColorMode:v.properties.textColorMode}:null}}],textRuns:y?[y]:void 0},selection:{startOffset:h.startOffset,endOffset:h.endOffset,collapsed:!1,segmentId:d}});return b?p.syncExecuteCommand(b.id,b.params):!1}};function h(e){return e.trim().length===0}function g(e){return/^[a-zA-Z]+:\/\//.test(e)}function _(e){return/^[\w.-]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function v(e){return g(e)?e:_(e)?`mailto://${e}`:`https://${e}`}function y(){let e=(0,n.useDependency)(L),t=(0,n.useObservable)(e.editingLink$,e.editing),a=(0,n.useDependency)(r.ICommandService),o=(0,n.useDependency)(r.IUniverInstanceService),s=(0,n.useDependency)(i.DocSelectionManagerService),[c,u]=(0,l.useState)(``),[d,f]=(0,l.useState)(``),[g,_]=(0,l.useState)(!1),y=r.Tools.isLegalUrl(c),b=t?o.getUnit(t.unitId,r.UniverInstanceType.UNIVER_DOC):o.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_DOC);return(0,l.useEffect)(()=>{var e,n;let i=s.getActiveTextRange();if(!i)return;if(t){var a,o;let e=b==null||(a=b.getSelfOrHeaderFooterModel(t.segmentId))==null?void 0:a.getBody(),n=e==null||(o=e.customRanges)==null?void 0:o.find(e=>t.linkId===e.rangeId&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex);if(b&&n){var c;u(((c=n.properties)==null?void 0:c.url)??``),f(r.BuildTextUtils.transform.getPlainText((0,r.getBodySlice)(e,n.startIndex,n.endIndex+1).dataStream))}return}let l=b==null||(e=b.getSelfOrHeaderFooterModel(i.segmentId))==null?void 0:e.getBody(),d=l?i:null,p=d&&((n=r.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(d,(l==null?void 0:l.customRanges)??[]))==null?void 0:n[0]);if(b&&p){var m;u(((m=p.properties)==null?void 0:m.url)??``)}},[b,s,t]),{doc:b,editing:t,handleCancel:()=>e.hideEditPopup(),handleConfirm:()=>{if(_(!0),!y||!b)return;let n=v(c);if(t){if(h(d))return;a.executeCommand(m.id,{unitId:b.getUnitId(),payload:n,linkId:t.linkId,label:d,segmentId:t.segmentId}).catch(()=>void 0)}else a.executeCommand(p.id,{unitId:b.getUnitId(),payload:n}).catch(()=>void 0);e.hideEditPopup()},isLegal:y,label:d,link:c,setLabel:f,setLink:u,showError:g}}let b=()=>{let e=(0,n.useDependency)(r.LocaleService),{doc:t,editing:i,handleCancel:a,handleConfirm:o,isLegal:s,label:l,link:d,setLabel:f,setLink:p,showError:m}=y();if(t)return(0,u.jsxs)(`div`,{className:(0,c.clsx)(`univer-box-border univer-w-[328px] univer-rounded-xl univer-bg-gray-0 univer-px-6 univer-py-5 univer-shadow dark:!univer-bg-gray-900`,c.borderClassName),children:[(0,u.jsxs)(`div`,{children:[i?(0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.label`),error:m&&h(l)?e.t(`docs-hyper-link-ui.edit.labelError`):``,children:(0,u.jsx)(c.Input,{value:l,onChange:f,autoFocus:!0,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()}})}):null,(0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.address`),error:m&&!s?e.t(`docs-hyper-link-ui.edit.addressError`):``,children:(0,u.jsx)(c.Input,{value:d,onChange:p,autoFocus:!0,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()}})})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-justify-end univer-gap-3`,children:[(0,u.jsx)(c.Button,{onClick:a,children:e.t(`docs-hyper-link-ui.edit.cancel`)}),(0,u.jsx)(c.Button,{variant:`primary`,disabled:h(d),onClick:o,children:e.t(`docs-hyper-link-ui.edit.confirm`)})]})]})};b.componentKey=`docs-hyper-link-edit`;function x({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,l.useId)()}`,d=(0,l.useRef)(null);return(0,l.useImperativeHandle)(e,()=>d.current),(0,l.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return T(d.current)},[n,r]),S(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:c,...s},o)}function S(e,t,n,r,i){return(0,l.createElement)(e.tag,{key:t,...C(e,n,i),...r},(w(e,n).children||[]).map((r,a)=>S(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function C(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function w(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function T(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:E(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(D(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function E(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function D(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}x.displayName=`UniverIcon`;let O={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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`}}]},k=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`copy-icon`,ref:t,icon:O}))});k.displayName=`CopyIcon`;let A={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M7.30999 8.71386C6.39955 7.80343 6.37922 6.34731 7.26629 5.45772L10.313 2.41112C11.2111 1.51303 12.6799 1.51258 13.5691 2.45476C14.4811 3.36679 14.4798 4.84384 13.6128 5.71094L10.9677 8.35604`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.22}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5.0456 7.66774L2.4005 10.3128C1.50242 11.2109 1.50197 12.6798 2.44413 13.5691C3.35615 14.4811 4.8332 14.4798 5.70033 13.6127L8.747 10.566C9.65743 9.65558 9.67776 8.19945 8.7905 7.30999`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.22}}]},j=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`link-icon`,ref:t,icon:A}))});j.displayName=`LinkIcon`;let ee={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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.76157C6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449C14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797C11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.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.05395C4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092C3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721C8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332C2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302C13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332Z`}}]},te=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`unlink-icon`,ref:t,icon:ee}))});te.displayName=`UnlinkIcon`;let ne={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,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`}}]},re=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(x,Object.assign({},e,{id:`write-icon`,ref:t,icon:ne}))});re.displayName=`WriteIcon`;let M=()=>{var e,t,a,o,s;let l=(0,n.useDependency)(L),p=(0,n.useDependency)(r.ICommandService),m=(0,n.useDependency)(n.IMessageService),h=(0,n.useDependency)(r.LocaleService),g=(0,n.useObservable)(l.showingLink$,l.showing),_=(0,n.useDependency)(r.IUniverInstanceService),v=(0,n.useDependency)(r.IPermissionService);if(!g)return null;let{unitId:y,linkId:b,segmentId:x,startIndex:S,endIndex:C}=g,w=_.getUnit(y,r.UniverInstanceType.UNIVER_DOC),T=w instanceof r.DocumentDataModel?(e=w.getSelfOrHeaderFooterModel(x))==null?void 0:e.getBody():void 0,E=T==null||(t=T.customRanges)==null?void 0:t.find(e=>e.rangeId===b&&e.rangeType===r.CustomRangeType.HYPERLINK&&e.startIndex===S&&e.endIndex===C);if(!E)return null;let D=((a=E.properties)==null?void 0:a.url)??`#${((o=E.properties)==null?void 0:o.bookmarkId)??((s=E.properties)==null?void 0:s.headingId)??``}`,O=l.canEditLink(y,g),A=(0,i.getDocumentPermissionValue)(v,y,y,d.UnitAction.Copy);return(0,u.jsxs)(`div`,{className:(0,c.clsx)(`univer-box-border univer-flex univer-max-w-80 univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-gray-0 univer-p-3 univer-shadow dark:!univer-bg-gray-900`,c.borderClassName),onPointerEnter:()=>{l.cancelScheduledHideInfoPopup()},onPointerLeave:()=>{l.scheduleHideInfoPopup()},onClick:()=>{l.hideInfoPopup()},children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-500`,onClick:()=>p.executeCommand(B.id,{unitId:y,linkId:b,segmentId:x}),children:[(0,u.jsx)(`div`,{className:`univer-mr-2 univer-flex univer-size-5 univer-flex-[0_0_auto] univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-gray-0`,children:(0,u.jsx)(j,{})}),(0,u.jsx)(c.Tooltip,{showIfEllipsis:!0,title:D,children:(0,u.jsx)(`span`,{className:`univer-flex-1 univer-truncate`,children:D})})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-h-6 univer-flex-[0_0_auto] univer-items-center univer-justify-center`,children:[(0,u.jsx)(c.Button,{type:`button`,variant:`text`,size:`small`,"aria-label":h.t(`docs-hyper-link-ui.info.copy`),className:`univer-ml-2 !univer-flex univer-size-6 !univer-rounded !univer-border-0 !univer-bg-transparent !univer-p-0 !univer-text-base !univer-font-normal hover:!univer-bg-transparent active:!univer-bg-transparent disabled:!univer-pointer-events-auto disabled:!univer-opacity-40`,disabled:!A,onClick:()=>{navigator.clipboard.writeText(D),m.show({content:h.t(`docs-hyper-link-ui.info.coped`),type:c.MessageType.Info})},children:(0,u.jsx)(c.Tooltip,{placement:`bottom`,title:h.t(`docs-hyper-link-ui.info.copy`),children:(0,u.jsx)(k,{})})}),O&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base`,onClick:()=>{p.executeCommand(z.id,{link:g})},children:(0,u.jsx)(c.Tooltip,{placement:`bottom`,title:h.t(`docs-hyper-link-ui.info.edit`),children:(0,u.jsx)(re,{})})}),(0,u.jsx)(`div`,{className:`univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base`,onClick:()=>{p.executeCommand(f.id,{unitId:y,linkId:E.rangeId,segmentId:x})},children:(0,u.jsx)(c.Tooltip,{placement:`bottom`,title:h.t(`docs-hyper-link-ui.info.cancel`),children:(0,u.jsx)(te,{})})})]})]})]})};M.componentKey=`univer.doc.link-info-popup`;function N(e){"@babel/helpers - typeof";return N=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},N(e)}function ie(e,t){if(N(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(N(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ae(e){var t=ie(e,`string`);return N(t)==`symbol`?t:t+``}function P(e,t,n){return(t=ae(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F(e,t){return function(n,r){t(n,r,e)}}function I(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function oe(e,t){return(e==null?void 0:e.linkId)===t.linkId&&e.unitId===t.unitId&&(e.segmentId??``)===(t.segmentId??``)&&e.segmentPage===t.segmentPage&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex}let L=class extends r.Disposable{constructor(e,t,n,r,i,a,s,c){super(),this._docCanvasPopupManagerService=e,this._textSelectionManagerService=t,this._univerInstanceService=n,this._permissionService=r,this._renderManagerService=i,this._dialogService=a,this._localeService=s,this._commandService=c,P(this,`_editingLink$`,new o.BehaviorSubject(null)),P(this,`_showingLink$`,new o.BehaviorSubject(null)),P(this,`editingLink$`,this._editingLink$.asObservable()),P(this,`showingLink$`,this._showingLink$.asObservable()),P(this,`_editPopup`,null),P(this,`_editPopupUnitId`,null),P(this,`_infoPopup`,null),P(this,`_infoPopupPinned`,!1),P(this,`_infoPopupHideTimer`,null),P(this,`_infoPopupSuppressed`,!1),P(this,`_infoPopupSuppressionTimer`,null),this.disposeWithMe(()=>{this.cancelScheduledHideInfoPopup(),this._infoPopupSuppressionTimer!==null&&clearTimeout(this._infoPopupSuppressionTimer),this._editingLink$.complete(),this._showingLink$.complete()}),this.disposeWithMe(this._permissionService.permissionPointUpdate$.subscribe(()=>{let e=this.editing;e&&!this.canEditLink(e.unitId,e)&&this.hideEditPopup();let t=this.showing;t&&this._showingLink$.next({...t})})),this.disposeWithMe(this._renderManagerService.disposed$.subscribe(e=>{var t;this._editPopupUnitId===e&&this.hideEditPopup(),((t=this.showing)==null?void 0:t.unitId)===e&&this.hideInfoPopup()}))}dispose(){this.hideEditPopup(),this.hideInfoPopup(),super.dispose()}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}get infoPopupPinned(){return this._infoPopupPinned}showEditPopup(e,n){var i;let a=this._univerInstanceService.getUnit(e,r.UniverInstanceType.UNIVER_DOC);if(a&&(i=(0,t.getEditorRuntimeConfig)(a))!=null&&i.customHyperLinkUI||!this.canEditLink(e,n))return null;this._editPopup&&(this._editPopup.dispose(),this._editPopup=null,this._editPopupUnitId=null),this._editingLink$.next(n);let o=this._textSelectionManagerService.getTextRanges({unitId:e,subUnitId:e}),s=o==null?void 0:o[o.length-1];if(n){let{segmentId:e,segmentPage:t,startIndex:r,endIndex:i}=n;s={collapsed:!1,startOffset:r,endOffset:i+1,segmentId:e,segmentPage:t},this._textSelectionManagerService.replaceDocRanges([{startOffset:r,endOffset:i+1}])}return s?(this._editPopup=this._openEditSurface(s,e),this._editPopupUnitId=e,this._editPopup):null}hideEditPopup(){this._editingLink$.next(null);let e=this._editPopup;this._editPopup=null,e==null||e.dispose(),this._editPopupUnitId=null}showInfoPopup(e,n){var i;let a=this._univerInstanceService.getUnit(e.unitId,r.UniverInstanceType.UNIVER_DOC);if(!(a instanceof r.DocumentDataModel)||(i=(0,t.getEditorRuntimeConfig)(a))!=null&&i.customHyperLinkUI||(this.cancelScheduledHideInfoPopup(),this._infoPopupSuppressed))return;let{linkId:o,unitId:s,segmentId:c,segmentPage:l,startIndex:u,endIndex:d}=e;if(oe(this.showing,e)){n!=null&&n.pinned&&(this._infoPopupPinned=!0);return}return this._infoPopup&&=(this._infoPopup.dispose(),null),this._infoPopupPinned=(n==null?void 0:n.pinned)??!1,this._showingLink$.next({unitId:s,linkId:o,segmentId:c,segmentPage:l,startIndex:u,endIndex:d}),this._infoPopup=this._openInfoSurface(e),this._infoPopup}_openEditSurface(e,t){return this._docCanvasPopupManagerService.attachPopupToRange(e,{componentKey:b.componentKey,direction:`bottom`,offset:[0,10]},t)}_openInfoSurface(e,t=M.componentKey){let{unitId:n,linkId:r,segmentId:i,segmentPage:a,startIndex:o,endIndex:s}=e;return this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:o,endOffset:s+1,segmentId:i,segmentPage:a},{componentKey:t,extraProps:{onEdit:()=>{this.hideInfoPopup(),this.showEditPopup(n,e)},onDelete:async()=>{await this._commandService.executeCommand(f.id,{unitId:n,linkId:r,segmentId:i})&&this.hideInfoPopup()}},direction:`top-center`,multipleDirection:`top`,offset:[0,10],onClickOutside:()=>{this.hideInfoPopup()}},n)}showInfoPopupFromHover(e){this.cancelScheduledHideInfoPopup(),!(this._infoPopupPinned||this._infoPopupSuppressed)&&(this.showing||this.showInfoPopup(e))}hideInfoPopup(){this.cancelScheduledHideInfoPopup(),this._infoPopupPinned=!1,this._showingLink$.next(null);let e=this._infoPopup;this._infoPopup=null,e==null||e.dispose()}scheduleHideInfoPopup(){!this._infoPopupPinned&&this.showing&&(this.cancelScheduledHideInfoPopup(),this._infoPopupHideTimer=setTimeout(()=>{this._infoPopupHideTimer=null,this._infoPopupPinned||this.hideInfoPopup()},150))}cancelScheduledHideInfoPopup(){this._infoPopupHideTimer!==null&&(clearTimeout(this._infoPopupHideTimer),this._infoPopupHideTimer=null)}hideInfoPopupOnPointerDown(){this._infoPopupSuppressed=!0,this._infoPopupSuppressionTimer!==null&&clearTimeout(this._infoPopupSuppressionTimer),this.hideInfoPopup(),this._infoPopupSuppressionTimer=setTimeout(()=>{this._infoPopupSuppressed=!1,this._infoPopupSuppressionTimer=null},0)}canEditLink(e,t){let n=this._univerInstanceService.getUnit(e,r.UniverInstanceType.UNIVER_DOC);if(!(n instanceof r.DocumentDataModel))return!1;if(!t)return(0,i.canEditDocumentTargets)(this._permissionService,e,[]);let a=t.segmentId??``;return(0,i.canEditDocumentTargets)(this._permissionService,e,[...(0,i.getDocumentEntityParentPermissionObjectIds)(n,a,`custom-range`,t.linkId),(0,i.getDocumentEntityPermissionObjectId)(a,`custom-range`,t.linkId)])}};L=I([F(0,(0,r.Inject)(t.DocCanvasPopManagerService)),F(1,(0,r.Inject)(i.DocSelectionManagerService)),F(2,r.IUniverInstanceService),F(3,r.IPermissionService),F(4,a.IRenderManagerService),F(5,n.IDialogService),F(6,(0,r.Inject)(r.LocaleService)),F(7,r.ICommandService)],L);let R=e=>{let t=e.get(i.DocSelectionManagerService),n=e.get(r.IUniverInstanceService),a=t.getTextRanges();if(!(a!=null&&a.length))return!0;let o=a[0];return!(n.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_DOC)&&o&&!o.collapsed)},z={type:r.CommandType.OPERATION,id:`doc.operation.show-hyper-link-edit-popup`,handler(e,t){var n;let i=t==null?void 0:t.link,a=e.get(r.IUniverInstanceService);if(R(e)&&!i)return!1;let o=e.get(L),s=(i==null?void 0:i.unitId)||((n=a.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_DOC))==null?void 0:n.getUnitId());return s?(o.showEditPopup(s,i??null),!0):!1}},se={type:r.CommandType.OPERATION,id:`doc.operation.toggle-hyper-link-info-popup`,handler(e,t){let n=e.get(L);return t?(t.fromHover?n.showInfoPopupFromHover(t):n.showInfoPopup(t),!0):(n.hideInfoPopup(),!0)}},B={type:r.CommandType.OPERATION,id:`doc.operation.click-hyper-link`,handler(e,n){var o,s;if(!n)return!1;let{unitId:c,linkId:l,segmentId:u}=n,d=e.get(r.IUniverInstanceService).getUnit(c,r.UniverInstanceType.UNIVER_DOC),f=d==null||(o=d.getSelfOrHeaderFooterModel(u))==null?void 0:o.getBody(),p=f==null||(s=f.customRanges)==null||(s=s.find(e=>e.rangeId===l&&e.rangeType===r.CustomRangeType.HYPERLINK))==null?void 0:s.properties;if(p!=null&&p.bookmarkId||p!=null&&p.headingId){var m;let n=ce(d==null?void 0:d.getBody(),p.bookmarkId,p.headingId);if(n==null)return!1;let r={startOffset:n,endOffset:n,collapsed:!0},o=e.get(i.DocSelectionManagerService),s=()=>o.replaceDocRanges([r],{unitId:c,subUnitId:c},!1,{[i.DOC_SELECTION_OPTION_PRESERVE_CARET]:!0}),l=e.get(a.IRenderManagerService).getRenderUnitById(c),u=l==null||(m=l.getInjector)==null?void 0:m.call(l),f=u!=null&&u.has(t.DocBackScrollRenderController)?l==null?void 0:l.with(t.DocBackScrollRenderController):null;return f?f.scrollToRange(r,s):s(),!0}return!(p!=null&&p.url)||!(0,r.isSafeUrl)(p.url)?!1:(window.open(p.url,`_blank`,`noopener noreferrer`),!0)}};function ce(e,t,n){if(e){if(t){var i;let n=(i=e.customRanges)==null?void 0:i.find(e=>{var n;return e.rangeType===r.CustomRangeType.BOOKMARK&&(e.rangeId===t||((n=e.properties)==null?void 0:n.bookmarkId)===t)});if(n)return n.startIndex}if(n){var a;let t=((a=e.paragraphs)==null?void 0:a.findIndex(e=>{var t;return((t=e.paragraphStyle)==null?void 0:t.headingId)===n}))??-1;if(t>=0)return t===0?0:e.paragraphs[t-1].startIndex+1}}}function V(e){return{id:z.id,type:n.MenuItemType.BUTTON,icon:`LinkIcon`,title:`docs-hyper-link-ui.menu.tooltip`,tooltip:`docs-hyper-link-ui.menu.tooltip`,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_DOC),disabled$:new o.Observable(function(t){let n=e.get(i.DocSelectionManagerService).textSelection$.pipe((0,o.debounceTime)(16)).subscribe(()=>{t.next(R(e))});return()=>{n.unsubscribe()}})}}let le={id:z.id,binding:n.MetaKeys.CTRL_COMMAND|n.KeyCode.K,description:`docs-hyper-link-ui.menu.tooltip`,preconditions:t.whenDocAndEditorFocused},ue={[n.RibbonInsertGroup.MEDIA]:{[z.id]:{order:1,gridLayout:{row:1,column:5},menuItemFactory:V}},[t.FLOAT_TOOLBAR_MENU_POSITION]:{[z.id]:{order:20,menuItemFactory:V}},[n.ContextMenuPosition.MAIN_AREA]:{[n.ContextMenuGroup.DATA]:{[z.id]:{order:0,menuItemFactory:V}}},[n.ContextMenuPosition.PARAGRAPH]:{[n.ContextMenuGroup.LAYOUT]:{[t.INSERT_BELLOW_MENU_ID]:{[z.id]:{order:6,menuItemFactory:V}}},[t.EMPTY_PARAGRAPH_MENU_ID]:{[n.ContextMenuGroup.LAYOUT]:{[z.id]:{order:6,menuItemFactory:V}}}}};var de=`@univerjs/docs-hyper-link-ui`,fe=`1.0.3`;let pe=`docs-hyper-link-ui.config`,H={},U=class extends r.Disposable{constructor(e,t,n){super(),this._commandService=e,this._univerInstanceService=t,this._docHyperLinkService=n,P(this,`_selection`,null),this._initSelectionChange(),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(e=>{var t;((t=this._selection)==null?void 0:t.unitId)===e.getUnitId()&&(this._selection=null)}))}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===i.RichTextEditingMutation.id){var t;e.params.unitId===((t=this._docHyperLinkService.showing)==null?void 0:t.unitId)&&this._docHyperLinkService.hideInfoPopup();return}if(e.id===i.SetTextSelectionsOperation.id){var n;let t=e.params,{unitId:i,ranges:o,segmentId:s}=t,c=this._univerInstanceService.getUnit(i,r.UniverInstanceType.UNIVER_DOC),l=o[0],u=JSON.stringify([i,s??``,l==null?void 0:l.startOffset,l==null?void 0:l.endOffset,l==null?void 0:l.segmentPage]),d=u===((n=this._selection)==null?void 0:n.key);this._selection={unitId:i,key:u};let f=this._docHyperLinkService.editing;if((f==null?void 0:f.unitId)===i&&(f.segmentId??``)===(s??``)&&(l==null?void 0:l.startOffset)===f.startIndex&&l.endOffset===f.endIndex+1)return;if(t.isEditing){this._docHyperLinkService.hideInfoPopup();return}if(d)return;if(l!=null&&l.collapsed&&c){var a;let{startOffset:e,endOffset:t,segmentPage:n}=l,o=(a=c.getSelfOrHeaderFooterModel(s))==null||(a=a.getBody())==null?void 0:a.customRanges,u=this._docHyperLinkService.showing,d=((u==null?void 0:u.unitId)===i&&(u.segmentId??``)===s&&u.segmentPage===n&&u.endIndex===t-1?o==null?void 0:o.find(n=>n.rangeId===u.linkId&&n.rangeType===r.CustomRangeType.HYPERLINK&&n.startIndex<=e&&n.endIndex===t-1):void 0)??(o==null?void 0:o.find(n=>n.rangeType===r.CustomRangeType.HYPERLINK&&n.startIndex<=e&&n.endIndex>t-1));if(d){this._docHyperLinkService.showInfoPopup({unitId:i,linkId:d.rangeId,segmentId:s,segmentPage:n,startIndex:d.startIndex,endIndex:d.endIndex});return}}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}}))}};U=I([F(0,r.ICommandService),F(1,r.IUniverInstanceService),F(2,(0,r.Inject)(L))],U);function W(){let e=(0,n.useDependency)(r.LocaleService),{doc:t,editing:i,handleCancel:a,handleConfirm:o,isLegal:s,label:l,link:d,setLabel:f,setLink:p,showError:m}=y();if(t)return(0,u.jsxs)(`div`,{className:`univer-box-border univer-w-full univer-bg-gray-0 univer-py-2 dark:!univer-bg-gray-900`,children:[(0,u.jsxs)(`div`,{children:[i?(0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.label`),error:m&&h(l)?e.t(`docs-hyper-link-ui.edit.labelError`):``,children:(0,u.jsx)(c.Input,{value:l,onChange:f,autoFocus:!0,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()}})}):null,(0,u.jsx)(c.FormLayout,{label:e.t(`docs-hyper-link-ui.edit.address`),error:m&&!s?e.t(`docs-hyper-link-ui.edit.addressError`):``,children:(0,u.jsx)(c.Input,{value:d,onChange:p,autoFocus:!i,onKeyDown:e=>{e.keyCode===n.KeyCode.ENTER&&o()}})})]}),(0,u.jsxs)(`div`,{className:`univer-mt-5 univer-flex univer-gap-3`,children:[(0,u.jsx)(c.Button,{className:`univer-h-12 univer-flex-1`,onClick:a,children:e.t(`docs-hyper-link-ui.edit.cancel`)}),(0,u.jsx)(c.Button,{variant:`primary`,className:`univer-h-12 univer-flex-1`,disabled:h(d),onClick:o,children:e.t(`docs-hyper-link-ui.edit.confirm`)})]})]})}W.componentKey=`univer.doc.mobile-hyper-link-edit`;function G(){var e,t,a;let o=(0,n.useDependency)(r.ICommandService),s=(0,n.useDependency)(L),l=(0,n.useDependency)(r.LocaleService),p=(0,n.useDependency)(n.IMessageService),m=(0,n.useDependency)(r.IPermissionService),h=(0,n.useDependency)(r.IUniverInstanceService),g=(0,n.useObservable)(s.showingLink$,s.showing);if(!g)return null;let{unitId:_,linkId:v,segmentId:y,startIndex:b,endIndex:x}=g,S=h.getUnit(_,r.UniverInstanceType.UNIVER_DOC),C=S instanceof r.DocumentDataModel?(e=S.getSelfOrHeaderFooterModel(y))==null?void 0:e.getBody():void 0,w=C==null||(t=C.customRanges)==null?void 0:t.find(e=>e.rangeId===v&&e.rangeType===r.CustomRangeType.HYPERLINK&&e.startIndex===b&&e.endIndex===x);if(!w)return null;let T=(a=w.properties)==null?void 0:a.url,E=s.canEditLink(_,g),D=(0,i.getDocumentPermissionValue)(m,_,_,d.UnitAction.Copy);return(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2 univer-py-2`,children:[(0,u.jsx)(c.MobileActionRow,{title:(0,u.jsx)(`span`,{className:`univer-truncate univer-text-primary-600`,children:T}),"aria-label":T,variant:`subtle`,onClick:()=>window.open(T,void 0,`noopener noreferrer`)}),D&&(0,u.jsx)(c.MobileActionRow,{title:l.t(`docs-hyper-link-ui.info.copy`),"aria-label":l.t(`docs-hyper-link-ui.info.copy`),variant:`subtle`,onClick:()=>navigator.clipboard.writeText(T).then(()=>{p.show({content:l.t(`docs-hyper-link-ui.info.coped`),type:c.MessageType.Info})}).catch(()=>void 0)}),E&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.MobileActionRow,{title:l.t(`docs-hyper-link-ui.info.edit`),"aria-label":l.t(`docs-hyper-link-ui.info.edit`),variant:`subtle`,onClick:()=>{o.executeCommand(z.id,{link:g}).catch(()=>void 0)}}),(0,u.jsx)(c.MobileActionRow,{title:l.t(`docs-hyper-link-ui.info.cancel`),"aria-label":l.t(`docs-hyper-link-ui.info.cancel`),variant:`subtle`,onClick:()=>{o.executeCommand(f.id,{unitId:_,linkId:w.rangeId,segmentId:y}).catch(()=>void 0)}})]})]})}G.componentKey=`univer.doc.mobile-link-info-popup`;let K=class extends r.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[W.componentKey,W],[G.componentKey,G]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({LinkIcon:j}))}};K=I([F(0,(0,r.Inject)(n.ComponentManager)),F(1,(0,r.Inject)(n.IconManager))],K);let q=class extends r.Disposable{get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}constructor(e,t,n,i,a,o){super(),this._context=e,this._docEventManagerService=t,this._commandService=n,this._hyperLinkPopupService=i,this._docSkeletonManagerService=a,this._mobileElementMenuService=o,this._context.unitId!==r.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&(this._initPointerDown(),this._initClick())}_initPointerDown(){this.disposeWithMe(this._docEventManagerService.pointerDownCustomRanges$.subscribe(e=>{let t=e.find(e=>e.range.rangeType===r.CustomRangeType.HYPERLINK);if(!t){this._hyperLinkPopupService.hideInfoPopupOnPointerDown();return}let n={unitId:this._context.unitId,linkId:t.range.rangeId,segmentId:t.segmentId,segmentPage:t.segmentPageIndex,startIndex:t.range.startIndex,endIndex:t.range.endIndex},i=t.rects[0];i&&this._hyperLinkPopupService.canEditLink(n.unitId,n)&&this._mobileElementMenuService.capture({unitId:n.unitId,rect:i,onEdit:()=>this._hyperLinkPopupService.showEditPopup(n.unitId,n),onDelete:()=>this._commandService.executeCommand(f.id,n)})}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(e=>{let t=e.range;if(t.rangeType===r.CustomRangeType.HYPERLINK){if(!e.ctrlKey&&!e.metaKey){this._hyperLinkPopupService.showInfoPopup({unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId,segmentPage:e.segmentPageIndex,startIndex:t.startIndex,endIndex:t.endIndex},{pinned:!0});return}this._commandService.executeCommand(B.id,{unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId})}}))}};q=I([F(1,(0,r.Inject)(t.DocEventManagerService)),F(2,r.ICommandService),F(3,(0,r.Inject)(L)),F(4,(0,r.Inject)(i.DocSkeletonManagerService)),F(5,(0,r.Inject)(t.DocMobileElementMenuService))],q);let J=class extends r.Disposable{constructor(e,t,n){super(),this._docInterceptorService=t,this._hyperLinkService=n,this._init()}_init(){this._docInterceptorService.intercept(i.DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:(e,t,n)=>{if(!e)return n(e);let{unitId:r,index:i}=t,a=this._hyperLinkService.showing;if(!a)return n({...e,active:!1});let{linkId:o,unitId:s,startIndex:c,endIndex:l}=a,u=s===r&&e.rangeId===o&&i>=c&&i<=l;return n({...e,active:u})}})}};J=I([F(1,(0,r.Inject)(i.DocInterceptorService)),F(2,(0,r.Inject)(L))],J);let Y=class extends r.Disposable{constructor(e,t,n){super(),this._commandService=e,this._menuManagerService=t,this._shortcutService=n,this._initCommands(),this._initMenus(),this._initShortcut()}_initCommands(){[p,m,f,z,se,B].forEach(e=>{this._commandService.registerCommand(e)})}_initShortcut(){[le].forEach(e=>{this._shortcutService.registerShortcut(e)})}_initMenus(){this._menuManagerService.appendRootMenu({[t.FLOAT_TOOLBAR_MENU_POSITION]:{}}),this._menuManagerService.mergeMenu(ue)}};Y=I([F(0,r.ICommandService),F(1,n.IMenuManagerService),F(2,n.IShortcutService)],Y);var me=class extends L{_openEditSurface(e,t){return this._dialogService.open({id:`doc-mobile-hyper-link-editor`,title:{title:this._localeService.t(`docs-hyper-link-ui.menu.tooltip`)},children:{label:W.componentKey},maskClosable:!1,onClose:()=>this.hideEditPopup()})}_openInfoSurface(e){return this.canEditLink(e.unitId,e)?super._openInfoSurface(e,t.MOBILE_DOC_ELEMENT_MENU):this._dialogService.open({id:`doc-mobile-hyper-link-viewer`,title:{title:this._localeService.t(`docs-hyper-link-ui.menu.tooltip`)},children:{label:G.componentKey},onClose:()=>this.hideInfoPopup()})}};let he=`DOC_HYPER_LINK_UI_PLUGIN`,X=class extends r.Plugin{constructor(e=H,t,n,i){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._configService=i;let{menu:a,...o}=(0,r.merge)({},H,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(pe,o)}onStarting(){[[K],[L,{useClass:me}],[Y],[U]].forEach(e=>this._injector.add(e)),this._injector.get(K),this._injector.get(Y)}onReady(){this._injector.get(U)}onRendered(){[[J],[q]].forEach(e=>{this._renderManagerSrv.registerRenderModule(r.UniverInstanceType.UNIVER_DOC,e)})}};P(X,`pluginName`,he),P(X,`packageName`,de),P(X,`version`,fe),P(X,`type`,r.UniverInstanceType.UNIVER_DOC),X=I([(0,r.DependentOn)(i.UniverDocsPlugin,a.UniverRenderEnginePlugin,s.UniverDocsHyperLinkPlugin,t.UniverDocsMobileUIPlugin),F(1,(0,r.Inject)(r.Injector)),F(2,a.IRenderManagerService),F(3,r.IConfigService)],X);let Z=class extends r.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[b.componentKey,b],[M.componentKey,M]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({LinkIcon:j}))}};Z=I([F(0,(0,r.Inject)(n.ComponentManager)),F(1,(0,r.Inject)(n.IconManager))],Z);let Q=class extends r.Disposable{get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}constructor(e,n,i,a,o,s){var c;super(),this._context=e,this._docEventManagerService=n,this._commandService=i,this._hyperLinkPopupService=a,this._docSkeletonManagerService=o,this._docSelectionManagerService=s,!(this._context.unitId===r.DOCS_NORMAL_EDITOR_UNIT_ID_KEY||(c=(0,t.getEditorRuntimeConfig)(this._context.unit))!=null&&c.customHyperLinkUI)&&(this._initPointerDown(),this._initHover(),this._initClick())}_hideInfoPopup(){this._hyperLinkPopupService.infoPopupPinned||this._hyperLinkPopupService.showing&&this._hyperLinkPopupService.scheduleHideInfoPopup()}_normalizeSegmentId(e){var t;return e?(t=this._context.unit.getBody())!=null&&(t=t.tables)!=null&&t.some(t=>t.tableId===e)?``:e:``}_initPointerDown(){this.disposeWithMe(this._docEventManagerService.pointerDownCustomRanges$.subscribe(e=>{e.find(e=>e.range.rangeType===r.CustomRangeType.HYPERLINK)||this._hyperLinkPopupService.hideInfoPopupOnPointerDown()}))}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe(e=>{var t;let n=e.find(e=>e.range.rangeType===r.CustomRangeType.HYPERLINK),i=this._docSelectionManagerService.getTextRanges(),a=i==null||(t=i[0])==null?void 0:t.segmentId;if(this._normalizeSegmentId(n==null?void 0:n.segmentId)!==this._normalizeSegmentId(a)){this._hideInfoPopup();return}if(n){let e={unitId:this._context.unitId,linkId:n.range.rangeId,segmentId:n.segmentId,segmentPage:n.segmentPageIndex,startIndex:n.range.startIndex,endIndex:n.range.endIndex};this._commandService.executeCommand(se.id,{...e,fromHover:!0})}else this._hideInfoPopup()}))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe(e=>{let t=e.range;if(t.rangeType===r.CustomRangeType.HYPERLINK){if(!e.ctrlKey&&!e.metaKey){this._hyperLinkPopupService.showInfoPopup({unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId,segmentPage:e.segmentPageIndex,startIndex:t.startIndex,endIndex:t.endIndex},{pinned:!0});return}this._commandService.executeCommand(B.id,{unitId:this._context.unitId,linkId:t.rangeId,segmentId:e.segmentId})}}))}};Q=I([F(1,(0,r.Inject)(t.DocEventManagerService)),F(2,r.ICommandService),F(3,(0,r.Inject)(L)),F(4,(0,r.Inject)(i.DocSkeletonManagerService)),F(5,(0,r.Inject)(i.DocSelectionManagerService))],Q);let $=class extends r.Plugin{constructor(e=H,t,n,i){super(),this._config=e,this._injector=t,this._renderManagerSrv=n,this._configService=i;let{menu:a,...o}=(0,r.merge)({},H,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(pe,o)}onStarting(){[[Z],[L],[Y],[U]].forEach(e=>{this._injector.add(e)}),this._injector.get(Z),this._injector.get(Y)}onReady(){this._injector.get(U)}onRendered(){this._initRenderModule()}_initRenderModule(){[[J],[Q]].forEach(e=>{this._renderManagerSrv.registerRenderModule(r.UniverInstanceType.UNIVER_DOC,e)})}};P($,`pluginName`,he),P($,`packageName`,de),P($,`version`,fe),P($,`type`,r.UniverInstanceType.UNIVER_DOC),$=I([(0,r.DependentOn)(i.UniverDocsPlugin,a.UniverRenderEnginePlugin,s.UniverDocsHyperLinkPlugin,t.UniverDocsUIPlugin),F(1,(0,r.Inject)(r.Injector)),F(2,a.IRenderManagerService),F(3,r.IConfigService)],$),e.DocsHyperLinkUIMenuSchema=ue,Object.defineProperty(e,"UniverDocsHyperLinkMobileUIPlugin",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"UniverDocsHyperLinkUIPlugin",{enumerable:!0,get:function(){return $}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-hyper-link-ui",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "private": false,
5
5
  "description": "Hyperlink editing UI for Univer Docs.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -58,18 +58,18 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/core": "1.0.2",
62
- "@univerjs/design": "1.0.2",
63
- "@univerjs/docs": "1.0.2",
64
- "@univerjs/docs-hyper-link": "1.0.2",
65
- "@univerjs/docs-ui": "1.0.2",
66
- "@univerjs/engine-render": "1.0.2",
61
+ "@univerjs/core": "1.0.3",
62
+ "@univerjs/design": "1.0.3",
63
+ "@univerjs/docs": "1.0.3",
64
+ "@univerjs/docs-hyper-link": "1.0.3",
65
+ "@univerjs/docs-ui": "1.0.3",
66
+ "@univerjs/engine-render": "1.0.3",
67
67
  "@univerjs/icons": "1.43.1",
68
- "@univerjs/protocol": "1.0.2",
69
- "@univerjs/ui": "1.0.2"
68
+ "@univerjs/protocol": "1.0.3",
69
+ "@univerjs/ui": "1.0.3"
70
70
  },
71
71
  "devDependencies": {
72
- "@univerjs-infra/shared": "1.0.2",
72
+ "@univerjs-infra/shared": "1.0.3",
73
73
  "postcss": "^8.5.28",
74
74
  "react": "18.3.1",
75
75
  "rxjs": "^7.8.2",