1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571 |
- import {
- F as F2,
- H,
- _ as _2,
- j,
- u
- } from "./chunk-DS5QSAGN.js";
- import {
- $t,
- Er,
- Hr,
- Sn,
- _s,
- aE as aE2,
- ap,
- dn,
- dt,
- gr,
- me,
- ni,
- rt as rt2,
- tt as tt2,
- ue,
- vi
- } from "./chunk-T4NNB5UY.js";
- import {
- $o,
- Bn,
- Br,
- F,
- Fn,
- Gn,
- Hn,
- Jn,
- Js,
- Kn,
- Me,
- Mn,
- N,
- Oe,
- Oo,
- Pe,
- Pt as Pt2,
- Qt,
- Te,
- Tt,
- V,
- Wo,
- Xt,
- Zt as Zt2,
- an,
- ea,
- et,
- gh,
- gt,
- jn as jn2,
- kr,
- mt,
- ne,
- nt as nt2,
- oe,
- on,
- pt,
- qn,
- qt as qt2,
- sn,
- tt,
- ut,
- yr,
- zn
- } from "./chunk-BW43Z7N3.js";
- import "./chunk-QRYBFJ3R.js";
- import {
- Vi,
- rf
- } from "./chunk-MIOQ566M.js";
- import {
- De,
- Ke,
- Kt,
- cn as cn2,
- jn,
- vr,
- xe
- } from "./chunk-AGSU7DWG.js";
- import {
- $e,
- Fa,
- I1,
- Le,
- f1,
- fl,
- it,
- l1,
- l3,
- m1,
- n1,
- o3,
- rt
- } from "./chunk-POAJ2YNP.js";
- import {
- Xw,
- e_,
- t_
- } from "./chunk-GBYP4PB2.js";
- import "./chunk-PZD7N4BC.js";
- import {
- A1,
- Y,
- Yx,
- aS,
- b3,
- ff,
- i2,
- ie,
- pf
- } from "./chunk-2MK3Q52E.js";
- import "./chunk-BSDDCPAW.js";
- import {
- _,
- f
- } from "./chunk-23GLNZMH.js";
- import {
- At,
- On,
- Ut,
- Yt,
- Zt,
- bn,
- ln,
- mn,
- vn,
- wn
- } from "./chunk-QG2HZMYH.js";
- import {
- B0,
- BehaviorSubject,
- DR,
- Fe,
- Hd,
- Ht,
- IR,
- J0,
- K0,
- Kp,
- Mf,
- Mi,
- OR,
- Oa,
- Ot,
- Pt,
- Ra,
- SE,
- Sr,
- Subject,
- UE,
- Ve,
- Vn,
- Vr,
- W0,
- Xp,
- Ze,
- _n,
- aE,
- am,
- ar,
- cn,
- combineLatest,
- distinctUntilChanged,
- en,
- filter,
- fm,
- fs,
- g0,
- gm,
- kt,
- map,
- mu,
- nt,
- nu,
- oE,
- om,
- ot,
- qt,
- re,
- rr,
- st,
- su,
- switchMap,
- take,
- takeUntil,
- tr,
- we,
- wu,
- yR
- } from "./chunk-23V3HWTR.js";
- import {
- require_react
- } from "./chunk-GNR2UJZM.js";
- import {
- __toESM
- } from "./chunk-2LSFTFF7.js";
- // node_modules/.pnpm/@univerjs+sheets-drawing-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-drawing-ui/lib/es/index.js
- var import_react = __toESM(require_react());
- var vr2 = Object.defineProperty;
- var Sr2 = (i, e, n) => e in i ? vr2(i, e, { enumerable: true, configurable: true, writable: true, value: n }) : i[e] = n;
- var J = (i, e, n) => Sr2(i, typeof e != "symbol" ? e + "" : e, n);
- var Hi = "sheets-drawing-ui.config";
- var Cn = {};
- var F3 = {
- id: "sheet.operation.clear-drawing-transformer",
- type: ar.MUTATION,
- handler: (i, e) => {
- const n = i.get(Yx);
- return e.forEach((t) => {
- var r, s;
- (s = (r = n.getRenderById(t)) == null ? void 0 : r.scene.getTransformer()) == null || s.debounceRefreshControls();
- }), true;
- }
- };
- var Nt = {
- id: "sheet.command.remove-sheet-image",
- type: ar.COMMAND,
- handler: (i, e) => {
- var I, S, R;
- const n = i.get(Pt), t = i.get(cn), r = i.get(V), s = i.get(u);
- if (!e)
- return false;
- const { drawings: o } = e, c = [];
- o.forEach((v) => {
- const { unitId: C } = v;
- c.push(C);
- });
- const d = s.getBatchRemoveOp(o), { unitId: g, subUnitId: a, undo: l, redo: h, objects: u2 } = d, m = r.onCommandExecute({ id: Nt.id, params: e }), p = { id: H.id, params: { unitId: g, subUnitId: a, op: h, objects: u2, type: F2.REMOVE } }, f2 = { id: H.id, params: { unitId: g, subUnitId: a, op: l, objects: u2, type: F2.INSERT } };
- return mu([...(I = m.preRedos) != null ? I : [], p, ...m.redos], n) ? (t.pushUndoRedo({
- unitID: g,
- undoMutations: [
- ...(S = m.preUndos) != null ? S : [],
- f2,
- ...m.undos,
- { id: F3.id, params: c }
- ],
- redoMutations: [
- ...(R = m.preRedos) != null ? R : [],
- p,
- ...m.redos,
- { id: F3.id, params: c }
- ]
- }), true) : false;
- }
- };
- var rr2 = "COMPONENT_SHEET_DRAWING_PANEL";
- var ir = {
- id: "sidebar.operation.sheet-image",
- type: ar.COMMAND,
- handler: async (i, e) => {
- const n = i.get(rt), t = i.get(Vr), r = i.get(_n), s = i.get(Pt);
- if (!N(r))
- return false;
- switch (e.value) {
- case "open":
- n.open({
- header: { title: t.t("sheetImage.panel.title") },
- children: { label: rr2 },
- onClose: () => {
- s.syncExecuteCommand(ln.id, []);
- },
- width: 360
- });
- break;
- case "close":
- default:
- n.close();
- break;
- }
- return true;
- }
- };
- var sr = {
- id: "sheet.operation.edit-sheet-image",
- type: ar.OPERATION,
- handler: (i, e) => {
- const n = i.get(Pt);
- return e == null ? false : (n.syncExecuteCommand(ln.id, [e]), n.executeCommand(ir.id, { value: "open" }), true);
- }
- };
- var Kt2 = { exports: {} };
- var Xe = {};
- var Rn;
- function Xi() {
- if (Rn)
- return Xe;
- Rn = 1;
- var i = import_react.default, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), t = Object.prototype.hasOwnProperty, r = i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: true, ref: true, __self: true, __source: true };
- function o(c, d, g) {
- var a, l = {}, h = null, u2 = null;
- g !== void 0 && (h = "" + g), d.key !== void 0 && (h = "" + d.key), d.ref !== void 0 && (u2 = d.ref);
- for (a in d)
- t.call(d, a) && !s.hasOwnProperty(a) && (l[a] = d[a]);
- if (c && c.defaultProps)
- for (a in d = c.defaultProps, d)
- l[a] === void 0 && (l[a] = d[a]);
- return { $$typeof: e, type: c, key: h, ref: u2, props: l, _owner: r.current };
- }
- return Xe.Fragment = n, Xe.jsx = o, Xe.jsxs = o, Xe;
- }
- var bn2;
- function zi() {
- return bn2 || (bn2 = 1, Kt2.exports = Xi()), Kt2.exports;
- }
- var G = zi();
- var Ki = "univer-upload-loading";
- var Ji = "univer-upload-loading-body";
- var Zi = "univer-upload-loading-body-animation";
- var qi = "univer-UniverCircleAnimation";
- var Qi = "univer-upload-loading-body-text";
- var mt2 = {
- uploadLoading: Ki,
- uploadLoadingBody: Ji,
- uploadLoadingBodyAnimation: Zi,
- univerCircleAnimation: qi,
- uploadLoadingBodyText: Qi
- };
- var es = () => {
- const i = W0(Oa), e = W0(Vr), [n, t] = import_react.default.useState(0);
- return (0, import_react.useEffect)(() => {
- const r = i.change$.subscribe((s) => {
- t(s);
- });
- return () => {
- r.unsubscribe();
- };
- }, [i]), G.jsx("div", { style: { display: n > 0 ? "block" : "none" }, className: mt2.uploadLoading, children: G.jsxs("div", { className: mt2.uploadLoadingBody, children: [
- G.jsx("div", { className: mt2.uploadLoadingBodyAnimation }),
- G.jsx("div", { className: mt2.uploadLoadingBodyText, children: `${e.t("uploadLoading.loading")}: ${n}` })
- ] }) });
- };
- var ts = Object.defineProperty;
- var ns = Object.getOwnPropertyDescriptor;
- var rs = (i, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? ns(e, n) : e, s = i.length - 1, o; s >= 0; s--)
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
- return t && r && ts(e, n, r), r;
- };
- var fe = (i, e) => (n, t) => e(n, t, i);
- var It = class extends J0 {
- constructor(e, n, t, r, s, o, c, d) {
- super();
- J(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
- this._injector = e, this._drawingManagerService = n, this._canvasPopManagerService = t, this._renderManagerService = r, this._univerInstanceService = s, this._contextService = o, this._uiPartsService = c, this._commandService = d, this._init();
- }
- _init() {
- this._univerInstanceService.getCurrentTypeOfUnit$(Fe.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((e) => this._create(e)), this._univerInstanceService.getTypeOfUnitDisposed$(Fe.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((e) => this._dispose(e)), this._univerInstanceService.getAllUnitsForType(Fe.UNIVER_SHEET).forEach((e) => this._create(e)), this._uiPartsService.registerComponent(Le.CONTENT, () => B0(es, this._injector));
- }
- _dispose(e) {
- const n = e.getUnitId();
- this._renderManagerService.removeRender(n);
- }
- _create(e) {
- if (!e)
- return;
- const n = e.getUnitId();
- this._renderManagerService.has(n) && !this._initImagePopupMenu.has(n) && (this._popupMenuListener(n), this._initImagePopupMenu.add(n));
- }
- _hasCropObject(e) {
- const n = e.getAllObjectsByOrder();
- for (const t of n)
- if (t instanceof xe)
- return true;
- return false;
- }
- _popupMenuListener(e) {
- var s;
- const n = (s = this._renderManagerService.getRenderById(e)) == null ? void 0 : s.scene;
- if (!n)
- return;
- const t = n.getTransformerByCreate();
- if (!t)
- return;
- let r;
- this.disposeWithMe(
- Ze(
- t.createControl$.subscribe(() => {
- if (this._contextService.setContextValue(yR, true), this._hasCropObject(n))
- return;
- const o = t.getSelectedObjectMap();
- if (o.size > 1) {
- r == null || r.dispose();
- return;
- }
- const c = o.values().next().value;
- if (!c)
- return;
- const d = c.oKey, g = this._drawingManagerService.getDrawingOKey(d);
- if (!g)
- return;
- const { unitId: a, subUnitId: l, drawingId: h, drawingType: u2 } = g, m = g.data;
- if (m && m.disablePopup)
- return;
- r == null || r.dispose();
- const p = this._canvasPopManagerService.getFeatureMenu(a, l, h, u2);
- r = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(c, {
- componentKey: Kt,
- direction: "horizontal",
- offset: [2, 0],
- extraProps: {
- menuItems: p || this._getImageMenuItems(a, l, h, u2)
- }
- }));
- })
- )
- ), this.disposeWithMe(
- t.clearControl$.subscribe(() => {
- r == null || r.dispose(), this._contextService.setContextValue(yR, false), this._commandService.syncExecuteCommand(ln.id, []);
- })
- ), this.disposeWithMe(
- this._contextService.contextChanged$.subscribe((o) => {
- o[yR] === false && (r == null || r.dispose());
- })
- ), this.disposeWithMe(
- t.changing$.subscribe(() => {
- r == null || r.dispose();
- })
- );
- }
- _getImageMenuItems(e, n, t, r) {
- return [
- {
- label: "image-popup.edit",
- index: 0,
- commandId: sr.id,
- commandParams: { unitId: e, subUnitId: n, drawingId: t },
- disable: r === gm.DRAWING_DOM
- },
- {
- label: "image-popup.delete",
- index: 1,
- commandId: Nt.id,
- commandParams: { unitId: e, drawings: [{ unitId: e, subUnitId: n, drawingId: t }] },
- disable: false
- },
- {
- label: "image-popup.crop",
- index: 2,
- commandId: Ke.id,
- commandParams: { unitId: e, subUnitId: n, drawingId: t },
- disable: r === gm.DRAWING_DOM
- },
- {
- label: "image-popup.reset",
- index: 3,
- commandId: jn.id,
- commandParams: [{ unitId: e, subUnitId: n, drawingId: t }],
- disable: r === gm.DRAWING_DOM
- }
- ];
- }
- };
- It = rs([
- fe(0, ot(Ot)),
- fe(1, Ut),
- fe(2, ot(vi)),
- fe(3, Yx),
- fe(4, _n),
- fe(5, fs),
- fe(6, ot(f1)),
- fe(7, Pt)
- ], It);
- function z(i, e, n) {
- const { from: t, to: r, flipY: s = false, flipX: o = false, angle: c = 0, skewX: d = 0, skewY: g = 0 } = i, a = n.getCurrent();
- if (a == null)
- return;
- const l = aE2(
- a.unitId,
- a.sheetId,
- { from: t, to: r },
- n
- );
- let { left: h, top: u2, width: m, height: p } = l;
- const f2 = n.getCurrentSkeleton(), w = f2.rowHeaderWidth + f2.columnTotalWidth, I = f2.columnHeaderHeight + f2.rowTotalHeight;
- return h + m > w && (h = w - m), u2 + p > I && (u2 = I - p), {
- flipY: s,
- flipX: o,
- angle: c,
- skewX: d,
- skewY: g,
- left: h,
- top: u2,
- width: m,
- height: p
- };
- }
- function k(i, e) {
- const { left: n = 0, top: t = 0, width: r = 0, height: s = 0, flipY: o = false, flipX: c = false, angle: d = 0, skewX: g = 0, skewY: a = 0 } = i, l = e.getCellWithCoordByOffset(n, t);
- if (l == null)
- return;
- const h = {
- column: l.actualColumn,
- columnOffset: ie(n - l.startX, 1),
- row: l.actualRow,
- rowOffset: ie(t - l.startY, 1)
- }, u2 = e.getCellWithCoordByOffset(n + r, t + s);
- if (u2 == null)
- return;
- const m = {
- column: u2.actualColumn,
- columnOffset: ie(n + r - u2.startX, 1),
- row: u2.actualRow,
- rowOffset: ie(t + s - u2.startY, 1)
- };
- return {
- flipY: o,
- flipX: c,
- angle: d,
- skewX: g,
- skewY: a,
- from: h,
- to: m
- };
- }
- var is = Object.defineProperty;
- var ss = Object.getOwnPropertyDescriptor;
- var os = (i, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? ss(e, n) : e, s = i.length - 1, o; s >= 0; s--)
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
- return t && r && is(e, n, r), r;
- };
- var ft = (i, e) => (n, t) => e(n, t, i);
- var nn = class extends nt {
- constructor(i, e, n, t, r) {
- super(), this._context = i, this._sheetDrawingService = e, this._drawingManagerService = n, this._sheetSelectionRenderService = t, this._sheetSkeletonManagerService = r, this._init();
- }
- _init() {
- this._drawingInitializeListener();
- }
- _drawingInitializeListener() {
- this._sheetDrawingService.initializeNotification(this._context.unitId);
- const i = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);
- for (const e in i) {
- const n = i[e];
- for (const t in n.data) {
- const r = n.data[t];
- r.transform = z(r.sheetTransform, this._sheetSelectionRenderService, this._sheetSkeletonManagerService);
- }
- }
- this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)), this._drawingManagerService.initializeNotification(this._context.unitId);
- }
- };
- nn = os([
- ft(1, u),
- ft(2, Ut),
- ft(3, ot(dt)),
- ft(4, ot(me))
- ], nn);
- function as(i) {
- const e = [];
- return i.forEach((n) => {
- const { parent: t, children: r } = n, { unitId: s, subUnitId: o, drawingId: c } = t, d = pf(0, 0, r.map((l) => l.transform || {})), g = r.map((l) => {
- const h = l.transform || { left: 0, top: 0 }, { unitId: u2, subUnitId: m, drawingId: p } = l;
- return {
- unitId: u2,
- subUnitId: m,
- drawingId: p,
- transform: {
- ...h,
- left: h.left - d.left,
- top: h.top - d.top
- },
- groupId: c
- };
- }), a = {
- unitId: s,
- subUnitId: o,
- drawingId: c,
- drawingType: gm.DRAWING_GROUP,
- transform: d
- };
- e.push({
- parent: a,
- children: g
- });
- }), e;
- }
- function cs(i) {
- const e = [];
- return i.forEach((n) => {
- const { parent: t, children: r } = n, { unitId: s, subUnitId: o, drawingId: c, transform: d = { width: 0, height: 0 } } = t;
- if (d == null)
- return;
- const g = r.map((l) => {
- const { transform: h } = l, { unitId: u2, subUnitId: m, drawingId: p } = l, f2 = ff(h || {}, d, d.width || 0, d.height || 0);
- return {
- unitId: u2,
- subUnitId: m,
- drawingId: p,
- transform: f2,
- groupId: void 0
- };
- }), a = {
- unitId: s,
- subUnitId: o,
- drawingId: c,
- drawingType: gm.DRAWING_GROUP,
- transform: {
- left: 0,
- top: 0
- }
- };
- e.push({
- parent: a,
- children: g
- });
- }), e;
- }
- var or = {
- id: "sheet.command.group-sheet-image",
- type: ar.COMMAND,
- handler: (i, e) => {
- const n = i.get(Pt), t = i.get(cn), r = i.get(u);
- if (!e)
- return false;
- const s = [];
- e.forEach(({ parent: u2, children: m }) => {
- s.push(u2.unitId), m.forEach((p) => {
- s.push(p.unitId);
- });
- });
- const o = r.getGroupDrawingOp(e), { unitId: c, subUnitId: d, undo: g, redo: a, objects: l } = o;
- return n.syncExecuteCommand(H.id, { op: a, unitId: c, subUnitId: d, objects: l, type: F2.GROUP }) ? (t.pushUndoRedo({
- unitID: c,
- undoMutations: [
- { id: H.id, params: { op: g, unitId: c, subUnitId: d, objects: cs(l), type: F2.UNGROUP } },
- { id: F3.id, params: s }
- ],
- redoMutations: [
- { id: H.id, params: { op: a, unitId: c, subUnitId: d, objects: l, type: F2.GROUP } },
- { id: F3.id, params: s }
- ]
- }), true) : false;
- }
- };
- var jt = {
- id: "sheet.command.insert-sheet-image",
- type: ar.COMMAND,
- handler: (i, e) => {
- var I, S, R;
- const n = i.get(Pt), t = i.get(cn), r = i.get(u), s = i.get(V);
- if (!e)
- return false;
- const o = e.drawings, c = o.map((v) => v.unitId), d = r.getBatchAddOp(o), { unitId: g, subUnitId: a, undo: l, redo: h, objects: u2 } = d, m = s.onCommandExecute({ id: jt.id, params: e }), p = { id: H.id, params: { op: h, unitId: g, subUnitId: a, objects: u2, type: F2.INSERT } }, f2 = { id: H.id, params: { op: l, unitId: g, subUnitId: a, objects: u2, type: F2.REMOVE } };
- return mu([...(I = m.preRedos) != null ? I : [], p, ...m.redos], n) ? (t.pushUndoRedo({
- unitID: g,
- undoMutations: [
- ...(S = m.preUndos) != null ? S : [],
- f2,
- ...m.undos,
- { id: F3.id, params: c }
- ],
- redoMutations: [
- ...(R = m.preRedos) != null ? R : [],
- p,
- ...m.redos,
- { id: F3.id, params: c }
- ]
- }), true) : false;
- }
- };
- var ar2 = {
- id: "sheet.command.set-drawing-arrange",
- type: ar.COMMAND,
- handler: (i, e) => {
- const n = i.get(Pt), t = i.get(cn);
- if (!e)
- return false;
- const r = i.get(u), { unitId: s, subUnitId: o, drawingIds: c, arrangeType: d } = e, g = { unitId: s, subUnitId: o, drawingIds: c };
- let a;
- if (d === fm.forward ? a = r.getForwardDrawingsOp(g) : d === fm.backward ? a = r.getBackwardDrawingOp(g) : d === fm.front ? a = r.getFrontDrawingsOp(g) : d === fm.back && (a = r.getBackDrawingsOp(g)), a == null)
- return false;
- const { objects: l, redo: h, undo: u2 } = a;
- return n.syncExecuteCommand(H.id, { op: h, unitId: s, subUnitId: o, objects: l, type: F2.ARRANGE }) ? (t.pushUndoRedo({
- unitID: s,
- undoMutations: [
- { id: H.id, params: { op: u2, unitId: s, subUnitId: o, objects: l, type: F2.ARRANGE } }
- ],
- redoMutations: [
- { id: H.id, params: { op: h, unitId: s, subUnitId: o, objects: l, type: F2.ARRANGE } }
- ]
- }), true) : false;
- }
- };
- var Wt = {
- id: "sheet.command.set-sheet-image",
- type: ar.COMMAND,
- handler: (i, e) => {
- const n = i.get(Pt), t = i.get(cn), r = i.get(u);
- if (!e)
- return false;
- const { drawings: s } = e, o = r.getBatchUpdateOp(s), { unitId: c, subUnitId: d, undo: g, redo: a, objects: l } = o;
- return n.syncExecuteCommand(H.id, { unitId: c, subUnitId: d, op: a, objects: l, type: F2.UPDATE }) ? (t.pushUndoRedo({
- unitID: c,
- undoMutations: [
- { id: H.id, params: { unitId: c, subUnitId: d, op: g, objects: l, type: F2.UPDATE } },
- { id: F3.id, params: [c] }
- ],
- redoMutations: [
- { id: H.id, params: { unitId: c, subUnitId: d, op: a, objects: l, type: F2.UPDATE } },
- { id: F3.id, params: [c] }
- ]
- }), true) : false;
- }
- };
- var cr = {
- id: "sheet.command.ungroup-sheet-image",
- type: ar.COMMAND,
- handler: (i, e) => {
- const n = i.get(Pt), t = i.get(cn), r = i.get(u);
- if (!e)
- return false;
- const s = [];
- e.forEach(({ parent: u2, children: m }) => {
- s.push(u2.unitId), m.forEach((p) => {
- s.push(p.unitId);
- });
- });
- const o = r.getUngroupDrawingOp(e), { unitId: c, subUnitId: d, undo: g, redo: a, objects: l } = o;
- return n.syncExecuteCommand(H.id, { op: a, unitId: c, subUnitId: d, objects: l, type: F2.UNGROUP }) ? (t.pushUndoRedo({
- unitID: c,
- undoMutations: [
- { id: H.id, params: { op: g, unitId: c, subUnitId: d, objects: as(l), type: F2.GROUP } },
- { id: F3.id, params: s }
- ],
- redoMutations: [
- { id: H.id, params: { op: a, unitId: c, subUnitId: d, objects: l, type: F2.UNGROUP } },
- { id: F3.id, params: s }
- ]
- }), true) : false;
- }
- };
- var ds = Object.defineProperty;
- var ls = Object.getOwnPropertyDescriptor;
- var us = (i, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? ls(e, n) : e, s = i.length - 1, o; s >= 0; s--)
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
- return t && r && ds(e, n, r), r;
- };
- var te = (i, e) => (n, t) => e(n, t, i);
- function hs(i, e, n) {
- const t = n * Math.PI / 180, r = Math.abs(i * Math.cos(t)) + Math.abs(e * Math.sin(t)), s = Math.abs(i * Math.sin(t)) + Math.abs(e * Math.cos(t));
- return { rotatedWidth: r, rotatedHeight: s };
- }
- function dr(i, e, n, t, r) {
- var I;
- const { rotatedHeight: s, rotatedWidth: o } = hs(n, t, r), d = i.get(Yx).getRenderById(e.unitId);
- if (!d)
- return false;
- const a = (I = d.with(me).getWorksheetSkeleton(e.subUnitId)) == null ? void 0 : I.skeleton;
- if (a == null)
- return false;
- const l = a.getCellByIndex(e.row, e.col), h = l.mergeInfo.endX - l.mergeInfo.startX - 2, u2 = l.mergeInfo.endY - l.mergeInfo.startY - 2, m = o / s, f2 = Math.ceil(Math.min(h, u2 * m)) / o, w = !f2 || Number.isNaN(f2) ? 1e-3 : f2;
- return {
- width: n * w,
- height: t * w
- };
- }
- var Ze2 = class extends nt {
- constructor(e, n, t, r, s, o, c, d, g, a, l, h, u2) {
- super();
- J(this, "_workbookSelections");
- this._context = e, this._skeletonManagerService = n, this._commandService = t, this._selectionRenderService = r, this._imageIoService = s, this._fileOpenerService = o, this._sheetDrawingService = c, this._drawingManagerService = d, this._contextService = g, this._messageService = a, this._localeService = l, this._injector = u2, this._workbookSelections = h.getWorkbookSelections(this._context.unitId), this._updateImageListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener();
- }
- async insertFloatImage() {
- const e = await this._fileOpenerService.openFile({
- multiple: true,
- accept: Zt.map((t) => `.${t.replace("image/", "")}`).join(",")
- }), n = e.length;
- return n > wn ? (this._messageService.show({
- type: Xw.Error,
- content: this._localeService.t("update-status.exceedMaxCount", String(wn))
- }), false) : n === 0 ? false : (e.forEach(async (t) => await this._insertFloatImage(t)), true);
- }
- async insertCellImage() {
- const n = (await this._fileOpenerService.openFile({
- multiple: false,
- accept: Zt.map((t) => `.${t.replace("image/", "")}`).join(",")
- }))[0];
- return n ? (await this._insertCellImage(n), true) : false;
- }
- async _insertFloatImage(e) {
- let n;
- try {
- n = await this._imageIoService.saveImage(e);
- } catch (I) {
- const S = I.message;
- S === g0.ERROR_EXCEED_SIZE ? this._messageService.show({
- type: Xw.Error,
- content: this._localeService.t("update-status.exceedMaxSize", String(Yt / (1024 * 1024)))
- }) : S === g0.ERROR_IMAGE_TYPE ? this._messageService.show({
- type: Xw.Error,
- content: this._localeService.t("update-status.invalidImageType")
- }) : S === g0.ERROR_IMAGE && this._messageService.show({
- type: Xw.Error,
- content: this._localeService.t("update-status.invalidImage")
- });
- }
- if (n == null)
- return;
- const t = this._getUnitInfo(), { unitId: r, subUnitId: s } = t, { imageId: o, imageSourceType: c, source: d, base64Cache: g } = n, { width: a, height: l, image: h } = await vn(g || ""), { width: u2, height: m } = this._context.scene;
- this._imageIoService.addImageSourceCache(d, c, h);
- let p = 1;
- if (a > mn || l > On) {
- const I = mn / a, S = On / l;
- p = Math.max(I, S);
- }
- const f2 = this._getImagePosition(a * p, l * p, u2, m);
- if (f2 == null)
- return;
- const w = {
- unitId: r,
- subUnitId: s,
- drawingId: o,
- drawingType: gm.DRAWING_IMAGE,
- imageSourceType: c,
- source: d,
- transform: z(f2, this._selectionRenderService, this._skeletonManagerService),
- sheetTransform: f2
- };
- this._commandService.executeCommand(jt.id, {
- unitId: r,
- drawings: [w]
- });
- }
- // eslint-disable-next-line max-lines-per-function
- async _insertCellImage(e) {
- let n;
- try {
- n = await this._imageIoService.saveImage(e);
- } catch (f2) {
- const w = f2.message;
- w === g0.ERROR_EXCEED_SIZE ? this._messageService.show({
- type: Xw.Error,
- content: this._localeService.t("update-status.exceedMaxSize", String(Yt / (1024 * 1024)))
- }) : w === g0.ERROR_IMAGE_TYPE ? this._messageService.show({
- type: Xw.Error,
- content: this._localeService.t("update-status.invalidImageType")
- }) : w === g0.ERROR_IMAGE && this._messageService.show({
- type: Xw.Error,
- content: this._localeService.t("update-status.invalidImage")
- });
- }
- if (n == null)
- return;
- const { imageId: t, imageSourceType: r, source: s, base64Cache: o } = n, { width: c, height: d, image: g } = await vn(o || "");
- this._imageIoService.addImageSourceCache(s, r, g);
- const a = this._workbookSelections.getCurrentLastSelection();
- if (!a)
- return false;
- const l = Sr("", {}), h = dr(
- this._injector,
- {
- unitId: this._context.unitId,
- subUnitId: this._context.unit.getActiveSheet().getSheetId(),
- row: a.primary.actualRow,
- col: a.primary.actualColumn
- },
- c,
- d,
- 0
- );
- if (!h)
- return false;
- const u2 = {
- size: {
- width: h.width,
- height: h.height
- },
- positionH: {
- relativeFrom: om.PAGE,
- posOffset: 0
- },
- positionV: {
- relativeFrom: am.PARAGRAPH,
- posOffset: 0
- },
- angle: 0
- }, m = {
- unitId: l.getUnitId(),
- subUnitId: l.getUnitId(),
- drawingId: t,
- drawingType: gm.DRAWING_IMAGE,
- imageSourceType: r,
- source: s,
- transform: rf(u2),
- docTransform: u2,
- behindDoc: we.FALSE,
- title: "",
- description: "",
- layoutType: Xp.INLINE,
- // Insert inline drawing by default.
- wrapText: Kp.BOTH_SIDES,
- distB: 0,
- distL: 0,
- distR: 0,
- distT: 0
- }, p = st.drawing.add({
- documentDataModel: l,
- drawings: [m],
- selection: {
- collapsed: true,
- startOffset: 0,
- endOffset: 0
- }
- });
- return p ? (l.apply(p), this._commandService.syncExecuteCommand(on.id, {
- value: {
- [a.primary.actualRow]: {
- [a.primary.actualColumn]: {
- p: l.getSnapshot(),
- t: 1
- }
- }
- }
- })) : false;
- }
- _getUnitInfo() {
- const e = this._context.unit, n = e.getActiveSheet(), t = e.getUnitId(), r = n.getSheetId();
- return {
- unitId: t,
- subUnitId: r
- };
- }
- _getImagePosition(e, n, t, r) {
- const s = this._workbookSelections.getCurrentSelections();
- let o = {
- startRow: 0,
- endRow: 0,
- startColumn: 0,
- endColumn: 0
- };
- s && s.length > 0 && (o = s[s.length - 1].range);
- const c = ni(this._skeletonManagerService.getCurrent().skeleton, o);
- if (c == null)
- return;
- let { startColumn: d, startRow: g, startX: a, startY: l } = c, h = false;
- if (a + e > t && (a = t - e, a < 0 && (a = 0, e = t), h = true), l + n > r && (l = r - n, l < 0 && (l = 0, n = r), h = true), h) {
- const f2 = this._selectionRenderService.getCellWithCoordByOffset(a, l);
- if (f2 == null)
- return;
- a = f2.startX, l = f2.startY, d = f2.actualColumn, g = f2.actualRow;
- }
- const u2 = {
- column: d,
- columnOffset: 0,
- row: g,
- rowOffset: 0
- }, m = this._selectionRenderService.getCellWithCoordByOffset(a + e, l + n);
- if (m == null)
- return;
- const p = {
- column: m.actualColumn,
- columnOffset: a + e - m.startX,
- row: m.actualRow,
- rowOffset: l + n - m.startY
- };
- return {
- from: u2,
- to: p
- };
- }
- _updateOrderListener() {
- this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe((e) => {
- const { unitId: n, subUnitId: t, drawingIds: r, arrangeType: s } = e;
- this._commandService.executeCommand(ar2.id, {
- unitId: n,
- subUnitId: t,
- drawingIds: r,
- arrangeType: s
- });
- }));
- }
- _updateImageListener() {
- this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe((e) => {
- const n = [];
- e.length !== 0 && (e.forEach((t) => {
- const { unitId: r, subUnitId: s, drawingId: o, drawingType: c, transform: d } = t;
- if (d == null)
- return;
- const g = this._sheetDrawingService.getDrawingByParam({ unitId: r, subUnitId: s, drawingId: o });
- if (g == null || g.unitId !== this._context.unitId)
- return;
- const a = k({ ...g.transform, ...d }, this._selectionRenderService);
- if (a == null)
- return;
- const l = {
- ...t,
- transform: { ...g.transform, ...d, ...z(a, this._selectionRenderService, this._skeletonManagerService) },
- sheetTransform: { ...a }
- };
- n.push(l);
- }), n.length > 0 && this._commandService.executeCommand(Wt.id, {
- unitId: e[0].unitId,
- drawings: n
- }));
- }));
- }
- _groupDrawingListener() {
- this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe((e) => {
- this._commandService.executeCommand(or.id, e);
- const { unitId: n, subUnitId: t, drawingId: r } = e[0].parent;
- this._commandService.syncExecuteCommand(ln.id, [{ unitId: n, subUnitId: t, drawingId: r }]);
- })), this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((e) => {
- this._commandService.executeCommand(cr.id, e);
- }));
- }
- _focusDrawingListener() {
- this.disposeWithMe(
- this._drawingManagerService.focus$.subscribe((e) => {
- e == null || e.length === 0 ? (this._contextService.setContextValue(yR, false), this._sheetDrawingService.focusDrawing([])) : (this._contextService.setContextValue(yR, true), this._sheetDrawingService.focusDrawing(e));
- })
- );
- }
- };
- Ze2 = us([
- te(1, ot(me)),
- te(2, Pt),
- te(3, dt),
- te(4, Oa),
- te(5, fl),
- te(6, u),
- te(7, Ut),
- te(8, fs),
- te(9, o3),
- te(10, ot(Vr)),
- te(11, ot(F)),
- te(12, ot(Ot))
- ], Ze2);
- var gs = Object.defineProperty;
- var ms = Object.getOwnPropertyDescriptor;
- var fs2 = (i, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? ms(e, n) : e, s = i.length - 1, o; s >= 0; s--)
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
- return t && r && gs(e, n, r), r;
- };
- var ye = (i, e) => (n, t) => e(n, t, i);
- function rn(i, e, n) {
- var t, r, s, o;
- if (((r = (t = n == null ? void 0 : n.p) == null ? void 0 : t.body) == null ? void 0 : r.dataStream.length) === 3 && ((o = (s = n.p) == null ? void 0 : s.drawingsOrder) == null ? void 0 : o.length) === 1) {
- const c = n.p.drawings[n.p.drawingsOrder[0]], d = dr(
- i,
- {
- unitId: e.unitId,
- subUnitId: e.subUnitId,
- row: e.row,
- col: e.col
- },
- c.docTransform.size.width,
- c.docTransform.size.height,
- c.docTransform.angle
- );
- if (d)
- return c.transform.width = d.width, c.transform.height = d.height, c.docTransform.size.width = d.width, c.docTransform.size.height = d.height, c.transform.left = 0, c.transform.top = 0, c.docTransform.positionH.posOffset = 0, c.docTransform.positionV.posOffset = 0, n.p.documentStyle.pageSize.width = 1 / 0, n.p.documentStyle.pageSize.height = 1 / 0, true;
- }
- return false;
- }
- var Ct = class extends nt {
- constructor(i, e, n, t, r, s, o) {
- super(), this._commandService = i, this._sheetInterceptorService = e, this._univerInstanceService = n, this._injector = t, this._drawingManagerService = r, this._docDrawingController = s, this._editorBridgeService = o, this._initHandleResize(), this._handleInitEditor(), this._handleWriteCell(), this._initCellContentInterceptor();
- }
- _initHandleResize() {
- this.disposeWithMe(this._commandService.onCommandExecuted((i) => {
- let e, n = [];
- if (i.id === nt2.id) {
- const t = i.params;
- n = t.ranges, e = N(this._univerInstanceService, { unitId: t.unitId, subUnitId: t.subUnitId });
- } else if (i.id === tt.id) {
- const t = i.params;
- n = t.ranges, e = N(this._univerInstanceService, { unitId: t.unitId, subUnitId: t.subUnitId });
- } else if (i.id === Oe.id) {
- const t = i.params;
- n = t.ranges, e = N(this._univerInstanceService, { unitId: t.unitId, subUnitId: t.subUnitId });
- } else if (i.id === Br.id) {
- const t = i.params;
- e = N(this._univerInstanceService, { unitId: t.unitId, subUnitId: t.subUnitId }), n = t.rowsAutoHeightInfo.map((r) => ({
- startRow: r.row,
- endRow: r.row,
- startColumn: 0,
- endColumn: 9999
- }));
- } else if (i.id === ne.id) {
- const t = i.params;
- n = t.ranges, e = N(this._univerInstanceService, { unitId: t.unitId, subUnitId: t.subUnitId });
- } else if (i.id === oe.id) {
- const t = i.params;
- n = t.ranges, e = N(this._univerInstanceService, { unitId: t.unitId, subUnitId: t.subUnitId });
- }
- e && n.length && n.forEach((t) => {
- const r = tr.transformRange(t, e.worksheet);
- for (let s = r.startRow; s <= r.endRow; s++)
- for (let o = r.startColumn; o <= r.endColumn; o++)
- rn(this._injector, { unitId: e.unitId, subUnitId: e.subUnitId, row: s, col: o }, e.worksheet.getCellRaw(s, o));
- });
- }));
- }
- _handleInitEditor() {
- this.disposeWithMe(this._editorBridgeService.visible$.subscribe((i) => {
- i.visible ? i.visible && (this._drawingManagerService.removeDrawingDataForUnit(su), this._docDrawingController.loadDrawingDataForUnit(su), this._drawingManagerService.initializeNotification(su)) : this._drawingManagerService.removeDrawingDataForUnit(su);
- })), this.disposeWithMe(this._commandService.onCommandExecuted((i) => {
- i.id === Vi.id && i.params.unitId === Hd && (this._drawingManagerService.removeDrawingDataForUnit(Hd), this._docDrawingController.loadDrawingDataForUnit(Hd), this._drawingManagerService.initializeNotification(Hd));
- }));
- }
- _handleWriteCell() {
- this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(qn, {
- priority: 9999,
- handler: (i, e, n) => (rn(this._injector, { unitId: e.unitId, subUnitId: e.subUnitId, row: e.row, col: e.col }, i), n(i))
- }));
- }
- _initCellContentInterceptor() {
- this.disposeWithMe(
- this._sheetInterceptorService.intercept(
- et.CELL_CONTENT,
- {
- effect: Vn.Style,
- priority: ea.CELL_IMAGE,
- handler: (i, e, n) => {
- var t;
- return i != null && i.p && ((t = i.p.drawingsOrder) != null && t.length) && (i.interceptorStyle || (i.interceptorStyle = {}), i.interceptorStyle.tr = { a: 0 }), n(i);
- }
- }
- )
- );
- }
- };
- Ct = fs2([
- ye(0, Pt),
- ye(1, ot(V)),
- ye(2, _n),
- ye(3, ot(Ot)),
- ye(4, Ut),
- ye(5, ot(_)),
- ye(6, ot(tt2))
- ], Ct);
- var ps = Object.defineProperty;
- var ws = Object.getOwnPropertyDescriptor;
- var _s2 = (i, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? ws(e, n) : e, s = i.length - 1, o; s >= 0; s--)
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
- return t && r && ps(e, n, r), r;
- };
- var Dn = (i, e) => (n, t) => e(n, t, i);
- var Rt = class extends nt {
- constructor(i, e) {
- super(), this._autoFillService = i, this._injector = e, this._initAutoFillHooks();
- }
- _initAutoFillHooks() {
- this.disposeWithMe(
- this._autoFillService.addHook({
- id: "sheet-cell-image-autofill",
- onBeforeSubmit: (i, e, n, t) => {
- new kt(t).forValue((r, s, o) => {
- rn(this._injector, { unitId: i.unitId, subUnitId: i.subUnitId, row: r, col: s }, o);
- });
- }
- })
- );
- }
- };
- Rt = _s2([
- Dn(0, ot(Hr)),
- Dn(1, ot(Ot))
- ], Rt);
- var vs = Object.defineProperty;
- var Ss = Object.getOwnPropertyDescriptor;
- var Is = (i, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? Ss(e, n) : e, s = i.length - 1, o; s >= 0; s--)
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
- return t && r && vs(e, n, r), r;
- };
- var pt2 = (i, e) => (n, t) => e(n, t, i);
- var bt = class extends nt {
- constructor(e, n, t, r) {
- super();
- J(this, "_isSetCursor", false);
- this._hoverManagerService = e, this._renderManagerService = n, this._selectionsService = t, this._drawingRenderService = r;
- }
- _initHover() {
- }
- _initImageClick() {
- }
- };
- bt = Is([
- pt2(0, ot(Er)),
- pt2(1, ot(Yx)),
- pt2(2, ot(F)),
- pt2(3, ot(De))
- ], bt);
- var Cs = Object.defineProperty;
- var Rs = Object.getOwnPropertyDescriptor;
- var bs = (i, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? Rs(e, n) : e, s = i.length - 1, o; s >= 0; s--)
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
- return t && r && Cs(e, n, r), r;
- };
- var Jt = (i, e) => (n, t) => e(n, t, i);
- var Dt = class extends nt {
- constructor(e, n, t) {
- super();
- J(this, "_copyInfo");
- this._sheetClipboardService = e, this._renderManagerService = n, this._sheetDrawingService = t, this._initCopyPaste();
- }
- _initCopyPaste() {
- this._sheetClipboardService.addClipboardHook({
- id: "SHEET_IMAGE_UI_PLUGIN",
- onBeforeCopy: (e, n, t) => this._collect(e, n, t),
- onPasteCells: (e, n, t, r) => {
- const { copyType: s = gr.COPY, pasteType: o } = r, { range: c } = e || {}, { range: d, unitId: g, subUnitId: a } = n;
- return this._generateMutations(d, { copyType: s, pasteType: o, copyRange: c, unitId: g, subUnitId: a });
- },
- onPastePlainText: (e, n) => ({ undos: [], redos: [] })
- });
- }
- _collect(e, n, t) {
- var h;
- const r = (h = this._renderManagerService.getRenderById(e)) == null ? void 0 : h.with(me);
- if (!r)
- return;
- const s = r.attachRangeWithCoord(t);
- if (!s)
- return;
- const { startX: o, endX: c, startY: d, endY: g } = s, a = this._sheetDrawingService.getDrawingData(e, n), l = [];
- Object.keys(a).forEach((u2) => {
- const m = a[u2], { transform: p } = m;
- if (m.anchorType !== j.Both || !p)
- return;
- const { left: f2 = 0, top: w = 0, width: I = 0, height: S = 0 } = p, { drawingStartX: R, drawingEndX: v, drawingStartY: C, drawingEndY: _3 } = {
- drawingStartX: f2,
- drawingEndX: f2 + I,
- drawingStartY: w,
- drawingEndY: w + S
- };
- o <= R && v <= c && d <= C && _3 <= g && l.push(m);
- }), l.length && (this._copyInfo = {
- drawings: l,
- unitId: e,
- subUnitId: n
- });
- }
- // eslint-disable-next-line max-lines-per-function
- _generateMutations(e, n) {
- var x;
- if (!this._copyInfo)
- return { redos: [], undos: [] };
- if ([
- rt2.SPECIAL_PASTE_COL_WIDTH,
- rt2.SPECIAL_PASTE_VALUE,
- rt2.SPECIAL_PASTE_FORMAT,
- rt2.SPECIAL_PASTE_FORMULA
- ].includes(n.pasteType))
- return { redos: [], undos: [] };
- const { copyRange: r } = n;
- if (!r)
- return { redos: [], undos: [] };
- const { drawings: s, unitId: o, subUnitId: c } = this._copyInfo, { ranges: [d, g], mapFunc: a } = _s([r, e]), { row: l, col: h } = a(d.startRow, d.startColumn), { row: u2, col: m } = a(g.startRow, g.startColumn), p = (x = this._renderManagerService.getRenderById(o)) == null ? void 0 : x.with(me);
- if (!p)
- return { redos: [], undos: [] };
- const f2 = p.attachRangeWithCoord({
- startRow: l,
- endRow: l,
- startColumn: h,
- endColumn: h
- }), w = p.attachRangeWithCoord({
- startRow: u2,
- endRow: u2,
- startColumn: m,
- endColumn: m
- });
- if (!f2 || !w)
- return { redos: [], undos: [] };
- const I = [], S = [], R = w.startX - f2.startX, v = w.startY - f2.startY, C = u2 - l, _3 = m - h, y = n.copyType === gr.CUT, { _sheetDrawingService: M } = this;
- return s.forEach((U) => {
- const { transform: D, sheetTransform: b } = U;
- if (!D)
- return;
- const P = {
- ...U,
- unitId: o,
- subUnitId: c,
- drawingId: y ? U.drawingId : re.generateRandomId(),
- transform: {
- ...D,
- left: D.left + R,
- top: D.top + v
- },
- sheetTransform: {
- to: { ...b.to, row: b.to.row + C, column: b.to.column + _3 },
- from: { ...b.from, row: b.from.row + C, column: b.from.column + _3 }
- }
- };
- if (y) {
- const { undo: A, redo: j2, objects: B } = M.getBatchUpdateOp([P]);
- I.push({
- id: H.id,
- params: {
- unitId: o,
- subUnitId: c,
- type: F2.UPDATE,
- op: j2,
- objects: B
- }
- }), S.push({
- id: H.id,
- params: {
- unitId: o,
- subUnitId: c,
- type: F2.UPDATE,
- op: A,
- objects: B
- }
- });
- } else {
- const { undo: A, redo: j2, objects: B } = M.getBatchAddOp([P]);
- I.push({ id: H.id, params: { op: j2, unitId: o, subUnitId: c, objects: B, type: F2.INSERT } }), S.push({ id: H.id, params: { op: A, unitId: o, subUnitId: c, objects: B, type: F2.REMOVE } });
- }
- }), {
- redos: I,
- undos: S
- };
- }
- };
- Dt = bs([
- Jt(0, Sn),
- Jt(1, Yx),
- Jt(2, u)
- ], Dt);
- var Ds = Object.defineProperty;
- var Ms = Object.getOwnPropertyDescriptor;
- var ys = (i, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? Ms(e, n) : e, s = i.length - 1, o; s >= 0; s--)
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
- return t && r && Ds(e, n, r), r;
- };
- var ze = (i, e) => (n, t) => e(n, t, i);
- var Mt = class extends nt {
- constructor(i, e, n, t, r) {
- super(), this._drawingManagerService = i, this._renderManagerService = e, this._permissionService = n, this._univerInstanceService = t, this._userManagerService = r, this._initDrawingVisible(), this._initDrawingEditable(), this._initViewPermissionChange(), this._initEditPermissionChange();
- }
- _initDrawingVisible() {
- const i = this._univerInstanceService.getCurrentTypeOfUnit$(Fe.UNIVER_SHEET);
- this.disposeWithMe(
- combineLatest([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
- if (!e) {
- this._drawingManagerService.setDrawingVisible(false);
- return;
- }
- e.activeSheet$.subscribe((t) => {
- if (!t) {
- this._drawingManagerService.setDrawingVisible(false);
- return;
- }
- const r = e.getUnitId(), s = t.getSheetId();
- if (this._permissionService.composePermission([new Js(r).id, new Hn(r, s).id]).every((c) => c.value))
- this._drawingManagerService.setDrawingVisible(true);
- else {
- this._drawingManagerService.setDrawingVisible(false);
- const c = e.getUnitId(), d = t.getSheetId(), g = this._drawingManagerService.getDrawingData(c, d), a = Object.values(g), l = this._renderManagerService.getRenderById(c), h = l == null ? void 0 : l.scene;
- if (h == null)
- return;
- h.getAllObjectsByOrder().forEach((m) => {
- m.classType === Y.IMAGE && a.some((p) => m.oKey.includes(p.drawingId)) && h.removeObject(m);
- });
- }
- });
- })
- );
- }
- _initDrawingEditable() {
- const i = this._univerInstanceService.getCurrentTypeOfUnit$(Fe.UNIVER_SHEET);
- this.disposeWithMe(
- combineLatest([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
- if (!e) {
- this._drawingManagerService.setDrawingEditable(false);
- return;
- }
- e.activeSheet$.subscribe((t) => {
- if (!t) {
- this._drawingManagerService.setDrawingEditable(false);
- return;
- }
- const r = e.getUnitId(), s = t.getSheetId();
- if (this._permissionService.composePermission([new Me(r).id, new Te(r, s).id]).every((c) => c.value))
- this._drawingManagerService.setDrawingEditable(true);
- else {
- this._drawingManagerService.setDrawingEditable(false);
- const c = e.getUnitId(), d = t.getSheetId(), g = this._drawingManagerService.getDrawingData(c, d), a = Object.values(g), l = this._renderManagerService.getRenderById(c), h = l == null ? void 0 : l.scene;
- if (h == null)
- return;
- h.getAllObjectsByOrder().forEach((m) => {
- m.classType === Y.IMAGE && a.some((p) => m.oKey.includes(p.drawingId)) && h.detachTransformerFrom(m);
- });
- }
- });
- })
- );
- }
- _initViewPermissionChange() {
- const i = this._univerInstanceService.getCurrentTypeOfUnit$(Fe.UNIVER_SHEET);
- this.disposeWithMe(
- combineLatest([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
- e && e.activeSheet$.subscribe((t) => {
- var l;
- if (!t)
- return;
- const r = e.getUnitId(), s = t.getSheetId();
- let o = true;
- const c = this._renderManagerService.getRenderById(r), d = c == null ? void 0 : c.scene;
- if (d == null)
- return;
- const g = d.getTransformerByCreate(), a = this._permissionService.composePermission$([new Js(r).id, new Hn(r, s).id]).pipe(map((h) => h.every((u2) => u2.value)));
- a == null || a.pipe(
- filter((h) => h !== o),
- distinctUntilChanged()
- ).subscribe({
- next: (h) => {
- o = h, this._drawingManagerService.setDrawingVisible(h);
- const u2 = d.getAllObjectsByOrder(), m = this._drawingManagerService.getDrawingData(r, s), p = Object.values(m);
- h ? this._drawingManagerService.addNotification(p) : (u2.forEach((f2) => {
- f2.classType === Y.IMAGE && p.some((w) => f2.oKey.includes(w.drawingId)) && d.removeObject(f2);
- }), g.clearSelectedObjects());
- }
- }), (l = this._permissionService.getPermissionPoint$(new Hn(r, s).id)) == null || l.pipe(
- filter((h) => h.value !== o),
- distinctUntilChanged()
- ).subscribe({
- complete: () => {
- o = true, this._drawingManagerService.setDrawingVisible(true);
- const h = this._drawingManagerService.getDrawingData(r, s), u2 = Object.values(h);
- this._drawingManagerService.addNotification(u2);
- }
- });
- });
- })
- );
- }
- _initEditPermissionChange() {
- const i = this._univerInstanceService.getCurrentTypeOfUnit$(Fe.UNIVER_SHEET);
- this.disposeWithMe(
- combineLatest([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
- e && e.activeSheet$.subscribe((t) => {
- var l;
- if (!t)
- return;
- const r = e.getUnitId(), s = t.getSheetId();
- let o = true;
- const c = this._renderManagerService.getRenderById(r), d = c == null ? void 0 : c.scene;
- if (d == null)
- return;
- const g = d.getTransformerByCreate(), a = this._permissionService.composePermission$([new Me(r).id, new Te(r, s).id]).pipe(map((h) => h.every((u2) => u2.value)));
- a == null || a.pipe(
- filter((h) => h !== o),
- distinctUntilChanged()
- ).subscribe({
- next: (h) => {
- o = h, this._drawingManagerService.setDrawingEditable(h);
- const u2 = d.getAllObjectsByOrder(), m = this._drawingManagerService.getDrawingData(r, s), p = Object.values(m);
- h ? (u2.forEach((f2) => {
- f2.classType === Y.IMAGE && p.some((w) => f2.oKey.includes(w.drawingId)) && d.attachTransformerTo(f2);
- }), this._drawingManagerService.addNotification(p)) : (u2.forEach((f2) => {
- f2.classType === Y.IMAGE && p.some((w) => f2.oKey.includes(w.drawingId)) && d.detachTransformerFrom(f2);
- }), g.clearSelectedObjects());
- }
- }), (l = this._permissionService.getPermissionPoint$(new Te(r, s).id)) == null || l.pipe(
- filter((h) => h.value !== o),
- distinctUntilChanged()
- ).subscribe({
- complete: () => {
- o = true;
- const h = e.getUnitId(), u2 = t.getSheetId(), m = this._drawingManagerService.getDrawingData(h, u2), p = Object.values(m), f2 = this._renderManagerService.getRenderById(h), w = f2 == null ? void 0 : f2.scene;
- if (w == null)
- return;
- this._drawingManagerService.setDrawingEditable(true), w.getAllObjectsByOrder().forEach((S) => {
- S.classType === Y.IMAGE && p.some((R) => S.oKey.includes(R.drawingId)) && w.detachTransformerFrom(S);
- });
- }
- });
- });
- })
- );
- }
- };
- Mt = ys([
- ze(0, Ut),
- ze(1, Yx),
- ze(2, UE),
- ze(3, _n),
- ze(4, ot(rr))
- ], Mt);
- var Os = Object.defineProperty;
- var Ts = Object.getOwnPropertyDescriptor;
- var Es = (i, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? Ts(e, n) : e, s = i.length - 1, o; s >= 0; s--)
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
- return t && r && Os(e, n, r), r;
- };
- var wt = (i, e) => (n, t) => e(n, t, i);
- var yt = class extends nt {
- constructor(i, e, n, t) {
- super(), this._sheetPrintInterceptorService = i, this._drawingRenderService = e, this._drawingManagerService = n, this._renderManagerService = t, this._initPrinting();
- }
- _initPrinting() {
- this.disposeWithMe(
- this._sheetPrintInterceptorService.interceptor.intercept(
- this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,
- {
- handler: (i, e, n) => {
- const { unitId: t, scene: r, subUnitId: s } = e, o = this._drawingManagerService.getDrawingDataForUnit(t), c = o == null ? void 0 : o[s];
- return c && c.order.forEach((d) => {
- this._drawingRenderService.renderDrawing(c.data[d], r);
- }), n();
- }
- }
- )
- ), this.disposeWithMe(
- this._sheetPrintInterceptorService.interceptor.intercept(
- this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,
- {
- handler: (i, e, n) => {
- const { unitId: t, subUnitId: r } = e, s = this._renderManagerService.getRenderById(t);
- if (!s)
- return n(i);
- const o = s.with(me).getWorksheetSkeleton(r);
- if (!o)
- return n(i);
- const c = this._drawingManagerService.getDrawingDataForUnit(t), d = c == null ? void 0 : c[e.subUnitId];
- if (!d)
- return n(i);
- const { scaleX: g, scaleY: a } = s.scene, l = i ? { ...i } : { startColumn: 0, endColumn: 0, endRow: 0, startRow: 0 }, h = d.order.map((u2) => d.data[u2]).filter((u2) => u2.drawingType !== gm.DRAWING_DOM);
- return h.length ? (h.forEach((u2) => {
- if (!u2.groupId && u2.transform && re.isDefine(u2.transform.left) && re.isDefine(u2.transform.top) && re.isDefine(u2.transform.width) && re.isDefine(u2.transform.height)) {
- const m = o.skeleton.getCellIndexByOffset(u2.transform.left, u2.transform.top, g, a, { x: 0, y: 0 }), p = o.skeleton.getCellIndexByOffset(u2.transform.left + u2.transform.width, u2.transform.top + u2.transform.height, g, a, { x: 0, y: 0 });
- m.column < l.startColumn && (l.startColumn = m.column), m.row < l.startRow && (l.startRow = m.row), l.endRow < p.row && (l.endRow = p.row), l.endColumn < p.column && (l.endColumn = p.column);
- }
- }), n(l)) : n(i);
- }
- }
- )
- );
- }
- };
- yt = Es([
- wt(0, ot(ap)),
- wt(1, ot(De)),
- wt(2, Ut),
- wt(3, Yx)
- ], yt);
- var Ps = Object.defineProperty;
- var Us = Object.getOwnPropertyDescriptor;
- var As = (i, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? Us(e, n) : e, s = i.length - 1, o; s >= 0; s--)
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
- return t && r && Ps(e, n, r), r;
- };
- var pe = (i, e) => (n, t) => e(n, t, i);
- var Ns = [
- mt.id,
- gt.id,
- Gn.id,
- zn.id,
- Pt2.id,
- Tt.id,
- sn.id,
- Bn.id,
- $o.id,
- Wo.id,
- Oo.id,
- Mn.id,
- kr.id,
- Jn.id,
- Kn.id,
- yr.id,
- jn2.id,
- Fn.id,
- pt.id
- ];
- var js = [
- Zt2.id,
- Qt.id,
- qt2.id,
- Xt.id,
- nt2.id,
- tt.id
- ];
- var sn2 = class extends nt {
- constructor(i, e, n, t, r, s, o, c, d) {
- super(), this._context = i, this._renderManagerService = e, this._commandService = n, this._selectionRenderService = t, this._skeletonManagerService = r, this._sheetInterceptorService = s, this._sheetDrawingService = o, this._drawingManagerService = c, this._univerInstanceService = d, this._sheetInterceptorListener(), this._commandListener(), this._sheetRefreshListener();
- }
- _sheetInterceptorListener() {
- this.disposeWithMe(
- this._sheetInterceptorService.interceptCommand({
- getMutations: (i) => {
- if (!Ns.includes(i.id))
- return { redos: [], undos: [] };
- if (i.params == null)
- return { redos: [], undos: [] };
- const e = i.id;
- if (e === mt.id)
- return this._moveRowInterceptor(i.params, "insert");
- if ([jn2.id, Fn.id, pt.id].includes(e))
- return this._moveRangeInterceptor(i.params);
- if (e === gt.id)
- return this._moveColInterceptor(i.params, "insert");
- if (e === Gn.id)
- return this._moveRowInterceptor(i.params, "remove");
- if (e === zn.id)
- return this._moveColInterceptor(i.params, "remove");
- if (e === Pt2.id) {
- const { range: n } = i.params;
- return this._getRangeMoveUndo(
- n,
- 0
- /* deleteLeft */
- );
- } else if (e === Tt.id) {
- const { range: n } = i.params;
- return this._getRangeMoveUndo(
- n,
- 1
- /* deleteUp */
- );
- } else if (e === sn.id) {
- const { range: n } = i.params;
- return this._getRangeMoveUndo(
- n,
- 2
- /* insertDown */
- );
- } else if (e === Bn.id) {
- const { range: n } = i.params;
- return this._getRangeMoveUndo(
- n,
- 3
- /* insertRight */
- );
- } else if (e === kr.id || e === Jn.id) {
- const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n;
- return this._getDrawingUndoForRowVisible(t, r, s);
- } else if (e === Kn.id || e === yr.id) {
- const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n;
- return this._getDrawingUndoForColVisible(t, r, s);
- } else if (e === $o.id || e === Wo.id || e === Oo.id || e === Mn.id) {
- const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n, o = e === $o.id || e === Wo.id;
- return this._getDrawingUndoForRowAndColSize(t, r, s, o);
- }
- return { redos: [], undos: [] };
- }
- })
- );
- }
- _getRangeMoveUndo(i, e) {
- const n = N(this._univerInstanceService);
- if (n == null)
- return { redos: [], undos: [] };
- const t = n.unitId, r = n.subUnitId, s = [], o = [], c = this._sheetDrawingService.getDrawingData(t, r), d = [], g = [];
- if (Object.keys(c).forEach((a) => {
- const l = c[a], { updateDrawings: h, deleteDrawings: u2 } = this._getUpdateOrDeleteDrawings(i, e, l);
- d.push(...h), g.push(...u2);
- }), d.length === 0 && g.length === 0)
- return { redos: [], undos: [] };
- if (d.length > 0) {
- const a = this._sheetDrawingService.getBatchUpdateOp(d), { undo: l, redo: h, objects: u2 } = a;
- s.push({ id: H.id, params: { unitId: t, subUnitId: r, op: h, objects: u2, type: F2.UPDATE } }), o.push({ id: H.id, params: { unitId: t, subUnitId: r, op: l, objects: u2, type: F2.UPDATE } });
- }
- if (g.length > 0) {
- const a = this._sheetDrawingService.getBatchRemoveOp(g), l = a.undo, h = a.redo, u2 = a.objects;
- s.push({ id: H.id, params: { unitId: t, subUnitId: r, op: h, objects: u2, type: F2.REMOVE } }), o.push({ id: H.id, params: { unitId: t, subUnitId: r, op: l, objects: u2, type: F2.INSERT } });
- }
- return s.push({ id: F3.id, params: [t] }), o.push({ id: F3.id, params: [t] }), {
- redos: s,
- undos: o
- };
- }
- _getUpdateOrDeleteDrawings(i, e, n) {
- const t = [], r = [], { sheetTransform: s, anchorType: o = j.Position, transform: c, unitId: d, subUnitId: g, drawingId: a } = n, { from: l, to: h } = s, { row: u2, column: m } = l, { row: p, column: f2 } = h;
- if (s == null || c == null)
- return {
- updateDrawings: t,
- deleteDrawings: r
- };
- const { startRow: w, endRow: I, startColumn: S, endColumn: R } = i;
- let v = null, C = null;
- if (e === 0 && u2 >= w && p <= I)
- if (m >= S && f2 <= R)
- r.push({ unitId: d, subUnitId: g, drawingId: a });
- else {
- const _3 = this._shrinkCol(s, c, S, R, o);
- v = _3 == null ? void 0 : _3.newSheetTransform, C = _3 == null ? void 0 : _3.newTransform;
- }
- else if (e === 1 && m >= S && f2 <= R)
- if (u2 >= w && p <= I)
- r.push({ unitId: d, subUnitId: g, drawingId: a });
- else {
- const _3 = this._shrinkRow(s, c, w, I, o);
- v = _3 == null ? void 0 : _3.newSheetTransform, C = _3 == null ? void 0 : _3.newTransform;
- }
- else if (e === 2) {
- const _3 = this._expandRow(s, c, w, I, o);
- v = _3 == null ? void 0 : _3.newSheetTransform, C = _3 == null ? void 0 : _3.newTransform;
- } else if (e === 3) {
- const _3 = this._expandCol(s, c, S, R, o);
- v = _3 == null ? void 0 : _3.newSheetTransform, C = _3 == null ? void 0 : _3.newTransform;
- }
- if (v != null && C != null) {
- const _3 = z(v, this._selectionRenderService, this._skeletonManagerService);
- t.push({ ...n, sheetTransform: v, transform: _3 });
- }
- return { updateDrawings: t, deleteDrawings: r };
- }
- _remainDrawingSize(i, e, n) {
- const t = k({ ...i }, this._selectionRenderService);
- t != null && e.push({
- ...n,
- sheetTransform: t
- });
- }
- // eslint-disable-next-line max-lines-per-function
- _getDrawingUndoForColVisible(i, e, n) {
- const t = this._drawingManagerService.getDrawingData(i, e), r = [], s = [];
- if (Object.keys(t).forEach((a) => {
- const l = t[a], { sheetTransform: h, transform: u2, anchorType: m = j.Position } = l;
- if (m === j.None)
- this._remainDrawingSize(u2, r, l);
- else {
- const { from: p, to: f2 } = h, { row: w, column: I } = p, { row: S, column: R } = f2;
- for (let v = 0; v < n.length; v++) {
- const C = n[v], { startRow: _3, endRow: y, startColumn: M, endColumn: x } = C;
- if (R < M)
- continue;
- if (m === j.Position) {
- let b = null, P = null;
- if (I >= M && I <= x) {
- const A = this._skeletonManagerService.attachRangeWithCoord({ startColumn: I, endColumn: x, startRow: p.row, endRow: f2.row });
- if (A == null)
- return;
- P = { ...u2, left: A.startX };
- }
- if (P != null && (b = k(P, this._selectionRenderService), b != null && P != null)) {
- r.push({ ...l, sheetTransform: b, transform: P });
- break;
- }
- this._remainDrawingSize(u2, r, l);
- continue;
- }
- if (I >= M && R <= x)
- continue;
- let U = null, D = null;
- if (I >= M && I <= x) {
- const b = this._skeletonManagerService.attachRangeWithCoord({ startColumn: I, endColumn: x, startRow: p.row, endRow: f2.row });
- if (b == null)
- return;
- D = {
- ...u2,
- left: (b == null ? void 0 : b.startX) || 0,
- width: ((u2 == null ? void 0 : u2.width) || 0) - b.endX + b.startX
- };
- } else if (R >= M && R <= x) {
- const b = this._skeletonManagerService.attachRangeWithCoord({ startColumn: M, endColumn: R, startRow: p.row, endRow: f2.row });
- if (b == null)
- return;
- D = {
- ...u2,
- left: b.startX - ((u2 == null ? void 0 : u2.width) || 0)
- };
- } else {
- const b = this._skeletonManagerService.attachRangeWithCoord({ startColumn: M, endColumn: x, startRow: p.row, endRow: f2.row });
- if (b == null)
- return;
- if (D = {
- ...u2,
- width: ((u2 == null ? void 0 : u2.width) || 0) - b.endX + b.startX
- }, U = k(D, this._selectionRenderService), U != null && D != null) {
- s.push({ ...l, sheetTransform: U, transform: D });
- break;
- }
- }
- if (D != null && (U = k(D, this._selectionRenderService)), D != null && U != null) {
- r.push({ ...l, sheetTransform: U, transform: D });
- break;
- } else
- this._remainDrawingSize(u2, r, l);
- }
- }
- }), r.length === 0 && s.length === 0)
- return { redos: [], undos: [] };
- const { redos: o, undos: c } = this._createUndoAndRedoMutation(i, e, r), d = [], g = [];
- if (s.length > 0) {
- const { redos: a, undos: l } = this._createUndoAndRedoMutation(i, e, s);
- d.push(...a), g.push(...l);
- }
- return {
- redos: o,
- undos: c,
- preRedos: d,
- preUndos: g
- };
- }
- _createUndoAndRedoMutation(i, e, n) {
- const t = this._sheetDrawingService.getBatchUpdateOp(n), { undo: r, redo: s, objects: o } = t, c = [
- { id: H.id, params: { unitId: i, subUnitId: e, op: s, objects: o, type: F2.UPDATE } },
- { id: F3.id, params: [i] }
- ], d = [
- { id: H.id, params: { unitId: i, subUnitId: e, op: r, objects: o, type: F2.UPDATE } },
- { id: F3.id, params: [i] }
- ];
- return {
- redos: c,
- undos: d
- };
- }
- // eslint-disable-next-line max-lines-per-function
- _getDrawingUndoForRowVisible(i, e, n) {
- const t = this._drawingManagerService.getDrawingData(i, e), r = [], s = [];
- if (Object.keys(t).forEach((a) => {
- const l = t[a], { sheetTransform: h, transform: u2, anchorType: m = j.Position } = l;
- if (m === j.None)
- this._remainDrawingSize(u2, r, l);
- else {
- const { from: p, to: f2 } = h, { row: w, column: I } = p, { row: S, column: R } = f2;
- for (let v = 0; v < n.length; v++) {
- const C = n[v], { startRow: _3, endRow: y, startColumn: M, endColumn: x } = C;
- if (S < _3)
- continue;
- if (m === j.Position) {
- let b = null, P = null;
- if (w >= _3 && w <= y) {
- const A = this._skeletonManagerService.attachRangeWithCoord({ startColumn: p.column, endColumn: f2.column, startRow: w, endRow: y });
- if (A == null)
- return;
- P = { ...u2, top: A.startY };
- }
- if (P != null && (b = k(P, this._selectionRenderService), b != null && P != null)) {
- r.push({ ...l, sheetTransform: b, transform: P });
- break;
- }
- this._remainDrawingSize(u2, r, l);
- continue;
- }
- if (w >= _3 && S <= y)
- continue;
- let U = null, D = null;
- if (w >= _3 && w <= y) {
- const b = this._skeletonManagerService.attachRangeWithCoord({ startColumn: p.column, endColumn: f2.column, startRow: w, endRow: y });
- if (b == null)
- return;
- D = {
- ...u2,
- top: (b == null ? void 0 : b.startY) || 0,
- height: ((u2 == null ? void 0 : u2.height) || 0) - b.endY + b.startY
- };
- } else if (S >= _3 && S <= y) {
- const b = this._skeletonManagerService.attachRangeWithCoord({ startColumn: p.column, endColumn: f2.column, startRow: _3, endRow: S });
- if (b == null)
- return;
- D = {
- ...u2,
- top: b.startY - ((u2 == null ? void 0 : u2.height) || 0)
- };
- } else {
- const b = this._skeletonManagerService.attachRangeWithCoord({ startColumn: p.column, endColumn: f2.column, startRow: _3, endRow: y });
- if (b == null)
- return;
- if (D = {
- ...u2,
- height: ((u2 == null ? void 0 : u2.height) || 0) - b.endY + b.startY
- }, U = k(D, this._selectionRenderService), U != null && D != null) {
- s.push({ ...l, sheetTransform: U, transform: D });
- break;
- }
- }
- if (D != null && (U = k(D, this._selectionRenderService)), D != null && U != null) {
- r.push({ ...l, sheetTransform: U, transform: D });
- break;
- } else
- this._remainDrawingSize(u2, r, l);
- }
- }
- }), r.length === 0 && s.length === 0)
- return { redos: [], undos: [] };
- const { redos: o, undos: c } = this._createUndoAndRedoMutation(i, e, r), d = [], g = [];
- if (s.length > 0) {
- const { redos: a, undos: l } = this._createUndoAndRedoMutation(i, e, s);
- d.push(...a), g.push(...l);
- }
- return {
- redos: o,
- undos: c,
- preRedos: d,
- preUndos: g
- };
- }
- _getDrawingUndoForRowAndColSize(i, e, n, t) {
- const r = this._drawingManagerService.getDrawingData(i, e), s = [];
- return Object.keys(r).forEach((o) => {
- const c = r[o], { sheetTransform: d, transform: g, anchorType: a = j.Position } = c;
- if (a === j.None)
- this._remainDrawingSize(g, s, c);
- else {
- const { from: l, to: h } = d, { row: u2, column: m } = l, { row: p, column: f2 } = h;
- for (let w = 0; w < n.length; w++) {
- const I = n[w], { startRow: S, endRow: R, startColumn: v, endColumn: C } = I;
- if (p < S || f2 < v)
- continue;
- if (a === j.Position && (u2 <= S && p >= R || m <= v && f2 >= C)) {
- this._remainDrawingSize(g, s, c);
- continue;
- }
- const _3 = z(
- { ...d },
- this._selectionRenderService,
- this._skeletonManagerService
- );
- if (_3 != null) {
- s.push({
- ...c,
- transform: _3
- });
- break;
- }
- }
- }
- }), s.length === 0 ? { redos: [], undos: [] } : this._createUndoAndRedoMutation(i, e, s);
- }
- _getUnitIdAndSubUnitId(i, e) {
- let n, t;
- if (e === "insert")
- n = i.unitId, t = i.subUnitId;
- else {
- const r = N(this._univerInstanceService);
- if (r == null)
- return;
- n = r.unitId, t = r.subUnitId;
- }
- return { unitId: n, subUnitId: t };
- }
- _moveRangeInterceptor(i) {
- var S, R;
- const { toRange: e, fromRange: n } = i, t = N(this._univerInstanceService);
- if (!t)
- return { redos: [], undos: [] };
- const { unitId: r, subUnitId: s } = t, o = (R = (S = this._renderManagerService.getRenderById(r)) == null ? void 0 : S.with(me)) == null ? void 0 : R.getCurrentSkeleton();
- if (!o)
- return { redos: [], undos: [] };
- const c = ni(o, n);
- if (!c)
- return { redos: [], undos: [] };
- const { startX: d, endX: g, startY: a, endY: l } = c, h = this._sheetDrawingService.getDrawingData(r, s), u2 = [];
- Object.keys(h).forEach((v) => {
- const C = h[v];
- if (C.anchorType !== j.Both)
- return;
- const { transform: _3 } = C;
- if (!_3)
- return;
- const { left: y = 0, top: M = 0, width: x = 0, height: U = 0 } = _3, { drawingStartX: D, drawingEndX: b, drawingStartY: P, drawingEndY: A } = {
- drawingStartX: y,
- drawingEndX: y + x,
- drawingStartY: M,
- drawingEndY: M + U
- };
- d <= D && b <= g && a <= P && A <= l && u2.push(C);
- });
- const m = [], p = [], f2 = e.startRow - n.startRow, w = e.startColumn - n.startColumn, I = u2.map((v) => {
- const C = v.sheetTransform, _3 = {
- to: { ...C.to, row: C.to.row + f2, column: C.to.column + w },
- from: { ...C.from, row: C.from.row + f2, column: C.from.column + w }
- }, y = z(_3, this._selectionRenderService, this._skeletonManagerService);
- return {
- unitId: r,
- subUnitId: s,
- drawingId: v.drawingId,
- transform: y,
- sheetTransform: _3
- };
- });
- if (I.length) {
- const v = this._sheetDrawingService.getBatchUpdateOp(I), { undo: C, redo: _3, objects: y } = v;
- m.push({ id: H.id, params: { unitId: r, subUnitId: s, op: _3, objects: y, type: F2.UPDATE } }), p.push({ id: H.id, params: { unitId: r, subUnitId: s, op: C, objects: y, type: F2.UPDATE } });
- }
- return { redos: m, undos: p };
- }
- _moveRowInterceptor(i, e) {
- const n = this._getUnitIdAndSubUnitId(i, e);
- if (n == null)
- return { redos: [], undos: [] };
- const { unitId: t, subUnitId: r } = n, { range: s } = i, o = s.startRow, c = s.endRow, d = [], g = [], a = this._sheetDrawingService.getDrawingData(t, r), l = [], h = [];
- if (Object.keys(a).forEach((u2) => {
- const m = a[u2], { sheetTransform: p, transform: f2, anchorType: w = j.Position } = m;
- if (p == null || f2 == null)
- return;
- let I, S;
- if (e === "insert") {
- const v = this._expandRow(p, f2, o, c, w);
- I = v == null ? void 0 : v.newSheetTransform, S = v == null ? void 0 : v.newTransform;
- } else {
- const { from: v, to: C } = p, { row: _3 } = v, { row: y } = C;
- if (w === j.Both && _3 >= o && y <= c)
- h.push({ unitId: t, subUnitId: r, drawingId: u2 });
- else {
- const M = this._shrinkRow(p, f2, o, c, w);
- I = M == null ? void 0 : M.newSheetTransform, S = M == null ? void 0 : M.newTransform;
- }
- }
- if (!I || !S)
- return;
- const R = { unitId: t, subUnitId: r, drawingId: u2, transform: S, sheetTransform: I };
- l.push(R);
- }), l.length === 0 && h.length === 0)
- return { redos: [], undos: [] };
- if (l.length > 0) {
- const u2 = this._sheetDrawingService.getBatchUpdateOp(l), { undo: m, redo: p, objects: f2 } = u2;
- d.push({ id: H.id, params: { unitId: t, subUnitId: r, op: p, objects: f2, type: F2.UPDATE } }), g.push({ id: H.id, params: { unitId: t, subUnitId: r, op: m, objects: f2, type: F2.UPDATE } });
- }
- if (h.length > 0) {
- const u2 = this._sheetDrawingService.getBatchRemoveOp(h), m = u2.undo, p = u2.redo, f2 = u2.objects;
- d.push({ id: H.id, params: { unitId: t, subUnitId: r, op: p, objects: f2, type: F2.REMOVE } }), g.push({ id: H.id, params: { unitId: t, subUnitId: r, op: m, objects: f2, type: F2.INSERT } });
- }
- return d.push({ id: F3.id, params: [t] }), g.push({ id: F3.id, params: [t] }), {
- redos: d,
- undos: g
- };
- }
- _moveColInterceptor(i, e) {
- const n = this._getUnitIdAndSubUnitId(i, e);
- if (n == null)
- return { redos: [], undos: [] };
- const { unitId: t, subUnitId: r } = n, { range: s } = i, o = s.startColumn, c = s.endColumn, d = [], g = [], a = this._sheetDrawingService.getDrawingData(t, r), l = [], h = [];
- if (Object.keys(a).forEach((u2) => {
- const m = a[u2], { sheetTransform: p, transform: f2, anchorType: w = j.Position } = m;
- if (p == null || f2 == null)
- return;
- let I, S;
- if (e === "insert") {
- const v = this._expandCol(p, f2, o, c, w);
- I = v == null ? void 0 : v.newSheetTransform, S = v == null ? void 0 : v.newTransform;
- } else {
- const { from: v, to: C } = p, { column: _3 } = v, { column: y } = C;
- if (w === j.Both && _3 >= o && y <= c)
- h.push({ unitId: t, subUnitId: r, drawingId: u2 });
- else {
- const M = this._shrinkCol(p, f2, o, c, w);
- I = M == null ? void 0 : M.newSheetTransform, S = M == null ? void 0 : M.newTransform;
- }
- }
- if (!I || !S)
- return;
- const R = { unitId: t, subUnitId: r, drawingId: u2, transform: S, sheetTransform: I };
- l.push(R);
- }), l.length === 0 && h.length === 0)
- return { redos: [], undos: [] };
- if (l.length > 0) {
- const u2 = this._sheetDrawingService.getBatchUpdateOp(l), { undo: m, redo: p, objects: f2 } = u2;
- d.push({ id: H.id, params: { unitId: t, subUnitId: r, op: p, objects: f2, type: F2.UPDATE } }), g.push({ id: H.id, params: { unitId: t, subUnitId: r, op: m, objects: f2, type: F2.UPDATE } });
- }
- if (h.length > 0) {
- const u2 = this._sheetDrawingService.getBatchRemoveOp(h), m = u2.undo, p = u2.redo, f2 = u2.objects;
- d.push({ id: H.id, params: { unitId: t, subUnitId: r, op: p, objects: f2, type: F2.REMOVE } }), g.push({ id: H.id, params: { unitId: t, subUnitId: r, op: m, objects: f2, type: F2.INSERT } });
- }
- return d.push({ id: F3.id, params: [t] }), g.push({ id: F3.id, params: [t] }), { redos: d, undos: g };
- }
- _expandCol(i, e, n, t, r = j.Position) {
- const s = t - n + 1, { from: o, to: c } = i, { column: d } = o, { column: g } = c;
- if (r === j.None)
- return {
- newSheetTransform: k({ ...e }, this._selectionRenderService),
- newTransform: e
- };
- let a = null, l = null;
- if (d >= n) {
- const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: n, endColumn: t, startRow: o.row, endRow: c.row });
- if (h == null)
- return;
- l = { ...e, left: (e.left || 0) + h.endX - h.startX }, a = k(l, this._selectionRenderService);
- } else if (g >= t)
- if (r === j.Both)
- a = {
- from: { ...o },
- to: { ...c, column: g + s }
- }, l = z(a, this._selectionRenderService, this._skeletonManagerService);
- else
- return {
- newSheetTransform: k({ ...e }, this._selectionRenderService),
- newTransform: e
- };
- return a != null && l != null ? {
- newSheetTransform: a,
- newTransform: l
- } : null;
- }
- _shrinkCol(i, e, n, t, r = j.Position) {
- const s = t - n + 1, { from: o, to: c } = i, { column: d } = o, { column: g } = c;
- if (r === j.None)
- return {
- newSheetTransform: k({ ...e }, this._selectionRenderService),
- newTransform: e
- };
- let a = null, l = null;
- if (d > t)
- a = {
- from: { ...o, column: d - s },
- to: { ...c, column: g - s }
- }, l = z(a, this._selectionRenderService, this._skeletonManagerService);
- else {
- if (d >= n && g <= t)
- return null;
- if (d < n && g > t)
- if (r === j.Both)
- a = {
- from: { ...o },
- to: { ...c, column: g - s }
- }, l = z(a, this._selectionRenderService, this._skeletonManagerService);
- else
- return {
- newSheetTransform: k({ ...e }, this._selectionRenderService),
- newTransform: e
- };
- else if (d >= n && d <= t) {
- if (d === n)
- l = { ...e, left: (e.left || 0) - i.from.columnOffset };
- else {
- const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: n, endColumn: d - 1, startRow: o.row, endRow: c.row });
- if (h == null)
- return;
- l = { ...e, left: (e.left || 0) - h.endX + h.startX - i.from.columnOffset };
- }
- a = k(l, this._selectionRenderService);
- } else if (g >= n && g <= t && r === j.Both) {
- const h = this._skeletonManagerService.attachRangeWithCoord({
- startColumn: n - 1,
- endColumn: n - 1,
- startRow: o.row,
- endRow: c.row
- });
- if (h == null)
- return;
- a = {
- from: { ...o },
- to: { ...c, column: n - 1, columnOffset: h.endX - h.startX }
- }, l = z(a, this._selectionRenderService, this._skeletonManagerService);
- }
- }
- return a != null && l != null ? {
- newSheetTransform: a,
- newTransform: l
- } : null;
- }
- _expandRow(i, e, n, t, r = j.Position) {
- const s = t - n + 1, { from: o, to: c } = i, { row: d } = o, { row: g } = c;
- if (r === j.None)
- return {
- newSheetTransform: k({ ...e }, this._selectionRenderService),
- newTransform: e
- };
- let a = null, l = null;
- if (d >= n) {
- const h = this._skeletonManagerService.attachRangeWithCoord({ startRow: n, endRow: t, startColumn: o.column, endColumn: c.column });
- if (h == null)
- return;
- l = { ...e, top: (e.top || 0) + h.endY - h.startY }, a = k(l, this._selectionRenderService);
- } else if (g >= t)
- if (r === j.Both)
- a = {
- from: { ...o },
- to: {
- ...c,
- row: g + s
- }
- }, l = z(a, this._selectionRenderService, this._skeletonManagerService);
- else
- return {
- newSheetTransform: k({ ...e }, this._selectionRenderService),
- newTransform: e
- };
- return a != null && l != null ? {
- newSheetTransform: a,
- newTransform: l
- } : null;
- }
- _shrinkRow(i, e, n, t, r = j.Position) {
- const s = t - n + 1, { from: o, to: c } = i, { row: d } = o, { row: g } = c;
- if (r === j.None)
- return {
- newSheetTransform: k({ ...e }, this._selectionRenderService),
- newTransform: e
- };
- let a = null, l = null;
- if (d > t)
- a = {
- from: { ...o, row: d - s },
- to: { ...c, row: g - s }
- }, l = z(a, this._selectionRenderService, this._skeletonManagerService);
- else {
- if (d >= n && g <= t)
- return null;
- if (d < n && g > t)
- if (r === j.Both)
- a = {
- from: { ...o },
- to: { ...c, row: g - s }
- }, l = z(a, this._selectionRenderService, this._skeletonManagerService);
- else
- return {
- newSheetTransform: k({ ...e }, this._selectionRenderService),
- newTransform: e
- };
- else if (d >= n && d <= t) {
- if (d === n)
- l = { ...e, top: (e.top || 0) - i.from.rowOffset };
- else {
- const h = this._skeletonManagerService.attachRangeWithCoord({ startRow: n, endRow: d - 1, startColumn: o.column, endColumn: c.column });
- if (h == null)
- return;
- l = { ...e, top: (e.top || 0) - h.endY + h.startY - i.from.rowOffset };
- }
- a = k(l, this._selectionRenderService);
- } else if (g >= n && g <= t && r === j.Both) {
- const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: o.column, endColumn: o.column, startRow: n - 1, endRow: n - 1 });
- if (h == null)
- return;
- a = {
- from: { ...o },
- to: { ...c, row: n - 1, rowOffset: h.endY - h.startY }
- }, l = z(a, this._selectionRenderService, this._skeletonManagerService);
- }
- }
- return a != null && l != null ? {
- newSheetTransform: a,
- newTransform: l
- } : null;
- }
- _commandListener() {
- this.disposeWithMe(
- this._commandService.onCommandExecuted((i) => {
- i.id === an.id && setTimeout(() => {
- const e = i.params, { unitId: n, subUnitId: t } = e, r = this._drawingManagerService.drawingManagerData, s = [], o = [];
- Object.keys(r).forEach((c) => {
- const d = r[c];
- d != null && Object.keys(d).forEach((g) => {
- const a = d[g].data;
- a != null && Object.keys(a).forEach((l) => {
- if (c === n && g === t) {
- const h = a[l];
- h.transform = z(h.sheetTransform, this._selectionRenderService, this._skeletonManagerService), s.push(a[l]);
- } else
- o.push(a[l]);
- });
- });
- }), this._drawingManagerService.removeNotification(o), this._drawingManagerService.addNotification(s);
- }, 0);
- })
- );
- }
- _sheetRefreshListener() {
- this.disposeWithMe(
- this._commandService.onCommandExecuted((i) => {
- js.includes(i.id) && requestIdleCallback(() => {
- const e = i.params, { unitId: n, subUnitId: t, ranges: r } = e;
- this._refreshDrawingTransform(n, t, r);
- });
- })
- );
- }
- _refreshDrawingTransform(i, e, n) {
- const t = this._drawingManagerService.getDrawingData(i, e), r = [];
- Object.keys(t).forEach((s) => {
- const o = t[s], { sheetTransform: c, transform: d, anchorType: g = j.Position } = o;
- if (g === j.None)
- return true;
- const { from: a, to: l } = c, { row: h, column: u2 } = a, { row: m, column: p } = l;
- for (let f2 = 0; f2 < n.length; f2++) {
- const w = n[f2], { startRow: I, endRow: S, startColumn: R, endColumn: v } = w;
- if (en.intersects(
- {
- startRow: I,
- endRow: S,
- startColumn: R,
- endColumn: v
- },
- {
- startRow: h,
- endRow: m,
- startColumn: u2,
- endColumn: p
- }
- ) || h > S || u2 > v) {
- const C = g === j.Position, _3 = z(c, this._selectionRenderService, this._skeletonManagerService);
- r.push({
- ...o,
- transform: {
- ..._3,
- width: C ? d == null ? void 0 : d.width : _3 == null ? void 0 : _3.width,
- height: C ? d == null ? void 0 : d.height : _3 == null ? void 0 : _3.height
- }
- });
- break;
- }
- }
- }), r.length !== 0 && (this._drawingManagerService.refreshTransform(r), this._commandService.syncExecuteCommand(F3.id, [i]));
- }
- };
- sn2 = As([
- pe(1, Yx),
- pe(2, Pt),
- pe(3, dt),
- pe(4, ot(me)),
- pe(5, ot(V)),
- pe(6, u),
- pe(7, Ut),
- pe(8, _n)
- ], sn2);
- var ne2 = function() {
- return ne2 = Object.assign || function(i) {
- for (var e, n = 1, t = arguments.length; n < t; n++) {
- e = arguments[n];
- for (var r in e)
- Object.prototype.hasOwnProperty.call(e, r) && (i[r] = e[r]);
- }
- return i;
- }, ne2.apply(this, arguments);
- };
- var Ws = function(i, e) {
- var n = {};
- for (var t in i)
- Object.prototype.hasOwnProperty.call(i, t) && e.indexOf(t) < 0 && (n[t] = i[t]);
- if (i != null && typeof Object.getOwnPropertySymbols == "function")
- for (var r = 0, t = Object.getOwnPropertySymbols(i); r < t.length; r++)
- e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(i, t[r]) && (n[t[r]] = i[t[r]]);
- return n;
- };
- var lr = (0, import_react.forwardRef)(function(i, e) {
- var n = i.icon, t = i.id, r = i.className, s = i.extend, o = Ws(i, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), d = (0, import_react.useRef)("_".concat($s()));
- return ur(n, "".concat(t), { defIds: n.defIds, idSuffix: d.current }, ne2({ ref: e, className: c }, o), s);
- });
- function ur(i, e, n, t, r) {
- return (0, import_react.createElement)(i.tag, ne2(ne2({ key: e }, xs(i, n, r)), t), (Bs(i, n).children || []).map(function(s, o) {
- return ur(s, "".concat(e, "-").concat(i.tag, "-").concat(o), n, void 0, r);
- }));
- }
- function xs(i, e, n) {
- var t = ne2({}, i.attrs);
- n != null && n.colorChannel1 && t.fill === "colorChannel1" && (t.fill = n.colorChannel1);
- var r = e.defIds;
- return !r || r.length === 0 || (i.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + e.idSuffix), Object.entries(t).forEach(function(s) {
- var o = s[0], c = s[1];
- typeof c == "string" && (t[o] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
- })), t;
- }
- function Bs(i, e) {
- var n, t = e.defIds;
- return !t || t.length === 0 ? i : i.tag === "defs" && (!((n = i.children) === null || n === void 0) && n.length) ? ne2(ne2({}, i), { children: i.children.map(function(r) {
- return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? ne2(ne2({}, r), { attrs: ne2(ne2({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
- }) }) : i;
- }
- function $s() {
- return Math.random().toString(36).substring(2, 8);
- }
- lr.displayName = "UniverIcon";
- var ks = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z" } }] };
- var hr = (0, import_react.forwardRef)(function(i, e) {
- return (0, import_react.createElement)(lr, Object.assign({}, i, {
- id: "add-image-single",
- ref: e,
- icon: ks
- }));
- });
- hr.displayName = "AddImageSingle";
- var gr2 = {
- id: "sheet.command.delete-drawing",
- type: ar.COMMAND,
- handler: (i) => {
- const e = i.get(Pt), t = i.get(u).getFocusDrawings();
- if (t.length === 0)
- return false;
- const r = t[0].unitId, s = t.map((o) => {
- const { unitId: c, subUnitId: d, drawingId: g, drawingType: a } = o;
- return {
- unitId: c,
- subUnitId: d,
- drawingId: g,
- drawingType: a
- };
- });
- return e.executeCommand(Nt.id, {
- unitId: r,
- drawings: s
- });
- }
- };
- var cn3 = {
- id: "sheet.command.insert-float-image",
- type: ar.COMMAND,
- handler: (i) => {
- var n, t;
- return (t = (n = i.get(Yx).getCurrentTypeOfRenderer(Fe.UNIVER_SHEET)) == null ? void 0 : n.with(Ze2).insertFloatImage()) != null ? t : false;
- }
- };
- var dn2 = {
- id: "sheet.command.insert-cell-image",
- type: ar.COMMAND,
- handler: (i) => {
- var n, t;
- return (t = (n = i.get(Yx).getCurrentTypeOfRenderer(Fe.UNIVER_SHEET)) == null ? void 0 : n.with(Ze2).insertCellImage()) != null ? t : false;
- }
- };
- var et2 = {
- id: "sheet.command.move-drawing",
- type: ar.COMMAND,
- handler: (i, e) => {
- const n = i.get(Pt), t = i.get(u), r = i.get(dt), { direction: s } = e, o = t.getFocusDrawings();
- if (o.length === 0)
- return false;
- const c = o[0].unitId, d = o.map((a) => {
- const { transform: l } = a;
- if (l == null)
- return null;
- const h = { ...l }, { left: u2 = 0, top: m = 0 } = l;
- return s === wu.UP ? h.top = m - 1 : s === wu.DOWN ? h.top = m + 1 : s === wu.LEFT ? h.left = u2 - 1 : s === wu.RIGHT && (h.left = u2 + 1), {
- ...a,
- transform: h,
- sheetTransform: k(h, r)
- };
- }).filter((a) => a != null);
- return n.syncExecuteCommand(Wt.id, {
- unitId: c,
- drawings: d
- }) ? (n.syncExecuteCommand(F3.id, [c]), true) : false;
- }
- };
- var mr = "addition-and-subtraction-single";
- var fr = "sheet.menu.image";
- function Ls(i) {
- return {
- id: fr,
- type: $e.SUBITEMS,
- icon: mr,
- tooltip: "sheetImage.title",
- hidden$: Fa(i, Fe.UNIVER_SHEET),
- disabled$: ue(i, { workbookTypes: [Me], worksheetTypes: [Te], rangeTypes: [Pe] })
- };
- }
- function Fs(i) {
- return {
- id: cn3.id,
- title: "sheetImage.upload.float",
- type: $e.BUTTON,
- hidden$: Fa(i, Fe.UNIVER_SHEET)
- };
- }
- function Gs(i) {
- return {
- id: dn2.id,
- title: "sheetImage.upload.cell",
- type: $e.BUTTON
- };
- }
- var Vs = "univer-image-common-panel";
- var Ys = "univer-image-common-panel-grid";
- var Hs = "univer-image-common-panel-border";
- var Xs = "univer-image-common-panel-title";
- var zs = "univer-image-common-panel-subtitle";
- var Ks = "univer-image-common-panel-row";
- var Js2 = "univer-image-common-panel-row-vertical";
- var Zs = "univer-image-common-panel-column";
- var qs = "univer-image-common-panel-column-center";
- var Qs = "univer-image-common-panel-inline";
- var eo = "univer-image-common-panel-span2";
- var to = "univer-image-common-panel-span3";
- var no = "univer-image-common-panel-input";
- var ro = "univer-sheet-image-menu";
- var io = "univer-sheet-image-menu-input";
- var we2 = {
- imageCommonPanel: Vs,
- imageCommonPanelGrid: Ys,
- imageCommonPanelBorder: Hs,
- imageCommonPanelTitle: Xs,
- imageCommonPanelSubtitle: zs,
- imageCommonPanelRow: Ks,
- imageCommonPanelRowVertical: Js2,
- imageCommonPanelColumn: Zs,
- imageCommonPanelColumnCenter: qs,
- imageCommonPanelInline: Qs,
- imageCommonPanelSpan2: eo,
- imageCommonPanelSpan3: to,
- imageCommonPanelInput: no,
- sheetImageMenu: ro,
- sheetImageMenuInput: io
- };
- function pr(i) {
- var e, n, t = "";
- if (typeof i == "string" || typeof i == "number")
- t += i;
- else if (typeof i == "object")
- if (Array.isArray(i)) {
- var r = i.length;
- for (e = 0; e < r; e++)
- i[e] && (n = pr(i[e])) && (t && (t += " "), t += n);
- } else
- for (n in i)
- i[n] && (t && (t += " "), t += n);
- return t;
- }
- function _t() {
- for (var i, e, n = 0, t = "", r = arguments.length; n < r; n++)
- (i = arguments[n]) && (e = pr(i)) && (t && (t += " "), t += e);
- return t;
- }
- var so = (i) => {
- var S;
- const e = W0(Pt), n = W0(Vr), t = W0(Ut), r = W0(Yx), { drawings: s } = i, o = s[0];
- if (o == null)
- return;
- const { unitId: c } = o, d = r.getRenderById(c), g = d == null ? void 0 : d.scene;
- if (g == null)
- return;
- const a = g.getTransformerByCreate(), [l, h] = (0, import_react.useState)(true), u2 = (S = o.anchorType) != null ? S : j.Position, [m, p] = (0, import_react.useState)(u2);
- function f2(R, v) {
- const C = [];
- return R.forEach((_3) => {
- const { oKey: y } = _3, M = v.getDrawingOKey(y);
- if (M == null)
- return C.push(null), true;
- const { unitId: x, subUnitId: U, drawingId: D, drawingType: b, anchorType: P, sheetTransform: A } = M;
- C.push({
- unitId: x,
- subUnitId: U,
- drawingId: D,
- anchorType: P,
- sheetTransform: A,
- drawingType: b
- });
- }), C;
- }
- (0, import_react.useEffect)(() => {
- const R = a.clearControl$.subscribe((C) => {
- C === true && h(false);
- }), v = a.changeStart$.subscribe((C) => {
- var M;
- const { objects: _3 } = C, y = f2(_3, t);
- if (y.length === 0)
- h(false);
- else if (y.length >= 1) {
- h(true);
- const x = ((M = y[0]) == null ? void 0 : M.anchorType) || j.Position;
- p(x);
- }
- });
- return () => {
- v.unsubscribe(), R.unsubscribe();
- };
- }, []);
- function w(R) {
- p(R);
- const v = t.getFocusDrawings();
- if (v.length === 0)
- return;
- const C = v.map((_3) => ({
- unitId: _3.unitId,
- subUnitId: _3.subUnitId,
- drawingId: _3.drawingId,
- anchorType: R
- }));
- e.executeCommand(Wt.id, {
- unitId: v[0].unitId,
- drawings: C
- });
- }
- const I = (R) => R ? "block" : "none";
- return G.jsxs("div", { className: _t(we2.imageCommonPanelGrid, we2.imageCommonPanelBorder), style: { display: I(l) }, children: [
- G.jsx("div", { className: we2.imageCommonPanelRow, children: G.jsx("div", { className: _t(we2.imageCommonPanelColumn, we2.imageCommonPanelTitle), children: G.jsx("div", { children: n.t("drawing-anchor.title") }) }) }),
- G.jsx("div", { className: _t(we2.imageCommonPanelRow), children: G.jsx("div", { className: _t(we2.imageCommonPanelColumn), children: G.jsxs(t_, { value: m, onChange: w, direction: "vertical", children: [
- G.jsx(e_, { value: j.Both, children: n.t("drawing-anchor.both") }),
- G.jsx(e_, { value: j.Position, children: n.t("drawing-anchor.position") }),
- G.jsx(e_, { value: j.None, children: n.t("drawing-anchor.none") })
- ] }) }) })
- ] });
- };
- var oo = () => {
- const i = W0(Ut), e = i.getFocusDrawings(), [n, t] = (0, import_react.useState)(e);
- return (0, import_react.useEffect)(() => {
- const r = i.focus$.subscribe((s) => {
- t(s);
- });
- return () => {
- r.unsubscribe();
- };
- }, []), !!(n != null && n.length) && G.jsxs("div", { className: we2.imageCommonPanel, children: [
- G.jsx(vr, { drawings: n }),
- G.jsx(so, { drawings: n })
- ] });
- };
- var ao = {
- [l1.FORMULAS_INSERT]: {
- [fr]: {
- order: 3,
- menuItemFactory: Ls,
- [cn3.id]: {
- order: 0,
- menuItemFactory: Fs
- },
- [dn2.id]: {
- order: 1,
- menuItemFactory: Gs
- }
- }
- }
- };
- function tt3(i) {
- return !i.getContextValue(aE) && !i.getContextValue(oE) && !i.getContextValue(IR) && i.getContextValue(yR);
- }
- var co = {
- id: et2.id,
- description: "shortcut.sheet.drawing-move-down",
- group: "4_sheet-drawing-view",
- binding: I1.ARROW_DOWN,
- priority: 100,
- preconditions: tt3,
- staticParameters: {
- direction: wu.DOWN
- }
- };
- var lo = {
- id: et2.id,
- description: "shortcut.sheet.drawing-move-up",
- group: "4_sheet-drawing-view",
- binding: I1.ARROW_UP,
- priority: 100,
- preconditions: tt3,
- staticParameters: {
- direction: wu.UP
- }
- };
- var uo = {
- id: et2.id,
- description: "shortcut.sheet.drawing-move-left",
- group: "4_sheet-drawing-view",
- binding: I1.ARROW_LEFT,
- priority: 100,
- preconditions: tt3,
- staticParameters: {
- direction: wu.LEFT
- }
- };
- var ho = {
- id: et2.id,
- description: "shortcut.sheet.drawing-move-right",
- group: "4_sheet-drawing-view",
- binding: I1.ARROW_RIGHT,
- priority: 100,
- preconditions: tt3,
- staticParameters: {
- direction: wu.RIGHT
- }
- };
- var go = {
- id: gr2.id,
- description: "shortcut.sheet.drawing-delete",
- group: "4_sheet-drawing-view",
- // when focusing on any other input tag do not trigger this shortcut
- preconditions: tt3,
- binding: I1.DELETE,
- mac: I1.BACKSPACE
- };
- var mo = Object.defineProperty;
- var fo = Object.getOwnPropertyDescriptor;
- var po = (i, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? fo(e, n) : e, s = i.length - 1, o; s >= 0; s--)
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
- return t && r && mo(e, n, r), r;
- };
- var vt = (i, e) => (n, t) => e(n, t, i);
- var Ot2 = class extends nt {
- constructor(i, e, n, t) {
- super(), this._componentManager = i, this._menuManagerService = e, this._commandService = n, this._shortcutService = t, this._init();
- }
- _initCustomComponents() {
- const i = this._componentManager;
- this.disposeWithMe(i.register(mr, hr)), this.disposeWithMe(i.register(rr2, oo));
- }
- _initMenus() {
- this._menuManagerService.mergeMenu(ao);
- }
- _initCommands() {
- [
- cn3,
- dn2,
- jt,
- Nt,
- Wt,
- ir,
- F3,
- sr,
- or,
- cr,
- et2,
- gr2,
- ar2
- ].forEach((i) => this.disposeWithMe(this._commandService.registerCommand(i)));
- }
- _initShortcuts() {
- [
- // sheet drawing shortcuts
- co,
- lo,
- uo,
- ho,
- go
- ].forEach((i) => {
- this.disposeWithMe(this._shortcutService.registerShortcut(i));
- });
- }
- _init() {
- this._initCommands(), this._initCustomComponents(), this._initMenus(), this._initShortcuts();
- }
- };
- Ot2 = po([
- vt(0, ot(n1)),
- vt(1, m1),
- vt(2, Pt),
- vt(3, it)
- ], Ot2);
- var wo = Object.defineProperty;
- var _o = Object.getOwnPropertyDescriptor;
- var vo = (i, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? _o(e, n) : e, s = i.length - 1, o; s >= 0; s--)
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
- return t && r && wo(e, n, r), r;
- };
- var Oe2 = (i, e) => (n, t) => e(n, t, i);
- function So(i, e, n, t, r) {
- const { scaleX: s, scaleY: o } = e.getAncestorScale(), c = e.getViewport(i2.VIEW_MAIN), d = {
- left: true,
- top: true
- };
- if (!c)
- return {
- ...i,
- absolute: d
- };
- const { left: g, right: a, top: l, bottom: h } = i;
- let { top: u2, left: m, viewportScrollX: p, viewportScrollY: f2 } = c;
- const { boundsOfViewArea: w, scrollDirectionResponse: I } = r || {};
- w && (re.isDefine(w.top) && (u2 = w.top), re.isDefine(w.left) && (m = w.left)), I === "HORIZONTAL" && (f2 = 0), I === "VERTICAL" && (p = 0);
- let S, R;
- g < m ? (d.left = true, S = (m + (g - m)) * s, R = Math.max(
- Math.min(
- (m + (a - m)) * s,
- m * s
- ),
- (a - p) * s
- )) : (d.left = false, S = Math.max((g - p) * s, m * s), R = Math.max((a - p) * s, m * s));
- let v, C;
- return l < u2 ? (d.top = true, v = (u2 + (l - u2)) * o, C = Math.max(
- Math.min(
- (u2 + (a - u2)) * o,
- u2 * o
- ),
- (h - f2) * o
- )) : (d.top = false, v = Math.max((l - f2) * o, u2 * o), C = Math.max((h - f2) * o, u2 * o)), {
- left: S,
- right: R,
- top: v,
- bottom: C,
- absolute: d
- };
- }
- var Te2 = (i, e, n, t, r) => {
- const { scene: s } = e, { left: o, top: c, width: d, height: g, angle: a } = i, l = {
- left: o,
- right: o + d,
- top: c,
- bottom: c + g
- }, h = So(l, s, n, t, r), { scaleX: u2, scaleY: m } = s.getAncestorScale();
- return {
- startX: h.left,
- endX: h.right,
- startY: h.top,
- endY: h.bottom,
- rotate: a,
- width: d * u2,
- height: g * m,
- absolute: h.absolute
- };
- };
- var Tt2 = class extends nt {
- constructor(e, n, t, r, s, o, c) {
- super();
- J(this, "_domLayerMap", /* @__PURE__ */ new Map());
- J(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
- J(this, "_transformChange$", new Subject());
- J(this, "transformChange$", this._transformChange$.asObservable());
- J(this, "_add$", new Subject());
- J(this, "add$", this._add$.asObservable());
- J(this, "_remove$", new Subject());
- J(this, "remove$", this._remove$.asObservable());
- J(this, "_hooks", []);
- this._renderManagerService = e, this._univerInstanceService = n, this._commandService = t, this._drawingManagerService = r, this._canvasFloatDomService = s, this._sheetDrawingService = o, this._lifecycleService = c, this._drawingAddListener(), this._featureUpdateListener(), this._deleteListener(), this._bindScrollEvent();
- }
- _bindScrollEvent() {
- this._lifecycleService.lifecycle$.pipe(filter((e) => e === Ve.Rendered), take(1)).subscribe(() => {
- this._scrollUpdateListener();
- });
- }
- _ensureMap(e, n) {
- let t = this._domLayerMap.get(e);
- t || (t = /* @__PURE__ */ new Map(), this._domLayerMap.set(e, t));
- let r = t.get(n);
- return r || (r = /* @__PURE__ */ new Map(), t.set(n, r)), r;
- }
- getFloatDomInfo(e) {
- return this._domLayerInfoMap.get(e);
- }
- _getSceneAndTransformerByDrawingSearch(e) {
- if (e == null)
- return;
- const n = this._renderManagerService.getRenderById(e), t = n == null ? void 0 : n.scene;
- if (n == null || t == null)
- return null;
- const r = t.getTransformerByCreate(), s = n.engine.getCanvasElement();
- return { scene: t, transformer: r, renderUnit: n, canvas: s };
- }
- _getFloatDomProps(e) {
- let n;
- return this._hooks.forEach((t) => {
- n = t.onGetFloatDomProps(e);
- }), n;
- }
- _drawingAddListener() {
- this.disposeWithMe(
- this._drawingManagerService.add$.subscribe((e) => {
- e.forEach((n) => {
- var Se, ge, ce;
- const { unitId: t, subUnitId: r, drawingId: s } = n, o = N(this._univerInstanceService, { unitId: t, subUnitId: r }), c = this._drawingManagerService.getDrawingByParam(n), d = this._univerInstanceService.getUnit(t, Fe.UNIVER_SHEET);
- if (!d)
- return;
- const g = d.getActiveSheet().getSheetId();
- if (!c || !o)
- return;
- const a = (Se = this._renderManagerService.getRenderById(t)) == null ? void 0 : Se.with(me).getWorksheetSkeleton(r);
- if (!a)
- return;
- const { transform: l, drawingType: h, data: u2 } = c;
- if (h !== gm.DRAWING_DOM && h !== gm.DRAWING_CHART)
- return;
- const m = this._getSceneAndTransformerByDrawingSearch(t);
- if (m == null)
- return;
- const { scene: p, canvas: f2 } = m;
- if (l == null)
- return true;
- if (g !== r)
- return;
- const { left: w, top: I, width: S, height: R, angle: v, flipX: C, flipY: _3, skewX: y, skewY: M } = l, x = bn({ unitId: t, subUnitId: r, drawingId: s }), U = p.getObject(x);
- if (U != null) {
- U.transformByState({ left: w, top: I, width: S, height: R, angle: v, flipX: C, flipY: _3, skewX: y, skewY: M });
- return;
- }
- const D = {
- left: w,
- top: I,
- width: S,
- height: R,
- zIndex: this._drawingManagerService.getDrawingOrder(t, r).length - 1
- }, b = h === gm.DRAWING_CHART;
- if (b) {
- const $ = u2 ? u2.backgroundColor : "white";
- D.fill = $, D.rotateEnabled = false, u2 && u2.border && (D.stroke = u2.border), D.paintFirst = "stroke", D.strokeWidth = 1, D.borderEnabled = false, D.radius = 8;
- }
- const P = new A1(x, D);
- b && P.setObjectType(b3.CHART), p.addObject(P, aS), c.allowTransform !== false && p.attachTransformerTo(P);
- const A = this._ensureMap(t, r), j2 = new Mi(), B = Te2(P, m.renderUnit, a.skeleton, o.worksheet), X = new BehaviorSubject(B), se = {
- dispose: j2,
- rect: P,
- position$: X,
- unitId: t,
- subUnitId: r
- };
- this._canvasFloatDomService.addFloatDom({
- position$: X,
- id: s,
- componentKey: c.componentKey,
- onPointerDown: ($) => {
- f2.dispatchEvent(new PointerEvent($.type, $));
- },
- onPointerMove: ($) => {
- f2.dispatchEvent(new PointerEvent($.type, $));
- },
- onPointerUp: ($) => {
- f2.dispatchEvent(new PointerEvent($.type, $));
- },
- onWheel: ($) => {
- f2.dispatchEvent(new WheelEvent($.type, $));
- },
- props: (ce = (ge = A.get(s)) == null ? void 0 : ge.props) != null ? ce : this._getFloatDomProps(s),
- data: u2,
- unitId: t
- });
- const oe2 = P.onTransformChange$.subscribeEvent(() => {
- const $ = Te2(P, m.renderUnit, a.skeleton, o.worksheet);
- X.next(
- $
- );
- });
- j2.add(() => {
- this._canvasFloatDomService.removeFloatDom(s);
- }), oe2 && j2.add(oe2), this._domLayerInfoMap.set(s, se), A.set(s, {
- ...A.get(s)
- });
- });
- })
- ), this.disposeWithMe(
- this._drawingManagerService.remove$.subscribe((e) => {
- e.forEach((n) => {
- const { unitId: t, subUnitId: r, drawingId: s } = n, o = bn({ unitId: t, subUnitId: r, drawingId: s }), c = this._getSceneAndTransformerByDrawingSearch(t);
- if (c == null)
- return;
- const { transformer: d, scene: g } = c, a = g.getObject(o);
- a != null && a.oKey && d.clearControlByIds([a == null ? void 0 : a.oKey]);
- });
- })
- );
- }
- _scrollUpdateListener() {
- const e = (n, t) => {
- var g;
- const r = this._getSceneAndTransformerByDrawingSearch(n), s = this._ensureMap(n, t), o = Array.from(s.keys()), c = N(this._univerInstanceService, { unitId: n, subUnitId: t }), d = (g = this._renderManagerService.getRenderById(n)) == null ? void 0 : g.with(me).getWorksheetSkeleton(t);
- !r || !c || !d || o.forEach((a) => {
- const l = this._domLayerInfoMap.get(a);
- if (l) {
- const h = Te2(l.rect, r.renderUnit, d.skeleton, c.worksheet, l);
- l.position$.next(h);
- }
- });
- };
- this.disposeWithMe(
- this._univerInstanceService.getCurrentTypeOfUnit$(Fe.UNIVER_SHEET).pipe(
- filter((n) => !!n),
- switchMap((n) => n.activeSheet$),
- filter((n) => !!n),
- map((n) => {
- const t = this._renderManagerService.getRenderById(n.getUnitId());
- return t ? { render: t, unitId: n.getUnitId(), subUnitId: n.getSheetId() } : null;
- }),
- filter((n) => !!n),
- switchMap(
- (n) => DR(n.render.scene.getViewport(i2.VIEW_MAIN).onScrollAfter$).pipe(map(() => ({ unitId: n.unitId, subUnitId: n.subUnitId })))
- )
- ).subscribe(({ unitId: n, subUnitId: t }) => {
- e(n, t);
- })
- ), this.disposeWithMe(this._commandService.onCommandExecuted((n) => {
- var t, r;
- if (n.id === $t.id) {
- const s = n.params, { unitId: o } = s;
- Array.from((r = (t = this._domLayerMap.get(o)) == null ? void 0 : t.keys()) != null ? r : []).forEach((d) => {
- e(o, d);
- });
- } else if (n.id === ut.id) {
- const { unitId: s, subUnitId: o } = n.params;
- e(s, o);
- }
- }));
- }
- _getPosition(e, n) {
- var h;
- const { startX: t, endX: r, startY: s, endY: o } = e, c = (h = this._renderManagerService.getRenderById(n)) == null ? void 0 : h.with(dt);
- if (c == null)
- return;
- const d = c.getCellWithCoordByOffset(t, s);
- if (d == null)
- return;
- const g = {
- column: d.actualColumn,
- columnOffset: t - d.startX,
- row: d.actualRow,
- rowOffset: s - d.startY
- }, a = c.getCellWithCoordByOffset(r, o);
- if (a == null)
- return;
- const l = {
- column: a.actualColumn,
- columnOffset: r - a.startX,
- row: a.actualRow,
- rowOffset: o - a.startY
- };
- return {
- from: g,
- to: l
- };
- }
- _featureUpdateListener() {
- this.disposeWithMe(
- this._drawingManagerService.update$.subscribe((e) => {
- e.forEach((n) => {
- const t = this._drawingManagerService.getDrawingByParam(n);
- if (!t || t.drawingType !== gm.DRAWING_DOM && t.drawingType !== gm.DRAWING_CHART)
- return;
- const r = {
- ...t.transform
- };
- this._transformChange$.next({ id: n.drawingId, value: r });
- });
- })
- );
- }
- _deleteListener() {
- this.disposeWithMe(
- this._drawingManagerService.remove$.subscribe((e) => {
- e.forEach((n) => {
- this._removeDom(n.drawingId);
- });
- })
- );
- }
- updateFloatDomProps(e, n, t, r) {
- const s = this._domLayerInfoMap.get(t), o = this._getSceneAndTransformerByDrawingSearch(e);
- if (s && o) {
- const { scene: c } = o, d = bn({ unitId: e, subUnitId: n, drawingId: t }), g = c.getObject(d);
- g && g instanceof A1 && g.setProps(r);
- }
- }
- // CreateFloatDomCommand --> floatDomService.addFloatDomToPosition
- addFloatDomToPosition(e, n) {
- const t = N(this._univerInstanceService, {
- unitId: e.unitId,
- subUnitId: e.subUnitId
- });
- if (!t)
- throw new Error("cannot find current target!");
- const { unitId: r, subUnitId: s } = t, { initPosition: o, componentKey: c, data: d, allowTransform: g = true } = e, a = n != null ? n : qt(), l = this._getPosition(o, r);
- if (l == null)
- return;
- this._ensureMap(r, s).set(a, e);
- const u2 = {
- unitId: r,
- subUnitId: s,
- drawingId: a,
- drawingType: e.type || gm.DRAWING_DOM,
- componentKey: c,
- sheetTransform: l,
- transform: {
- left: o.startX,
- top: o.startY,
- width: o.endX - o.startX,
- height: o.endY - o.startY
- },
- data: d,
- allowTransform: g
- };
- return this._commandService.executeCommand(jt.id, {
- unitId: r,
- drawings: [u2]
- }), this._add$.next({ unitId: r, subUnitId: s, id: a }), {
- id: a,
- dispose: () => {
- this._removeDom(a, true);
- }
- };
- }
- _removeDom(e, n = false) {
- const t = this._domLayerInfoMap.get(e);
- if (!t)
- return;
- const { unitId: r, subUnitId: s } = t;
- this._domLayerInfoMap.delete(e), t.dispose.dispose();
- const o = this._getSceneAndTransformerByDrawingSearch(r);
- if (o && o.scene.removeObject(t.rect), n) {
- this._ensureMap(r, s).delete(e);
- const d = this._drawingManagerService.getDrawingByParam({ unitId: r, subUnitId: s, drawingId: e });
- if (!d)
- return;
- const g = this._sheetDrawingService.getBatchRemoveOp([d]), { redo: a, objects: l } = g;
- this._commandService.syncExecuteCommand(H.id, { unitId: r, subUnitId: s, op: a, objects: l, type: F2.REMOVE });
- }
- }
- addHook(e) {
- return this._hooks.push(e), {
- dispose: () => {
- const n = this._hooks.findIndex((t) => t === e);
- this._hooks.splice(n, 1);
- }
- };
- }
- addFloatDomToRange(e, n, t, r) {
- var M, x, U, D, b, P;
- const s = N(this._univerInstanceService, {
- unitId: n.unitId,
- subUnitId: n.subUnitId
- });
- if (!s)
- throw new Error("cannot find current target!");
- const { unitId: o, subUnitId: c } = s;
- if (!this._getSceneAndTransformerByDrawingSearch(o))
- return;
- const g = this._renderManagerService.getRenderById(o);
- if (!g)
- return;
- const a = (M = this._renderManagerService.getRenderById(o)) == null ? void 0 : M.with(me).getWorksheetSkeleton(c);
- if (!a)
- return;
- const { componentKey: l, data: h, allowTransform: u2 = true } = n, m = r != null ? r : qt(), { position: p } = this._createRangePositionObserver(e, g, a.skeleton), f2 = this._getPosition(p, o);
- if (f2 == null)
- return;
- this._ensureMap(o, c).set(m, n);
- const I = p.endX - p.startX, S = p.endY - p.startY, R = (x = t.width) != null ? x : I, v = (U = t.height) != null ? U : S, C = p.startX + je(t.marginX, I), _3 = p.startY + je(t.marginY, S), y = {
- unitId: o,
- subUnitId: c,
- drawingId: m,
- drawingType: n.type || gm.DRAWING_DOM,
- componentKey: l,
- sheetTransform: f2,
- transform: {
- left: C,
- top: _3,
- width: R,
- height: v
- },
- data: h,
- allowTransform: u2
- };
- {
- const { unitId: A, subUnitId: j2, drawingId: B } = y, X = N(this._univerInstanceService, { unitId: A, subUnitId: j2 }), se = y, oe2 = this._univerInstanceService.getUnit(A, Fe.UNIVER_SHEET);
- if (!oe2)
- return;
- const Se = oe2.getActiveSheet().getSheetId();
- if (!se || !X)
- return;
- const ge = (D = this._renderManagerService.getRenderById(A)) == null ? void 0 : D.with(me).getWorksheetSkeleton(j2);
- if (!ge)
- return;
- const { transform: ce, drawingType: $, data: de } = se;
- if ($ !== gm.DRAWING_DOM && $ !== gm.DRAWING_CHART)
- return;
- const Ue = this._getSceneAndTransformerByDrawingSearch(A);
- if (Ue == null)
- return;
- const { scene: le, canvas: ue2 } = Ue;
- if (ce == null || Se !== j2)
- return;
- const { left: Ie, top: ke, width: Le2, height: Fe2, angle: nt3, flipX: xt, flipY: Bt, skewX: $t2, skewY: kt2 } = ce, rt3 = bn({ unitId: A, subUnitId: j2, drawingId: B }), Ge = le.getObject(rt3);
- if (Ge != null) {
- Ge.transformByState({ left: Ie, top: ke, width: Le2, height: Fe2, angle: nt3, flipX: xt, flipY: Bt, skewX: $t2, skewY: kt2 });
- return;
- }
- const re2 = {
- left: Ie,
- top: ke,
- width: Le2,
- height: Fe2,
- zIndex: this._drawingManagerService.getDrawingOrder(A, j2).length - 1
- }, it2 = $ === gm.DRAWING_CHART;
- if (it2) {
- const W = de ? de.backgroundColor : "white";
- re2.fill = W, re2.rotateEnabled = false, de && de.border && (re2.stroke = de.border), re2.paintFirst = "stroke", re2.strokeWidth = 1, re2.borderEnabled = false, re2.radius = 8;
- }
- const K = new A1(rt3, re2);
- it2 && K.setObjectType(b3.CHART), le.addObject(K, aS), se.allowTransform !== false && le.attachTransformerTo(K);
- const Ce = this._ensureMap(A, j2), Re = new Mi(), me2 = le.getMainViewport(), Lt = {
- top: me2.top,
- left: me2.left,
- bottom: me2.bottom,
- right: me2.right
- }, he = {
- dispose: Re,
- rect: K,
- boundsOfViewArea: Lt,
- // position$,
- unitId: A,
- subUnitId: j2
- }, Ft = Te2(K, Ue.renderUnit, ge.skeleton, X.worksheet, he), be = new BehaviorSubject(Ft);
- he.position$ = be;
- let De2 = {
- position$: be,
- id: B,
- componentKey: se.componentKey,
- onPointerDown: () => {
- },
- onPointerMove: () => {
- },
- onPointerUp: () => {
- },
- onWheel: (W) => {
- ue2.dispatchEvent(new WheelEvent(W.type, W));
- },
- props: (P = (b = Ce.get(B)) == null ? void 0 : b.props) != null ? P : this._getFloatDomProps(B),
- data: de,
- unitId: A
- };
- n.eventPassThrough && (De2 = {
- ...De2,
- onPointerDown: (W) => {
- ue2.dispatchEvent(new PointerEvent(W.type, W));
- },
- onPointerMove: (W) => {
- ue2.dispatchEvent(new PointerEvent(W.type, W));
- },
- onPointerUp: (W) => {
- ue2.dispatchEvent(new PointerEvent(W.type, W));
- }
- }), this._canvasFloatDomService.addFloatDom(De2);
- const Ve2 = K.onTransformChange$.subscribeEvent(() => {
- const W = Te2(K, Ue.renderUnit, ge.skeleton, X.worksheet, he);
- be.next(
- W
- );
- });
- Re.add(() => {
- this._canvasFloatDomService.removeFloatDom(B);
- }), Ve2 && Re.add(Ve2), this._domLayerInfoMap.set(B, he), Ce.set(B, {
- ...Ce.get(B)
- });
- }
- return {
- id: m,
- dispose: () => {
- this._removeDom(m, true);
- }
- };
- }
- addFloatDomToColumnHeader(e, n, t, r) {
- var x, U, D, b, P, A;
- const s = N(this._univerInstanceService, {
- unitId: n.unitId,
- subUnitId: n.subUnitId
- });
- if (!s)
- throw new Error("cannot find current target!");
- const { unitId: o, subUnitId: c } = s;
- if (!this._getSceneAndTransformerByDrawingSearch(o))
- return;
- const g = this._renderManagerService.getRenderById(o);
- if (!g)
- return;
- const a = (x = this._renderManagerService.getRenderById(o)) == null ? void 0 : x.with(me).getWorksheetSkeleton(c);
- if (!a)
- return;
- const { componentKey: l, data: h, allowTransform: u2 = true } = n, m = r != null ? r : qt(), { position: p } = this._createRangePositionObserver({
- startRow: 0,
- endRow: 0,
- startColumn: e,
- endColumn: e
- }, g, a.skeleton), f2 = p;
- f2.startY = 0;
- const w = this._getPosition(p, o);
- if (w == null)
- return;
- this._ensureMap(o, c).set(m, n);
- const S = p.endX - p.startX, R = p.endY - p.startY, v = (U = t.width) != null ? U : S, C = (D = t.height) != null ? D : R;
- let _3 = 0, y = 0;
- if (t.horizonOffsetAlign === "right") {
- const j2 = je(t.marginX, S);
- _3 = f2.endX - j2 - v;
- } else
- _3 = f2.startX + je(t.marginX, S);
- if (t.verticalOffsetAlign === "bottom") {
- const j2 = je(t.marginY, R);
- y = f2.endY - j2 - C;
- } else
- y = f2.startY + je(t.marginY, R);
- const M = {
- unitId: o,
- subUnitId: c,
- drawingId: m,
- drawingType: n.type || gm.DRAWING_DOM,
- componentKey: l,
- sheetTransform: w,
- transform: {
- left: _3,
- top: y,
- width: v,
- height: C
- },
- data: h,
- allowTransform: u2
- };
- {
- const { unitId: j2, subUnitId: B, drawingId: X } = M, se = N(this._univerInstanceService, { unitId: j2, subUnitId: B }), oe2 = M, Se = this._univerInstanceService.getUnit(j2, Fe.UNIVER_SHEET);
- if (!Se)
- return;
- const ge = Se.getActiveSheet().getSheetId();
- if (!oe2 || !se)
- return;
- const ce = (b = this._renderManagerService.getRenderById(j2)) == null ? void 0 : b.with(me).getWorksheetSkeleton(B);
- if (!ce)
- return;
- const { transform: $, drawingType: de, data: Ue } = oe2;
- if (de !== gm.DRAWING_DOM && de !== gm.DRAWING_CHART)
- return;
- const le = this._getSceneAndTransformerByDrawingSearch(j2);
- if (le == null)
- return;
- const { scene: ue2, canvas: Ie } = le;
- if ($ == null || ge !== B)
- return;
- const { left: ke, top: Le2, width: Fe2, height: nt3, angle: xt, flipX: Bt, flipY: $t2, skewX: kt2, skewY: rt3 } = $, Ge = bn({ unitId: j2, subUnitId: B, drawingId: X }), re2 = ue2.getObject(Ge);
- if (re2 != null) {
- re2.transformByState({ left: ke, top: Le2, width: Fe2, height: nt3, angle: xt, flipX: Bt, flipY: $t2, skewX: kt2, skewY: rt3 });
- return;
- }
- const it2 = {
- left: ke,
- top: Le2,
- width: Fe2,
- height: nt3,
- zIndex: this._drawingManagerService.getDrawingOrder(j2, B).length - 1
- }, K = new A1(Ge, it2);
- ue2.addObject(K, aS), oe2.allowTransform !== false && ue2.attachTransformerTo(K);
- const Ce = this._ensureMap(j2, B), Re = new Mi(), me2 = ue2.getMainViewport(), Lt = {
- top: 0,
- //viewMain.top,
- left: me2.left,
- bottom: me2.bottom,
- right: me2.right
- }, he = {
- dispose: Re,
- rect: K,
- // position$,
- unitId: j2,
- subUnitId: B,
- boundsOfViewArea: Lt,
- scrollDirectionResponse: "HORIZONTAL"
- /* HORIZONTAL */
- }, Ft = Te2(K, le.renderUnit, ce.skeleton, se.worksheet, he), be = new BehaviorSubject(Ft);
- he.position$ = be;
- let De2 = {
- position$: be,
- id: X,
- componentKey: oe2.componentKey,
- onPointerDown: () => {
- },
- onPointerMove: () => {
- },
- onPointerUp: () => {
- },
- onWheel: (W) => {
- Ie.dispatchEvent(new WheelEvent(W.type, W));
- },
- props: (A = (P = Ce.get(X)) == null ? void 0 : P.props) != null ? A : this._getFloatDomProps(X),
- data: Ue,
- unitId: j2
- };
- n.eventPassThrough && (De2 = {
- ...De2,
- onPointerDown: (W) => {
- Ie.dispatchEvent(new PointerEvent(W.type, W));
- },
- onPointerMove: (W) => {
- Ie.dispatchEvent(new PointerEvent(W.type, W));
- },
- onPointerUp: (W) => {
- Ie.dispatchEvent(new PointerEvent(W.type, W));
- }
- }), this._canvasFloatDomService.addFloatDom(De2);
- const Ve2 = K.onTransformChange$.subscribeEvent(() => {
- const W = Te2(K, le.renderUnit, ce.skeleton, se.worksheet, he);
- be.next(
- W
- );
- });
- Re.add(() => {
- this._canvasFloatDomService.removeFloatDom(X);
- }), Ve2 && Re.add(Ve2), this._domLayerInfoMap.set(X, he), Ce.set(X, {
- ...Ce.get(X)
- });
- }
- return {
- id: m,
- dispose: () => {
- this._removeDom(m, true);
- }
- };
- }
- /**
- * Unlike _createCellPositionObserver, this accept a range not a single cell.
- *
- * @param initialRow
- * @param initialCol
- * @param currentRender
- * @param skeleton
- * @param activeViewport
- * @returns position of cell to canvas.
- */
- _createRangePositionObserver(e, n, t) {
- let { startRow: r, startColumn: s } = e;
- const o = Ke2(r, s, t), c = new BehaviorSubject(o), d = Ke2(e.endRow, e.endColumn, t), g = new BehaviorSubject(d), a = () => {
- const f2 = Ke2(r, s, t), w = Ke2(e.endRow, e.endColumn, t);
- c.next(f2), g.next(w);
- }, l = new Mi();
- l.add(n.engine.clientRect$.subscribe(() => a())), l.add(this._commandService.onCommandExecuted((f2) => {
- if (f2.id === Br.id && f2.params.rowsAutoHeightInfo.findIndex((I) => I.row === r) > -1) {
- a();
- return;
- }
- (gh.indexOf(f2.id) > -1 || f2.id === dn.id || f2.id === $t.id) && a();
- }));
- const h = (f2, w) => {
- r = f2, s = w, a();
- }, u2 = () => ({
- rotate: 0,
- width: d.right - o.left,
- height: d.bottom - o.top,
- absolute: {
- left: true,
- top: true
- },
- startX: o.left,
- startY: o.top,
- endX: d.right,
- endY: d.bottom
- }), m = c.pipe(
- map((f2) => {
- const w = Ke2(e.endRow, e.endColumn, t);
- return console.log("service", f2.left, f2.top), {
- rotate: 0,
- width: w.right - f2.left,
- height: w.bottom - f2.top,
- absolute: {
- left: true,
- top: true
- },
- startX: f2.left,
- startY: f2.top,
- endX: w.right,
- endY: w.bottom
- };
- })
- ), p = u2();
- return console.log("init position", p), {
- position$: m,
- position: p,
- updateRowCol: h,
- topLeftPos$: c,
- rightBottomPos$: g,
- disposable: l
- };
- }
- };
- Tt2 = vo([
- Oe2(0, ot(Yx)),
- Oe2(1, _n),
- Oe2(2, ot(Pt)),
- Oe2(3, Ut),
- Oe2(4, ot(l3)),
- Oe2(5, u),
- Oe2(6, ot(Ht))
- ], Tt2);
- function Ke2(i, e, n) {
- const t = n.getCellWithCoordByIndex(i, e), r = t.isMergedMainCell ? t.mergeInfo : t;
- return {
- left: r.startX,
- right: r.endX,
- top: r.startY,
- bottom: r.endY
- };
- }
- function je(i, e) {
- if (i === void 0)
- return 0;
- if (typeof i == "number")
- return i;
- const n = Number.parseFloat(i);
- return e * n / 100;
- }
- var wr = Object.defineProperty;
- var Io = Object.getOwnPropertyDescriptor;
- var Co = (i, e, n) => e in i ? wr(i, e, { enumerable: true, configurable: true, writable: true, value: n }) : i[e] = n;
- var Ro = (i, e, n, t) => {
- for (var r = t > 1 ? void 0 : t ? Io(e, n) : e, s = i.length - 1, o; s >= 0; s--)
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
- return t && r && wr(e, n, r), r;
- };
- var Zt3 = (i, e) => (n, t) => e(n, t, i);
- var _r = (i, e, n) => Co(i, typeof e != "symbol" ? e + "" : e, n);
- var bo = "SHEET_IMAGE_UI_PLUGIN";
- var Et = class extends Ra {
- constructor(i = Cn, e, n, t) {
- super(), this._config = i, this._injector = e, this._renderManagerService = n, this._configService = t;
- const { menu: r, ...s } = nu(
- {},
- Cn,
- this._config
- );
- r && this._configService.setConfig("menu", r, { merge: true }), this._configService.setConfig(Hi, s);
- }
- onStarting() {
- K0(this._injector, [
- [Tt2],
- [Ot2],
- [It],
- [yt],
- [Mt],
- [Dt],
- [Ct],
- [bt],
- [Rt]
- ]), Mf(this._injector, [
- [Tt2]
- ]);
- }
- onReady() {
- Mf(this._injector, [
- [Dt]
- ]);
- }
- onRendered() {
- this._registerRenderModules(), Mf(this._injector, [
- [Mt],
- [yt],
- [Ot2],
- [Ct],
- [bt],
- [Rt]
- ]);
- }
- onSteady() {
- this._injector.get(It);
- }
- _registerRenderModules() {
- [
- [Ze2],
- [sn2],
- [nn]
- ].forEach((i) => {
- this.disposeWithMe(this._renderManagerService.registerRenderModule(Fe.UNIVER_SHEET, i));
- });
- }
- };
- _r(Et, "type", Fe.UNIVER_SHEET);
- _r(Et, "pluginName", bo);
- Et = Ro([
- OR(At, f, cn2, _2),
- Zt3(1, ot(Ot)),
- Zt3(2, Yx),
- Zt3(3, SE)
- ], Et);
- export {
- F3 as ClearSheetDrawingTransformerOperation,
- gr2 as DeleteDrawingsCommand,
- sr as EditSheetDrawingOperation,
- or as GroupSheetDrawingCommand,
- cn3 as InsertFloatImageCommand,
- jt as InsertSheetDrawingCommand,
- et2 as MoveDrawingsCommand,
- Nt as RemoveSheetDrawingCommand,
- fr as SHEETS_IMAGE_MENU_ID,
- ar2 as SetDrawingArrangeCommand,
- Wt as SetSheetDrawingCommand,
- Tt2 as SheetCanvasFloatDomManagerService,
- ir as SidebarSheetDrawingOperation,
- cr as UngroupSheetDrawingCommand,
- Et as UniverSheetsDrawingUIPlugin
- };
- /*! Bundled license information:
- @univerjs/sheets-drawing-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=@univerjs_sheets-drawing-ui.js.map
|