import { Se, Vs } from "./chunk-MIOQ566M.js"; import "./chunk-POAJ2YNP.js"; import "./chunk-GBYP4PB2.js"; import "./chunk-PZD7N4BC.js"; import { Yx } from "./chunk-2MK3Q52E.js"; import "./chunk-BSDDCPAW.js"; import "./chunk-QG2HZMYH.js"; import { Ag, Bi, Fe, Nn, Ot, Pt, Tn, _n, ot, pi } from "./chunk-23V3HWTR.js"; import "./chunk-GNR2UJZM.js"; import "./chunk-2LSFTFF7.js"; // node_modules/.pnpm/@univerjs+docs-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/docs-ui/lib/es/facade.js var h = Object.defineProperty; var v = (n, e, t) => e in n ? h(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t; var u = (n, e, t) => v(n, typeof e != "symbol" ? e + "" : e, t); var y = Object.defineProperty; var O = Object.getOwnPropertyDescriptor; var R = (n, e, t, r) => { for (var s = r > 1 ? void 0 : r ? O(e, t) : e, i = n.length - 1, a; i >= 0; i--) (a = n[i]) && (s = (r ? a(e, t, s) : a(s)) || s); return r && s && y(e, t, s), s; }; var c = (n, e) => (t, r) => e(t, r, n); var o = class { constructor(n, e, t, r, s, i) { u(this, "id"); this._documentDataModel = n, this._injector = e, this._univerInstanceService = t, this._commandService = r, this._resourceManagerService = s, this._renderManagerService = i, this.id = this._documentDataModel.getUnitId(); } getId() { return this._documentDataModel.getUnitId(); } getName() { return this.getSnapshot().title || ""; } getSnapshot() { const n = this._resourceManagerService.getResourcesByType(this.id, Fe.UNIVER_DOC), e = this._documentDataModel.getSnapshot(); return e.resources = n, e; } undo() { return this._univerInstanceService.focusUnit(this.id), this._commandService.executeCommand(Nn.id); } redo() { return this._univerInstanceService.focusUnit(this.id), this._commandService.executeCommand(Tn.id); } /** * Adds the specified text to the end of this text region. * @param text - The text to be added to the end of this text region. */ appendText(n) { const e = this.id, { body: t } = this.getSnapshot(); if (!t) throw new Error("The document body is empty"); const r = t.dataStream.length - 2, s = { startOffset: r, endOffset: r, collapsed: true, segmentId: "" }, { segmentId: i } = s; return this._commandService.executeCommand(Vs.id, { unitId: e, body: { dataStream: n }, range: s, segmentId: i }); } /** * Sets the selection to a specified text range in the document. * @param startOffset - The starting offset of the selection in the document. * @param endOffset - The ending offset of the selection in the document. * @example * ```typescript * document.setSelection(10, 20); * ``` */ setSelection(n, e) { var r; const t = (r = this._renderManagerService.getRenderById(this.getId())) == null ? void 0 : r.with(Se); t == null || t.removeAllRanges(), t == null || t.addDocRanges( [ { startOffset: n, endOffset: e, rangeType: Ag.TEXT } ], true ); } }; o = R([ c(1, ot(Ot)), c(2, _n), c(3, Pt), c(4, Bi), c(5, Yx) ], o); var T = class extends pi { createUniverDoc(e) { const t = this._univerInstanceService.createUnit(Fe.UNIVER_DOC, e); return this._injector.createInstance(o, t); } getActiveDocument() { const e = this._univerInstanceService.getCurrentUnitForType(Fe.UNIVER_DOC); return e ? this._injector.createInstance(o, e) : null; } getUniverDoc(e) { const t = this._univerInstanceService.getUniverDocInstance(e); return t ? this._injector.createInstance(o, t) : null; } }; pi.extend(T); export { o as FDocument }; //# sourceMappingURL=@univerjs_docs-ui_facade.js.map