| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889 |
- var rr = Object.defineProperty;
- var ir = (t, e, n) => e in t ? rr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
- var B = (t, e, n) => ir(t, typeof e != "symbol" ? e + "" : e, n);
- import { Tools as Ce, Inject as R, LocaleService as ct, UniverInstanceType as w, isValidRange as Rn, IUniverInstanceService as Y, ICommandService as ie, IConfigService as Ln, RANGE_TYPE as sn, Rectangle as ye, Injector as lt, Disposable as z, Range as Pn, ObjectMatrix as sr, useDependency as E, IContextService as bn, ThemeService as or, DataStreamTreeTokenType as on, CustomRangeType as Ge, BuildTextUtils as Se, ColorKit as ar, DOCS_ZEN_EDITOR_UNIT_ID_KEY as x, DisposableCollection as cr, FOCUSING_SHEET as Ct, generateRandomId as lr, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Ie, DataValidationType as It, CommandType as ut, FOCUSING_FX_BAR_EDITOR as ur, IPermissionService as dr, InterceptorEffectEnum as pr, DependentOn as hr, Plugin as gr, merge as fr } from "@univerjs/core";
- import { SheetHyperLinkType as S, ERROR_RANGE as mr, HyperLinkModel as dt, RemoveHyperLinkMutation as Ue, AddHyperLinkMutation as He, SheetsHyperLinkParserService as kt, UpdateRichHyperLinkCommand as _r, UpdateHyperLinkCommand as vr, AddRichHyperLinkCommand as Sr, AddHyperLinkCommand as Cr, CancelRichHyperLinkCommand as Ir, CancelHyperLinkCommand as yr, UniverSheetsHyperLinkPlugin as Er } from "@univerjs/sheets-hyper-link";
- import { ScrollToRangeOperation as wn, COPY_TYPE as Rr, virtualizeDiscreteRanges as Lt, rangeToDiscreteRange as Lr, PREDEFINED_HOOK_NAME as Ae, getRepeatRange as Pr, ISheetClipboardService as br, IEditorBridgeService as re, IMarkSelectionService as wr, SheetCanvasPopManagerService as Or, getEditingCustomRangePosition as kr, getCustomRangePosition as Tr, whenSheetEditorFocused as xr, getCurrentRangeDisable$ as Nr, IAutoFillService as Mr, APPLY_TYPE as Oe, getAutoFillRepeatRange as Ur, HoverManagerService as Hr, HoverRenderController as Dr, SheetSkeletonManagerService as an } from "@univerjs/sheets-ui";
- import { MessageType as xe, FormLayout as _e, Input as cn, Select as yt, Button as ln, Tooltip as Be } from "@univerjs/design";
- import { deserializeRangeWithSheet as Fe, IDefinedNamesService as On, serializeRangeWithSheet as $r, serializeRangeToRefString as jr, serializeRange as Ar } from "@univerjs/engine-formula";
- import { SetSelectionsOperation as kn, SetWorksheetActiveOperation as Tn, SheetsSelectionsService as Tt, getSheetCommandTarget as xn, WorkbookEditablePermission as xt, WorksheetEditPermission as Nt, WorksheetSetCellValuePermission as Nn, WorksheetInsertHyperlinkPermission as Mt, RangeProtectionPermissionEditPoint as Ut, SheetPermissionCheckController as Mn, WorkbookViewPermission as Br, WorksheetViewPermission as Vr, RangeProtectionPermissionViewPoint as Fr, WorkbookCopyPermission as Wr, WorksheetCopyPermission as Zr, ClearSelectionContentCommand as Gr, ClearSelectionAllCommand as Kr, ClearSelectionFormatCommand as Yr, SheetInterceptorService as zr, INTERCEPTOR_POINT as qr } from "@univerjs/sheets";
- import { IMessageService as Un, useObservable as Jr, IZenZoneService as pt, useEvent as Xr, KeyCode as Pt, MenuItemType as Hn, MetaKeys as Qr, getMenuHiddenObservable as ht, RibbonStartGroup as ei, ContextMenuPosition as ti, ContextMenuGroup as ni, ComponentManager as ri, IShortcutService as ii, IMenuManagerService as si } from "@univerjs/ui";
- import { DocSelectionRenderService as Dn, DocBackScrollRenderController as oi, DocCanvasPopManagerService as ai, calcDocRangePositions as ci, DocEventManagerService as un, UniverDocsUIPlugin as li } from "@univerjs/docs-ui";
- import { IRenderManagerService as $e } from "@univerjs/engine-render";
- import { Subject as ui, BehaviorSubject as di, of as Ne, map as le, filter as dn, switchMap as ue, combineLatest as pi, distinctUntilChanged as hi, debounceTime as We, Observable as gi } from "rxjs";
- import { DocSelectionManagerService as De } from "@univerjs/docs";
- import fi, { useState as X, useMemo as pn, useRef as bt, useCallback as mi, useEffect as ne, forwardRef as he, createElement as ge } from "react";
- import { RangeSelector as _i } from "@univerjs/sheets-formula-ui";
- import { SheetDataValidationModel as hn } from "@univerjs/sheets-data-validation";
- function Ke(t) {
- return Ce.isLegalUrl(t);
- }
- function vi(t) {
- return /^[a-zA-Z]+:\/\//.test(t);
- }
- function Si(t) {
- return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t);
- }
- function Ci(t) {
- if (Ke(t)) {
- const e = vi(t) ? t : Si(t) ? `mailto://${t}` : `http://${t}`;
- let n;
- try {
- n = new URL(e);
- } catch {
- return t;
- }
- return n.hostname === location.hostname && n.port === location.port && n.protocol === location.protocol && n.pathname === location.pathname && n.hash && !n.search ? n.hash : e;
- }
- return t;
- }
- const $n = "sheets-hyper-link-ui.config", gn = {};
- var Ii = Object.defineProperty, yi = Object.getOwnPropertyDescriptor, Ei = (t, e, n, i) => {
- for (var r = i > 1 ? void 0 : i ? yi(e, n) : e, o = t.length - 1, s; o >= 0; o--)
- (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
- return i && r && Ii(e, n, r), r;
- }, ve = (t, e) => (n, i) => e(n, i, t);
- function Ri(t, e) {
- const n = e.getMergeData(), i = e.getMaxColumns() - 1, r = e.getMaxRows() - 1;
- if (i < t.endColumn && (t.endColumn = i), r < t.endRow && (t.endRow = r), t.rangeType === sn.COLUMN || sn.ROW)
- return t;
- const o = [];
- return n.forEach((s) => {
- ye.intersects(t, s) && o.push(s);
- }), ye.realUnion(t, ...o);
- }
- let pe = class {
- constructor(t, e, n, i, r, o) {
- this._univerInstanceService = t, this._commandService = e, this._definedNamesService = n, this._messageService = i, this._localeService = r, this._configService = o;
- }
- navigate(t) {
- switch (t.type) {
- case S.URL:
- this.navigateToOtherWebsite(t.url);
- break;
- default:
- this._navigateToUniver(t.searchObj);
- }
- }
- _navigateToUniver(t) {
- const { gid: e, range: n, rangeid: i } = t, r = this._univerInstanceService.getCurrentUnitForType(w.UNIVER_SHEET);
- if (!r)
- return;
- const o = r.getUnitId();
- if (i) {
- const s = this._definedNamesService.getValueById(o, i);
- if (!s)
- return;
- const { formulaOrRefString: c } = s, l = this._definedNamesService.getWorksheetByRef(o, c);
- if (!l) {
- this._messageService.show({
- content: this._localeService.t("hyperLink.message.refError"),
- type: xe.Error
- });
- return;
- }
- if (l.isSheetHidden()) {
- this._messageService.show({
- content: this._localeService.t("hyperLink.message.hiddenSheet"),
- type: xe.Error
- });
- return;
- }
- this.navigateToDefineName(o, i);
- }
- if (e) {
- if (n) {
- const s = Fe(n);
- Rn(s.range) && n !== mr && this.navigateToRange(o, e, s.range);
- return;
- }
- this.navigateToSheetById(o, e);
- }
- }
- async navigateToRange(t, e, n, i) {
- const r = await this.navigateToSheetById(t, e);
- if (r) {
- const o = Ri(n, r);
- await this._commandService.executeCommand(
- kn.id,
- {
- unitId: t,
- subUnitId: e,
- selections: [{
- range: o,
- primary: null
- }]
- }
- ), await this._commandService.executeCommand(wn.id, {
- range: o,
- forceTop: i
- });
- }
- }
- async navigateToSheetById(t, e) {
- const n = this._univerInstanceService.getUnit(t, w.UNIVER_SHEET);
- if (!n)
- return !1;
- const i = n.getActiveSheet();
- if (!i)
- return !1;
- if (i.getSheetId() === e)
- return i;
- const r = n.getSheetBySheetId(e);
- return r ? n.getHiddenWorksheets().indexOf(e) > -1 ? (this._messageService.show({
- content: this._localeService.t("hyperLink.message.hiddenSheet"),
- type: xe.Error
- }), !1) : await this._commandService.executeCommand(Tn.id, { unitId: t, subUnitId: e }) ? r : !1 : (this._messageService.show({
- content: this._localeService.t("hyperLink.message.noSheet"),
- type: xe.Error
- }), !1);
- }
- async navigateToDefineName(t, e) {
- return this._definedNamesService.focusRange(t, e), !0;
- }
- async navigateToOtherWebsite(t) {
- var n;
- const e = this._configService.getConfig($n);
- if ((n = e == null ? void 0 : e.urlHandler) != null && n.navigateToOtherWebsite)
- return e.urlHandler.navigateToOtherWebsite(t);
- window.open(t, "_blank", "noopener noreferrer");
- }
- };
- pe = Ei([
- ve(0, Y),
- ve(1, ie),
- ve(2, On),
- ve(3, Un),
- ve(4, R(ct)),
- ve(5, Ln)
- ], pe);
- const Ht = "SHEET_HYPER_LINK_UI_PLUGIN";
- var Li = Object.defineProperty, Pi = Object.getOwnPropertyDescriptor, bi = (t, e, n, i) => {
- for (var r = i > 1 ? void 0 : i ? Pi(e, n) : e, o = t.length - 1, s; o >= 0; o--)
- (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
- return i && r && Li(e, n, r), r;
- }, Ve = (t, e) => (n, i) => e(n, i, t);
- let Ye = class extends z {
- constructor(e, n, i, r) {
- super();
- B(this, "_plainTextFilter", /* @__PURE__ */ new Set());
- B(this, "_copyInfo");
- this._sheetClipboardService = e, this._hyperLinkModel = n, this._injector = i, this._resolverService = r, this._initCopyPaste(), this.disposeWithMe(() => {
- this._plainTextFilter.clear();
- });
- }
- registerPlainTextFilter(e) {
- this._plainTextFilter.add(e);
- }
- removePlainTextFilter(e) {
- this._plainTextFilter.delete(e);
- }
- /* If return false the process of paste text will be stop */
- _filterPlainText(e) {
- return Array.from(this._plainTextFilter).every((n) => n(e));
- }
- _initCopyPaste() {
- this._sheetClipboardService.addClipboardHook({
- id: Ht,
- onBeforeCopy: (e, n, i) => this._collect(e, n, i),
- onPasteCells: (e, n, i, r) => {
- const { copyType: o = Rr.COPY, pasteType: s } = r, { range: c } = e || {}, { range: l, unitId: p, subUnitId: u } = n;
- return this._generateMutations(l, { copyType: o, pasteType: s, copyRange: c, unitId: p, subUnitId: u });
- },
- onPastePlainText: (e, n) => {
- const i = this._filterPlainText(n);
- if (Ke(n) && i) {
- const { range: r, unitId: o, subUnitId: s } = e, { ranges: [c], mapFunc: l } = Lt([r]), p = [], u = [];
- return Pn.foreach(c, (g, d) => {
- const { row: v, col: C } = l(g, d), _ = this._hyperLinkModel.getHyperLinkByLocation(o, s, v, C);
- _ && p.push({
- id: Ue.id,
- params: {
- unitId: o,
- subUnitId: s,
- id: _.id
- }
- }), _ && u.push({
- id: He.id,
- params: {
- unitId: o,
- subUnitId: s,
- link: _
- }
- });
- }), { redos: p, undos: u };
- }
- return { undos: [], redos: [] };
- },
- priority: 99
- });
- }
- _collect(e, n, i) {
- const r = new sr();
- this._copyInfo = {
- unitId: e,
- subUnitId: n,
- matrix: r
- };
- const o = this._injector.invoke((l) => Lr(i, l, e, n));
- if (!o)
- return;
- const { rows: s, cols: c } = o;
- s.forEach((l, p) => {
- c.forEach((u, g) => {
- var v;
- const d = this._hyperLinkModel.getHyperLinkByLocation(e, n, l, u);
- r.setValue(p, g, (v = d == null ? void 0 : d.id) != null ? v : "");
- });
- });
- }
- // eslint-disable-next-line max-lines-per-function
- _generateMutations(e, n) {
- if (!this._copyInfo)
- return { redos: [], undos: [] };
- if (!this._copyInfo || !this._copyInfo.matrix.getSizeOf() || !n.copyRange)
- return { redos: [], undos: [] };
- if ([
- Ae.SPECIAL_PASTE_COL_WIDTH,
- Ae.SPECIAL_PASTE_VALUE,
- Ae.SPECIAL_PASTE_FORMAT,
- Ae.SPECIAL_PASTE_FORMULA
- ].includes(n.pasteType))
- return { redos: [], undos: [] };
- const { unitId: r, subUnitId: o } = this._copyInfo, s = [], c = [], { ranges: [l, p], mapFunc: u } = Lt([n.copyRange, e]);
- return Pr(l, p, !0).forEach(({ startRange: d }) => {
- var v;
- (v = this._copyInfo) == null || v.matrix.forValue((C, _, O) => {
- const a = ye.getPositionRange(
- {
- startRow: C,
- endRow: C,
- startColumn: _,
- endColumn: _
- },
- d
- ), b = this._hyperLinkModel.getHyperLink(r, o, O), { row: M, col: k } = u(a.startRow, a.startColumn), L = this._hyperLinkModel.getHyperLinkByLocation(n.unitId, n.subUnitId, M, k), j = Ce.generateRandomId();
- L && s.push({
- id: Ue.id,
- params: {
- unitId: n.unitId,
- subUnitId: n.subUnitId,
- id: L.id
- }
- }), b && (s.push({
- id: He.id,
- params: {
- unitId: n.unitId,
- subUnitId: n.subUnitId,
- link: {
- ...b,
- id: j,
- row: M,
- column: k
- }
- }
- }), c.push({
- id: Ue.id,
- params: {
- unitId: n.unitId,
- subUnitId: n.subUnitId,
- id: j
- }
- })), L && c.push({
- id: He.id,
- params: {
- unitId: n.unitId,
- subUnitId: n.subUnitId,
- link: L
- }
- });
- });
- }), { redos: s, undos: c };
- }
- };
- Ye = bi([
- Ve(0, br),
- Ve(1, R(dt)),
- Ve(2, R(lt)),
- Ve(3, R(pe))
- ], Ye);
- var m = /* @__PURE__ */ ((t) => (t.EDITING = "editing", t.VIEWING = "viewing", t.ZEN_EDITOR = "zen_mode", t))(m || {}), Et = { exports: {} }, ke = {};
- /**
- * @license React
- * react-jsx-runtime.production.min.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- var fn;
- function wi() {
- if (fn) return ke;
- fn = 1;
- var t = fi, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, r = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, o = { key: !0, ref: !0, __self: !0, __source: !0 };
- function s(c, l, p) {
- var u, g = {}, d = null, v = null;
- p !== void 0 && (d = "" + p), l.key !== void 0 && (d = "" + l.key), l.ref !== void 0 && (v = l.ref);
- for (u in l) i.call(l, u) && !o.hasOwnProperty(u) && (g[u] = l[u]);
- if (c && c.defaultProps) for (u in l = c.defaultProps, l) g[u] === void 0 && (g[u] = l[u]);
- return { $$typeof: e, type: c, key: d, ref: v, props: g, _owner: r.current };
- }
- return ke.Fragment = n, ke.jsx = s, ke.jsxs = s, ke;
- }
- var mn;
- function Oi() {
- return mn || (mn = 1, Et.exports = wi()), Et.exports;
- }
- var f = Oi();
- class jn extends z {
- constructor() {
- super(...arguments);
- B(this, "_customHyperLinks", /* @__PURE__ */ new Map());
- }
- isBuiltInLinkType(n) {
- return n !== S.URL;
- }
- getOptions() {
- return Array.from(this._customHyperLinks.values()).map(({ option: n }) => n);
- }
- findCustomHyperLink(n) {
- return Array.from(this._customHyperLinks.values()).find((r) => r.match(n));
- }
- registerCustomHyperLink(n) {
- this._customHyperLinks.set(n.type, n);
- }
- getCustomHyperLink(n) {
- return this._customHyperLinks.get(n);
- }
- removeCustomHyperLink(n) {
- const { _customHyperLinks: i } = this;
- i.delete(n);
- }
- dispose() {
- super.dispose(), this._customHyperLinks.clear();
- }
- }
- const ki = "univer-cell-link-edit", Ti = "univer-cell-link-edit-buttons", _n = {
- cellLinkEdit: ki,
- cellLinkEditButtons: Ti
- }, ze = () => {
- var Ft;
- const [t, e] = X(""), [n, i] = X(!1), [r, o] = X(""), [s, c] = X(!0), [l, p] = X(S.URL), [u, g] = X(""), d = E(ct), v = E(On), C = E(re), _ = E(Y), O = E(K), a = Jr(O.currentEditing$), b = E(kt), M = E(pe), k = E(ie), L = E(jn), j = pn(() => L.getOptions(), [L]), D = E(pt), q = E($e), Ee = E(wr), je = E(De), se = E(bn), Re = E(or), Le = E(De), Pe = bt({}), oe = pn(() => {
- if (!L.isBuiltInLinkType(l))
- return L.getCustomHyperLink(l);
- }, [L, l]), [A, Jn] = X(!1), [be, gt] = X(!1), H = bt(!1), V = _.getCurrentUnitForType(w.UNIVER_SHEET), Xn = (V == null ? void 0 : V.getActiveSheet().getSheetId()) || "", Q = mi((h) => {
- o(h.replaceAll(on.CUSTOM_RANGE_START, "").replaceAll(on.CUSTOM_RANGE_END, ""));
- }, [o]);
- ne(() => {
- var h, y, I, P, N, F, Wt, Zt, Gt, Kt, Yt, zt, qt, Jt, Xt, Qt, en;
- if ((a == null ? void 0 : a.row) !== void 0 && a.col !== void 0) {
- const { customRange: ae, row: vt, col: St } = a;
- let { label: J } = a;
- typeof J == "number" && (J = `${J}`);
- let W;
- if (ae)
- W = {
- id: (h = ae == null ? void 0 : ae.rangeId) != null ? h : "",
- display: J != null ? J : "",
- payload: (I = (y = ae == null ? void 0 : ae.properties) == null ? void 0 : y.url) != null ? I : "",
- row: vt,
- column: St
- };
- else if (a.type === m.VIEWING) {
- const T = _.getUnit(a.unitId), te = T == null ? void 0 : T.getSheetBySheetId(a.subUnitId), U = te == null ? void 0 : te.getCellRaw(a.row, a.col), me = (F = (N = (P = U == null ? void 0 : U.p) == null ? void 0 : P.body) == null ? void 0 : N.customRanges) == null ? void 0 : F.find((nn) => {
- var rn;
- return nn.rangeType === Ge.HYPERLINK && ((rn = nn.properties) == null ? void 0 : rn.url);
- }), we = U == null ? void 0 : U.v;
- U && (!Se.transform.isEmptyDocument((Zt = (Wt = U.p) == null ? void 0 : Wt.body) == null ? void 0 : Zt.dataStream) || Ce.isDefine(we)) && c(!1), W = {
- id: "",
- display: "",
- payload: (Kt = (Gt = me == null ? void 0 : me.properties) == null ? void 0 : Gt.url) != null ? Kt : "",
- row: vt,
- column: St
- };
- } else {
- const T = _.getCurrentUnitForType(w.UNIVER_DOC), te = je.getActiveTextRange(), U = T == null ? void 0 : T.getBody(), me = te && U ? te : null, we = me && ((zt = Se.customRange.getCustomRangesInterestsWithSelection(me, (Yt = U == null ? void 0 : U.customRanges) != null ? Yt : [])) == null ? void 0 : zt[0]);
- c(!1), W = {
- id: "",
- display: J != null ? J : "",
- payload: (Jt = (qt = we == null ? void 0 : we.properties) == null ? void 0 : qt.url) != null ? Jt : "",
- row: vt,
- column: St
- };
- }
- e(W.id);
- const tn = L.findCustomHyperLink(W);
- if (tn) {
- const T = tn.convert(W);
- p(T.type), g(T.payload), Q(T.display);
- return;
- }
- Q(W.display);
- const ee = b.parseHyperLink(W.payload);
- switch (p(ee.type === S.INVALID ? S.RANGE : ee.type), ee.type) {
- case S.URL: {
- g(ee.url), ee.url === W.display && (H.current = !0);
- break;
- }
- case S.RANGE: {
- const T = ee.searchObj, te = T.gid && (en = (Qt = (Xt = _.getUnit(a.unitId)) == null ? void 0 : Xt.getSheetBySheetId(T.gid)) == null ? void 0 : Qt.getName()) != null ? en : "", U = $r(te, Fe(T.range).range);
- g(U), U === W.display && (H.current = !0);
- break;
- }
- case S.SHEET: {
- const T = ee.searchObj;
- g(T.gid);
- break;
- }
- case S.DEFINE_NAME: {
- const T = ee.searchObj;
- g(T.rangeid);
- break;
- }
- default:
- g("");
- break;
- }
- }
- }, [a, M, L, je, _]), ne(() => {
- let h = null;
- if (a && !a.customRangeId && a.type === m.VIEWING && Ce.isDefine(a.row) && Ce.isDefine(a.col)) {
- const y = _.getUnit(a.unitId, w.UNIVER_SHEET), I = y == null ? void 0 : y.getSheetBySheetId(a.subUnitId), P = I == null ? void 0 : I.getMergedCell(a.row, a.col), N = new ar(Re.getCurrentTheme().hyacinth500).toRgb();
- h = Ee.addShape(
- {
- range: P != null ? P : {
- startColumn: a.col,
- endColumn: a.col,
- startRow: a.row,
- endRow: a.row
- },
- style: {
- // hasAutoFill: false,
- fill: `rgb(${N.r}, ${N.g}, ${N.b}, 0.12)`,
- strokeWidth: 1,
- stroke: "#FFBD37",
- widgets: {}
- },
- primary: null
- },
- [],
- -1
- );
- }
- return () => {
- h && Ee.removeShape(h);
- };
- }, [a, Ee, Re, _]), ne(() => {
- gt(l === S.RANGE);
- }, [l]), ne(() => {
- const h = (a == null ? void 0 : a.type) === m.ZEN_EDITOR ? q.getRenderById(x) : q.getRenderById(C.getCurrentEditorId()), y = new cr();
- if (h) {
- const I = h.with(Dn);
- I.setReserveRangesStatus(!0), y.add(() => {
- I.setReserveRangesStatus(!1);
- });
- }
- return () => {
- C.disableForceKeepVisible(), y.dispose();
- };
- }, [a == null ? void 0 : a.type, C, q]), ne(() => (O.setIsKeepVisible(be), () => {
- O.setIsKeepVisible(!1);
- }), [be, O]), ne(() => () => {
- D.temporaryHidden && (D.show(), se.setContextValue(Ct, !1));
- }, [se, D]), ne(() => {
- if (be)
- return C.enableForceKeepVisible(), () => {
- C.disableForceKeepVisible();
- };
- }, [be, C]);
- const Qn = [
- {
- label: d.t("hyperLink.form.link"),
- value: S.URL
- },
- {
- label: d.t("hyperLink.form.range"),
- value: S.RANGE
- },
- {
- label: d.t("hyperLink.form.worksheet"),
- value: S.SHEET
- },
- {
- label: d.t("hyperLink.form.definedName"),
- value: S.DEFINE_NAME
- },
- ...j
- ];
- if (!V)
- return;
- const er = V.getHiddenWorksheets(), ft = V.getSheets().map((h) => ({ label: h.getName(), value: h.getSheetId() })).filter((h) => er.indexOf(h.value) === -1), mt = Object.values((Ft = v.getDefinedNameMap(V.getUnitId())) != null ? Ft : {}).map((h) => ({
- label: h.name,
- value: h.id
- })), Vt = (h, y) => {
- if (h === S.URL)
- return Ci(y);
- if (h === S.RANGE) {
- const I = Fe(y), P = V.getSheetBySheetName(I.sheetName);
- if (P)
- return `#gid=${P.getSheetId()}&range=${Ar(I.range)}`;
- }
- return `#${h}=${y}`;
- }, tr = Xr((h) => {
- var N;
- const I = h.split(",").map(Fe)[0];
- if (!I || !Rn(I.range))
- return;
- I.sheetName || (I.sheetName = ((N = V.getActiveSheet()) == null ? void 0 : N.getName()) || "");
- const P = jr(I);
- g(P), P && (H.current || !r) && (Q(P), H.current = !0);
- }), _t = async () => {
- if (s && !r || !u || l === S.URL && !Ke(u)) {
- Jn(!0);
- return;
- }
- if (a)
- if (t) {
- const h = a.type === m.ZEN_EDITOR || a.type === m.EDITING ? _r.id : vr.id;
- await k.executeCommand(h, {
- id: t,
- unitId: a.unitId,
- subUnitId: a.subUnitId,
- payload: {
- display: s ? r : "",
- payload: Vt(l, u)
- },
- row: a.row,
- column: a.col,
- documentId: a.type === m.ZEN_EDITOR ? x : C.getCurrentEditorId()
- });
- } else {
- const h = a.type === m.ZEN_EDITOR || a.type === m.EDITING ? Sr.id : Cr.id;
- await k.executeCommand(h, {
- unitId: a.unitId,
- subUnitId: a.subUnitId,
- link: {
- id: lr(),
- row: a.row,
- column: a.col,
- payload: Vt(l, u),
- display: s ? r : ""
- },
- documentId: a.type === m.ZEN_EDITOR ? x : C.getCurrentEditorId()
- });
- }
- if ((a == null ? void 0 : a.type) === m.VIEWING) {
- await k.executeCommand(Tn.id, {
- unitId: a.unitId,
- subUnitId: a.subUnitId
- });
- const h = 1;
- await k.executeCommand(wn.id, {
- range: {
- startRow: Math.max(a.row - h, 0),
- endRow: a.row + h,
- startColumn: Math.max(a.col - h, 0),
- endColumn: a.col + h
- }
- });
- }
- k.executeCommand(Je.id);
- }, nr = (h) => {
- var I;
- if (l !== S.RANGE)
- return;
- const y = (I = Pe.current) == null ? void 0 : I.handleOutClick;
- y && y(h, () => gt(!1));
- };
- return a ? /* @__PURE__ */ f.jsxs("div", { className: _n.cellLinkEdit, style: { display: n ? "none" : "block" }, onClick: nr, children: [
- s ? /* @__PURE__ */ f.jsx(
- _e,
- {
- label: d.t("hyperLink.form.label"),
- error: A && !r ? d.t("hyperLink.form.inputError") : "",
- children: /* @__PURE__ */ f.jsx(
- cn,
- {
- value: r,
- onChange: (h) => {
- Q(h), H.current = !1;
- },
- placeholder: d.t("hyperLink.form.labelPlaceholder"),
- autoFocus: !0,
- onKeyDown: (h) => {
- h.keyCode === Pt.ENTER && _t();
- }
- }
- )
- }
- ) : null,
- /* @__PURE__ */ f.jsx(_e, { label: d.t("hyperLink.form.type"), children: /* @__PURE__ */ f.jsx(
- yt,
- {
- options: Qn,
- value: l,
- onChange: (h) => {
- p(h), g("");
- }
- }
- ) }),
- l === S.URL && /* @__PURE__ */ f.jsx(
- _e,
- {
- error: A ? u ? Ke(u) ? "" : d.t("hyperLink.form.linkError") : d.t("hyperLink.form.inputError") : "",
- children: /* @__PURE__ */ f.jsx(
- cn,
- {
- value: u,
- onChange: (h) => {
- g(h), h && (H.current || !r || r === u) && (Q(h), H.current = !0);
- },
- placeholder: d.t("hyperLink.form.linkPlaceholder"),
- autoFocus: !0,
- onKeyDown: (h) => {
- h.keyCode === Pt.ENTER && _t();
- }
- }
- )
- }
- ),
- l === S.RANGE && /* @__PURE__ */ f.jsx(_e, { error: A && !u ? d.t("hyperLink.form.inputError") : "", children: /* @__PURE__ */ f.jsx(
- _i,
- {
- unitId: V.getUnitId(),
- subUnitId: Xn,
- isOnlyOneRange: !0,
- isSupportAcrossSheet: !0,
- initValue: u,
- onChange: tr,
- isFocus: be,
- onFocus: () => gt(!0),
- actions: Pe.current,
- onRangeSelectorDialogVisibleChange: async (h) => {
- var y, I;
- if (h)
- a.type === m.ZEN_EDITOR && (D.hide(), se.setContextValue(Ct, !0)), a.type !== m.VIEWING && C.enableForceKeepVisible(), i(!0);
- else {
- if (await M.navigateToRange(a.unitId, a.subUnitId, { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col }, !0), a.type === m.ZEN_EDITOR) {
- await k.executeCommand(kn.id, {
- unitId: a.unitId,
- subUnitId: a.subUnitId,
- selections: [{ range: { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col } }]
- }), D.show(), se.setContextValue(Ct, !1);
- const P = (y = q.getRenderById(x)) == null ? void 0 : y.with(oi), N = (I = Le.getTextRanges({ unitId: x, subUnitId: x })) == null ? void 0 : I[0];
- P && N && (P.scrollToRange(N), Le.refreshSelection({ unitId: x, subUnitId: x }));
- }
- C.disableForceKeepVisible(), i(!1);
- }
- }
- }
- ) }),
- l === S.SHEET && /* @__PURE__ */ f.jsx(_e, { error: A && !u ? d.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ f.jsx(
- yt,
- {
- options: ft,
- value: u,
- onChange: (h) => {
- var P, N;
- g(h);
- const y = (P = ft.find((F) => F.value === h)) == null ? void 0 : P.label, I = (N = ft.find((F) => F.value === u)) == null ? void 0 : N.label;
- y && (H.current || !r || r === I) && (Q(y), H.current = !0);
- }
- }
- ) }),
- l === S.DEFINE_NAME && /* @__PURE__ */ f.jsx(_e, { error: A && !u ? d.t("hyperLink.form.selectError") : "", children: /* @__PURE__ */ f.jsx(
- yt,
- {
- options: mt,
- value: u,
- onChange: (h) => {
- var P, N;
- g(h);
- const y = (P = mt.find((F) => F.value === h)) == null ? void 0 : P.label, I = (N = mt.find((F) => F.value === u)) == null ? void 0 : N.label;
- y && (H.current || !r || r === I) && (Q(y), H.current = !0);
- }
- }
- ) }),
- (oe == null ? void 0 : oe.Form) && /* @__PURE__ */ f.jsx(
- oe.Form,
- {
- linkId: t,
- payload: u,
- display: r,
- showError: A,
- setByPayload: H,
- setDisplay: (h) => {
- Q(h), H.current = !0;
- },
- setPayload: g
- }
- ),
- /* @__PURE__ */ f.jsxs("div", { className: _n.cellLinkEditButtons, children: [
- /* @__PURE__ */ f.jsx(
- ln,
- {
- onClick: () => {
- a && M.navigateToRange(a.unitId, a.subUnitId, { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col }, !0), k.executeCommand(Je.id);
- },
- children: d.t("hyperLink.form.cancel")
- }
- ),
- /* @__PURE__ */ f.jsx(
- ln,
- {
- type: "primary",
- style: { marginLeft: 8 },
- onClick: async () => {
- _t();
- },
- children: d.t("hyperLink.form.ok")
- }
- )
- ] })
- ] }) : null;
- };
- ze.componentKey = "univer.sheet.cell-link-edit";
- var $ = function() {
- return $ = Object.assign || function(t) {
- for (var e, n = 1, i = arguments.length; n < i; n++) {
- e = arguments[n];
- for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (t[r] = e[r]);
- }
- return t;
- }, $.apply(this, arguments);
- }, xi = function(t, e) {
- var n = {};
- for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
- if (t != null && typeof Object.getOwnPropertySymbols == "function")
- for (var r = 0, i = Object.getOwnPropertySymbols(t); r < i.length; r++)
- e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[r]) && (n[i[r]] = t[i[r]]);
- return n;
- }, fe = he(function(t, e) {
- var n = t.icon, i = t.id, r = t.className, o = t.extend, s = xi(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), l = bt("_".concat(Ui()));
- return An(n, "".concat(i), { defIds: n.defIds, idSuffix: l.current }, $({ ref: e, className: c }, s), o);
- });
- function An(t, e, n, i, r) {
- return ge(t.tag, $($({ key: e }, Ni(t, n, r)), i), (Mi(t, n).children || []).map(function(o, s) {
- return An(o, "".concat(e, "-").concat(t.tag, "-").concat(s), n, void 0, r);
- }));
- }
- function Ni(t, e, n) {
- var i = $({}, t.attrs);
- n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1);
- var r = e.defIds;
- return !r || r.length === 0 || (t.tag === "use" && i["xlink:href"] && (i["xlink:href"] = i["xlink:href"] + e.idSuffix), Object.entries(i).forEach(function(o) {
- var s = o[0], c = o[1];
- typeof c == "string" && (i[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
- })), i;
- }
- function Mi(t, e) {
- var n, i = e.defIds;
- return !i || i.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? $($({}, t), { children: t.children.map(function(r) {
- return typeof r.attrs.id == "string" && i && i.indexOf(r.attrs.id) > -1 ? $($({}, r), { attrs: $($({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
- }) }) : t;
- }
- function Ui() {
- return Math.random().toString(36).substring(2, 8);
- }
- fe.displayName = "UniverIcon";
- var Hi = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Ze = he(function(t, e) {
- return ge(fe, Object.assign({}, t, {
- id: "all-border-single",
- ref: e,
- icon: Hi
- }));
- });
- Ze.displayName = "AllBorderSingle";
- var Di = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Bn = he(function(t, e) {
- return ge(fe, Object.assign({}, t, {
- id: "copy-single",
- ref: e,
- icon: Di
- }));
- });
- Bn.displayName = "CopySingle";
- var $i = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z" } }] }, Dt = he(function(t, e) {
- return ge(fe, Object.assign({}, t, {
- id: "link-single",
- ref: e,
- icon: $i
- }));
- });
- Dt.displayName = "LinkSingle";
- var ji = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z" } }] }, Vn = he(function(t, e) {
- return ge(fe, Object.assign({}, t, {
- id: "unlink-single",
- ref: e,
- icon: ji
- }));
- });
- Vn.displayName = "UnlinkSingle";
- var Ai = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z" } }] }, Fn = he(function(t, e) {
- return ge(fe, Object.assign({}, t, {
- id: "write-single",
- ref: e,
- icon: Ai
- }));
- });
- Fn.displayName = "WriteSingle";
- var Bi = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "#35BD4B", d: "M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z" } }, { tag: "path", attrs: { fill: "#32A846", d: "M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z" } }, { tag: "path", attrs: { fill: "#fff", d: "M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Wn = he(function(t, e) {
- return ge(fe, Object.assign({}, t, {
- id: "xlsx",
- ref: e,
- icon: Bi
- }));
- });
- Wn.displayName = "Xlsx";
- function Zn(t) {
- var e, n, i = "";
- if (typeof t == "string" || typeof t == "number") i += t;
- else if (typeof t == "object") if (Array.isArray(t)) {
- var r = t.length;
- for (e = 0; e < r; e++) t[e] && (n = Zn(t[e])) && (i && (i += " "), i += n);
- } else for (n in t) t[n] && (i && (i += " "), i += n);
- return i;
- }
- function vn() {
- for (var t, e, n = 0, i = "", r = arguments.length; n < r; n++) (t = arguments[n]) && (e = Zn(t)) && (i && (i += " "), i += e);
- return i;
- }
- const Vi = "univer-cell-link", Fi = "univer-cell-link-type", Wi = "univer-cell-link-content", Zi = "univer-cell-link-content-error", Gi = "univer-cell-link-url", Ki = "univer-cell-link-operations", Yi = "univer-cell-link-operation", zi = "univer-cell-link-operation-error", Z = {
- cellLink: Vi,
- cellLinkType: Fi,
- cellLinkContent: Wi,
- cellLinkContentError: Zi,
- cellLinkUrl: Gi,
- cellLinkOperations: Ki,
- cellLinkOperation: Yi,
- cellLinkOperationError: zi
- }, qi = {
- [S.URL]: /* @__PURE__ */ f.jsx(Dt, {}),
- [S.SHEET]: /* @__PURE__ */ f.jsx(Wn, {}),
- [S.RANGE]: /* @__PURE__ */ f.jsx(Ze, {}),
- [S.DEFINE_NAME]: /* @__PURE__ */ f.jsx(Ze, {}),
- [S.INVALID]: /* @__PURE__ */ f.jsx(Ze, {})
- }, Sn = (t) => {
- var M, k;
- const e = E(K), n = E(ie), i = E(Un), r = E(ct), o = E(pe), s = E(re), c = E(kt), l = E(pt), { customRange: p, row: u, col: g, unitId: d, subUnitId: v, editPermission: C, copyPermission: _, type: O } = t;
- if (!((M = p == null ? void 0 : p.properties) != null && M.url))
- return null;
- const a = c.parseHyperLink((k = p.properties.url) != null ? k : ""), b = a.type === S.INVALID;
- return /* @__PURE__ */ f.jsxs("div", { className: Z.cellLink, onClick: () => e.hideCurrentPopup(), children: [
- /* @__PURE__ */ f.jsxs(
- "div",
- {
- className: vn(Z.cellLinkContent, { [Z.cellLinkContentError]: b }),
- onClick: () => {
- l.visible || b || o.navigate(a);
- },
- children: [
- /* @__PURE__ */ f.jsx("div", { className: Z.cellLinkType, children: qi[a.type] }),
- /* @__PURE__ */ f.jsx(Be, { showIfEllipsis: !0, title: a.name, asChild: !0, children: /* @__PURE__ */ f.jsx("span", { className: Z.cellLinkUrl, children: a.name }) })
- ]
- }
- ),
- /* @__PURE__ */ f.jsxs("div", { className: Z.cellLinkOperations, children: [
- _ && /* @__PURE__ */ f.jsx(
- "div",
- {
- className: vn(Z.cellLinkOperation, { [Z.cellLinkOperationError]: b }),
- onClick: () => {
- if (!b) {
- if (a.type !== S.URL) {
- const L = new URL(window.location.href);
- L.hash = a.url.slice(1), navigator.clipboard.writeText(L.href);
- } else
- navigator.clipboard.writeText(a.url);
- i.show({
- content: r.t("hyperLink.message.coped"),
- type: xe.Info
- });
- }
- },
- children: /* @__PURE__ */ f.jsx(Be, { placement: "bottom", title: r.t("hyperLink.popup.copy"), children: /* @__PURE__ */ f.jsx(Bn, {}) })
- }
- ),
- C && /* @__PURE__ */ f.jsxs(f.Fragment, { children: [
- /* @__PURE__ */ f.jsx(
- "div",
- {
- className: Z.cellLinkOperation,
- onClick: () => {
- n.executeCommand(jt.id, {
- unitId: d,
- subUnitId: v,
- row: u,
- col: g,
- customRangeId: p.rangeId,
- type: O
- });
- },
- children: /* @__PURE__ */ f.jsx(Be, { placement: "bottom", title: r.t("hyperLink.popup.edit"), children: /* @__PURE__ */ f.jsx(Fn, {}) })
- }
- ),
- /* @__PURE__ */ f.jsx(
- "div",
- {
- className: Z.cellLinkOperation,
- onClick: () => {
- const L = O === m.EDITING || O === m.ZEN_EDITOR ? Ir.id : yr.id;
- n.syncExecuteCommand(L, {
- unitId: d,
- subUnitId: v,
- id: p.rangeId,
- row: u,
- column: g,
- documentId: O === m.ZEN_EDITOR ? x : s.getCurrentEditorId()
- }) && e.hideCurrentPopup(void 0, !0);
- },
- children: /* @__PURE__ */ f.jsx(Be, { placement: "bottom", title: r.t("hyperLink.popup.cancel"), children: /* @__PURE__ */ f.jsx(Vn, {}) })
- }
- )
- ] })
- ] })
- ] });
- }, qe = () => {
- var r, o;
- const t = E(K), [e, n] = X(null), i = E(Y);
- if (ne(() => {
- n(t.currentPopup);
- const s = t.currentPopup$.subscribe((c) => {
- n(c);
- });
- return () => {
- s.unsubscribe();
- };
- }, [t.currentPopup, t.currentPopup$]), !e)
- return null;
- if (e.showAll) {
- const s = i.getUnit(e.unitId, w.UNIVER_SHEET), c = s == null ? void 0 : s.getSheetBySheetId(e.subUnitId), l = c == null ? void 0 : c.getCell(e.row, e.col), p = (o = (r = l == null ? void 0 : l.p) == null ? void 0 : r.body) == null ? void 0 : o.customRanges;
- return p != null && p.length ? /* @__PURE__ */ f.jsx("div", { children: p.map((u) => /* @__PURE__ */ f.jsx(Sn, { ...e, customRange: u }, u.rangeId)) }) : null;
- }
- return /* @__PURE__ */ f.jsx(Sn, { ...e });
- };
- qe.componentKey = "univer.sheet.cell-link-popup";
- var Ji = Object.defineProperty, Xi = Object.getOwnPropertyDescriptor, Qi = (t, e, n, i) => {
- for (var r = i > 1 ? void 0 : i ? Xi(e, n) : e, o = t.length - 1, s; o >= 0; o--)
- (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
- return i && r && Ji(e, n, r), r;
- }, ce = (t, e) => (n, i) => e(n, i, t);
- const Cn = (t, e) => {
- var n, i;
- return t.unitId === e.unitId && t.subUnitId === e.subUnitId && t.row === e.row && t.col === e.col && ((n = t.customRange) == null ? void 0 : n.rangeId) === ((i = e.customRange) == null ? void 0 : i.rangeId) && t.type === e.type;
- };
- let K = class extends z {
- constructor(e, n, i, r, o, s, c) {
- super();
- B(this, "_currentPopup", null);
- B(this, "_currentPopup$", new ui());
- B(this, "currentPopup$", this._currentPopup$.asObservable());
- B(this, "_currentEditingPopup", null);
- B(this, "_currentEditing$", new di(null));
- B(this, "currentEditing$", this._currentEditing$.asObservable());
- B(this, "_isKeepVisible", !1);
- this._sheetCanvasPopManagerService = e, this._injector = n, this._univerInstanceService = i, this._editorBridgeService = r, this._textSelectionManagerService = o, this._docCanvasPopManagerService = s, this._zenZoneService = c, this.disposeWithMe(() => {
- this.hideCurrentPopup(), this.endEditing(), this._currentEditing$.complete(), this._currentPopup$.complete();
- });
- }
- get currentPopup() {
- return this._currentPopup;
- }
- get currentEditing() {
- return this._currentEditing$.getValue();
- }
- setIsKeepVisible(e) {
- this._isKeepVisible = e;
- }
- getIsKeepVisible() {
- return this._isKeepVisible;
- }
- showPopup(e) {
- if (this._currentPopup && Cn(e, this._currentPopup) || (this.hideCurrentPopup(void 0, !0), e.type !== m.ZEN_EDITOR && this._zenZoneService.visible))
- return;
- const n = this._currentEditing$.getValue();
- if (n && Cn(e, n))
- return;
- const { unitId: i, subUnitId: r, row: o, col: s, customRangeRect: c, customRange: l } = e;
- let p;
- const u = {
- componentKey: qe.componentKey,
- direction: "bottom",
- onClickOutside: () => {
- this.hideCurrentPopup();
- },
- onClick: () => {
- this.hideCurrentPopup(e.type, !0);
- }
- };
- if (e.type === m.EDITING) {
- if (!l)
- return;
- p = c && this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
- c,
- u
- );
- } else if (e.type === m.ZEN_EDITOR) {
- if (!l)
- return;
- p = this._docCanvasPopManagerService.attachPopupToRange(
- {
- startOffset: l.startIndex,
- endOffset: l.endIndex + 1,
- collapsed: !1
- },
- u,
- x
- );
- } else if (e.showAll)
- p = this._sheetCanvasPopManagerService.attachPopupToCell(e.row, e.col, u, i, r);
- else {
- if (!l)
- return;
- p = c && this._sheetCanvasPopManagerService.attachPopupByPosition(
- c,
- u,
- e
- );
- }
- p && (this._currentPopup = {
- unitId: i,
- subUnitId: r,
- disposable: p,
- row: o,
- col: s,
- editPermission: !!e.editPermission,
- copyPermission: !!e.copyPermission,
- customRange: l,
- type: e.type,
- showAll: e.showAll
- }, this._currentPopup$.next(this._currentPopup));
- }
- hideCurrentPopup(e, n) {
- var i, r;
- this._currentPopup && ((!e || e === this._currentPopup.type) && this._currentPopup.disposable.canDispose() || n) && ((r = (i = this._currentPopup) == null ? void 0 : i.disposable) == null || r.dispose(), this._currentPopup = null, this._currentPopup$.next(null));
- }
- _getEditingRange() {
- var i, r, o;
- const e = this._editorBridgeService.isVisible().visible, n = this._editorBridgeService.getEditCellState();
- if (e && n) {
- const s = this._textSelectionManagerService.getActiveTextRange(), c = (i = n.documentLayoutObject.documentModel) == null ? void 0 : i.getBody();
- if (!c)
- return null;
- if (!s || s.collapsed)
- return {
- startOffset: 0,
- endOffset: c.dataStream.length - 2,
- collapsed: c.dataStream.length - 2 === 0,
- label: Se.transform.getPlainText(c.dataStream)
- };
- const l = Se.customRange.getCustomRangesInterestsWithSelection(s, (o = (r = c.customRanges) == null ? void 0 : r.filter((g) => g.rangeType === Ge.HYPERLINK)) != null ? o : []);
- let p = s.startOffset, u = s.endOffset;
- return l.forEach((g) => {
- p = Math.min(p, g.startIndex), u = Math.max(u, g.endIndex + 1);
- }), {
- startOffset: p,
- endOffset: u,
- collapsed: p === u,
- label: Se.transform.getPlainText(c.dataStream.slice(p, u))
- };
- }
- return null;
- }
- get _editPopup() {
- return {
- componentKey: ze.componentKey,
- direction: "vertical",
- onClickOutside: () => {
- this.getIsKeepVisible() || this.endEditing();
- },
- onContextMenu: () => {
- this.getIsKeepVisible() || this.endEditing();
- },
- hiddenType: "hide"
- };
- }
- startAddEditing(e) {
- var o, s, c, l, p;
- const { unitId: n, subUnitId: i, type: r } = e;
- if (r === m.ZEN_EDITOR) {
- const u = this._univerInstanceService.getUnit(x, w.UNIVER_DOC);
- if (!u)
- return;
- const g = this._textSelectionManagerService.getActiveTextRange();
- if (!g)
- return;
- this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange(
- g,
- this._editPopup,
- x
- );
- const d = (o = u.getBody()) == null ? void 0 : o.dataStream.slice(g.startOffset, g.endOffset);
- this._currentEditing$.next({
- ...e,
- label: d
- });
- } else if (r === m.EDITING) {
- const u = this._getEditingRange();
- if (!u)
- return;
- this._textSelectionManagerService.replaceDocRanges([{ ...u }], { unitId: Ie, subUnitId: Ie });
- const g = this._injector.get($e).getRenderById(Ie);
- if (!g)
- return;
- const d = ci(u, g);
- if (!(d != null && d.length))
- return;
- this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
- d.pop(),
- this._editPopup,
- n,
- i
- ), this._currentEditing$.next({
- ...e,
- label: (s = u == null ? void 0 : u.label) != null ? s : ""
- });
- } else {
- this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
- e.row,
- e.col,
- this._editPopup,
- n,
- i
- );
- const u = this._univerInstanceService.getUnit(n, w.UNIVER_SHEET), g = u == null ? void 0 : u.getSheetBySheetId(i), d = g == null ? void 0 : g.getCellRaw(e.row, e.col);
- this._currentEditing$.next({
- ...e,
- label: d != null && d.p ? Se.transform.getPlainText((l = (c = d.p.body) == null ? void 0 : c.dataStream) != null ? l : "") : ((p = d == null ? void 0 : d.v) != null ? p : "").toString()
- });
- }
- }
- // eslint-disable-next-line complexity, max-lines-per-function
- startEditing(e) {
- var s, c, l, p, u, g;
- (s = this._currentEditingPopup) == null || s.dispose(), this.hideCurrentPopup(void 0, !0);
- const { unitId: n, subUnitId: i } = e;
- let r, o;
- if (e.type === m.ZEN_EDITOR) {
- const d = this._univerInstanceService.getUnit(x, w.UNIVER_DOC);
- if (r = (l = (c = d == null ? void 0 : d.getBody()) == null ? void 0 : c.customRanges) == null ? void 0 : l.find((v) => v.rangeId === e.customRangeId), o = r ? (p = d == null ? void 0 : d.getBody()) == null ? void 0 : p.dataStream.slice(r.startIndex, r.endIndex + 1) : "", !r || !o)
- return;
- this._textSelectionManagerService.replaceTextRanges([
- {
- startOffset: r.startIndex,
- endOffset: r.endIndex + 1
- }
- ]), this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange(
- {
- startOffset: r.startIndex,
- endOffset: r.endIndex,
- collapsed: !1
- },
- this._editPopup,
- x
- );
- } else if (e.type === m.EDITING) {
- const d = kr(this._injector, e.unitId, e.subUnitId, e.row, e.col, e.customRangeId);
- if (!d || !((u = d.rects) != null && u.length))
- return;
- r = d.customRange, o = d.label, this._textSelectionManagerService.replaceTextRanges([
- {
- startOffset: r.startIndex,
- endOffset: r.endIndex + 1
- }
- ]), this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
- d.rects.pop(),
- this._editPopup,
- n,
- i
- );
- } else {
- const d = this._univerInstanceService.getUnit(n, w.UNIVER_SHEET), v = d == null ? void 0 : d.getSheetBySheetId(i), C = v == null ? void 0 : v.getCellRaw(e.row, e.col), _ = d == null ? void 0 : d.getStyles().getStyleByCell(C), O = _ == null ? void 0 : _.tr, a = Tr(this._injector, e.unitId, e.subUnitId, e.row, e.col, e.customRangeId);
- if (!a || !((g = a.rects) != null && g.length))
- return;
- r = a.customRange, o = a.label, O ? this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupToCell(
- e.row,
- e.col,
- this._editPopup,
- n,
- i
- ) : this._currentEditingPopup = this._sheetCanvasPopManagerService.attachPopupByPosition(
- a.rects.pop(),
- this._editPopup,
- {
- unitId: n,
- subUnitId: i,
- row: e.row,
- col: e.col
- }
- );
- }
- this._currentEditing$.next({
- ...e,
- customRange: r,
- label: o
- });
- }
- endEditing(e) {
- var i;
- const n = this._currentEditing$.getValue();
- n && (!e || e === n.type) && ((i = this._currentEditingPopup) == null || i.dispose(), this._currentEditing$.next(null));
- }
- };
- K = Qi([
- ce(0, R(Or)),
- ce(1, R(lt)),
- ce(2, Y),
- ce(3, re),
- ce(4, R(De)),
- ce(5, R(ai)),
- ce(6, pt)
- ], K);
- var Me = /* @__PURE__ */ ((t) => (t[t.ALLOWED = 0] = "ALLOWED", t[t.DISABLED_BY_CELL = 1] = "DISABLED_BY_CELL", t[t.ALLOW_ON_EDITING = 2] = "ALLOW_ON_EDITING", t))(Me || {});
- const es = /* @__PURE__ */ new Set([
- It.CHECKBOX,
- It.LIST,
- It.LIST_MULTIPLE
- ]), $t = (t, e, n, i) => {
- var c, l;
- const r = e.getCell(n, i);
- if (r != null && r.f || r != null && r.si)
- return 1;
- const o = t.has(hn) ? t.get(hn) : null, s = o == null ? void 0 : o.getRuleByLocation(e.getUnitId(), e.getSheetId(), n, i);
- return s && es.has(s.type) ? !0 : (l = (c = r == null ? void 0 : r.p) == null ? void 0 : c.drawingsOrder) != null && l.length ? 2 : 0;
- }, ts = (t) => {
- const e = t.get(Y).getCurrentUnitForType(w.UNIVER_SHEET);
- if (!e)
- return !0;
- const n = e.getActiveSheet(), i = t.get(Tt).getCurrentSelections();
- if (!i.length)
- return !0;
- const r = i[0].range.startRow, o = i[0].range.startColumn;
- return $t(t, n, r, o) === 1;
- }, ns = (t) => {
- const e = t.get(De), n = t.get(Y), i = e.getTextRanges();
- if (!(i != null && i.length))
- return !0;
- const r = n.getCurrentUnitForType(w.UNIVER_DOC);
- return !!(!r || i.every((s) => s.collapsed) || !r.getSelfOrHeaderFooterModel(i[0].segmentId).getBody());
- }, jt = {
- type: ut.OPERATION,
- id: "sheet.operation.open-hyper-link-edit-panel",
- handler(t, e) {
- if (!e)
- return !1;
- const n = t.get(K);
- return e.customRangeId ? n.startEditing(e) : n.startAddEditing(e), !0;
- }
- }, Je = {
- type: ut.OPERATION,
- id: "sheet.operation.close-hyper-link-popup",
- handler(t) {
- return t.get(K).endEditing(), !0;
- }
- }, At = {
- type: ut.OPERATION,
- id: "sheet.operation.insert-hyper-link",
- handler(t) {
- var g;
- const e = t.get(Y), n = xn(e), i = t.get(re);
- if (!n)
- return !1;
- const r = t.get(ie), s = t.get(Tt).getCurrentLastSelection();
- if (!s)
- return !1;
- const c = s.range.startRow, l = s.range.startColumn, p = i.isVisible(), u = ((g = e.getFocusedUnit()) == null ? void 0 : g.getUnitId()) === x;
- return r.executeCommand(jt.id, {
- unitId: n.unitId,
- subUnitId: n.subUnitId,
- row: c,
- col: l,
- type: u ? m.ZEN_EDITOR : p.visible ? m.EDITING : m.VIEWING
- });
- }
- }, de = {
- type: ut.OPERATION,
- id: "sheet.operation.insert-hyper-link-toolbar",
- handler(t) {
- if (ts(t))
- return !1;
- const e = t.get(ie);
- return t.get(K).currentEditing ? e.executeCommand(Je.id) : e.executeCommand(At.id);
- }
- }, Bt = (t, e = x) => {
- var r;
- const n = t.get(Y), i = (r = t.get($e).getRenderById(e)) == null ? void 0 : r.with(Dn);
- return i ? i.textSelectionInner$.pipe(le(() => {
- const s = t.get(re).getEditCellState();
- if (!s)
- return !0;
- const c = xn(n, { unitId: s.unitId, subUnitId: s.sheetId });
- return !(c != null && c.worksheet) || $t(t, c.worksheet, s.row, s.column) === 1 ? !0 : ns(t);
- })) : Ne(!0);
- }, Gn = (t) => {
- const e = Nr(t, { workbookTypes: [xt], worksheetTypes: [Nt, Nn, Mt], rangeTypes: [Ut] }, !0), n = t.get(Y), i = t.get(Tt), r = t.has(re) ? t.get(re) : null, o = n.focused$.pipe(
- dn((s) => !!s),
- le((s) => n.getUnit(s, w.UNIVER_SHEET)),
- dn((s) => !!s),
- ue((s) => s.activeSheet$),
- ue((s) => i.selectionMoveEnd$.pipe(le((c) => s && { selections: c, sheet: s }))),
- le((s) => {
- if (!s)
- return Me.DISABLED_BY_CELL;
- const { selections: c, sheet: l } = s;
- if (!c.length)
- return Me.DISABLED_BY_CELL;
- const p = c[0].range.startRow, u = c[0].range.startColumn;
- return $t(t, l, p, u);
- }),
- ue((s) => {
- if (s === Me.DISABLED_BY_CELL)
- return Ne(!0);
- const c = (r ? r.visible$ : Ne(null)).pipe(le((p) => p != null && p.visible ? Ie : void 0)), l = t.get(bn).subscribeContextValue$(ur);
- return pi([c, l]).pipe(
- ue(
- ([p, u]) => p ? u ? Ne(!0) : Bt(t, p) : Ne(s === Me.ALLOW_ON_EDITING)
- )
- );
- })
- );
- return e.pipe(
- hi(),
- ue((s) => o.pipe(le((c) => s || c)))
- );
- }, Xe = {
- commandId: At.id,
- type: Hn.BUTTON,
- title: "hyperLink.menu.add",
- icon: "LinkSingle"
- }, Qe = (t) => `${t}-zen-editor`, rs = (t) => ({
- ...Xe,
- id: Xe.commandId,
- hidden$: ht(t, w.UNIVER_SHEET),
- disabled$: Gn(t)
- // disabled$: getObservableWithExclusiveRange$(accessor, getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })),
- }), is = (t) => ({
- ...Xe,
- id: Qe(Xe.commandId),
- hidden$: ht(t, w.UNIVER_DOC, x),
- disabled$: Bt(t)
- }), et = {
- tooltip: "hyperLink.form.addTitle",
- commandId: de.id,
- type: Hn.BUTTON,
- icon: "LinkSingle"
- }, ss = (t) => ({
- ...et,
- id: et.commandId,
- hidden$: ht(t, w.UNIVER_SHEET),
- disabled$: Gn(t)
- }), os = (t) => ({
- ...et,
- id: Qe(et.commandId),
- hidden$: ht(t, w.UNIVER_DOC, x),
- disabled$: Bt(t)
- }), Kn = {
- id: de.id,
- binding: Pt.K | Qr.CTRL_COMMAND,
- preconditions: xr
- };
- var as = Object.defineProperty, cs = Object.getOwnPropertyDescriptor, ls = (t, e, n, i) => {
- for (var r = i > 1 ? void 0 : i ? cs(e, n) : e, o = t.length - 1, s; o >= 0; o--)
- (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
- return i && r && as(e, n, r), r;
- }, In = (t, e) => (n, i) => e(n, i, t);
- let tt = class extends z {
- constructor(t, e) {
- super(), this._autoFillService = t, this._hyperLinkModel = e, this._initAutoFill();
- }
- // eslint-disable-next-line max-lines-per-function
- _initAutoFill() {
- const t = () => ({ redos: [], undos: [] }), e = (i, r) => {
- const { source: o, target: s, unitId: c, subUnitId: l } = i, p = Lt([o, s]), [u, g] = p.ranges, { mapFunc: d } = p, v = {
- row: u.startRow,
- col: u.startColumn
- }, C = Ur(u, g), _ = [], O = [];
- return C.forEach((a) => {
- const b = a.repeatStartCell, M = a.relativeRange, k = {
- startRow: v.row,
- startColumn: v.col,
- endColumn: v.col,
- endRow: v.row
- }, L = {
- startRow: b.row,
- startColumn: b.col,
- endColumn: b.col,
- endRow: b.row
- };
- Pn.foreach(M, (j, D) => {
- const q = ye.getPositionRange(
- {
- startRow: j,
- startColumn: D,
- endColumn: D,
- endRow: j
- },
- k
- ), { row: Ee, col: je } = d(q.startRow, q.startColumn), se = this._hyperLinkModel.getHyperLinkByLocation(c, l, Ee, je), Re = ye.getPositionRange(
- {
- startRow: j,
- startColumn: D,
- endColumn: D,
- endRow: j
- },
- L
- ), { row: Le, col: Pe } = d(Re.startRow, Re.startColumn), oe = Ce.generateRandomId(), A = this._hyperLinkModel.getHyperLinkByLocation(c, l, Le, Pe);
- A && _.push({
- id: Ue.id,
- params: {
- unitId: c,
- subUnitId: l,
- id: A.id
- }
- }), (Oe.COPY === r || Oe.SERIES === r) && se && (_.push({
- id: He.id,
- params: {
- unitId: c,
- subUnitId: l,
- link: {
- ...se,
- id: oe,
- row: Le,
- column: Pe
- }
- }
- }), O.push({
- id: Ue.id,
- params: {
- unitId: c,
- subUnitId: l,
- id: oe
- }
- })), A && O.push({
- id: He.id,
- params: {
- unitId: c,
- subUnitId: l,
- link: A
- }
- });
- });
- }), {
- undos: O,
- redos: _
- };
- }, n = {
- id: Ht,
- onFillData: (i, r, o) => o === Oe.COPY || o === Oe.ONLY_FORMAT || o === Oe.SERIES ? e(i, o) : t()
- };
- this.disposeWithMe(this._autoFillService.addHook(n));
- }
- };
- tt = ls([
- In(0, Mr),
- In(1, R(dt))
- ], tt);
- var us = Object.defineProperty, ds = Object.getOwnPropertyDescriptor, ps = (t, e, n, i) => {
- for (var r = i > 1 ? void 0 : i ? ds(e, n) : e, o = t.length - 1, s; o >= 0; o--)
- (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
- return i && r && us(e, n, r), r;
- }, Rt = (t, e) => (n, i) => e(n, i, t);
- let nt = class extends z {
- constructor(t, e, n) {
- super(), this._localeService = t, this._commandService = e, this._sheetPermissionCheckController = n, this._commandExecutedListener();
- }
- _commandExecutedListener() {
- this.disposeWithMe(
- this._commandService.beforeCommandExecuted((t) => {
- t.id === Kn.id && (this._sheetPermissionCheckController.permissionCheckWithRanges({
- workbookTypes: [xt],
- rangeTypes: [Ut],
- worksheetTypes: [Nt, Nn, Mt]
- }) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr")));
- })
- );
- }
- };
- nt = ps([
- Rt(0, R(ct)),
- Rt(1, ie),
- Rt(2, R(Mn))
- ], nt);
- var hs = Object.defineProperty, gs = Object.getOwnPropertyDescriptor, fs = (t, e, n, i) => {
- for (var r = i > 1 ? void 0 : i ? gs(e, n) : e, o = t.length - 1, s; o >= 0; o--)
- (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
- return i && r && hs(e, n, r), r;
- }, G = (t, e) => (n, i) => e(n, i, t);
- let rt = class extends z {
- constructor(t, e, n, i, r, o, s, c, l, p) {
- super(), this._hoverManagerService = t, this._sheetsHyperLinkPopupService = e, this._renderManagerService = n, this._permissionService = i, this._sheetPermissionCheckController = r, this._commandService = o, this._editorBridgeService = s, this._textSelectionManagerService = c, this._univerInstanceService = l, this._zenZoneService = p, this._initHoverListener(), this._initCommandListener(), this._initHoverEditingListener(), this._initTextSelectionListener(), this._initZenEditor();
- }
- _getLinkPermission(t) {
- const { unitId: e, subUnitId: n, row: i, col: r } = t, o = this._univerInstanceService.getUnit(e, w.UNIVER_SHEET);
- if (!(o == null ? void 0 : o.getSheetBySheetId(n)))
- return {
- viewPermission: !1,
- editPermission: !1,
- copyPermission: !1
- };
- const c = this._sheetPermissionCheckController.permissionCheckWithRanges({
- workbookTypes: [Br],
- worksheetTypes: [Vr],
- rangeTypes: [Fr]
- }, [{ startRow: i, startColumn: r, endRow: i, endColumn: r }]), l = this._sheetPermissionCheckController.permissionCheckWithRanges({
- workbookTypes: [xt],
- worksheetTypes: [Nt, Mt],
- rangeTypes: [Ut]
- }, [{ startRow: i, startColumn: r, endRow: i, endColumn: r }]), p = this._permissionService.composePermission([new Wr(e).id, new Zr(e, n).id]).every((u) => u.value);
- return {
- viewPermission: c,
- editPermission: l,
- copyPermission: p
- };
- }
- _initHoverListener() {
- this.disposeWithMe(
- // hover over not editing cell
- this._hoverManagerService.currentRichText$.pipe(We(200)).subscribe((t) => {
- var k, L;
- if (!t) {
- this._sheetsHyperLinkPopupService.hideCurrentPopup();
- return;
- }
- const { unitId: e, subUnitId: n, row: i, col: r } = t, o = this._renderManagerService.getRenderById(e);
- if (!o)
- return;
- const s = this._univerInstanceService.getUnit(e, w.UNIVER_SHEET), c = s == null ? void 0 : s.getSheetBySheetId(n);
- if (!c)
- return;
- if (!o.with(Dr).active) {
- this._sheetsHyperLinkPopupService.hideCurrentPopup(m.VIEWING);
- return;
- }
- const p = (k = o == null ? void 0 : o.with(an).getWorksheetSkeleton(n)) == null ? void 0 : k.skeleton, u = r, g = i;
- let d = g, v = u;
- p && p.overflowCache.forValue((j, D, q) => {
- ye.contains(q, { startColumn: u, endColumn: u, startRow: g, endRow: g }) && (d = j, v = D);
- });
- const { viewPermission: C, editPermission: _, copyPermission: O } = this._getLinkPermission(t);
- if (!C) {
- this._sheetsHyperLinkPopupService.hideCurrentPopup();
- return;
- }
- const a = c.getCellStyleOnly(d, v), b = s.getStyles().getStyleByCell(a), M = (L = b == null ? void 0 : b.tr) == null ? void 0 : L.a;
- if (!M && !t.customRange) {
- this._sheetsHyperLinkPopupService.hideCurrentPopup();
- return;
- }
- this._sheetsHyperLinkPopupService.showPopup({
- row: d,
- col: v,
- editPermission: _,
- copyPermission: O,
- customRange: t.customRange,
- customRangeRect: t.rect,
- type: m.VIEWING,
- unitId: e,
- subUnitId: n,
- showAll: !!M
- });
- })
- );
- }
- _initHoverEditingListener() {
- let t = null;
- this.disposeWithMe(
- this._editorBridgeService.currentEditCellState$.pipe(ue((e) => this._editorBridgeService.visible$.pipe(le((n) => ({ visible: n, state: e }))))).subscribe(({ visible: e, state: n }) => {
- if (!n || n.editorUnitId !== Ie)
- return;
- if (!e.visible) {
- t == null || t.unsubscribe(), this._sheetsHyperLinkPopupService.hideCurrentPopup(m.EDITING), this._sheetsHyperLinkPopupService.endEditing(m.EDITING);
- return;
- }
- const { editorUnitId: i, unitId: r, sheetId: o, row: s, column: c } = n, l = this._renderManagerService.getRenderById(i);
- if (!l)
- return;
- const { editPermission: p, viewPermission: u, copyPermission: g } = this._getLinkPermission({ unitId: r, subUnitId: o, row: s, col: c }), d = l.with(un);
- u && (t == null || t.unsubscribe(), t = d.hoverCustomRanges$.pipe(We(200)).subscribe((v) => {
- var b, M;
- const C = v.find((k) => k.range.rangeType === Ge.HYPERLINK);
- if (!C) {
- this._sheetsHyperLinkPopupService.hideCurrentPopup();
- return;
- }
- const _ = C.rects[C.rects.length - 1];
- if (!((M = (b = this._renderManagerService.getRenderById(r)) == null ? void 0 : b.with(an).getWorksheetSkeleton(o)) == null ? void 0 : M.skeleton) || !_)
- return;
- const a = l.engine.getCanvasElement().getBoundingClientRect();
- this._sheetsHyperLinkPopupService.showPopup({
- unitId: r,
- subUnitId: o,
- row: s,
- col: c,
- customRange: C.range,
- customRangeRect: {
- left: _.left + a.left,
- top: _.top + a.top,
- bottom: _.bottom + a.top,
- right: _.right + a.left
- },
- editPermission: p,
- copyPermission: g,
- type: m.EDITING
- });
- }));
- })
- ), this.disposeWithMe(() => {
- t == null || t.unsubscribe();
- });
- }
- _initZenEditor() {
- this.disposeWithMe(
- this._zenZoneService.visible$.subscribe((t) => {
- t ? (this._sheetsHyperLinkPopupService.hideCurrentPopup(m.VIEWING), this._sheetsHyperLinkPopupService.hideCurrentPopup(m.EDITING), this._sheetsHyperLinkPopupService.endEditing(m.EDITING), this._sheetsHyperLinkPopupService.hideCurrentPopup(m.VIEWING)) : (this._sheetsHyperLinkPopupService.hideCurrentPopup(m.ZEN_EDITOR), this._sheetsHyperLinkPopupService.endEditing(m.ZEN_EDITOR));
- })
- ), this.disposeWithMe(
- this._univerInstanceService.focused$.pipe(
- ue((t) => {
- const e = t === x ? this._renderManagerService.getRenderById(t) : null;
- return e ? e.with(un).hoverCustomRanges$.pipe(We(200)) : new gi((n) => {
- n.next(null);
- });
- })
- ).subscribe((t) => {
- const e = t == null ? void 0 : t.find((i) => i.range.rangeType === Ge.HYPERLINK), n = this._editorBridgeService.getEditCellState();
- if (e && n) {
- const { unitId: i, sheetId: r, row: o, column: s } = n, { editPermission: c, viewPermission: l, copyPermission: p } = this._getLinkPermission({ unitId: i, subUnitId: r, row: o, col: s });
- l && this._sheetsHyperLinkPopupService.showPopup({
- type: m.ZEN_EDITOR,
- unitId: i,
- subUnitId: r,
- row: o,
- col: s,
- customRange: e.range,
- editPermission: c,
- copyPermission: p
- });
- } else
- this._sheetsHyperLinkPopupService.hideCurrentPopup(m.ZEN_EDITOR);
- })
- );
- }
- _initTextSelectionListener() {
- this.disposeWithMe(
- this._textSelectionManagerService.textSelection$.subscribe((t) => {
- t && t.unitId === Ie && this._sheetsHyperLinkPopupService.endEditing(m.EDITING);
- })
- );
- }
- _initCommandListener() {
- const t = [Gr.id, Kr.id, Yr.id];
- this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
- t.includes(e.id) && this._sheetsHyperLinkPopupService.hideCurrentPopup();
- }));
- }
- };
- rt = fs([
- G(0, R(Hr)),
- G(1, R(K)),
- G(2, R($e)),
- G(3, R(dr)),
- G(4, R(Mn)),
- G(5, ie),
- G(6, re),
- G(7, R(De)),
- G(8, Y),
- G(9, pt)
- ], rt);
- var ms = Object.defineProperty, _s = Object.getOwnPropertyDescriptor, Yn = (t, e, n, i) => {
- for (var r = i > 1 ? void 0 : i ? _s(e, n) : e, o = t.length - 1, s; o >= 0; o--)
- (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
- return i && r && ms(e, n, r), r;
- }, wt = (t, e) => (n, i) => e(n, i, t);
- let Ot = class extends z {
- constructor(t, e) {
- super(), this._context = t, this._hyperLinkModel = e, this._initSkeletonChange();
- }
- _initSkeletonChange() {
- const t = () => {
- var e;
- (e = this._context.mainComponent) == null || e.makeForceDirty();
- };
- this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(We(16)).subscribe(() => {
- t();
- }));
- }
- };
- Ot = Yn([
- wt(1, R(dt))
- ], Ot);
- let it = class extends z {
- constructor(t, e) {
- super(), this._sheetInterceptorService = t, this._hyperLinkModel = e, this._initViewModelIntercept();
- }
- _initViewModelIntercept() {
- this.disposeWithMe(
- this._sheetInterceptorService.intercept(
- qr.CELL_CONTENT,
- {
- effect: pr.Value,
- priority: 100,
- handler: (t, e, n) => {
- const { row: i, col: r, unitId: o, subUnitId: s } = e, c = this._hyperLinkModel.getHyperLinkByLocation(o, s, i, r);
- return n(c ? {
- ...t,
- linkUrl: c.payload,
- linkId: c.id
- } : t);
- }
- }
- )
- );
- }
- };
- it = Yn([
- wt(0, R(zr)),
- wt(1, R(dt))
- ], it);
- const vs = {
- [ei.OTHERS]: {
- [de.id]: {
- order: 2,
- menuItemFactory: ss
- },
- [Qe(de.id)]: {
- order: 2,
- menuItemFactory: os
- }
- },
- [ti.MAIN_AREA]: {
- [ni.OTHERS]: {
- order: 1,
- [de.id]: {
- order: 0,
- menuItemFactory: rs
- },
- [Qe(de.id)]: {
- order: 0,
- menuItemFactory: is
- }
- }
- }
- };
- var Ss = Object.defineProperty, Cs = Object.getOwnPropertyDescriptor, Is = (t, e, n, i) => {
- for (var r = i > 1 ? void 0 : i ? Cs(e, n) : e, o = t.length - 1, s; o >= 0; o--)
- (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
- return i && r && Ss(e, n, r), r;
- }, Te = (t, e) => (n, i) => e(n, i, t);
- let st = class extends z {
- constructor(t, e, n, i, r) {
- super(), this._componentManager = t, this._commandService = e, this._menuManagerService = n, this._injector = i, this._shortcutService = r, this._initComponents(), this._initCommands(), this._initMenus(), this._initShortCut();
- }
- _initComponents() {
- [
- [qe, qe.componentKey],
- [ze, ze.componentKey],
- [Dt, "LinkSingle"]
- ].forEach(([t, e]) => {
- this._componentManager.register(e, t);
- });
- }
- _initCommands() {
- [
- jt,
- Je,
- At,
- de
- ].forEach((t) => {
- this._commandService.registerCommand(t);
- });
- }
- _initMenus() {
- this._menuManagerService.mergeMenu(vs);
- }
- _initShortCut() {
- this._shortcutService.registerShortcut(Kn);
- }
- };
- st = Is([
- Te(0, R(ri)),
- Te(1, ie),
- Te(2, si),
- Te(3, R(lt)),
- Te(4, R(ii))
- ], st);
- var ys = Object.defineProperty, Es = Object.getOwnPropertyDescriptor, Rs = (t, e, n, i) => {
- for (var r = i > 1 ? void 0 : i ? Es(e, n) : e, o = t.length - 1, s; o >= 0; o--)
- (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
- return i && r && ys(e, n, r), r;
- }, yn = (t, e) => (n, i) => e(n, i, t);
- let ot = class extends z {
- constructor(t, e) {
- super(), this._parserService = t, this._resolverService = e, this._handleInitUrl();
- }
- _handleInitUrl() {
- const t = location.hash;
- if (t) {
- const e = this._parserService.parseHyperLink(t);
- this._resolverService.navigate(e);
- }
- }
- };
- ot = Rs([
- yn(0, R(kt)),
- yn(1, R(pe))
- ], ot);
- var zn = Object.defineProperty, Ls = Object.getOwnPropertyDescriptor, Ps = (t, e, n) => e in t ? zn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, bs = (t, e, n, i) => {
- for (var r = i > 1 ? void 0 : i ? Ls(e, n) : e, o = t.length - 1, s; o >= 0; o--)
- (s = t[o]) && (r = (i ? s(e, n, r) : s(r)) || r);
- return i && r && zn(e, n, r), r;
- }, En = (t, e) => (n, i) => e(n, i, t), qn = (t, e, n) => Ps(t, typeof e != "symbol" ? e + "" : e, n);
- let at = class extends gr {
- constructor(t = gn, e, n) {
- super(), this._config = t, this._injector = e, this._configService = n;
- const { menu: i, ...r } = fr(
- {},
- gn,
- this._config
- );
- i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig($n, r);
- }
- onStarting() {
- [
- [pe],
- [K],
- [jn],
- [it],
- [rt],
- [st],
- [tt],
- [Ye],
- [nt],
- [ot]
- ].forEach((e) => this._injector.add(e)), this._injector.get(it);
- }
- onReady() {
- this._injector.get($e).registerRenderModule(w.UNIVER_SHEET, [Ot]), this._injector.get(tt), this._injector.get(Ye), this._injector.get(st);
- }
- onRendered() {
- this._injector.get(nt), this._injector.get(ot), this._injector.get(rt);
- }
- };
- qn(at, "pluginName", Ht);
- qn(at, "type", w.UNIVER_SHEET);
- at = bs([
- hr(Er, li),
- En(1, R(lt)),
- En(2, Ln)
- ], at);
- export {
- Je as CloseHyperLinkPopupOperation,
- At as InsertHyperLinkOperation,
- Kn as InsertLinkShortcut,
- jt as OpenHyperLinkEditPanelOperation,
- Ye as SheetsHyperLinkCopyPasteController,
- K as SheetsHyperLinkPopupService,
- pe as SheetsHyperLinkResolverService,
- jn as SheetsHyperLinkSidePanelService,
- at as UniverSheetsHyperLinkUIPlugin
- };
|