chunk-23GLNZMH.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. import {
  2. Ut,
  3. on
  4. } from "./chunk-QG2HZMYH.js";
  5. import {
  6. Bi,
  7. Ct,
  8. Fe,
  9. Mf,
  10. Ot,
  11. Ra,
  12. SE,
  13. _n,
  14. nt,
  15. nu,
  16. ot
  17. } from "./chunk-23V3HWTR.js";
  18. // node_modules/.pnpm/@univerjs+docs-drawing@0.5.5_@grpc+grpc-js@1.13.4_react@18.3.1_rxjs@7.8.1/node_modules/@univerjs/docs-drawing/lib/es/index.js
  19. var w = Object.defineProperty;
  20. var S = (t, r, e) => r in t ? w(t, r, { enumerable: true, configurable: true, writable: true, value: e }) : t[r] = e;
  21. var D = (t, r, e) => S(t, typeof r != "symbol" ? r + "" : r, e);
  22. var G = "docs-drawing.config";
  23. var d = {};
  24. var v = class extends on {
  25. };
  26. var h = Ct("univer.doc.plugin.doc-drawing.service");
  27. var F = Object.defineProperty;
  28. var J = Object.getOwnPropertyDescriptor;
  29. var y = (t, r, e, n) => {
  30. for (var i = n > 1 ? void 0 : n ? J(r, e) : r, a = t.length - 1, s; a >= 0; a--)
  31. (s = t[a]) && (i = (n ? s(r, e, i) : s(i)) || i);
  32. return n && i && F(r, e, i), i;
  33. };
  34. var o = (t, r) => (e, n) => r(e, n, t);
  35. var l = "DOC_DRAWING_PLUGIN";
  36. var _ = class extends nt {
  37. constructor(t, r, e, n) {
  38. super(), this._docDrawingService = t, this._drawingManagerService = r, this._resourceManagerService = e, this._univerInstanceService = n, this._init();
  39. }
  40. _init() {
  41. this._initSnapshot();
  42. }
  43. _initSnapshot() {
  44. const t = (e) => {
  45. const n = this._univerInstanceService.getUnit(e, Fe.UNIVER_DOC);
  46. if (n) {
  47. const i = n.getSnapshot().drawings, a = n.getSnapshot().drawingsOrder, s = {
  48. data: i != null ? i : {},
  49. order: a != null ? a : []
  50. };
  51. return JSON.stringify(s);
  52. }
  53. return "";
  54. }, r = (e) => {
  55. if (!e)
  56. return { data: {}, order: [] };
  57. try {
  58. return JSON.parse(e);
  59. } catch {
  60. return { data: {}, order: [] };
  61. }
  62. };
  63. this.disposeWithMe(
  64. this._resourceManagerService.registerPluginResource({
  65. pluginName: l,
  66. businesses: [Fe.UNIVER_DOC],
  67. toJson: (e) => t(e),
  68. parseJson: (e) => r(e),
  69. onUnLoad: (e) => {
  70. this._setDrawingDataForUnit(e, { data: {}, order: [] });
  71. },
  72. onLoad: (e, n) => {
  73. var i, a;
  74. this._setDrawingDataForUnit(e, { data: (i = n.data) != null ? i : {}, order: (a = n.order) != null ? a : [] });
  75. }
  76. })
  77. );
  78. }
  79. _setDrawingDataForUnit(t, r) {
  80. const e = this._univerInstanceService.getUnit(t);
  81. e != null && (e.resetDrawing(r.data, r.order), this.loadDrawingDataForUnit(t));
  82. }
  83. loadDrawingDataForUnit(t) {
  84. const r = this._univerInstanceService.getUnit(t, Fe.UNIVER_DOC);
  85. if (!r)
  86. return false;
  87. const e = t, n = r.getDrawings(), i = r.getDrawingsOrder();
  88. if (!n || !i)
  89. return false;
  90. Object.keys(n).forEach((s) => {
  91. const p = n[s];
  92. n[s] = { ...p };
  93. });
  94. const a = {
  95. [e]: {
  96. unitId: t,
  97. subUnitId: e,
  98. data: n,
  99. order: i
  100. }
  101. };
  102. return this._docDrawingService.registerDrawingData(t, a), this._drawingManagerService.registerDrawingData(t, a), true;
  103. }
  104. };
  105. _ = y([
  106. o(0, h),
  107. o(1, Ut),
  108. o(2, Bi),
  109. o(3, _n)
  110. ], _);
  111. var L = Object.defineProperty;
  112. var x = Object.getOwnPropertyDescriptor;
  113. var V = (t, r, e, n) => {
  114. for (var i = n > 1 ? void 0 : n ? x(r, e) : r, a = t.length - 1, s; a >= 0; a--)
  115. (s = t[a]) && (i = (n ? s(r, e, i) : s(i)) || i);
  116. return n && i && L(r, e, i), i;
  117. };
  118. var u = (t, r) => (e, n) => r(e, n, t);
  119. var c;
  120. var f = (c = class extends Ra {
  121. constructor(t = d, r, e) {
  122. super(), this._config = t, this._injector = r, this._configService = e;
  123. const { ...n } = nu(
  124. {},
  125. d,
  126. this._config
  127. );
  128. this._configService.setConfig(G, n);
  129. }
  130. onStarting() {
  131. [
  132. [_],
  133. [v],
  134. [h, { useClass: v }]
  135. ].forEach((t) => this._injector.add(t)), Mf(this._injector, [
  136. [_]
  137. ]);
  138. }
  139. }, D(c, "pluginName", l), D(c, "type", Fe.UNIVER_DOC), c);
  140. f = V([
  141. u(1, ot(Ot)),
  142. u(2, SE)
  143. ], f);
  144. export {
  145. v,
  146. h,
  147. l,
  148. _,
  149. f
  150. };
  151. //# sourceMappingURL=chunk-23GLNZMH.js.map