12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132 |
- import {
- At,
- Bt,
- I,
- O,
- Q,
- Tt,
- U,
- Wt,
- ae,
- jt,
- k,
- xt,
- ye
- } from "./chunk-4SXJQ6MB.js";
- import {
- F as F2
- } from "./chunk-Q35HEJKG.js";
- import {
- Ei
- } from "./chunk-U3EPM6JO.js";
- import {
- De as De2,
- Er,
- Hr,
- Sn,
- Ys,
- _s,
- el,
- gr,
- iE,
- ke,
- lf,
- me,
- oE,
- rt,
- sE,
- tE,
- tt,
- ue,
- vi,
- ws
- } from "./chunk-T4NNB5UY.js";
- import {
- Co,
- F,
- Hn,
- Io,
- Js,
- Ls,
- Me,
- N,
- Nn,
- Pe,
- So,
- Te,
- V,
- Xs,
- an,
- et,
- or,
- po,
- re as re2,
- wn
- } from "./chunk-BW43Z7N3.js";
- import {
- fn,
- fr,
- pc,
- pr,
- ys
- } from "./chunk-QRYBFJ3R.js";
- import {
- Gn as Gn2,
- Se,
- gs,
- is,
- kn,
- ko
- } from "./chunk-MIOQ566M.js";
- import {
- $e,
- Ae,
- Fa,
- He,
- I1,
- P1,
- it,
- l1,
- m1,
- n1,
- n3,
- o3,
- u3
- } from "./chunk-POAJ2YNP.js";
- import {
- Gf,
- HO,
- Po,
- QC,
- Xw,
- r_
- } from "./chunk-GBYP4PB2.js";
- import {
- m
- } from "./chunk-PZD7N4BC.js";
- import {
- Yx
- } from "./chunk-2MK3Q52E.js";
- import {
- BehaviorSubject,
- De,
- Fe,
- Gn,
- Hd,
- Il,
- Mi,
- Nt,
- OR,
- Observable,
- Ot,
- Pt,
- Ra,
- SC,
- SE,
- Subject,
- UE,
- Vn,
- Vr,
- W0,
- _n,
- aE,
- ar,
- combineLatest,
- debounceTime,
- distinctUntilChanged,
- en,
- filter,
- fs,
- kt,
- ln,
- map,
- ml,
- mn,
- nt,
- nu,
- of,
- ot,
- qt,
- re,
- st,
- su,
- switchMap,
- tr,
- z0
- } from "./chunk-23V3HWTR.js";
- import {
- require_react
- } from "./chunk-GNR2UJZM.js";
- import {
- __toESM
- } from "./chunk-2LSFTFF7.js";
- // node_modules/.pnpm/@univerjs+sheets-hyper-link-ui@0.5.5_@grpc+grpc-js@1.13.4_react-dom@18.3.1_react@18.3.1_rxjs@7.8.1_typescript@5.4.5/node_modules/@univerjs/sheets-hyper-link-ui/lib/es/index.js
- var import_react = __toESM(require_react());
- var rr = Object.defineProperty;
- var ir = (t, e, n) => e in t ? rr(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
- var B = (t, e, n) => ir(t, typeof e != "symbol" ? e + "" : e, n);
- function Ke(t) {
- return re.isLegalUrl(t);
- }
- function vi2(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 = vi2(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;
- }
- var $n = "sheets-hyper-link-ui.config";
- var gn = {};
- var Ii = Object.defineProperty;
- var yi = Object.getOwnPropertyDescriptor;
- var Ei2 = (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;
- };
- var 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 === De.COLUMN || De.ROW)
- return t;
- const o = [];
- return n.forEach((s) => {
- en.intersects(t, s) && o.push(s);
- }), en.realUnion(t, ...o);
- }
- var 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 U.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(Fe.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: Xw.Error
- });
- return;
- }
- if (l.isSheetHidden()) {
- this._messageService.show({
- content: this._localeService.t("hyperLink.message.hiddenSheet"),
- type: Xw.Error
- });
- return;
- }
- this.navigateToDefineName(o, i);
- }
- if (e) {
- if (n) {
- const s = fn(n);
- SC(s.range) && n !== Q && 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(
- re2.id,
- {
- unitId: t,
- subUnitId: e,
- selections: [{
- range: o,
- primary: null
- }]
- }
- ), await this._commandService.executeCommand(lf.id, {
- range: o,
- forceTop: i
- });
- }
- }
- async navigateToSheetById(t, e) {
- const n = this._univerInstanceService.getUnit(t, Fe.UNIVER_SHEET);
- if (!n)
- return false;
- const i = n.getActiveSheet();
- if (!i)
- return false;
- 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: Xw.Error
- }), false) : await this._commandService.executeCommand(an.id, { unitId: t, subUnitId: e }) ? r : false : (this._messageService.show({
- content: this._localeService.t("hyperLink.message.noSheet"),
- type: Xw.Error
- }), false);
- }
- async navigateToDefineName(t, e) {
- return this._definedNamesService.focusRange(t, e), true;
- }
- 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 = Ei2([
- ve(0, _n),
- ve(1, Pt),
- ve(2, pr),
- ve(3, o3),
- ve(4, ot(Vr)),
- ve(5, SE)
- ], pe);
- var Ht = "SHEET_HYPER_LINK_UI_PLUGIN";
- var Li = Object.defineProperty;
- var Pi = Object.getOwnPropertyDescriptor;
- var 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;
- };
- var Ve = (t, e) => (n, i) => e(n, i, t);
- var Ye = class extends nt {
- 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 = gr.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 } = _s([r]), p = [], u = [];
- return tr.foreach(c, (g, d) => {
- const { row: v, col: C } = l(g, d), _ = this._hyperLinkModel.getHyperLinkByLocation(o, s, v, C);
- _ && p.push({
- id: k.id,
- params: {
- unitId: o,
- subUnitId: s,
- id: _.id
- }
- }), _ && u.push({
- id: O.id,
- params: {
- unitId: o,
- subUnitId: s,
- link: _
- }
- });
- }), { redos: p, undos: u };
- }
- return { undos: [], redos: [] };
- },
- priority: 99
- });
- }
- _collect(e, n, i) {
- const r = new kt();
- this._copyInfo = {
- unitId: e,
- subUnitId: n,
- matrix: r
- };
- const o = this._injector.invoke((l) => Ys(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 ([
- rt.SPECIAL_PASTE_COL_WIDTH,
- rt.SPECIAL_PASTE_VALUE,
- rt.SPECIAL_PASTE_FORMAT,
- rt.SPECIAL_PASTE_FORMULA
- ].includes(n.pasteType))
- return { redos: [], undos: [] };
- const { unitId: r, subUnitId: o } = this._copyInfo, s = [], c = [], { ranges: [l, p], mapFunc: u } = _s([n.copyRange, e]);
- return sE(l, p, true).forEach(({ startRange: d }) => {
- var v;
- (v = this._copyInfo) == null || v.matrix.forValue((C, _, O2) => {
- const a = en.getPositionRange(
- {
- startRow: C,
- endRow: C,
- startColumn: _,
- endColumn: _
- },
- d
- ), b = this._hyperLinkModel.getHyperLink(r, o, O2), { row: M, col: k2 } = u(a.startRow, a.startColumn), L = this._hyperLinkModel.getHyperLinkByLocation(n.unitId, n.subUnitId, M, k2), j = re.generateRandomId();
- L && s.push({
- id: k.id,
- params: {
- unitId: n.unitId,
- subUnitId: n.subUnitId,
- id: L.id
- }
- }), b && (s.push({
- id: O.id,
- params: {
- unitId: n.unitId,
- subUnitId: n.subUnitId,
- link: {
- ...b,
- id: j,
- row: M,
- column: k2
- }
- }
- }), c.push({
- id: k.id,
- params: {
- unitId: n.unitId,
- subUnitId: n.subUnitId,
- id: j
- }
- })), L && c.push({
- id: O.id,
- params: {
- unitId: n.unitId,
- subUnitId: n.subUnitId,
- link: L
- }
- });
- });
- }), { redos: s, undos: c };
- }
- };
- Ye = bi([
- Ve(0, Sn),
- Ve(1, ot(I)),
- Ve(2, ot(Ot)),
- Ve(3, ot(pe))
- ], Ye);
- var m2 = ((t) => (t.EDITING = "editing", t.VIEWING = "viewing", t.ZEN_EDITOR = "zen_mode", t))(m2 || {});
- var Et = { exports: {} };
- var ke2 = {};
- var fn2;
- function wi() {
- if (fn2)
- return ke2;
- fn2 = 1;
- var t = import_react.default, 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: true, ref: true, __self: true, __source: true };
- 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 ke2.Fragment = n, ke2.jsx = s, ke2.jsxs = s, ke2;
- }
- var mn2;
- function Oi() {
- return mn2 || (mn2 = 1, Et.exports = wi()), Et.exports;
- }
- var f = Oi();
- var jn = class extends nt {
- constructor() {
- super(...arguments);
- B(this, "_customHyperLinks", /* @__PURE__ */ new Map());
- }
- isBuiltInLinkType(n) {
- return n !== U.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();
- }
- };
- var ki = "univer-cell-link-edit";
- var Ti = "univer-cell-link-edit-buttons";
- var _n2 = {
- cellLinkEdit: ki,
- cellLinkEditButtons: Ti
- };
- var ze = () => {
- var Ft;
- const [t, e] = (0, import_react.useState)(""), [n, i] = (0, import_react.useState)(false), [r, o] = (0, import_react.useState)(""), [s, c] = (0, import_react.useState)(true), [l, p] = (0, import_react.useState)(U.URL), [u, g] = (0, import_react.useState)(""), d = W0(Vr), v = W0(pr), C = W0(tt), _ = W0(_n), O2 = W0(K), a = z0(O2.currentEditing$), b = W0(ye), M = W0(pe), k2 = W0(Pt), L = W0(jn), j = (0, import_react.useMemo)(() => L.getOptions(), [L]), D = W0(u3), q = W0(Yx), Ee = W0(ws), je = W0(m), se = W0(fs), Re = W0(ml), Le = W0(m), Pe2 = (0, import_react.useRef)({}), oe = (0, import_react.useMemo)(() => {
- if (!L.isBuiltInLinkType(l))
- return L.getCustomHyperLink(l);
- }, [L, l]), [A, Jn] = (0, import_react.useState)(false), [be, gt] = (0, import_react.useState)(false), H = (0, import_react.useRef)(false), V2 = _.getCurrentUnitForType(Fe.UNIVER_SHEET), Xn = (V2 == null ? void 0 : V2.getActiveSheet().getSheetId()) || "", Q2 = (0, import_react.useCallback)((h) => {
- o(h.replaceAll(ln.CUSTOM_RANGE_START, "").replaceAll(ln.CUSTOM_RANGE_END, ""));
- }, [o]);
- (0, import_react.useEffect)(() => {
- var h, y, I2, P, N2, F3, Wt2, Zt, Gt, Kt, Yt, zt, qt2, Jt, Xt, Qt, en2;
- if ((a == null ? void 0 : a.row) !== void 0 && a.col !== void 0) {
- const { customRange: ae2, row: vt, col: St } = a;
- let { label: J } = a;
- typeof J == "number" && (J = `${J}`);
- let W;
- if (ae2)
- W = {
- id: (h = ae2 == null ? void 0 : ae2.rangeId) != null ? h : "",
- display: J != null ? J : "",
- payload: (I2 = (y = ae2 == null ? void 0 : ae2.properties) == null ? void 0 : y.url) != null ? I2 : "",
- row: vt,
- column: St
- };
- else if (a.type === m2.VIEWING) {
- const T = _.getUnit(a.unitId), te = T == null ? void 0 : T.getSheetBySheetId(a.subUnitId), U2 = te == null ? void 0 : te.getCellRaw(a.row, a.col), me2 = (F3 = (N2 = (P = U2 == null ? void 0 : U2.p) == null ? void 0 : P.body) == null ? void 0 : N2.customRanges) == null ? void 0 : F3.find((nn) => {
- var rn;
- return nn.rangeType === mn.HYPERLINK && ((rn = nn.properties) == null ? void 0 : rn.url);
- }), we = U2 == null ? void 0 : U2.v;
- U2 && (!st.transform.isEmptyDocument((Zt = (Wt2 = U2.p) == null ? void 0 : Wt2.body) == null ? void 0 : Zt.dataStream) || re.isDefine(we)) && c(false), W = {
- id: "",
- display: "",
- payload: (Kt = (Gt = me2 == null ? void 0 : me2.properties) == null ? void 0 : Gt.url) != null ? Kt : "",
- row: vt,
- column: St
- };
- } else {
- const T = _.getCurrentUnitForType(Fe.UNIVER_DOC), te = je.getActiveTextRange(), U2 = T == null ? void 0 : T.getBody(), me2 = te && U2 ? te : null, we = me2 && ((zt = st.customRange.getCustomRangesInterestsWithSelection(me2, (Yt = U2 == null ? void 0 : U2.customRanges) != null ? Yt : [])) == null ? void 0 : zt[0]);
- c(false), W = {
- id: "",
- display: J != null ? J : "",
- payload: (Jt = (qt2 = we == null ? void 0 : we.properties) == null ? void 0 : qt2.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), Q2(T.display);
- return;
- }
- Q2(W.display);
- const ee = b.parseHyperLink(W.payload);
- switch (p(ee.type === U.INVALID ? U.RANGE : ee.type), ee.type) {
- case U.URL: {
- g(ee.url), ee.url === W.display && (H.current = true);
- break;
- }
- case U.RANGE: {
- const T = ee.searchObj, te = T.gid && (en2 = (Qt = (Xt = _.getUnit(a.unitId)) == null ? void 0 : Xt.getSheetBySheetId(T.gid)) == null ? void 0 : Qt.getName()) != null ? en2 : "", U2 = pc(te, fn(T.range).range);
- g(U2), U2 === W.display && (H.current = true);
- break;
- }
- case U.SHEET: {
- const T = ee.searchObj;
- g(T.gid);
- break;
- }
- case U.DEFINE_NAME: {
- const T = ee.searchObj;
- g(T.rangeid);
- break;
- }
- default:
- g("");
- break;
- }
- }
- }, [a, M, L, je, _]), (0, import_react.useEffect)(() => {
- let h = null;
- if (a && !a.customRangeId && a.type === m2.VIEWING && re.isDefine(a.row) && re.isDefine(a.col)) {
- const y = _.getUnit(a.unitId, Fe.UNIVER_SHEET), I2 = y == null ? void 0 : y.getSheetBySheetId(a.subUnitId), P = I2 == null ? void 0 : I2.getMergedCell(a.row, a.col), N2 = new Nt(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(${N2.r}, ${N2.g}, ${N2.b}, 0.12)`,
- strokeWidth: 1,
- stroke: "#FFBD37",
- widgets: {}
- },
- primary: null
- },
- [],
- -1
- );
- }
- return () => {
- h && Ee.removeShape(h);
- };
- }, [a, Ee, Re, _]), (0, import_react.useEffect)(() => {
- gt(l === U.RANGE);
- }, [l]), (0, import_react.useEffect)(() => {
- const h = (a == null ? void 0 : a.type) === m2.ZEN_EDITOR ? q.getRenderById(Hd) : q.getRenderById(C.getCurrentEditorId()), y = new Mi();
- if (h) {
- const I2 = h.with(Se);
- I2.setReserveRangesStatus(true), y.add(() => {
- I2.setReserveRangesStatus(false);
- });
- }
- return () => {
- C.disableForceKeepVisible(), y.dispose();
- };
- }, [a == null ? void 0 : a.type, C, q]), (0, import_react.useEffect)(() => (O2.setIsKeepVisible(be), () => {
- O2.setIsKeepVisible(false);
- }), [be, O2]), (0, import_react.useEffect)(() => () => {
- D.temporaryHidden && (D.show(), se.setContextValue(Gn, false));
- }, [se, D]), (0, import_react.useEffect)(() => {
- if (be)
- return C.enableForceKeepVisible(), () => {
- C.disableForceKeepVisible();
- };
- }, [be, C]);
- const Qn = [
- {
- label: d.t("hyperLink.form.link"),
- value: U.URL
- },
- {
- label: d.t("hyperLink.form.range"),
- value: U.RANGE
- },
- {
- label: d.t("hyperLink.form.worksheet"),
- value: U.SHEET
- },
- {
- label: d.t("hyperLink.form.definedName"),
- value: U.DEFINE_NAME
- },
- ...j
- ];
- if (!V2)
- return;
- const er = V2.getHiddenWorksheets(), ft = V2.getSheets().map((h) => ({ label: h.getName(), value: h.getSheetId() })).filter((h) => er.indexOf(h.value) === -1), mt = Object.values((Ft = v.getDefinedNameMap(V2.getUnitId())) != null ? Ft : {}).map((h) => ({
- label: h.name,
- value: h.id
- })), Vt = (h, y) => {
- if (h === U.URL)
- return Ci(y);
- if (h === U.RANGE) {
- const I2 = fn(y), P = V2.getSheetBySheetName(I2.sheetName);
- if (P)
- return `#gid=${P.getSheetId()}&range=${fr(I2.range)}`;
- }
- return `#${h}=${y}`;
- }, tr2 = n3((h) => {
- var N2;
- const I2 = h.split(",").map(fn)[0];
- if (!I2 || !SC(I2.range))
- return;
- I2.sheetName || (I2.sheetName = ((N2 = V2.getActiveSheet()) == null ? void 0 : N2.getName()) || "");
- const P = ys(I2);
- g(P), P && (H.current || !r) && (Q2(P), H.current = true);
- }), _t = async () => {
- if (s && !r || !u || l === U.URL && !Ke(u)) {
- Jn(true);
- return;
- }
- if (a)
- if (t) {
- const h = a.type === m2.ZEN_EDITOR || a.type === m2.EDITING ? jt.id : Bt.id;
- await k2.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 === m2.ZEN_EDITOR ? Hd : C.getCurrentEditorId()
- });
- } else {
- const h = a.type === m2.ZEN_EDITOR || a.type === m2.EDITING ? Tt.id : xt.id;
- await k2.executeCommand(h, {
- unitId: a.unitId,
- subUnitId: a.subUnitId,
- link: {
- id: qt(),
- row: a.row,
- column: a.col,
- payload: Vt(l, u),
- display: s ? r : ""
- },
- documentId: a.type === m2.ZEN_EDITOR ? Hd : C.getCurrentEditorId()
- });
- }
- if ((a == null ? void 0 : a.type) === m2.VIEWING) {
- await k2.executeCommand(an.id, {
- unitId: a.unitId,
- subUnitId: a.subUnitId
- });
- const h = 1;
- await k2.executeCommand(lf.id, {
- range: {
- startRow: Math.max(a.row - h, 0),
- endRow: a.row + h,
- startColumn: Math.max(a.col - h, 0),
- endColumn: a.col + h
- }
- });
- }
- k2.executeCommand(Je.id);
- }, nr = (h) => {
- var I2;
- if (l !== U.RANGE)
- return;
- const y = (I2 = Pe2.current) == null ? void 0 : I2.handleOutClick;
- y && y(h, () => gt(false));
- };
- return a ? f.jsxs("div", { className: _n2.cellLinkEdit, style: { display: n ? "none" : "block" }, onClick: nr, children: [
- s ? f.jsx(
- HO,
- {
- label: d.t("hyperLink.form.label"),
- error: A && !r ? d.t("hyperLink.form.inputError") : "",
- children: f.jsx(
- QC,
- {
- value: r,
- onChange: (h) => {
- Q2(h), H.current = false;
- },
- placeholder: d.t("hyperLink.form.labelPlaceholder"),
- autoFocus: true,
- onKeyDown: (h) => {
- h.keyCode === I1.ENTER && _t();
- }
- }
- )
- }
- ) : null,
- f.jsx(HO, { label: d.t("hyperLink.form.type"), children: f.jsx(
- r_,
- {
- options: Qn,
- value: l,
- onChange: (h) => {
- p(h), g("");
- }
- }
- ) }),
- l === U.URL && f.jsx(
- HO,
- {
- error: A ? u ? Ke(u) ? "" : d.t("hyperLink.form.linkError") : d.t("hyperLink.form.inputError") : "",
- children: f.jsx(
- QC,
- {
- value: u,
- onChange: (h) => {
- g(h), h && (H.current || !r || r === u) && (Q2(h), H.current = true);
- },
- placeholder: d.t("hyperLink.form.linkPlaceholder"),
- autoFocus: true,
- onKeyDown: (h) => {
- h.keyCode === I1.ENTER && _t();
- }
- }
- )
- }
- ),
- l === U.RANGE && f.jsx(HO, { error: A && !u ? d.t("hyperLink.form.inputError") : "", children: f.jsx(
- Ei,
- {
- unitId: V2.getUnitId(),
- subUnitId: Xn,
- isOnlyOneRange: true,
- isSupportAcrossSheet: true,
- initValue: u,
- onChange: tr2,
- isFocus: be,
- onFocus: () => gt(true),
- actions: Pe2.current,
- onRangeSelectorDialogVisibleChange: async (h) => {
- var y, I2;
- if (h)
- a.type === m2.ZEN_EDITOR && (D.hide(), se.setContextValue(Gn, true)), a.type !== m2.VIEWING && C.enableForceKeepVisible(), i(true);
- else {
- if (await M.navigateToRange(a.unitId, a.subUnitId, { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col }, true), a.type === m2.ZEN_EDITOR) {
- await k2.executeCommand(re2.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(Gn, false);
- const P = (y = q.getRenderById(Hd)) == null ? void 0 : y.with(kn), N2 = (I2 = Le.getTextRanges({ unitId: Hd, subUnitId: Hd })) == null ? void 0 : I2[0];
- P && N2 && (P.scrollToRange(N2), Le.refreshSelection({ unitId: Hd, subUnitId: Hd }));
- }
- C.disableForceKeepVisible(), i(false);
- }
- }
- }
- ) }),
- l === U.SHEET && f.jsx(HO, { error: A && !u ? d.t("hyperLink.form.selectError") : "", children: f.jsx(
- r_,
- {
- options: ft,
- value: u,
- onChange: (h) => {
- var P, N2;
- g(h);
- const y = (P = ft.find((F3) => F3.value === h)) == null ? void 0 : P.label, I2 = (N2 = ft.find((F3) => F3.value === u)) == null ? void 0 : N2.label;
- y && (H.current || !r || r === I2) && (Q2(y), H.current = true);
- }
- }
- ) }),
- l === U.DEFINE_NAME && f.jsx(HO, { error: A && !u ? d.t("hyperLink.form.selectError") : "", children: f.jsx(
- r_,
- {
- options: mt,
- value: u,
- onChange: (h) => {
- var P, N2;
- g(h);
- const y = (P = mt.find((F3) => F3.value === h)) == null ? void 0 : P.label, I2 = (N2 = mt.find((F3) => F3.value === u)) == null ? void 0 : N2.label;
- y && (H.current || !r || r === I2) && (Q2(y), H.current = true);
- }
- }
- ) }),
- (oe == null ? void 0 : oe.Form) && f.jsx(
- oe.Form,
- {
- linkId: t,
- payload: u,
- display: r,
- showError: A,
- setByPayload: H,
- setDisplay: (h) => {
- Q2(h), H.current = true;
- },
- setPayload: g
- }
- ),
- f.jsxs("div", { className: _n2.cellLinkEditButtons, children: [
- f.jsx(
- Po,
- {
- onClick: () => {
- a && M.navigateToRange(a.unitId, a.subUnitId, { startRow: a.row, endRow: a.row, startColumn: a.col, endColumn: a.col }, true), k2.executeCommand(Je.id);
- },
- children: d.t("hyperLink.form.cancel")
- }
- ),
- f.jsx(
- Po,
- {
- 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);
- };
- var 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;
- };
- var fe = (0, import_react.forwardRef)(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 = (0, import_react.useRef)("_".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 (0, import_react.createElement)(t.tag, $($({ key: e }, Ni(t, n, r)), i), (Mi2(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 Mi2(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" } }] };
- var Ze = (0, import_react.forwardRef)(function(t, e) {
- return (0, import_react.createElement)(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" } }] };
- var Bn = (0, import_react.forwardRef)(function(t, e) {
- return (0, import_react.createElement)(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" } }] };
- var Dt = (0, import_react.forwardRef)(function(t, e) {
- return (0, import_react.createElement)(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" } }] };
- var Vn2 = (0, import_react.forwardRef)(function(t, e) {
- return (0, import_react.createElement)(fe, Object.assign({}, t, {
- id: "unlink-single",
- ref: e,
- icon: ji
- }));
- });
- Vn2.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" } }] };
- var Fn = (0, import_react.forwardRef)(function(t, e) {
- return (0, import_react.createElement)(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" } }] };
- var Wn = (0, import_react.forwardRef)(function(t, e) {
- return (0, import_react.createElement)(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;
- }
- var Vi = "univer-cell-link";
- var Fi = "univer-cell-link-type";
- var Wi = "univer-cell-link-content";
- var Zi = "univer-cell-link-content-error";
- var Gi = "univer-cell-link-url";
- var Ki = "univer-cell-link-operations";
- var Yi = "univer-cell-link-operation";
- var zi = "univer-cell-link-operation-error";
- var Z = {
- cellLink: Vi,
- cellLinkType: Fi,
- cellLinkContent: Wi,
- cellLinkContentError: Zi,
- cellLinkUrl: Gi,
- cellLinkOperations: Ki,
- cellLinkOperation: Yi,
- cellLinkOperationError: zi
- };
- var qi = {
- [U.URL]: f.jsx(Dt, {}),
- [U.SHEET]: f.jsx(Wn, {}),
- [U.RANGE]: f.jsx(Ze, {}),
- [U.DEFINE_NAME]: f.jsx(Ze, {}),
- [U.INVALID]: f.jsx(Ze, {})
- };
- var Sn2 = (t) => {
- var M, k2;
- const e = W0(K), n = W0(Pt), i = W0(o3), r = W0(Vr), o = W0(pe), s = W0(tt), c = W0(ye), l = W0(u3), { customRange: p, row: u, col: g, unitId: d, subUnitId: v, editPermission: C, copyPermission: _, type: O2 } = t;
- if (!((M = p == null ? void 0 : p.properties) != null && M.url))
- return null;
- const a = c.parseHyperLink((k2 = p.properties.url) != null ? k2 : ""), b = a.type === U.INVALID;
- return f.jsxs("div", { className: Z.cellLink, onClick: () => e.hideCurrentPopup(), children: [
- f.jsxs(
- "div",
- {
- className: vn(Z.cellLinkContent, { [Z.cellLinkContentError]: b }),
- onClick: () => {
- l.visible || b || o.navigate(a);
- },
- children: [
- f.jsx("div", { className: Z.cellLinkType, children: qi[a.type] }),
- f.jsx(Gf, { showIfEllipsis: true, title: a.name, asChild: true, children: f.jsx("span", { className: Z.cellLinkUrl, children: a.name }) })
- ]
- }
- ),
- f.jsxs("div", { className: Z.cellLinkOperations, children: [
- _ && f.jsx(
- "div",
- {
- className: vn(Z.cellLinkOperation, { [Z.cellLinkOperationError]: b }),
- onClick: () => {
- if (!b) {
- if (a.type !== U.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: Xw.Info
- });
- }
- },
- children: f.jsx(Gf, { placement: "bottom", title: r.t("hyperLink.popup.copy"), children: f.jsx(Bn, {}) })
- }
- ),
- C && f.jsxs(f.Fragment, { children: [
- f.jsx(
- "div",
- {
- className: Z.cellLinkOperation,
- onClick: () => {
- n.executeCommand(jt2.id, {
- unitId: d,
- subUnitId: v,
- row: u,
- col: g,
- customRangeId: p.rangeId,
- type: O2
- });
- },
- children: f.jsx(Gf, { placement: "bottom", title: r.t("hyperLink.popup.edit"), children: f.jsx(Fn, {}) })
- }
- ),
- f.jsx(
- "div",
- {
- className: Z.cellLinkOperation,
- onClick: () => {
- const L = O2 === m2.EDITING || O2 === m2.ZEN_EDITOR ? Wt.id : At.id;
- n.syncExecuteCommand(L, {
- unitId: d,
- subUnitId: v,
- id: p.rangeId,
- row: u,
- column: g,
- documentId: O2 === m2.ZEN_EDITOR ? Hd : s.getCurrentEditorId()
- }) && e.hideCurrentPopup(void 0, true);
- },
- children: f.jsx(Gf, { placement: "bottom", title: r.t("hyperLink.popup.cancel"), children: f.jsx(Vn2, {}) })
- }
- )
- ] })
- ] })
- ] });
- };
- var qe = () => {
- var r, o;
- const t = W0(K), [e, n] = (0, import_react.useState)(null), i = W0(_n);
- if ((0, import_react.useEffect)(() => {
- 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, Fe.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 ? f.jsx("div", { children: p.map((u) => f.jsx(Sn2, { ...e, customRange: u }, u.rangeId)) }) : null;
- }
- return f.jsx(Sn2, { ...e });
- };
- qe.componentKey = "univer.sheet.cell-link-popup";
- var Ji = Object.defineProperty;
- var Xi = Object.getOwnPropertyDescriptor;
- var 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;
- };
- var ce = (t, e) => (n, i) => e(n, i, t);
- var 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;
- };
- var K = class extends nt {
- constructor(e, n, i, r, o, s, c) {
- super();
- B(this, "_currentPopup", null);
- B(this, "_currentPopup$", new Subject());
- B(this, "currentPopup$", this._currentPopup$.asObservable());
- B(this, "_currentEditingPopup", null);
- B(this, "_currentEditing$", new BehaviorSubject(null));
- B(this, "currentEditing$", this._currentEditing$.asObservable());
- B(this, "_isKeepVisible", false);
- 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, true), e.type !== m2.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, true);
- }
- };
- if (e.type === m2.EDITING) {
- if (!l)
- return;
- p = c && this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(
- c,
- u
- );
- } else if (e.type === m2.ZEN_EDITOR) {
- if (!l)
- return;
- p = this._docCanvasPopManagerService.attachPopupToRange(
- {
- startOffset: l.startIndex,
- endOffset: l.endIndex + 1,
- collapsed: false
- },
- u,
- Hd
- );
- } 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: st.transform.getPlainText(c.dataStream)
- };
- const l = st.customRange.getCustomRangesInterestsWithSelection(s, (o = (r = c.customRanges) == null ? void 0 : r.filter((g) => g.rangeType === mn.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: st.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 === m2.ZEN_EDITOR) {
- const u = this._univerInstanceService.getUnit(Hd, Fe.UNIVER_DOC);
- if (!u)
- return;
- const g = this._textSelectionManagerService.getActiveTextRange();
- if (!g)
- return;
- this._currentEditingPopup = this._docCanvasPopManagerService.attachPopupToRange(
- g,
- this._editPopup,
- Hd
- );
- const d = (o = u.getBody()) == null ? void 0 : o.dataStream.slice(g.startOffset, g.endOffset);
- this._currentEditing$.next({
- ...e,
- label: d
- });
- } else if (r === m2.EDITING) {
- const u = this._getEditingRange();
- if (!u)
- return;
- this._textSelectionManagerService.replaceDocRanges([{ ...u }], { unitId: su, subUnitId: su });
- const g = this._injector.get(Yx).getRenderById(su);
- if (!g)
- return;
- const d = ko(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, Fe.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 ? st.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, true);
- const { unitId: n, subUnitId: i } = e;
- let r, o;
- if (e.type === m2.ZEN_EDITOR) {
- const d = this._univerInstanceService.getUnit(Hd, Fe.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: false
- },
- this._editPopup,
- Hd
- );
- } else if (e.type === m2.EDITING) {
- const d = oE(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, Fe.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), O2 = _ == null ? void 0 : _.tr, a = iE(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, O2 ? 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, ot(vi)),
- ce(1, ot(Ot)),
- ce(2, _n),
- ce(3, tt),
- ce(4, ot(m)),
- ce(5, ot(is)),
- ce(6, u3)
- ], K);
- var Me2 = ((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))(Me2 || {});
- var es = /* @__PURE__ */ new Set([
- Il.CHECKBOX,
- Il.LIST,
- Il.LIST_MULTIPLE
- ]);
- var $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(F2) ? t.get(F2) : null, s = o == null ? void 0 : o.getRuleByLocation(e.getUnitId(), e.getSheetId(), n, i);
- return s && es.has(s.type) ? true : (l = (c = r == null ? void 0 : r.p) == null ? void 0 : c.drawingsOrder) != null && l.length ? 2 : 0;
- };
- var ts = (t) => {
- const e = t.get(_n).getCurrentUnitForType(Fe.UNIVER_SHEET);
- if (!e)
- return true;
- const n = e.getActiveSheet(), i = t.get(F).getCurrentSelections();
- if (!i.length)
- return true;
- const r = i[0].range.startRow, o = i[0].range.startColumn;
- return $t(t, n, r, o) === 1;
- };
- var ns = (t) => {
- const e = t.get(m), n = t.get(_n), i = e.getTextRanges();
- if (!(i != null && i.length))
- return true;
- const r = n.getCurrentUnitForType(Fe.UNIVER_DOC);
- return !!(!r || i.every((s) => s.collapsed) || !r.getSelfOrHeaderFooterModel(i[0].segmentId).getBody());
- };
- var jt2 = {
- type: ar.OPERATION,
- id: "sheet.operation.open-hyper-link-edit-panel",
- handler(t, e) {
- if (!e)
- return false;
- const n = t.get(K);
- return e.customRangeId ? n.startEditing(e) : n.startAddEditing(e), true;
- }
- };
- var Je = {
- type: ar.OPERATION,
- id: "sheet.operation.close-hyper-link-popup",
- handler(t) {
- return t.get(K).endEditing(), true;
- }
- };
- var At2 = {
- type: ar.OPERATION,
- id: "sheet.operation.insert-hyper-link",
- handler(t) {
- var g;
- const e = t.get(_n), n = N(e), i = t.get(tt);
- if (!n)
- return false;
- const r = t.get(Pt), s = t.get(F).getCurrentLastSelection();
- if (!s)
- return false;
- const c = s.range.startRow, l = s.range.startColumn, p = i.isVisible(), u = ((g = e.getFocusedUnit()) == null ? void 0 : g.getUnitId()) === Hd;
- return r.executeCommand(jt2.id, {
- unitId: n.unitId,
- subUnitId: n.subUnitId,
- row: c,
- col: l,
- type: u ? m2.ZEN_EDITOR : p.visible ? m2.EDITING : m2.VIEWING
- });
- }
- };
- var de = {
- type: ar.OPERATION,
- id: "sheet.operation.insert-hyper-link-toolbar",
- handler(t) {
- if (ts(t))
- return false;
- const e = t.get(Pt);
- return t.get(K).currentEditing ? e.executeCommand(Je.id) : e.executeCommand(At2.id);
- }
- };
- var Bt2 = (t, e = Hd) => {
- var r;
- const n = t.get(_n), i = (r = t.get(Yx).getRenderById(e)) == null ? void 0 : r.with(Se);
- return i ? i.textSelectionInner$.pipe(map(() => {
- const s = t.get(tt).getEditCellState();
- if (!s)
- return true;
- const c = N(n, { unitId: s.unitId, subUnitId: s.sheetId });
- return !(c != null && c.worksheet) || $t(t, c.worksheet, s.row, s.column) === 1 ? true : ns(t);
- })) : of(true);
- };
- var Gn3 = (t) => {
- const e = ue(t, { workbookTypes: [Me], worksheetTypes: [Te, wn, or], rangeTypes: [Pe] }, true), n = t.get(_n), i = t.get(F), r = t.has(tt) ? t.get(tt) : null, o = n.focused$.pipe(
- filter((s) => !!s),
- map((s) => n.getUnit(s, Fe.UNIVER_SHEET)),
- filter((s) => !!s),
- switchMap((s) => s.activeSheet$),
- switchMap((s) => i.selectionMoveEnd$.pipe(map((c) => s && { selections: c, sheet: s }))),
- map((s) => {
- if (!s)
- return Me2.DISABLED_BY_CELL;
- const { selections: c, sheet: l } = s;
- if (!c.length)
- return Me2.DISABLED_BY_CELL;
- const p = c[0].range.startRow, u = c[0].range.startColumn;
- return $t(t, l, p, u);
- }),
- switchMap((s) => {
- if (s === Me2.DISABLED_BY_CELL)
- return of(true);
- const c = (r ? r.visible$ : of(null)).pipe(map((p) => p != null && p.visible ? su : void 0)), l = t.get(fs).subscribeContextValue$(aE);
- return combineLatest([c, l]).pipe(
- switchMap(
- ([p, u]) => p ? u ? of(true) : Bt2(t, p) : of(s === Me2.ALLOW_ON_EDITING)
- )
- );
- })
- );
- return e.pipe(
- distinctUntilChanged(),
- switchMap((s) => o.pipe(map((c) => s || c)))
- );
- };
- var Xe = {
- commandId: At2.id,
- type: $e.BUTTON,
- title: "hyperLink.menu.add",
- icon: "LinkSingle"
- };
- var Qe = (t) => `${t}-zen-editor`;
- var rs = (t) => ({
- ...Xe,
- id: Xe.commandId,
- hidden$: Fa(t, Fe.UNIVER_SHEET),
- disabled$: Gn3(t)
- // disabled$: getObservableWithExclusiveRange$(accessor, getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellValuePermission, WorksheetInsertHyperlinkPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })),
- });
- var is2 = (t) => ({
- ...Xe,
- id: Qe(Xe.commandId),
- hidden$: Fa(t, Fe.UNIVER_DOC, Hd),
- disabled$: Bt2(t)
- });
- var et2 = {
- tooltip: "hyperLink.form.addTitle",
- commandId: de.id,
- type: $e.BUTTON,
- icon: "LinkSingle"
- };
- var ss = (t) => ({
- ...et2,
- id: et2.commandId,
- hidden$: Fa(t, Fe.UNIVER_SHEET),
- disabled$: Gn3(t)
- });
- var os = (t) => ({
- ...et2,
- id: Qe(et2.commandId),
- hidden$: Fa(t, Fe.UNIVER_DOC, Hd),
- disabled$: Bt2(t)
- });
- var Kn = {
- id: de.id,
- binding: I1.K | Ae.CTRL_COMMAND,
- preconditions: De2
- };
- var as = Object.defineProperty;
- var cs = Object.getOwnPropertyDescriptor;
- var 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;
- };
- var In = (t, e) => (n, i) => e(n, i, t);
- var tt2 = class extends nt {
- 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 = _s([o, s]), [u, g] = p.ranges, { mapFunc: d } = p, v = {
- row: u.startRow,
- col: u.startColumn
- }, C = tE(u, g), _ = [], O2 = [];
- return C.forEach((a) => {
- const b = a.repeatStartCell, M = a.relativeRange, k2 = {
- 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
- };
- tr.foreach(M, (j, D) => {
- const q = en.getPositionRange(
- {
- startRow: j,
- startColumn: D,
- endColumn: D,
- endRow: j
- },
- k2
- ), { row: Ee, col: je } = d(q.startRow, q.startColumn), se = this._hyperLinkModel.getHyperLinkByLocation(c, l, Ee, je), Re = en.getPositionRange(
- {
- startRow: j,
- startColumn: D,
- endColumn: D,
- endRow: j
- },
- L
- ), { row: Le, col: Pe2 } = d(Re.startRow, Re.startColumn), oe = re.generateRandomId(), A = this._hyperLinkModel.getHyperLinkByLocation(c, l, Le, Pe2);
- A && _.push({
- id: k.id,
- params: {
- unitId: c,
- subUnitId: l,
- id: A.id
- }
- }), (ke.COPY === r || ke.SERIES === r) && se && (_.push({
- id: O.id,
- params: {
- unitId: c,
- subUnitId: l,
- link: {
- ...se,
- id: oe,
- row: Le,
- column: Pe2
- }
- }
- }), O2.push({
- id: k.id,
- params: {
- unitId: c,
- subUnitId: l,
- id: oe
- }
- })), A && O2.push({
- id: O.id,
- params: {
- unitId: c,
- subUnitId: l,
- link: A
- }
- });
- });
- }), {
- undos: O2,
- redos: _
- };
- }, n = {
- id: Ht,
- onFillData: (i, r, o) => o === ke.COPY || o === ke.ONLY_FORMAT || o === ke.SERIES ? e(i, o) : t()
- };
- this.disposeWithMe(this._autoFillService.addHook(n));
- }
- };
- tt2 = ls([
- In(0, Hr),
- In(1, ot(I))
- ], tt2);
- var us = Object.defineProperty;
- var ds = Object.getOwnPropertyDescriptor;
- var 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;
- };
- var Rt = (t, e) => (n, i) => e(n, i, t);
- var nt2 = class extends nt {
- 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: [Me],
- rangeTypes: [Pe],
- worksheetTypes: [Te, wn, or]
- }) || this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.hyperLinkErr")));
- })
- );
- }
- };
- nt2 = ps([
- Rt(0, ot(Vr)),
- Rt(1, Pt),
- Rt(2, ot(Nn))
- ], nt2);
- var hs = Object.defineProperty;
- var gs2 = Object.getOwnPropertyDescriptor;
- var fs2 = (t, e, n, i) => {
- for (var r = i > 1 ? void 0 : i ? gs2(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;
- };
- var G = (t, e) => (n, i) => e(n, i, t);
- var rt2 = class extends nt {
- 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, Fe.UNIVER_SHEET);
- if (!(o == null ? void 0 : o.getSheetBySheetId(n)))
- return {
- viewPermission: false,
- editPermission: false,
- copyPermission: false
- };
- const c = this._sheetPermissionCheckController.permissionCheckWithRanges({
- workbookTypes: [Js],
- worksheetTypes: [Hn],
- rangeTypes: [Io]
- }, [{ startRow: i, startColumn: r, endRow: i, endColumn: r }]), l = this._sheetPermissionCheckController.permissionCheckWithRanges({
- workbookTypes: [Me],
- worksheetTypes: [Te, or],
- rangeTypes: [Pe]
- }, [{ startRow: i, startColumn: r, endRow: i, endColumn: r }]), p = this._permissionService.composePermission([new Ls(e).id, new Xs(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(debounceTime(200)).subscribe((t) => {
- var k2, 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, Fe.UNIVER_SHEET), c = s == null ? void 0 : s.getSheetBySheetId(n);
- if (!c)
- return;
- if (!o.with(el).active) {
- this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.VIEWING);
- return;
- }
- const p = (k2 = o == null ? void 0 : o.with(me).getWorksheetSkeleton(n)) == null ? void 0 : k2.skeleton, u = r, g = i;
- let d = g, v = u;
- p && p.overflowCache.forValue((j, D, q) => {
- en.contains(q, { startColumn: u, endColumn: u, startRow: g, endRow: g }) && (d = j, v = D);
- });
- const { viewPermission: C, editPermission: _, copyPermission: O2 } = 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: O2,
- customRange: t.customRange,
- customRangeRect: t.rect,
- type: m2.VIEWING,
- unitId: e,
- subUnitId: n,
- showAll: !!M
- });
- })
- );
- }
- _initHoverEditingListener() {
- let t = null;
- this.disposeWithMe(
- this._editorBridgeService.currentEditCellState$.pipe(switchMap((e) => this._editorBridgeService.visible$.pipe(map((n) => ({ visible: n, state: e }))))).subscribe(({ visible: e, state: n }) => {
- if (!n || n.editorUnitId !== su)
- return;
- if (!e.visible) {
- t == null || t.unsubscribe(), this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.EDITING), this._sheetsHyperLinkPopupService.endEditing(m2.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(Gn2);
- u && (t == null || t.unsubscribe(), t = d.hoverCustomRanges$.pipe(debounceTime(200)).subscribe((v) => {
- var b, M;
- const C = v.find((k2) => k2.range.rangeType === mn.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(me).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: m2.EDITING
- });
- }));
- })
- ), this.disposeWithMe(() => {
- t == null || t.unsubscribe();
- });
- }
- _initZenEditor() {
- this.disposeWithMe(
- this._zenZoneService.visible$.subscribe((t) => {
- t ? (this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.VIEWING), this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.EDITING), this._sheetsHyperLinkPopupService.endEditing(m2.EDITING), this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.VIEWING)) : (this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.ZEN_EDITOR), this._sheetsHyperLinkPopupService.endEditing(m2.ZEN_EDITOR));
- })
- ), this.disposeWithMe(
- this._univerInstanceService.focused$.pipe(
- switchMap((t) => {
- const e = t === Hd ? this._renderManagerService.getRenderById(t) : null;
- return e ? e.with(Gn2).hoverCustomRanges$.pipe(debounceTime(200)) : new Observable((n) => {
- n.next(null);
- });
- })
- ).subscribe((t) => {
- const e = t == null ? void 0 : t.find((i) => i.range.rangeType === mn.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: m2.ZEN_EDITOR,
- unitId: i,
- subUnitId: r,
- row: o,
- col: s,
- customRange: e.range,
- editPermission: c,
- copyPermission: p
- });
- } else
- this._sheetsHyperLinkPopupService.hideCurrentPopup(m2.ZEN_EDITOR);
- })
- );
- }
- _initTextSelectionListener() {
- this.disposeWithMe(
- this._textSelectionManagerService.textSelection$.subscribe((t) => {
- t && t.unitId === su && this._sheetsHyperLinkPopupService.endEditing(m2.EDITING);
- })
- );
- }
- _initCommandListener() {
- const t = [Co.id, po.id, So.id];
- this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
- t.includes(e.id) && this._sheetsHyperLinkPopupService.hideCurrentPopup();
- }));
- }
- };
- rt2 = fs2([
- G(0, ot(Er)),
- G(1, ot(K)),
- G(2, ot(Yx)),
- G(3, ot(UE)),
- G(4, ot(Nn)),
- G(5, Pt),
- G(6, tt),
- G(7, ot(m)),
- G(8, _n),
- G(9, u3)
- ], rt2);
- var ms = Object.defineProperty;
- var _s2 = Object.getOwnPropertyDescriptor;
- var Yn = (t, e, n, i) => {
- for (var r = i > 1 ? void 0 : i ? _s2(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;
- };
- var wt = (t, e) => (n, i) => e(n, i, t);
- var Ot2 = class extends nt {
- 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(debounceTime(16)).subscribe(() => {
- t();
- }));
- }
- };
- Ot2 = Yn([
- wt(1, ot(I))
- ], Ot2);
- var it2 = class extends nt {
- constructor(t, e) {
- super(), this._sheetInterceptorService = t, this._hyperLinkModel = e, this._initViewModelIntercept();
- }
- _initViewModelIntercept() {
- this.disposeWithMe(
- this._sheetInterceptorService.intercept(
- et.CELL_CONTENT,
- {
- effect: Vn.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);
- }
- }
- )
- );
- }
- };
- it2 = Yn([
- wt(0, ot(V)),
- wt(1, ot(I))
- ], it2);
- var vs = {
- [l1.OTHERS]: {
- [de.id]: {
- order: 2,
- menuItemFactory: ss
- },
- [Qe(de.id)]: {
- order: 2,
- menuItemFactory: os
- }
- },
- [P1.MAIN_AREA]: {
- [He.OTHERS]: {
- order: 1,
- [de.id]: {
- order: 0,
- menuItemFactory: rs
- },
- [Qe(de.id)]: {
- order: 0,
- menuItemFactory: is2
- }
- }
- }
- };
- var Ss = Object.defineProperty;
- var Cs = Object.getOwnPropertyDescriptor;
- var 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;
- };
- var Te2 = (t, e) => (n, i) => e(n, i, t);
- var st2 = class extends nt {
- 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() {
- [
- jt2,
- Je,
- At2,
- de
- ].forEach((t) => {
- this._commandService.registerCommand(t);
- });
- }
- _initMenus() {
- this._menuManagerService.mergeMenu(vs);
- }
- _initShortCut() {
- this._shortcutService.registerShortcut(Kn);
- }
- };
- st2 = Is([
- Te2(0, ot(n1)),
- Te2(1, Pt),
- Te2(2, m1),
- Te2(3, ot(Ot)),
- Te2(4, ot(it))
- ], st2);
- var ys2 = Object.defineProperty;
- var Es = Object.getOwnPropertyDescriptor;
- var 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 && ys2(e, n, r), r;
- };
- var yn = (t, e) => (n, i) => e(n, i, t);
- var ot2 = class extends nt {
- 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);
- }
- }
- };
- ot2 = Rs([
- yn(0, ot(ye)),
- yn(1, ot(pe))
- ], ot2);
- var zn = Object.defineProperty;
- var Ls2 = Object.getOwnPropertyDescriptor;
- var Ps = (t, e, n) => e in t ? zn(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
- var bs = (t, e, n, i) => {
- for (var r = i > 1 ? void 0 : i ? Ls2(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;
- };
- var En = (t, e) => (n, i) => e(n, i, t);
- var qn = (t, e, n) => Ps(t, typeof e != "symbol" ? e + "" : e, n);
- var at = class extends Ra {
- constructor(t = gn, e, n) {
- super(), this._config = t, this._injector = e, this._configService = n;
- const { menu: i, ...r } = nu(
- {},
- gn,
- this._config
- );
- i && this._configService.setConfig("menu", i, { merge: true }), this._configService.setConfig($n, r);
- }
- onStarting() {
- [
- [pe],
- [K],
- [jn],
- [it2],
- [rt2],
- [st2],
- [tt2],
- [Ye],
- [nt2],
- [ot2]
- ].forEach((e) => this._injector.add(e)), this._injector.get(it2);
- }
- onReady() {
- this._injector.get(Yx).registerRenderModule(Fe.UNIVER_SHEET, [Ot2]), this._injector.get(tt2), this._injector.get(Ye), this._injector.get(st2);
- }
- onRendered() {
- this._injector.get(nt2), this._injector.get(ot2), this._injector.get(rt2);
- }
- };
- qn(at, "pluginName", Ht);
- qn(at, "type", Fe.UNIVER_SHEET);
- at = bs([
- OR(ae, gs),
- En(1, ot(Ot)),
- En(2, SE)
- ], at);
- export {
- pe,
- Ye,
- jn,
- K,
- jt2 as jt,
- Je,
- At2 as At,
- Kn,
- at
- };
- /*! Bundled license information:
- @univerjs/sheets-hyper-link-ui/lib/es/index.js:
- (**
- * @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.
- *)
- */
- //# sourceMappingURL=chunk-S7YN35PX.js.map
|