@p10node/office-engine 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,9 +11,17 @@ View + edit **DOCX / XLSX / PPTX** directly in the browser. Loads progressively
11
11
 
12
12
  The demo has samples, heavy files (300k-row sheet, 305-slide deck), drag & drop your own file, edit and download.
13
13
 
14
- | DOCX | XLSX | PPTX |
15
- |-------------------------------------------|-------------------------------------------|-------------------------------------------|
16
- | ![DOCX editor](docs/screenshots/docx.png) | ![XLSX editor](docs/screenshots/xlsx.png) | ![PPTX editor](docs/screenshots/pptx.png) |
14
+ **Real-time collaboration**
15
+
16
+ ![Real-time collaboration: Ann and Bob edit one sheet side by side, Cara joins from a third browser](docs/screenshots/collab.gif)
17
+
18
+ **300k-row XLSX open in the browser**
19
+
20
+ ![300k-row XLSX opening in the browser: rows stream in, then a jump to the last row](docs/screenshots/xlsx-300k.gif)
21
+
22
+ | DOCX editor | PPTX editor |
23
+ |-------------------------------------------|-------------------------------------------|
24
+ | ![DOCX editor](docs/screenshots/docx.png) | ![PPTX editor](docs/screenshots/pptx.png) |
17
25
 
18
26
  ## Install
19
27
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { C as e, E as t, N as n, P as r, S as i, d as a, f as o, h as s, j as c, m as l, o as u, p as d, t as f, u as p, w as m } from "./default-worker-BDj6MNRA.js";
3
- import { C as h, D as g, E as _, O as v, S as y, T as b, _ as ee, b as x, d as S, f as C, g as w, h as te, k as ne, m as re, p as ie, t as ae, v as T, w as E, x as oe, y as se } from "./collab-BvjXvfJ9.js";
3
+ import { C as h, D as g, E as _, O as v, S as y, T as b, _ as ee, b as x, d as S, f as C, g as w, h as te, k as ne, m as re, p as ie, t as ae, v as T, w as E, x as oe, y as se } from "./collab-Dx00zqXR.js";
4
4
  import { Children as D, Fragment as ce, createContext as le, isValidElement as O, memo as ue, useCallback as de, useContext as fe, useEffect as k, useId as pe, useInsertionEffect as me, useLayoutEffect as A, useMemo as he, useReducer as ge, useRef as j, useState as M, useSyncExternalStore as _e } from "react";
5
5
  import { createPortal as N } from "react-dom";
6
6
  import { Fragment as P, jsx as F, jsxs as I } from "react/jsx-runtime";
@@ -1835,6 +1835,37 @@ var Pt = class {
1835
1835
  for (let e = 0; e < Math.min(n.length, r.length); e++) if (n[e] !== r[e]) return n[e] - r[e];
1836
1836
  return n.length - r.length;
1837
1837
  }
