chunk-SJCG2OJH.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. import {
  2. At,
  3. Bt,
  4. xt,
  5. ye
  6. } from "./chunk-4SXJQ6MB.js";
  7. import {
  8. S,
  9. f,
  10. m
  11. } from "./chunk-CLOCSTN3.js";
  12. import {
  13. Pt,
  14. hi,
  15. ln,
  16. mn,
  17. ot,
  18. pi,
  19. qt,
  20. xf
  21. } from "./chunk-23V3HWTR.js";
  22. // node_modules/.pnpm/@univerjs+sheets-hyper-link@0.5.5_@grpc+grpc-js@1.13.4_react@18.3.1_rxjs@7.8.1/node_modules/@univerjs/sheets-hyper-link/lib/es/facade.js
  23. var I = Object.defineProperty;
  24. var H = Object.getOwnPropertyDescriptor;
  25. var U = (o, e, i, r) => {
  26. for (var n = r > 1 ? void 0 : r ? H(e, i) : e, t = o.length - 1, s; t >= 0; t--)
  27. (s = o[t]) && (n = (r ? s(e, i, n) : s(n)) || n);
  28. return r && n && I(e, i, n), n;
  29. };
  30. var R = (o, e) => (i, r) => e(i, r, o);
  31. var m2 = class {
  32. constructor(o, e) {
  33. this._workbook = o, this._parserService = e;
  34. }
  35. getRangeUrl(o) {
  36. return this._parserService.buildHyperLink(this._workbook.getId(), o.getSheetId(), o.getRange()), this;
  37. }
  38. };
  39. m2 = U([
  40. R(1, ot(ye))
  41. ], m2);
  42. var E = class extends f {
  43. createSheetHyperlink(e, i) {
  44. return this._injector.get(ye).buildHyperLink(this.getId(), e, i);
  45. }
  46. /**
  47. * Parse the hyperlink string to get the hyperlink info.
  48. * @param {string} hyperlink the hyperlink string
  49. * @returns {ISheetHyperLinkInfo} the hyperlink info
  50. */
  51. parseSheetHyperlink(e) {
  52. return this._injector.get(ye).parseHyperLink(e);
  53. }
  54. };
  55. f.extend(E);
  56. var T = class extends m {
  57. getUrl() {
  58. return this._injector.get(ye).buildHyperLink(this._workbook.getUnitId(), this._worksheet.getSheetId());
  59. }
  60. };
  61. m.extend(T);
  62. var B = class extends S {
  63. // #region hyperlink
  64. setHyperLink(e, i) {
  65. const r = {
  66. unitId: this.getUnitId(),
  67. subUnitId: this._worksheet.getSheetId(),
  68. link: {
  69. row: this._range.startRow,
  70. column: this._range.startColumn,
  71. payload: e,
  72. display: i,
  73. id: qt()
  74. }
  75. };
  76. return this._commandService.executeCommand(xt.id, r);
  77. }
  78. getHyperLinks() {
  79. var i, r, n;
  80. const e = this._worksheet.getCellRaw(this._range.startRow, this._range.startColumn);
  81. return e != null && e.p ? (n = (r = (i = e.p.body) == null ? void 0 : i.customRanges) == null ? void 0 : r.filter((t) => t.rangeType === mn.HYPERLINK).map((t) => {
  82. var s, h, c, p, l;
  83. return {
  84. id: `${t.rangeId}`,
  85. startIndex: t.startIndex,
  86. endIndex: t.endIndex,
  87. url: (h = (s = t.properties) == null ? void 0 : s.url) != null ? h : "",
  88. label: (l = (p = (c = e.p) == null ? void 0 : c.body) == null ? void 0 : p.dataStream.slice(t.startIndex, t.endIndex + 1).replaceAll(ln.CUSTOM_RANGE_START, "").replaceAll(ln.CUSTOM_RANGE_END, "")) != null ? l : ""
  89. };
  90. })) != null ? n : [] : [];
  91. }
  92. updateHyperLink(e, i, r) {
  93. const n = {
  94. unitId: this.getUnitId(),
  95. subUnitId: this._worksheet.getSheetId(),
  96. row: this._range.startRow,
  97. column: this._range.startColumn,
  98. id: e,
  99. payload: {
  100. payload: i,
  101. display: r
  102. }
  103. };
  104. return this._commandService.executeCommand(Bt.id, n);
  105. }
  106. cancelHyperLink(e) {
  107. const i = {
  108. unitId: this.getUnitId(),
  109. subUnitId: this._worksheet.getSheetId(),
  110. row: this._range.startRow,
  111. column: this._range.startColumn,
  112. id: e
  113. };
  114. return this._commandService.syncExecuteCommand(At.id, i);
  115. }
  116. getUrl() {
  117. return this._injector.get(ye).buildHyperLink(this.getUnitId(), this.getSheetId(), this.getRange());
  118. }
  119. // #endregion
  120. };
  121. S.extend(B);
  122. var A = class {
  123. get BeforeSheetLinkAdd() {
  124. return "BeforeSheetLinkAdd";
  125. }
  126. get BeforeSheetLinkCancel() {
  127. return "BeforeSheetLinkCancel";
  128. }
  129. get BeforeSheetLinkUpdate() {
  130. return "BeforeSheetLinkUpdate";
  131. }
  132. };
  133. hi.extend(A);
  134. var F = class extends pi {
  135. _initialize(e) {
  136. const i = e.get(Pt);
  137. this.disposeWithMe(
  138. i.beforeCommandExecuted((r) => {
  139. if (r.id === xt.id) {
  140. if (!this._eventListend(this.Event.BeforeSheetLinkAdd))
  141. return;
  142. const n = this.getCommandSheetTarget(r);
  143. if (!n)
  144. return;
  145. const t = r.params, s = {
  146. workbook: n.workbook,
  147. worksheet: n.worksheet,
  148. row: t.link.row,
  149. col: t.link.column,
  150. link: t.link
  151. };
  152. if (this.fireEvent(this.Event.BeforeSheetLinkAdd, s), s.cancel)
  153. throw new xf();
  154. }
  155. if (r.id === Bt.id) {
  156. const n = this.getCommandSheetTarget(r);
  157. if (!n)
  158. return;
  159. const t = r.params, s = {
  160. workbook: n.workbook,
  161. worksheet: n.worksheet,
  162. row: t.row,
  163. column: t.column,
  164. id: t.id,
  165. payload: t.payload
  166. };
  167. if (this.fireEvent(this.Event.BeforeSheetLinkUpdate, s), s.cancel)
  168. throw new xf();
  169. }
  170. if (r.id === At.id) {
  171. const n = this.getCommandSheetTarget(r);
  172. if (!n)
  173. return;
  174. const t = r.params, s = {
  175. workbook: n.workbook,
  176. worksheet: n.worksheet,
  177. row: t.row,
  178. column: t.column,
  179. id: t.id
  180. };
  181. if (this.fireEvent(this.Event.BeforeSheetLinkCancel, s), s.cancel)
  182. throw new xf();
  183. }
  184. })
  185. );
  186. }
  187. };
  188. pi.extend(F);
  189. export {
  190. E
  191. };
  192. //# sourceMappingURL=chunk-SJCG2OJH.js.map