| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- var w = Object.defineProperty;
- var S = (t, r, e) => r in t ? w(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
- var D = (t, r, e) => S(t, typeof r != "symbol" ? r + "" : r, e);
- import { createIdentifier as O, Disposable as U, UniverInstanceType as g, IResourceManagerService as I, IUniverInstanceService as P, Plugin as C, merge as N, touchDependencies as M, Inject as b, Injector as j, IConfigService as m } from "@univerjs/core";
- import { UnitDrawingService as R, IDrawingManagerService as E } from "@univerjs/drawing";
- const G = "docs-drawing.config", d = {};
- class v extends R {
- }
- const h = O("univer.doc.plugin.doc-drawing.service");
- var F = Object.defineProperty, J = Object.getOwnPropertyDescriptor, y = (t, r, e, n) => {
- for (var i = n > 1 ? void 0 : n ? J(r, e) : r, a = t.length - 1, s; a >= 0; a--)
- (s = t[a]) && (i = (n ? s(r, e, i) : s(i)) || i);
- return n && i && F(r, e, i), i;
- }, o = (t, r) => (e, n) => r(e, n, t);
- const l = "DOC_DRAWING_PLUGIN";
- let _ = class extends U {
- constructor(t, r, e, n) {
- super(), this._docDrawingService = t, this._drawingManagerService = r, this._resourceManagerService = e, this._univerInstanceService = n, this._init();
- }
- _init() {
- this._initSnapshot();
- }
- _initSnapshot() {
- const t = (e) => {
- const n = this._univerInstanceService.getUnit(e, g.UNIVER_DOC);
- if (n) {
- const i = n.getSnapshot().drawings, a = n.getSnapshot().drawingsOrder, s = {
- data: i != null ? i : {},
- order: a != null ? a : []
- };
- return JSON.stringify(s);
- }
- return "";
- }, r = (e) => {
- if (!e)
- return { data: {}, order: [] };
- try {
- return JSON.parse(e);
- } catch {
- return { data: {}, order: [] };
- }
- };
- this.disposeWithMe(
- this._resourceManagerService.registerPluginResource({
- pluginName: l,
- businesses: [g.UNIVER_DOC],
- toJson: (e) => t(e),
- parseJson: (e) => r(e),
- onUnLoad: (e) => {
- this._setDrawingDataForUnit(e, { data: {}, order: [] });
- },
- onLoad: (e, n) => {
- var i, a;
- this._setDrawingDataForUnit(e, { data: (i = n.data) != null ? i : {}, order: (a = n.order) != null ? a : [] });
- }
- })
- );
- }
- _setDrawingDataForUnit(t, r) {
- const e = this._univerInstanceService.getUnit(t);
- e != null && (e.resetDrawing(r.data, r.order), this.loadDrawingDataForUnit(t));
- }
- loadDrawingDataForUnit(t) {
- const r = this._univerInstanceService.getUnit(t, g.UNIVER_DOC);
- if (!r)
- return !1;
- const e = t, n = r.getDrawings(), i = r.getDrawingsOrder();
- if (!n || !i)
- return !1;
- Object.keys(n).forEach((s) => {
- const p = n[s];
- n[s] = { ...p };
- });
- const a = {
- [e]: {
- unitId: t,
- subUnitId: e,
- data: n,
- order: i
- }
- };
- return this._docDrawingService.registerDrawingData(t, a), this._drawingManagerService.registerDrawingData(t, a), !0;
- }
- };
- _ = y([
- o(0, h),
- o(1, E),
- o(2, I),
- o(3, P)
- ], _);
- var L = Object.defineProperty, x = Object.getOwnPropertyDescriptor, V = (t, r, e, n) => {
- for (var i = n > 1 ? void 0 : n ? x(r, e) : r, a = t.length - 1, s; a >= 0; a--)
- (s = t[a]) && (i = (n ? s(r, e, i) : s(i)) || i);
- return n && i && L(r, e, i), i;
- }, u = (t, r) => (e, n) => r(e, n, t), c;
- let f = (c = class extends C {
- constructor(t = d, r, e) {
- super(), this._config = t, this._injector = r, this._configService = e;
- const { ...n } = N(
- {},
- d,
- this._config
- );
- this._configService.setConfig(G, n);
- }
- onStarting() {
- [
- [_],
- [v],
- [h, { useClass: v }]
- ].forEach((t) => this._injector.add(t)), M(this._injector, [
- [_]
- ]);
- }
- }, D(c, "pluginName", l), D(c, "type", g.UNIVER_DOC), c);
- f = V([
- u(1, b(j)),
- u(2, m)
- ], f);
- export {
- l as DOCS_DRAWING_PLUGIN,
- _ as DocDrawingController,
- v as DocDrawingService,
- h as IDocDrawingService,
- f as UniverDocsDrawingPlugin
- };
|