oasis-editor 0.0.365 → 0.0.366

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.
@@ -10418,19 +10418,19 @@ while (n === s[++o] && n === s[++o] && n === s[++o] && n === s[++o] && n === s[+
10418
10418
  n && (n.instruction += r);
10419
10419
  };
10420
10420
  for (let p = 0; p < e.childNodes.length; p += 1) {
10421
- const c = e.childNodes[p];
10422
- if (c?.nodeType !== c.ELEMENT_NODE) continue;
10423
- const f = c;
10424
- if ("http://schemas.openxmlformats.org/officeDocument/2006/math" === f.namespaceURI && ("oMath" === f.localName || "oMathPara" === f.localName)) {
10421
+ const f = e.childNodes[p];
10422
+ if (f?.nodeType !== f.ELEMENT_NODE) continue;
10423
+ const h = f;
10424
+ if ("http://schemas.openxmlformats.org/officeDocument/2006/math" === h.namespaceURI && ("oMath" === h.localName || "oMathPara" === h.localName)) {
10425
10425
  l.push({
10426
10426
  text: "",
10427
- math: Or(f)
10427
+ math: Or(h)
10428
10428
  });
10429
10429
  continue;
10430
10430
  }
10431
- if ("http://schemas.openxmlformats.org/wordprocessingml/2006/main" !== f.namespaceURI) continue;
10432
- if ("bookmarkStart" === f.localName || "bookmarkEnd" === f.localName) {
10433
- const e = un(f);
10431
+ if ("http://schemas.openxmlformats.org/wordprocessingml/2006/main" !== h.namespaceURI) continue;
10432
+ if ("bookmarkStart" === h.localName || "bookmarkEnd" === h.localName) {
10433
+ const e = un(h);
10434
10434
  if (!e) continue;
10435
10435
  l.push({
10436
10436
  text: "",
@@ -10438,8 +10438,8 @@ while (n === s[++o] && n === s[++o] && n === s[++o] && n === s[++o] && n === s[+
10438
10438
  });
10439
10439
  continue;
10440
10440
  }
10441
- if ("commentRangeStart" === f.localName || "commentRangeEnd" === f.localName) {
10442
- const e = dn(f);
10441
+ if ("commentRangeStart" === h.localName || "commentRangeEnd" === h.localName) {
10442
+ const e = dn(h);
10443
10443
  if (!e) continue;
10444
10444
  l.push({
10445
10445
  text: "",
@@ -10447,27 +10447,27 @@ while (n === s[++o] && n === s[++o] && n === s[++o] && n === s[++o] && n === s[+
10447
10447
  });
10448
10448
  continue;
10449
10449
  }
10450
- const h = hn(f);
10451
- if (h) {
10450
+ const m = hn(h);
10451
+ if (m) {
10452
10452
  l.push({
10453
10453
  text: "",
10454
- revisionRangeMarker: h
10454
+ revisionRangeMarker: m
10455
10455
  });
10456
10456
  continue;
10457
10457
  }
10458
- const m = fn(f);
10459
- if (m) {
10460
- const e = await gn(f, t, r, n, o, i, a, s);
10458
+ const g = fn(h);
10459
+ if (g) {
10460
+ const e = await gn(h, t, r, n, o, i, a, s);
10461
10461
  for (const t of e) l.push({
10462
10462
  ...t,
10463
- revision: t.revision ?? m
10463
+ revision: t.revision ?? g
10464
10464
  });
10465
10465
  continue;
10466
10466
  }
10467
- if ("sdt" === f.localName) {
10468
- const e = De(f, Ne, "sdtContent");
10467
+ if ("sdt" === h.localName) {
10468
+ const e = De(h, Ne, "sdtContent");
10469
10469
  if (!e) continue;
10470
- const c = De(f, Ne, "sdtPr"), u = De(f, Ne, "sdtEndPr"), d = {
10470
+ const c = De(h, Ne, "sdtPr"), u = De(h, Ne, "sdtEndPr"), d = {
10471
10471
  groupId: v("sdt"),
10472
10472
  sdtPr: Ur(c),
10473
10473
  ...u ? { sdtEndPrXml: new b.XMLSerializer().serializeToString(u) } : {}
@@ -10478,33 +10478,76 @@ while (n === s[++o] && n === s[++o] && n === s[++o] && n === s[++o] && n === s[+
10478
10478
  });
10479
10479
  continue;
10480
10480
  }
10481
- if ("r" === f.localName) {
10482
- const e = Ct(De(f, Ne, "rPr"), i), t = Array.from(f.childNodes).filter((e) => 1 === e.nodeType && !("http://schemas.openxmlformats.org/wordprocessingml/2006/main" === e.namespaceURI && "rPr" === e.localName));
10483
- if (1 === t.length) {
10484
- const r = Tr(t[0]);
10485
- if (r) {
10486
- l.push({
10487
- text: "",
10488
- opaque: r,
10489
- ...e ? { styles: e } : {}
10490
- });
10491
- continue;
10481
+ if ("r" === h.localName) {
10482
+ const e = Ct(De(h, Ne, "rPr"), i), t = Array.from(h.childNodes).filter((e) => 1 === e.nodeType && !("http://schemas.openxmlformats.org/wordprocessingml/2006/main" === e.namespaceURI && "rPr" === e.localName)), p = t.map((e) => ({
10483
+ child: e,
10484
+ opaque: Tr(e)
10485
+ })), f = (e) => "http://schemas.openxmlformats.org/wordprocessingml/2006/main" === e.namespaceURI && [
10486
+ "t",
10487
+ "delText",
10488
+ "tab",
10489
+ "noBreakHyphen",
10490
+ "softHyphen",
10491
+ "br",
10492
+ "cr",
10493
+ "lastRenderedPageBreak"
10494
+ ].includes(e.localName ?? "");
10495
+ if (p.some((e) => e.opaque) && (1 === t.length || !c.length && p.every((e) => e.opaque || f(e.child)))) {
10496
+ let t = "";
10497
+ const r = a ? {
10498
+ ...e,
10499
+ link: a
10500
+ } : e, n = () => {
10501
+ t.length && (l.push({
10502
+ text: t,
10503
+ ...r ? { styles: { ...r } } : {}
10504
+ }), t = "");
10505
+ };
10506
+ for (const { child: e, opaque: o } of p) if (o) n(), l.push({
10507
+ text: "",
10508
+ opaque: o,
10509
+ ...r ? { styles: { ...r } } : {}
10510
+ });
10511
+ else switch (e.localName) {
10512
+ case "t":
10513
+ case "delText":
10514
+ t += e.textContent ?? "";
10515
+ break;
10516
+ case "tab":
10517
+ t += " ";
10518
+ break;
10519
+ case "noBreakHyphen":
10520
+ t += "‑";
10521
+ break;
10522
+ case "softHyphen":
10523
+ t += "­";
10524
+ break;
10525
+ case "cr":
10526
+ t += "\n";
10527
+ break;
10528
+ case "br": {
10529
+ const r = Fe(e, "type");
10530
+ t += "page" === r ? "\f" : "column" === r ? "\v" : "\n";
10531
+ break;
10532
+ }
10492
10533
  }
10534
+ n();
10535
+ continue;
10493
10536
  }
10494
- if (Ae(f, "http://schemas.openxmlformats.org/wordprocessingml/2006/main", "fldChar").length > 0 || Ae(f, "http://schemas.openxmlformats.org/wordprocessingml/2006/main", "instrText").length > 0 || Ae(f, "http://schemas.openxmlformats.org/wordprocessingml/2006/main", "delInstrText").length > 0) {
10495
- for (let t = 0; t < f.childNodes.length; t += 1) {
10496
- const r = f.childNodes[t];
10537
+ if (Ae(h, "http://schemas.openxmlformats.org/wordprocessingml/2006/main", "fldChar").length > 0 || Ae(h, "http://schemas.openxmlformats.org/wordprocessingml/2006/main", "instrText").length > 0 || Ae(h, "http://schemas.openxmlformats.org/wordprocessingml/2006/main", "delInstrText").length > 0) {
10538
+ for (let t = 0; t < h.childNodes.length; t += 1) {
10539
+ const r = h.childNodes[t];
10497
10540
  if (r?.nodeType !== r.ELEMENT_NODE) continue;
10498
10541
  const n = r;
10499
10542
  "http://schemas.openxmlformats.org/wordprocessingml/2006/main" === n.namespaceURI && ("fldChar" === n.localName ? u(n, e) : "instrText" !== n.localName && "delInstrText" !== n.localName || d(n, e));
10500
10543
  }
10501
10544
  continue;
10502
10545
  }
10503
- const c = De(f, Ne, "footnoteReference");
10504
- if (c) {
10505
- const t = Fe(c, "id");
10546
+ const m = De(h, Ne, "footnoteReference");
10547
+ if (m) {
10548
+ const t = Fe(m, "id");
10506
10549
  if (!t) continue;
10507
- const r = Fe(c, "customMarkFollows");
10550
+ const r = Fe(m, "customMarkFollows");
10508
10551
  let n = e;
10509
10552
  (n ??= {}).styleId ??= "footnoteReference", void 0 === n.superscript && (n.superscript = !0), l.push({
10510
10553
  text: "?",
@@ -10516,11 +10559,11 @@ while (n === s[++o] && n === s[++o] && n === s[++o] && n === s[++o] && n === s[+
10516
10559
  });
10517
10560
  continue;
10518
10561
  }
10519
- const p = De(f, Ne, "endnoteReference");
10520
- if (p) {
10521
- const t = Fe(p, "id");
10562
+ const g = De(h, Ne, "endnoteReference");
10563
+ if (g) {
10564
+ const t = Fe(g, "id");
10522
10565
  if (!t) continue;
10523
- const r = Fe(p, "customMarkFollows");
10566
+ const r = Fe(g, "customMarkFollows");
10524
10567
  let n = e;
10525
10568
  (n ??= {}).styleId ??= "endnoteReference", void 0 === n.superscript && (n.superscript = !0), l.push({
10526
10569
  text: "?",
@@ -10532,61 +10575,61 @@ while (n === s[++o] && n === s[++o] && n === s[++o] && n === s[++o] && n === s[+
10532
10575
  });
10533
10576
  continue;
10534
10577
  }
10535
- const { text: h, image: m, textBox: g, innerBookmarks: w, innerComments: b, sym: v } = await mn(f, r, n, o, s);
10536
- let y = e;
10537
- v && !y?.fontFamily && ((y ??= {}).fontFamily = v.font), a && ((y ??= {}).link = a);
10538
- const x = [...(w ?? []).map((e) => ({
10578
+ const { text: w, image: b, textBox: v, innerBookmarks: y, innerComments: x, sym: E } = await mn(h, r, n, o, s);
10579
+ let S = e;
10580
+ E && !S?.fontFamily && ((S ??= {}).fontFamily = E.font), a && ((S ??= {}).link = a);
10581
+ const N = [...(y ?? []).map((e) => ({
10539
10582
  offset: e.offset,
10540
10583
  run: {
10541
10584
  text: "",
10542
10585
  bookmark: e.marker
10543
10586
  }
10544
- })), ...(b ?? []).map((e) => ({
10587
+ })), ...(x ?? []).map((e) => ({
10545
10588
  offset: e.offset,
10546
10589
  run: {
10547
10590
  text: "",
10548
10591
  comment: e.marker
10549
10592
  }
10550
10593
  }))];
10551
- if (x.length > 0 && !m && !g) {
10552
- x.sort((e, t) => e.offset - t.offset);
10594
+ if (N.length > 0 && !b && !v) {
10595
+ N.sort((e, t) => e.offset - t.offset);
10553
10596
  let e = 0;
10554
- for (const r of x) {
10555
- const t = h.slice(e, r.offset);
10597
+ for (const r of N) {
10598
+ const t = w.slice(e, r.offset);
10556
10599
  t.length > 0 && l.push({
10557
10600
  text: t,
10558
- ...y ? { styles: y } : {}
10601
+ ...S ? { styles: S } : {}
10559
10602
  }), l.push(r.run), e = r.offset;
10560
10603
  }
10561
- const t = h.slice(e);
10604
+ const t = w.slice(e);
10562
10605
  t.length > 0 && l.push({
10563
10606
  text: t,
10564
- ...y ? { styles: y } : {}
10607
+ ...S ? { styles: S } : {}
10565
10608
  });
10566
10609
  continue;
10567
10610
  }
10568
- if (0 === h.length && !m && !g) continue;
10611
+ if (0 === w.length && !b && !v) continue;
10569
10612
  if (l.push({
10570
- text: h,
10571
- ...m ? { image: m } : {},
10572
- ...g ? { textBox: g } : {},
10573
- ...v ? { sym: v } : {},
10574
- ...y ? { styles: y } : {}
10575
- }), w) for (const r of w) l.push({
10613
+ text: w,
10614
+ ...b ? { image: b } : {},
10615
+ ...v ? { textBox: v } : {},
10616
+ ...E ? { sym: E } : {},
10617
+ ...S ? { styles: S } : {}
10618
+ }), y) for (const r of y) l.push({
10576
10619
  text: "",
10577
10620
  bookmark: r.marker
10578
10621
  });
10579
10622
  continue;
10580
10623
  }
10581
- if ("fldSimple" === f.localName) {
10582
- const e = f.getAttribute("w:instr") ?? f.getAttributeNS("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "instr") ?? f.getAttribute("instr") ?? "", c = /\bNUMPAGES\b/i.test(e) ? "NUMPAGES" : /\bPAGE\b/i.test(e) ? "PAGE" : /\bDATE\b/i.test(e) ? "DATE" : /\bREF\b/i.test(e) ? "REF" : /\bPAGEREF\b/i.test(e) ? "PAGEREF" : null, u = /\*\s*([A-Za-z]+)/.exec(e)?.[1], d = Cr(u), p = "DATE" === c ? /@\s*"([^"]*)"/.exec(e)?.[1] : void 0, h = "REF" === c || "PAGEREF" === c ? cn(e) : void 0, m = await gn(f, t, r, n, o, i, a, s);
10624
+ if ("fldSimple" === h.localName) {
10625
+ const e = h.getAttribute("w:instr") ?? h.getAttributeNS("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "instr") ?? h.getAttribute("instr") ?? "", c = /\bNUMPAGES\b/i.test(e) ? "NUMPAGES" : /\bPAGE\b/i.test(e) ? "PAGE" : /\bDATE\b/i.test(e) ? "DATE" : /\bREF\b/i.test(e) ? "REF" : /\bPAGEREF\b/i.test(e) ? "PAGEREF" : null, u = /\*\s*([A-Za-z]+)/.exec(e)?.[1], d = Cr(u), p = "DATE" === c ? /@\s*"([^"]*)"/.exec(e)?.[1] : void 0, f = "REF" === c || "PAGEREF" === c ? cn(e) : void 0, m = await gn(h, t, r, n, o, i, a, s);
10583
10626
  if (c) {
10584
10627
  const e = m.map((e) => e.text).join("") || "1", t = m.find((e) => e.styles)?.styles, r = "DATE" === c ? p ? {
10585
10628
  type: "DATE",
10586
10629
  dateFormat: p
10587
10630
  } : { type: "DATE" } : "REF" === c || "PAGEREF" === c ? {
10588
10631
  type: c,
10589
- bookmark: h
10632
+ bookmark: f
10590
10633
  } : d ? {
10591
10634
  type: c,
10592
10635
  format: d
@@ -10611,13 +10654,13 @@ while (n === s[++o] && n === s[++o] && n === s[++o] && n === s[++o] && n === s[+
10611
10654
  });
10612
10655
  continue;
10613
10656
  }
10614
- if ("hyperlink" === f.localName) {
10615
- let e = n.get(f.getAttribute("r:id") ?? f.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "id") ?? "") ?? null;
10657
+ if ("hyperlink" === h.localName) {
10658
+ let e = n.get(h.getAttribute("r:id") ?? h.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "id") ?? "") ?? null;
10616
10659
  if (!e) {
10617
- const t = Fe(f, "anchor");
10660
+ const t = Fe(h, "anchor");
10618
10661
  t && (e = `#${t}`);
10619
10662
  }
10620
- l.push(...await gn(f, t, r, n, o, i, e, s));
10663
+ l.push(...await gn(h, t, r, n, o, i, e, s));
10621
10664
  }
10622
10665
  }
10623
10666
  return l;
@@ -10773,7 +10816,7 @@ while (n === s[++o] && n === s[++o] && n === s[++o] && n === s[++o] && n === s[+
10773
10816
  }
10774
10817
  };
10775
10818
  return n(e), r;
10776
- }(e, n), c = l.length === r.length ? l : void 0;
10819
+ }(e, n), c = r.some((e) => e.opaque) || l.length !== r.length ? void 0 : l;
10777
10820
  if (a || o || s || c) return {
10778
10821
  ...a ? { xml: a } : {},
10779
10822
  ...o ? { attributes: o } : {},