| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- import { createIdentifier as U, CommandType as E, Disposable as l, UniverInstanceType as h, ICommandService as D, IResourceManagerService as I, DependentOn as w, Inject as O, Injector as R, Plugin as b, merge as p, IConfigService as M } from "@univerjs/core";
- import { UnitDrawingService as G, IDrawingManagerService as d, UniverDrawingPlugin as C } from "@univerjs/drawing";
- const J = "sheets-drawing.config", v = {};
- var j = /* @__PURE__ */ ((e) => (e.Position = "0", e.Both = "1", e.None = "2", e))(j || {});
- class L extends G {
- }
- const u = U("sheets-drawing.sheet-drawing.service");
- var F = /* @__PURE__ */ ((e) => (e[e.INSERT = 0] = "INSERT", e[e.REMOVE = 1] = "REMOVE", e[e.UPDATE = 2] = "UPDATE", e[e.ARRANGE = 3] = "ARRANGE", e[e.GROUP = 4] = "GROUP", e[e.UNGROUP = 5] = "UNGROUP", e))(F || {});
- const H = {
- id: "sheet.mutation.set-drawing-apply",
- type: E.MUTATION,
- handler: (e, i) => {
- const r = e.get(d), t = e.get(u), { op: n, unitId: a, subUnitId: s, type: P, objects: o } = i;
- switch (r.applyJson1(a, s, n), t.applyJson1(a, s, n), P) {
- case 0:
- r.addNotification(o), t.addNotification(o);
- break;
- case 1:
- r.removeNotification(o), t.removeNotification(o);
- break;
- case 2:
- r.updateNotification(o), t.updateNotification(o);
- break;
- case 3:
- r.orderNotification(o), t.orderNotification(o);
- break;
- case 4:
- r.groupUpdateNotification(o);
- break;
- case 5:
- r.ungroupUpdateNotification(o);
- break;
- }
- return !0;
- }
- };
- var W = Object.defineProperty, x = Object.getOwnPropertyDescriptor, V = (e, i, r, t) => {
- for (var n = t > 1 ? void 0 : t ? x(i, r) : i, a = e.length - 1, s; a >= 0; a--)
- (s = e[a]) && (n = (t ? s(i, r, n) : s(n)) || n);
- return t && n && W(i, r, n), n;
- }, c = (e, i) => (r, t) => i(r, t, e);
- const S = "SHEET_DRAWING_PLUGIN";
- let g = class extends l {
- constructor(e, i, r, t) {
- super(), this._commandService = e, this._sheetDrawingService = i, this._drawingManagerService = r, this._resourceManagerService = t, this._initSnapshot(), this.disposeWithMe(this._commandService.registerCommand(H));
- }
- _initSnapshot() {
- const e = (r, t) => {
- const n = t || this._sheetDrawingService.getDrawingDataForUnit(r);
- return n ? JSON.stringify(n) : "";
- }, i = (r) => {
- if (!r)
- return {};
- try {
- return JSON.parse(r);
- } catch {
- return {};
- }
- };
- this.disposeWithMe(
- this._resourceManagerService.registerPluginResource({
- pluginName: S,
- businesses: [h.UNIVER_SHEET],
- toJson: (r, t) => e(r, t),
- parseJson: (r) => i(r),
- onUnLoad: (r) => {
- this._sheetDrawingService.removeDrawingDataForUnit(r), this._drawingManagerService.removeDrawingDataForUnit(r);
- },
- onLoad: (r, t) => {
- this._sheetDrawingService.registerDrawingData(r, t), this._drawingManagerService.registerDrawingData(r, t);
- }
- })
- );
- }
- };
- g = V([
- c(0, D),
- c(1, u),
- c(2, d),
- c(3, I)
- ], g);
- var N = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, B = (e, i, r) => i in e ? N(e, i, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[i] = r, K = (e, i, r, t) => {
- for (var n = t > 1 ? void 0 : t ? $(i, r) : i, a = e.length - 1, s; a >= 0; a--)
- (s = e[a]) && (n = (t ? s(i, r, n) : s(n)) || n);
- return t && n && N(i, r, n), n;
- }, f = (e, i) => (r, t) => i(r, t, e), m = (e, i, r) => B(e, typeof i != "symbol" ? i + "" : i, r);
- let _ = class extends b {
- constructor(e = v, i, r) {
- super(), this._config = e, this._injector = i, this._configService = r;
- const { ...t } = p(
- {},
- v,
- this._config
- );
- this._configService.setConfig(J, t);
- }
- onStarting() {
- [
- [g],
- [u, { useClass: L }]
- ].forEach((e) => this._injector.add(e)), this._injector.get(g);
- }
- };
- m(_, "pluginName", S);
- m(_, "type", h.UNIVER_SHEET);
- _ = K([
- w(C),
- f(1, O(R)),
- f(2, M)
- ], _);
- export {
- F as DrawingApplyType,
- u as ISheetDrawingService,
- S as SHEET_DRAWING_PLUGIN,
- H as SetDrawingApplyMutation,
- j as SheetDrawingAnchorType,
- _ as UniverSheetsDrawingPlugin
- };
|