@silurus/ooxml 0.12.0 → 0.13.0
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 +13 -0
- package/dist/{docx-5SgqrF74.cjs → docx-BWxysGzi.cjs} +1 -1
- package/dist/{docx-BdQTKYcj.js → docx-I_31kSX9.js} +50 -25
- package/dist/docx.cjs +1 -1
- package/dist/docx.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{pptx-VEtxsakL.js → pptx-8AYrKKlD.js} +152 -88
- package/dist/pptx-D0uqcB_p.cjs +1 -0
- package/dist/pptx.cjs +1 -1
- package/dist/pptx.mjs +1 -1
- package/dist/types/docx.d.ts +35 -3
- package/dist/types/index.d.ts +140 -6
- package/dist/types/pptx.d.ts +43 -1
- package/dist/types/xlsx.d.ts +58 -4
- package/dist/{xlsx-BWBXfR7z.js → xlsx-B-twWw7w.js} +296 -6
- package/dist/{xlsx-eilavpD_.cjs → xlsx-B4rNAWcg.cjs} +2 -1
- package/dist/xlsx.cjs +1 -1
- package/dist/xlsx.mjs +1 -1
- package/package.json +1 -1
- package/dist/pptx-f3apnG_M.cjs +0 -1
|
@@ -100,7 +100,8 @@ async function m(e, t, n, r = {}) {
|
|
|
100
100
|
docGrid: {
|
|
101
101
|
type: i.docGridType ?? null,
|
|
102
102
|
linePitchPt: i.docGridLinePitch ?? null
|
|
103
|
-
}
|
|
103
|
+
},
|
|
104
|
+
onTextRun: r.onTextRun
|
|
104
105
|
}, v = y(e.headers, n, f, e.section.titlePage, e.section.evenAndOddHeaders);
|
|
105
106
|
v && b(v, i.headerDistance * s, _);
|
|
106
107
|
let S = y(e.footers, n, f, e.section.titlePage, e.section.evenAndOddHeaders);
|
|
@@ -294,23 +295,30 @@ function T(e, t, n = !1) {
|
|
|
294
295
|
}
|
|
295
296
|
let u = n;
|
|
296
297
|
if (!l) {
|
|
297
|
-
let e = K(u, i),
|
|
298
|
-
r.font = q(u.bold, u.italic, e, u.fontFamily), u.highlight && (r.fillStyle = c[u.highlight] ?? "#FFFF00", r.fillRect(b, p +
|
|
299
|
-
|
|
298
|
+
let e = K(u, i), n = u.vertAlign === "super" ? -u.fontSize * i * .35 : u.vertAlign === "sub" ? u.fontSize * i * .15 : 0;
|
|
299
|
+
r.font = q(u.bold, u.italic, e, u.fontFamily), u.highlight && (r.fillStyle = c[u.highlight] ?? "#FFFF00", r.fillRect(b, p + n - e * .85, u.measuredWidth, e * 1.1)), r.fillStyle = u.color ? `#${u.color}` : s, r.fillText(u.text, b, p + n), t.onTextRun && u.text && t.onTextRun({
|
|
300
|
+
text: u.text,
|
|
301
|
+
x: b,
|
|
302
|
+
y: t.y,
|
|
303
|
+
w: u.measuredWidth,
|
|
304
|
+
h: d,
|
|
305
|
+
fontSize: e
|
|
306
|
+
});
|
|
307
|
+
let a = u.color ? `#${u.color}` : s, o = Math.max(.5, e * .05), l = r.measureText(u.text).width;
|
|
300
308
|
if (u.underline) {
|
|
301
|
-
r.strokeStyle =
|
|
302
|
-
let
|
|
303
|
-
r.beginPath(), r.moveTo(b,
|
|
309
|
+
r.strokeStyle = a, r.lineWidth = o;
|
|
310
|
+
let t = p + n + e * .12;
|
|
311
|
+
r.beginPath(), r.moveTo(b, t), r.lineTo(b + l, t), r.stroke();
|
|
304
312
|
}
|
|
305
313
|
if (u.strikethrough) {
|
|
306
|
-
r.strokeStyle =
|
|
307
|
-
let
|
|
308
|
-
r.beginPath(), r.moveTo(b,
|
|
314
|
+
r.strokeStyle = a, r.lineWidth = o;
|
|
315
|
+
let t = p + n - e * .3;
|
|
316
|
+
r.beginPath(), r.moveTo(b, t), r.lineTo(b + l, t), r.stroke();
|
|
309
317
|
}
|
|
310
318
|
if (u.doubleStrikethrough) {
|
|
311
|
-
r.strokeStyle =
|
|
312
|
-
let
|
|
313
|
-
r.beginPath(), r.moveTo(b,
|
|
319
|
+
r.strokeStyle = a, r.lineWidth = o;
|
|
320
|
+
let t = p + n - e * .35, i = p + n - e * .22;
|
|
321
|
+
r.beginPath(), r.moveTo(b, t), r.lineTo(b + l, t), r.stroke(), r.beginPath(), r.moveTo(b, i), r.lineTo(b + l, i), r.stroke();
|
|
314
322
|
}
|
|
315
323
|
}
|
|
316
324
|
if (b += u.measuredWidth, D > 0 && !o) {
|
|
@@ -793,12 +801,16 @@ var Q = class e {
|
|
|
793
801
|
_doc = null;
|
|
794
802
|
_currentPage = 0;
|
|
795
803
|
_canvas;
|
|
804
|
+
_wrapper;
|
|
805
|
+
_textLayer = null;
|
|
796
806
|
_opts;
|
|
797
807
|
constructor(e, t = {}) {
|
|
798
808
|
this._canvas = e, this._opts = t;
|
|
809
|
+
let n = e.parentElement;
|
|
810
|
+
this._wrapper = document.createElement("div"), this._wrapper.style.cssText = "position:relative;display:inline-block;", n && n.insertBefore(this._wrapper, e), this._wrapper.appendChild(e), t.enableTextSelection && (this._textLayer = document.createElement("div"), this._textLayer.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;user-select:text;-webkit-user-select:text;", this._wrapper.appendChild(this._textLayer));
|
|
799
811
|
}
|
|
800
812
|
async load(e) {
|
|
801
|
-
this._doc = await Q.load(e), this._currentPage = 0, this._render();
|
|
813
|
+
this._doc = await Q.load(e), this._currentPage = 0, await this._render();
|
|
802
814
|
}
|
|
803
815
|
get pageCount() {
|
|
804
816
|
return this._doc?.pageCount ?? 0;
|
|
@@ -806,17 +818,30 @@ var Q = class e {
|
|
|
806
818
|
get currentPage() {
|
|
807
819
|
return this._currentPage;
|
|
808
820
|
}
|
|
809
|
-
goToPage(e) {
|
|
810
|
-
this._doc && (this._currentPage = Math.max(0, Math.min(e, this.pageCount - 1)), this._render());
|
|
811
|
-
}
|
|
812
|
-
nextPage() {
|
|
813
|
-
this.goToPage(this._currentPage + 1);
|
|
814
|
-
}
|
|
815
|
-
prevPage() {
|
|
816
|
-
this.goToPage(this._currentPage - 1);
|
|
817
|
-
}
|
|
818
|
-
_render() {
|
|
819
|
-
|
|
821
|
+
async goToPage(e) {
|
|
822
|
+
this._doc && (this._currentPage = Math.max(0, Math.min(e, this.pageCount - 1)), await this._render());
|
|
823
|
+
}
|
|
824
|
+
async nextPage() {
|
|
825
|
+
await this.goToPage(this._currentPage + 1);
|
|
826
|
+
}
|
|
827
|
+
async prevPage() {
|
|
828
|
+
await this.goToPage(this._currentPage - 1);
|
|
829
|
+
}
|
|
830
|
+
async _render() {
|
|
831
|
+
if (!this._doc) return;
|
|
832
|
+
let e = [], t = this._textLayer ? (t) => e.push(t) : void 0;
|
|
833
|
+
await this._doc.renderPage(this._canvas, this._currentPage, {
|
|
834
|
+
...this._opts,
|
|
835
|
+
onTextRun: t
|
|
836
|
+
}), this._textLayer && this._buildTextLayer(e);
|
|
837
|
+
}
|
|
838
|
+
_buildTextLayer(e) {
|
|
839
|
+
let t = this._textLayer;
|
|
840
|
+
t.innerHTML = "", t.style.width = `${this._canvas.style.width || this._canvas.width + "px"}`, t.style.height = `${this._canvas.style.height || this._canvas.height + "px"}`;
|
|
841
|
+
for (let n of e) {
|
|
842
|
+
let e = document.createElement("span");
|
|
843
|
+
e.textContent = n.text, e.style.cssText = `position:absolute;left:${n.x}px;top:${n.y}px;font-size:${n.fontSize}px;line-height:${n.h}px;white-space:pre;color:transparent;cursor:text;pointer-events:all;`, t.appendChild(e);
|
|
844
|
+
}
|
|
820
845
|
}
|
|
821
846
|
}, re = /* @__PURE__ */ e({
|
|
822
847
|
DocxDocument: () => Q,
|
package/dist/docx.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./autoResize-ggn4hzd8.cjs`),t=require(`./docx-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./autoResize-ggn4hzd8.cjs`),t=require(`./docx-BWxysGzi.cjs`);exports.DocxDocument=t.r,exports.DocxViewer=t.n,exports.autoResize=e.t;
|
package/dist/docx.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./pptx-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./pptx-D0uqcB_p.cjs`),t=require(`./xlsx-B4rNAWcg.cjs`),n=require(`./docx-BWxysGzi.cjs`);Object.defineProperty(exports,`docx`,{enumerable:!0,get:function(){return n.t}}),Object.defineProperty(exports,`pptx`,{enumerable:!0,get:function(){return e.t}}),Object.defineProperty(exports,`xlsx`,{enumerable:!0,get:function(){return t.t}});
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./pptx-
|
|
2
|
-
import { t } from "./xlsx-
|
|
3
|
-
import { t as n } from "./docx-
|
|
1
|
+
import { t as e } from "./pptx-8AYrKKlD.js";
|
|
2
|
+
import { t } from "./xlsx-B-twWw7w.js";
|
|
3
|
+
import { t as n } from "./docx-I_31kSX9.js";
|
|
4
4
|
export { n as docx, e as pptx, t as xlsx };
|