1838
+ all() {
1839
+ let e = -1, t = -1;
1840
+ return this.st.blocks.forEach((n, r) => {
1841
+ this.para(String(r)) && (e < 0 && (e = r), t = r);
1842
+ }), e < 0 ? null : {
1843
+ a: {
1844
+ pa: String(e),
1845
+ o: 0
1846
+ },
1847
+ f: {
1848
+ pa: String(t),
1849
+ o: oe(this.para(String(t)).runs)
1850
+ }
1851
+ };
1852
+ }
1853
+ selectAll() {
1854
+ this.input.selectAll();
1855
+ }
1856
+ deleteAcross(e, t) {
1857
+ let n = Mt(e.pa), r = Mt(t.pa);
1858
+ if (n.length !== 1 || r.length !== 1 || n[0] >= r[0]) return null;
1859
+ let i = this.para(e.pa), a = this.para(t.pa);
1860
+ if (!i || !a) return null;
1861
+ let o = (e, t) => this.st.blocks[e]?.t === "p" && this.st.blocks[e].pid === t.pid;
1862
+ if (o(n[0] - 1, i) || o(r[0] + 1, a)) return null;
1863
+ let s = x([...b(i.runs, e.o)[0], ...b(a.runs, t.o)[1]]), c = this.st.blocks.slice(n[0] + 1, r[0]).filter((e) => e.t === "sect");
1864
+ return this.replaceBlocks(n[0], r[0] - n[0] + 1, [this.join(i, a, s), ...c], {
1865
+ a: e,
1866
+ f: e
1867
+ }), e;
1868
+ }
1838
1869
  withRuns(e, t) {
1839
1870
  return {
1840
1871
  ...e,
@@ -2328,7 +2359,12 @@ var Pt = class {
2328
2359
  item: e.item,
2329
2360
  spec: null
2330
2361
  });
2331
- if (n.forEach((t, n) => t.t === "tbl" && t.tid !== void 0 && this.commitTable(e + n)), this.onCommit?.({
2362
+ if (n.forEach((t, n) => {
2363
+ t.t === "tbl" && (t.tid === void 0 && !c.has(o(t)) && (this.st.blocks[e + n] = {
2364
+ ...t,
2365
+ tid: this.nextPid++
2366
+ }), this.commitTable(e + n));
2367
+ }), this.onCommit?.({
2332
2368
  kind: "blocks",
2333
2369
  bi: e,
2334
2370
  before: a,
@@ -4227,7 +4263,7 @@ function bn({ client: e, onStatus: t, initialZoom: n = "fit" }) {
4227
4263
  label: "Select all",
4228
4264
  icon: "selectAll",
4229
4265
  hint: `${Z}A`,
4230
- run: () => document.execCommand("selectAll")
4266
+ run: () => b.selectAll()
4231
4267
  }), r;
4232
4268
  }, $e = c?.styles?.find((e) => e.canon === "title")?.id, et = he(() => se ? vn(a.blocks, $e) : [], [
4233
4269
  se,
@@ -4262,10 +4298,11 @@ function bn({ client: e, onStatus: t, initialZoom: n = "fit" }) {
4262
4298
  className: "de-scroll",
4263
4299
  tabIndex: -1,
4264
4300
  onKeyDown: (e) => {
4265
- (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "f" && (e.preventDefault(), w((e) => ({
4301
+ let t = (e.metaKey || e.ctrlKey) && !e.altKey, n = e.key.toLowerCase();
4302
+ t && n === "f" ? (e.preventDefault(), w((e) => ({
4266
4303
  ...e,
4267
4304
  open: !0
4268
- })));
4305
+ }))) : t && n === "a" && !e.shiftKey && !x && y.current && (e.preventDefault(), ie(y.current)?.selectAllChildren(y.current));
4269
4306
  },
4270
4307
  children: [
4271
4308
  c && z.length > 0 && /* @__PURE__ */ F("div", {
@@ -9297,6 +9334,15 @@ function ua({ store: e, sheet: t, meta: n, client: r, edit: i, setEdit: a, hold:
9297
9334
  e.preventDefault(), d.save();
9298
9335
  return;
9299
9336
  }
9337
+ if (t && n === "a" && !e.altKey && !e.shiftKey) {
9338
+ e.preventDefault(), Ye({
9339
+ ar: 0,
9340
+ ac: 0,
9341
+ fr: Math.max(0, p.rows - 1),
9342
+ fc: Math.max(0, p.cols - 1)
9343
+ });
9344
+ return;
9345
+ }
9300
9346
  if (f && t && !e.altKey) {
9301
9347
  if (n === "z") {
9302
9348
  e.preventDefault(), e.shiftKey ? Wt() : Ut();
@@ -10567,4 +10613,4 @@ function Ca(e) {
10567
10613
  }
10568
10614
  export { ea as a, li as c, bn as d, ma as i, dr as l, _a as n, Ci as o, va as r, Si as s, Ca as t, lr as u };
10569
10615
 
10570
- //# sourceMappingURL=DocViewer-Co7q5D2H.js.map
10616
+ //# sourceMappingURL=DocViewer-CT8VAa1L.js.map