markloom 0.6.0 → 0.7.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/collab.md +25 -13
- package/dist/ai/index.cjs +5 -4
- package/dist/ai/index.d.cts +5 -5
- package/dist/ai/index.d.ts +5 -5
- package/dist/ai/index.js +4 -3
- package/dist/{chunk-KYZJIOOL.js → chunk-4Q7PAR2T.js} +3671 -904
- package/dist/chunk-75EJ4ARB.cjs +642 -0
- package/dist/{chunk-U3JZDFL4.cjs → chunk-BMPCVT3B.cjs} +2 -34
- package/dist/{chunk-VSBIMMI7.js → chunk-EFYT2223.js} +3 -35
- package/dist/chunk-HXABDVLZ.cjs +297 -0
- package/dist/{chunk-I5VK4U7J.cjs → chunk-I2LDEVLA.cjs} +434 -80
- package/dist/{chunk-YBAT343I.js → chunk-MQLRZQZL.js} +263 -119
- package/dist/chunk-OVHASRID.cjs +4279 -0
- package/dist/chunk-PCSVBPOR.cjs +40 -0
- package/dist/{chunk-TB2OY3D4.js → chunk-PSAXWBNM.js} +413 -59
- package/dist/{chunk-QEVME6ZU.cjs → chunk-PZRWTLLB.cjs} +260 -161
- package/dist/chunk-QO7JEZDB.js +4279 -0
- package/dist/{chunk-EJSFZHGT.js → chunk-WSJUXPAG.js} +18 -2
- package/dist/{chunk-ACFYBYZJ.cjs → chunk-Y4IXQFWL.cjs} +4212 -1445
- package/dist/{chunk-CGYCJORO.js → chunk-YLVSMDIO.js} +220 -121
- package/dist/chunk-ZL6WT6OY.js +297 -0
- package/dist/{client-CLYq17SW.d.ts → client-BvvyHjhh.d.ts} +57 -7
- package/dist/{client-DAth8pPq.d.cts → client-Ciy7Fa_k.d.cts} +57 -7
- package/dist/collab/index.cjs +5 -4
- package/dist/collab/index.d.cts +13 -15
- package/dist/collab/index.d.ts +13 -15
- package/dist/collab/index.js +4 -3
- package/dist/{controller-BIOO_XKJ.d.cts → controller-CHznEhAR.d.cts} +186 -27
- package/dist/{controller-6AJ36G52.d.ts → controller-DLqI8_jm.d.ts} +186 -27
- package/dist/index.cjs +69 -7
- package/dist/index.d.cts +127 -8
- package/dist/index.d.ts +127 -8
- package/dist/index.js +80 -18
- package/dist/io/index.cjs +58 -59
- package/dist/io/index.d.cts +1 -1
- package/dist/io/index.d.ts +1 -1
- package/dist/io/index.js +15 -16
- package/dist/react/index.cjs +9 -8
- package/dist/react/index.d.cts +5 -5
- package/dist/react/index.d.ts +5 -5
- package/dist/react/index.js +8 -7
- package/dist/{rebase-batch-DlerAcFN.d.ts → rebase-batch-CSnv8FKp.d.ts} +1 -1
- package/dist/{rebase-batch-PjENQ742.d.cts → rebase-batch-DO1ygkx9.d.cts} +1 -1
- package/dist/{types-COUweEav.d.cts → types-BkHlmUFL.d.cts} +5 -1
- package/dist/{types-COUweEav.d.ts → types-BkHlmUFL.d.ts} +5 -1
- package/dist/{versions-9mG1epfB.d.cts → versions-DNFf8zVz.d.cts} +1 -1
- package/dist/{versions-Bubyo4pt.d.ts → versions-DOkOyh2J.d.ts} +1 -1
- package/dist/view/index.cjs +215 -17
- package/dist/view/index.d.cts +82 -9
- package/dist/view/index.d.ts +82 -9
- package/dist/view/index.js +212 -14
- package/dist/view/theme.css +349 -75
- package/dist/{suggest-Bk4zLzuv.d.ts → word-count-BPw9G2Bg.d.ts} +15 -5
- package/dist/{suggest-BkGGiPKA.d.cts → word-count-DNLn1h_t.d.cts} +15 -5
- package/package.json +11 -6
- package/dist/chunk-EADZKEU4.cjs +0 -498
- package/dist/chunk-SNFF6X45.js +0 -2347
- package/dist/chunk-TWD5T4YC.cjs +0 -2347
- package/dist/chunk-ZKQSQSSM.cjs +0 -24
package/dist/io/index.cjs
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkPCSVBPORcjs = require('../chunk-PCSVBPOR.cjs');
|
|
7
9
|
|
|
8
10
|
// src/io/media.ts
|
|
9
11
|
var MIME = {
|
|
@@ -660,6 +662,8 @@ function runXml(text, marks) {
|
|
|
660
662
|
rPr.push('<w:rFonts w:ascii="Courier New" w:hAnsi="Courier New"/>');
|
|
661
663
|
else if (m.name === "highlight")
|
|
662
664
|
rPr.push('<w:highlight w:val="yellow"/>');
|
|
665
|
+
else if (m.name === "superscript")
|
|
666
|
+
rPr.push('<w:vertAlign w:val="superscript"/>');
|
|
663
667
|
else if (m.name === "link" && _optionalChain([m, 'access', _3 => _3.attrs, 'optionalAccess', _4 => _4.url]))
|
|
664
668
|
rPr.push(`<!-- link ${esc(String(m.attrs.url))} -->`);
|
|
665
669
|
}
|
|
@@ -673,15 +677,17 @@ function runXml(text, marks) {
|
|
|
673
677
|
function inlineXml(nodes) {
|
|
674
678
|
let o = "";
|
|
675
679
|
for (const n of nodes) {
|
|
676
|
-
if (
|
|
680
|
+
if (_chunkPCSVBPORcjs.isText.call(void 0, n))
|
|
677
681
|
o += runXml(n.text, n.marks);
|
|
678
|
-
else if (
|
|
682
|
+
else if (_chunkPCSVBPORcjs.isInlineAtom.call(void 0, n)) {
|
|
679
683
|
if (n.type === "hard_break")
|
|
680
684
|
o += "<w:r><w:br/></w:r>";
|
|
681
685
|
else if (n.type === "mention")
|
|
682
686
|
o += runXml(`@${String(_nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access', _5 => _5.attrs, 'optionalAccess', _6 => _6.label]), () => ( _optionalChain([n, 'access', _7 => _7.attrs, 'optionalAccess', _8 => _8.id]))), () => ( "")))}`);
|
|
683
687
|
else if (n.type === "math")
|
|
684
688
|
o += runXml(String(_nullishCoalesce(_optionalChain([n, 'access', _9 => _9.attrs, 'optionalAccess', _10 => _10.latex]), () => ( ""))));
|
|
689
|
+
else if (n.type === "footnote_ref")
|
|
690
|
+
o += runXml(String(_nullishCoalesce(_optionalChain([n, 'access', _11 => _11.attrs, 'optionalAccess', _12 => _12.label]), () => ( ""))), [{ name: "superscript" }]);
|
|
685
691
|
}
|
|
686
692
|
}
|
|
687
693
|
return o;
|
|
@@ -764,30 +770,28 @@ function docToDocx(doc) {
|
|
|
764
770
|
function block(n) {
|
|
765
771
|
switch (n.type) {
|
|
766
772
|
case "heading": {
|
|
767
|
-
const d = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([n, 'access',
|
|
773
|
+
const d = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([n, 'access', _13 => _13.attrs, 'optionalAccess', _14 => _14.depth]), () => ( 1))), 1), 6);
|
|
768
774
|
return paraXml(n.children, `Heading${d}`);
|
|
769
775
|
}
|
|
770
776
|
case "paragraph":
|
|
771
777
|
return paraXml(n.children);
|
|
772
|
-
case "quote":
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
const v = String(_nullishCoalesce(_optionalChain([n, 'access', _13 => _13.attrs, 'optionalAccess', _14 => _14.variant]), () => ( "info")));
|
|
776
|
-
return paraXml([{ text: `[${v}]` }]) + n.children.map((c) => _chunkZKQSQSSMcjs.isElement.call(void 0, c) ? block(c) : "").join("");
|
|
778
|
+
case "quote": {
|
|
779
|
+
const prefix = _chunkPCSVBPORcjs.isCallout.call(void 0, n) ? paraXml([{ text: `[${_nullishCoalesce(_optionalChain([n, 'access', _15 => _15.attrs, 'optionalAccess', _16 => _16.variant]), () => ( "info"))}]` }]) : _chunkPCSVBPORcjs.isFootnoteDef.call(void 0, n) ? paraXml([{ text: `[${_nullishCoalesce(_optionalChain([n, 'access', _17 => _17.attrs, 'optionalAccess', _18 => _18.footnote]), () => ( ""))}]` }]) : "";
|
|
780
|
+
return prefix + (n.children.map((c) => _chunkPCSVBPORcjs.isElement.call(void 0, c) ? block(c) : "").join("") || paraXml([{ text: "" }]));
|
|
777
781
|
}
|
|
778
782
|
case "code": {
|
|
779
|
-
const text = n.children.map((c) =>
|
|
783
|
+
const text = n.children.map((c) => _chunkPCSVBPORcjs.isText.call(void 0, c) ? c.text : "").join("");
|
|
780
784
|
return text.split("\n").map(
|
|
781
785
|
(line) => `<w:p><w:pPr><w:pStyle w:val="NoSpacing"/></w:pPr>${runXml(line || " ", [{ name: "code" }])}</w:p>`
|
|
782
786
|
).join("");
|
|
783
787
|
}
|
|
784
788
|
case "list": {
|
|
785
|
-
const ordered = !!_optionalChain([n, 'access',
|
|
789
|
+
const ordered = !!_optionalChain([n, 'access', _19 => _19.attrs, 'optionalAccess', _20 => _20.ordered]);
|
|
786
790
|
return n.children.map((item, i) => {
|
|
787
|
-
if (!
|
|
791
|
+
if (!_chunkPCSVBPORcjs.isElement.call(void 0, item) || item.type !== "list_item")
|
|
788
792
|
return "";
|
|
789
793
|
const prefix = ordered ? `${i + 1}. ` : "\u2022 ";
|
|
790
|
-
const paras = item.children.filter(
|
|
794
|
+
const paras = item.children.filter(_chunkPCSVBPORcjs.isElement);
|
|
791
795
|
if (!paras.length)
|
|
792
796
|
return paraXml([{ text: prefix }]);
|
|
793
797
|
return paras.map((p, pi) => {
|
|
@@ -797,17 +801,17 @@ function docToDocx(doc) {
|
|
|
797
801
|
}).join("");
|
|
798
802
|
}
|
|
799
803
|
case "table": {
|
|
800
|
-
const rows = Number(_nullishCoalesce(_optionalChain([n, 'access',
|
|
801
|
-
const cols = Number(_nullishCoalesce(_optionalChain([n, 'access',
|
|
804
|
+
const rows = Number(_nullishCoalesce(_optionalChain([n, 'access', _21 => _21.attrs, 'optionalAccess', _22 => _22.rows]), () => ( 0)));
|
|
805
|
+
const cols = Number(_nullishCoalesce(_optionalChain([n, 'access', _23 => _23.attrs, 'optionalAccess', _24 => _24.cols]), () => ( 0)));
|
|
802
806
|
if (!rows || !cols)
|
|
803
807
|
return "";
|
|
804
|
-
const cells = n.children.filter(
|
|
808
|
+
const cells = n.children.filter(_chunkPCSVBPORcjs.isElement);
|
|
805
809
|
let xml = '<w:tbl><w:tblPr><w:tblW w:w="0" w:type="auto"/></w:tblPr>';
|
|
806
810
|
for (let r = 0; r < rows; r++) {
|
|
807
811
|
xml += "<w:tr>";
|
|
808
812
|
for (let c = 0; c < cols; c++) {
|
|
809
813
|
const cell = cells[r * cols + c];
|
|
810
|
-
const inner = cell &&
|
|
814
|
+
const inner = cell && _chunkPCSVBPORcjs.isElement.call(void 0, cell) ? cell.children.map((ch) => _chunkPCSVBPORcjs.isElement.call(void 0, ch) ? block(ch) : "").join("") || paraXml([{ text: "" }]) : paraXml([{ text: "" }]);
|
|
811
815
|
xml += `<w:tc><w:tcPr><w:tcW w:w="2000" w:type="dxa"/></w:tcPr>${inner}</w:tc>`;
|
|
812
816
|
}
|
|
813
817
|
xml += "</w:tr>";
|
|
@@ -815,10 +819,10 @@ function docToDocx(doc) {
|
|
|
815
819
|
return xml + "</w:tbl>";
|
|
816
820
|
}
|
|
817
821
|
case "image": {
|
|
818
|
-
const url = String(_nullishCoalesce(_optionalChain([n, 'access',
|
|
819
|
-
const alt = String(_nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access',
|
|
820
|
-
const w = _optionalChain([n, 'access',
|
|
821
|
-
const h = _optionalChain([n, 'access',
|
|
822
|
+
const url = String(_nullishCoalesce(_optionalChain([n, 'access', _25 => _25.attrs, 'optionalAccess', _26 => _26.url]), () => ( "")));
|
|
823
|
+
const alt = String(_nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access', _27 => _27.attrs, 'optionalAccess', _28 => _28.alt]), () => ( _optionalChain([n, 'access', _29 => _29.attrs, 'optionalAccess', _30 => _30.caption]))), () => ( (url || "[image]"))));
|
|
824
|
+
const w = _optionalChain([n, 'access', _31 => _31.attrs, 'optionalAccess', _32 => _32.w]) != null ? Number(n.attrs.w) : void 0;
|
|
825
|
+
const h = _optionalChain([n, 'access', _33 => _33.attrs, 'optionalAccess', _34 => _34.h]) != null ? Number(n.attrs.h) : void 0;
|
|
822
826
|
if (url) {
|
|
823
827
|
const m = take(url, w, h);
|
|
824
828
|
if (m)
|
|
@@ -827,21 +831,23 @@ function docToDocx(doc) {
|
|
|
827
831
|
return paraXml([{ text: alt }]);
|
|
828
832
|
}
|
|
829
833
|
case "embed":
|
|
830
|
-
return paraXml([{ text: String(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access',
|
|
834
|
+
return paraXml([{ text: String(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access', _35 => _35.attrs, 'optionalAccess', _36 => _36.title]), () => ( _optionalChain([n, 'access', _37 => _37.attrs, 'optionalAccess', _38 => _38.name]))), () => ( _optionalChain([n, 'access', _39 => _39.attrs, 'optionalAccess', _40 => _40.src]))), () => ( "[embed]"))) }]);
|
|
831
835
|
case "raw":
|
|
832
|
-
|
|
836
|
+
if (_optionalChain([n, 'access', _41 => _41.attrs, 'optionalAccess', _42 => _42.mdType]) === "frontmatter")
|
|
837
|
+
return "";
|
|
838
|
+
return paraXml([{ text: n.children.map((c) => _chunkPCSVBPORcjs.isText.call(void 0, c) ? c.text : "").join("") }]);
|
|
833
839
|
default:
|
|
834
|
-
return _nullishCoalesce(_optionalChain([n, 'access',
|
|
840
|
+
return _nullishCoalesce(_optionalChain([n, 'access', _43 => _43.children, 'optionalAccess', _44 => _44.map, 'call', _45 => _45((c) => _chunkPCSVBPORcjs.isElement.call(void 0, c) ? block(c) : ""), 'access', _46 => _46.join, 'call', _47 => _47("")]), () => ( ""));
|
|
835
841
|
}
|
|
836
842
|
}
|
|
837
|
-
const body = (_nullishCoalesce(doc.children, () => ( []))).map((c) =>
|
|
843
|
+
const body = (_nullishCoalesce(doc.children, () => ( []))).map((c) => _chunkPCSVBPORcjs.isElement.call(void 0, c) ? block(c) : "").join("");
|
|
838
844
|
return packEntries(wrapDoc(body), media);
|
|
839
845
|
}
|
|
840
846
|
async function docToDocxAsync(doc, opts) {
|
|
841
847
|
const media = [];
|
|
842
848
|
let nextId = 1;
|
|
843
849
|
const resolve = async (url) => {
|
|
844
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
850
|
+
if (_optionalChain([opts, 'optionalAccess', _48 => _48.resolveImage])) {
|
|
845
851
|
const r = await opts.resolveImage(url);
|
|
846
852
|
if (r)
|
|
847
853
|
return r;
|
|
@@ -885,43 +891,34 @@ async function docToDocxAsync(doc, opts) {
|
|
|
885
891
|
async function block(n) {
|
|
886
892
|
switch (n.type) {
|
|
887
893
|
case "heading": {
|
|
888
|
-
const d = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([n, 'access',
|
|
894
|
+
const d = Math.min(Math.max(Number(_nullishCoalesce(_optionalChain([n, 'access', _49 => _49.attrs, 'optionalAccess', _50 => _50.depth]), () => ( 1))), 1), 6);
|
|
889
895
|
return paraXml(n.children, `Heading${d}`);
|
|
890
896
|
}
|
|
891
897
|
case "paragraph":
|
|
892
898
|
return paraXml(n.children);
|
|
893
899
|
case "quote": {
|
|
894
|
-
const parts2 = [];
|
|
900
|
+
const parts2 = _chunkPCSVBPORcjs.isCallout.call(void 0, n) ? [paraXml([{ text: `[${_nullishCoalesce(_optionalChain([n, 'access', _51 => _51.attrs, 'optionalAccess', _52 => _52.variant]), () => ( "info"))}]` }])] : _chunkPCSVBPORcjs.isFootnoteDef.call(void 0, n) ? [paraXml([{ text: `[${_nullishCoalesce(_optionalChain([n, 'access', _53 => _53.attrs, 'optionalAccess', _54 => _54.footnote]), () => ( ""))}]` }])] : [];
|
|
895
901
|
for (const c of n.children) {
|
|
896
|
-
if (
|
|
902
|
+
if (_chunkPCSVBPORcjs.isElement.call(void 0, c))
|
|
897
903
|
parts2.push(await block(c));
|
|
898
904
|
}
|
|
899
905
|
return parts2.join("") || paraXml([{ text: "" }]);
|
|
900
906
|
}
|
|
901
|
-
case "callout": {
|
|
902
|
-
const v = String(_nullishCoalesce(_optionalChain([n, 'access', _45 => _45.attrs, 'optionalAccess', _46 => _46.variant]), () => ( "info")));
|
|
903
|
-
const parts2 = [paraXml([{ text: `[${v}]` }])];
|
|
904
|
-
for (const c of n.children) {
|
|
905
|
-
if (_chunkZKQSQSSMcjs.isElement.call(void 0, c))
|
|
906
|
-
parts2.push(await block(c));
|
|
907
|
-
}
|
|
908
|
-
return parts2.join("");
|
|
909
|
-
}
|
|
910
907
|
case "code": {
|
|
911
|
-
const text = n.children.map((c) =>
|
|
908
|
+
const text = n.children.map((c) => _chunkPCSVBPORcjs.isText.call(void 0, c) ? c.text : "").join("");
|
|
912
909
|
return text.split("\n").map(
|
|
913
910
|
(line) => `<w:p><w:pPr><w:pStyle w:val="NoSpacing"/></w:pPr>${runXml(line || " ", [{ name: "code" }])}</w:p>`
|
|
914
911
|
).join("");
|
|
915
912
|
}
|
|
916
913
|
case "list": {
|
|
917
|
-
const ordered = !!_optionalChain([n, 'access',
|
|
914
|
+
const ordered = !!_optionalChain([n, 'access', _55 => _55.attrs, 'optionalAccess', _56 => _56.ordered]);
|
|
918
915
|
const parts2 = [];
|
|
919
916
|
let i = 0;
|
|
920
917
|
for (const item of n.children) {
|
|
921
|
-
if (!
|
|
918
|
+
if (!_chunkPCSVBPORcjs.isElement.call(void 0, item) || item.type !== "list_item")
|
|
922
919
|
continue;
|
|
923
920
|
const prefix = ordered ? `${++i}. ` : "\u2022 ";
|
|
924
|
-
const paras = item.children.filter(
|
|
921
|
+
const paras = item.children.filter(_chunkPCSVBPORcjs.isElement);
|
|
925
922
|
if (!paras.length) {
|
|
926
923
|
parts2.push(paraXml([{ text: prefix }]));
|
|
927
924
|
continue;
|
|
@@ -935,20 +932,20 @@ async function docToDocxAsync(doc, opts) {
|
|
|
935
932
|
return parts2.join("");
|
|
936
933
|
}
|
|
937
934
|
case "table": {
|
|
938
|
-
const rows = Number(_nullishCoalesce(_optionalChain([n, 'access',
|
|
939
|
-
const cols = Number(_nullishCoalesce(_optionalChain([n, 'access',
|
|
935
|
+
const rows = Number(_nullishCoalesce(_optionalChain([n, 'access', _57 => _57.attrs, 'optionalAccess', _58 => _58.rows]), () => ( 0)));
|
|
936
|
+
const cols = Number(_nullishCoalesce(_optionalChain([n, 'access', _59 => _59.attrs, 'optionalAccess', _60 => _60.cols]), () => ( 0)));
|
|
940
937
|
if (!rows || !cols)
|
|
941
938
|
return "";
|
|
942
|
-
const cells = n.children.filter(
|
|
939
|
+
const cells = n.children.filter(_chunkPCSVBPORcjs.isElement);
|
|
943
940
|
let xml = '<w:tbl><w:tblPr><w:tblW w:w="0" w:type="auto"/></w:tblPr>';
|
|
944
941
|
for (let r = 0; r < rows; r++) {
|
|
945
942
|
xml += "<w:tr>";
|
|
946
943
|
for (let c = 0; c < cols; c++) {
|
|
947
944
|
const cell = cells[r * cols + c];
|
|
948
945
|
let inner = "";
|
|
949
|
-
if (cell &&
|
|
946
|
+
if (cell && _chunkPCSVBPORcjs.isElement.call(void 0, cell)) {
|
|
950
947
|
for (const ch of cell.children) {
|
|
951
|
-
if (
|
|
948
|
+
if (_chunkPCSVBPORcjs.isElement.call(void 0, ch))
|
|
952
949
|
inner += await block(ch);
|
|
953
950
|
}
|
|
954
951
|
}
|
|
@@ -961,10 +958,10 @@ async function docToDocxAsync(doc, opts) {
|
|
|
961
958
|
return xml + "</w:tbl>";
|
|
962
959
|
}
|
|
963
960
|
case "image": {
|
|
964
|
-
const url = String(_nullishCoalesce(_optionalChain([n, 'access',
|
|
965
|
-
const alt = String(_nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access',
|
|
966
|
-
const w = _optionalChain([n, 'access',
|
|
967
|
-
const h = _optionalChain([n, 'access',
|
|
961
|
+
const url = String(_nullishCoalesce(_optionalChain([n, 'access', _61 => _61.attrs, 'optionalAccess', _62 => _62.url]), () => ( "")));
|
|
962
|
+
const alt = String(_nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access', _63 => _63.attrs, 'optionalAccess', _64 => _64.alt]), () => ( _optionalChain([n, 'access', _65 => _65.attrs, 'optionalAccess', _66 => _66.caption]))), () => ( (url || "[image]"))));
|
|
963
|
+
const w = _optionalChain([n, 'access', _67 => _67.attrs, 'optionalAccess', _68 => _68.w]) != null ? Number(n.attrs.w) : void 0;
|
|
964
|
+
const h = _optionalChain([n, 'access', _69 => _69.attrs, 'optionalAccess', _70 => _70.h]) != null ? Number(n.attrs.h) : void 0;
|
|
968
965
|
if (url) {
|
|
969
966
|
const m = await take(url, w, h);
|
|
970
967
|
if (m)
|
|
@@ -973,15 +970,17 @@ async function docToDocxAsync(doc, opts) {
|
|
|
973
970
|
return paraXml([{ text: alt }]);
|
|
974
971
|
}
|
|
975
972
|
case "embed":
|
|
976
|
-
return paraXml([{ text: String(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access',
|
|
973
|
+
return paraXml([{ text: String(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access', _71 => _71.attrs, 'optionalAccess', _72 => _72.title]), () => ( _optionalChain([n, 'access', _73 => _73.attrs, 'optionalAccess', _74 => _74.name]))), () => ( _optionalChain([n, 'access', _75 => _75.attrs, 'optionalAccess', _76 => _76.src]))), () => ( "[embed]"))) }]);
|
|
977
974
|
case "raw":
|
|
978
|
-
|
|
975
|
+
if (_optionalChain([n, 'access', _77 => _77.attrs, 'optionalAccess', _78 => _78.mdType]) === "frontmatter")
|
|
976
|
+
return "";
|
|
977
|
+
return paraXml([{ text: n.children.map((c) => _chunkPCSVBPORcjs.isText.call(void 0, c) ? c.text : "").join("") }]);
|
|
979
978
|
default: {
|
|
980
|
-
if (!_optionalChain([n, 'access',
|
|
979
|
+
if (!_optionalChain([n, 'access', _79 => _79.children, 'optionalAccess', _80 => _80.length]))
|
|
981
980
|
return "";
|
|
982
981
|
const parts2 = [];
|
|
983
982
|
for (const c of n.children) {
|
|
984
|
-
if (
|
|
983
|
+
if (_chunkPCSVBPORcjs.isElement.call(void 0, c))
|
|
985
984
|
parts2.push(await block(c));
|
|
986
985
|
}
|
|
987
986
|
return parts2.join("");
|
|
@@ -990,7 +989,7 @@ async function docToDocxAsync(doc, opts) {
|
|
|
990
989
|
}
|
|
991
990
|
const parts = [];
|
|
992
991
|
for (const c of _nullishCoalesce(doc.children, () => ( []))) {
|
|
993
|
-
if (
|
|
992
|
+
if (_chunkPCSVBPORcjs.isElement.call(void 0, c))
|
|
994
993
|
parts.push(await block(c));
|
|
995
994
|
}
|
|
996
995
|
return packEntries(wrapDoc(parts.join("")), media);
|
|
@@ -1010,7 +1009,7 @@ async function docToDocxBlobAsync(doc, opts) {
|
|
|
1010
1009
|
function parseXml(xml) {
|
|
1011
1010
|
if (typeof DOMParser !== "undefined")
|
|
1012
1011
|
return new DOMParser().parseFromString(xml, "application/xml");
|
|
1013
|
-
const { DOMParser: X } =
|
|
1012
|
+
const { DOMParser: X } = _chunkPCSVBPORcjs.__require.call(void 0, "@xmldom/xmldom");
|
|
1014
1013
|
return new X().parseFromString(xml, "application/xml");
|
|
1015
1014
|
}
|
|
1016
1015
|
function childrenOf(el) {
|
|
@@ -1246,7 +1245,7 @@ function imagesFromP(p, ctx) {
|
|
|
1246
1245
|
for (const d of drawings) {
|
|
1247
1246
|
const blips = findDeep(d, "blip");
|
|
1248
1247
|
for (const blip of blips) {
|
|
1249
|
-
const rId = blip.getAttribute("r:embed") || _optionalChain([blip, 'access',
|
|
1248
|
+
const rId = blip.getAttribute("r:embed") || _optionalChain([blip, 'access', _81 => _81.getAttributeNS, 'optionalCall', _82 => _82("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "embed")]) || blip.getAttribute("embed") || "";
|
|
1250
1249
|
if (!rId)
|
|
1251
1250
|
continue;
|
|
1252
1251
|
const img = loadImage(ctx, rId);
|
|
@@ -1313,7 +1312,7 @@ function tableToBlock(tbl, ctx) {
|
|
|
1313
1312
|
if (b.type === "paragraph" || b.type === "heading")
|
|
1314
1313
|
kids.push(b.type === "heading" ? { type: "paragraph", children: b.children } : b);
|
|
1315
1314
|
else if (b.type === "image")
|
|
1316
|
-
kids.push({ type: "paragraph", children: [{ text: String(_nullishCoalesce(_optionalChain([b, 'access',
|
|
1315
|
+
kids.push({ type: "paragraph", children: [{ text: String(_nullishCoalesce(_optionalChain([b, 'access', _83 => _83.attrs, 'optionalAccess', _84 => _84.alt]), () => ( "[image]"))) }] });
|
|
1317
1316
|
}
|
|
1318
1317
|
}
|
|
1319
1318
|
cells.push({
|
package/dist/io/index.d.cts
CHANGED
package/dist/io/index.d.ts
CHANGED
package/dist/io/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__require,
|
|
3
|
+
isCallout,
|
|
3
4
|
isElement,
|
|
5
|
+
isFootnoteDef,
|
|
4
6
|
isInlineAtom,
|
|
5
7
|
isText
|
|
6
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-WSJUXPAG.js";
|
|
7
9
|
|
|
8
10
|
// src/io/media.ts
|
|
9
11
|
var MIME = {
|
|
@@ -660,6 +662,8 @@ function runXml(text, marks) {
|
|
|
660
662
|
rPr.push('<w:rFonts w:ascii="Courier New" w:hAnsi="Courier New"/>');
|
|
661
663
|
else if (m.name === "highlight")
|
|
662
664
|
rPr.push('<w:highlight w:val="yellow"/>');
|
|
665
|
+
else if (m.name === "superscript")
|
|
666
|
+
rPr.push('<w:vertAlign w:val="superscript"/>');
|
|
663
667
|
else if (m.name === "link" && m.attrs?.url)
|
|
664
668
|
rPr.push(`<!-- link ${esc(String(m.attrs.url))} -->`);
|
|
665
669
|
}
|
|
@@ -682,6 +686,8 @@ function inlineXml(nodes) {
|
|
|
682
686
|
o += runXml(`@${String(n.attrs?.label ?? n.attrs?.id ?? "")}`);
|
|
683
687
|
else if (n.type === "math")
|
|
684
688
|
o += runXml(String(n.attrs?.latex ?? ""));
|
|
689
|
+
else if (n.type === "footnote_ref")
|
|
690
|
+
o += runXml(String(n.attrs?.label ?? ""), [{ name: "superscript" }]);
|
|
685
691
|
}
|
|
686
692
|
}
|
|
687
693
|
return o;
|
|
@@ -769,11 +775,9 @@ function docToDocx(doc) {
|
|
|
769
775
|
}
|
|
770
776
|
case "paragraph":
|
|
771
777
|
return paraXml(n.children);
|
|
772
|
-
case "quote":
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
const v = String(n.attrs?.variant ?? "info");
|
|
776
|
-
return paraXml([{ text: `[${v}]` }]) + n.children.map((c) => isElement(c) ? block(c) : "").join("");
|
|
778
|
+
case "quote": {
|
|
779
|
+
const prefix = isCallout(n) ? paraXml([{ text: `[${n.attrs?.variant ?? "info"}]` }]) : isFootnoteDef(n) ? paraXml([{ text: `[${n.attrs?.footnote ?? ""}]` }]) : "";
|
|
780
|
+
return prefix + (n.children.map((c) => isElement(c) ? block(c) : "").join("") || paraXml([{ text: "" }]));
|
|
777
781
|
}
|
|
778
782
|
case "code": {
|
|
779
783
|
const text = n.children.map((c) => isText(c) ? c.text : "").join("");
|
|
@@ -829,6 +833,8 @@ function docToDocx(doc) {
|
|
|
829
833
|
case "embed":
|
|
830
834
|
return paraXml([{ text: String(n.attrs?.title ?? n.attrs?.name ?? n.attrs?.src ?? "[embed]") }]);
|
|
831
835
|
case "raw":
|
|
836
|
+
if (n.attrs?.mdType === "frontmatter")
|
|
837
|
+
return "";
|
|
832
838
|
return paraXml([{ text: n.children.map((c) => isText(c) ? c.text : "").join("") }]);
|
|
833
839
|
default:
|
|
834
840
|
return n.children?.map((c) => isElement(c) ? block(c) : "").join("") ?? "";
|
|
@@ -891,22 +897,13 @@ async function docToDocxAsync(doc, opts) {
|
|
|
891
897
|
case "paragraph":
|
|
892
898
|
return paraXml(n.children);
|
|
893
899
|
case "quote": {
|
|
894
|
-
const parts2 = [];
|
|
900
|
+
const parts2 = isCallout(n) ? [paraXml([{ text: `[${n.attrs?.variant ?? "info"}]` }])] : isFootnoteDef(n) ? [paraXml([{ text: `[${n.attrs?.footnote ?? ""}]` }])] : [];
|
|
895
901
|
for (const c of n.children) {
|
|
896
902
|
if (isElement(c))
|
|
897
903
|
parts2.push(await block(c));
|
|
898
904
|
}
|
|
899
905
|
return parts2.join("") || paraXml([{ text: "" }]);
|
|
900
906
|
}
|
|
901
|
-
case "callout": {
|
|
902
|
-
const v = String(n.attrs?.variant ?? "info");
|
|
903
|
-
const parts2 = [paraXml([{ text: `[${v}]` }])];
|
|
904
|
-
for (const c of n.children) {
|
|
905
|
-
if (isElement(c))
|
|
906
|
-
parts2.push(await block(c));
|
|
907
|
-
}
|
|
908
|
-
return parts2.join("");
|
|
909
|
-
}
|
|
910
907
|
case "code": {
|
|
911
908
|
const text = n.children.map((c) => isText(c) ? c.text : "").join("");
|
|
912
909
|
return text.split("\n").map(
|
|
@@ -975,6 +972,8 @@ async function docToDocxAsync(doc, opts) {
|
|
|
975
972
|
case "embed":
|
|
976
973
|
return paraXml([{ text: String(n.attrs?.title ?? n.attrs?.name ?? n.attrs?.src ?? "[embed]") }]);
|
|
977
974
|
case "raw":
|
|
975
|
+
if (n.attrs?.mdType === "frontmatter")
|
|
976
|
+
return "";
|
|
978
977
|
return paraXml([{ text: n.children.map((c) => isText(c) ? c.text : "").join("") }]);
|
|
979
978
|
default: {
|
|
980
979
|
if (!n.children?.length)
|
package/dist/react/index.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
6
|
-
require('../chunk-
|
|
7
|
-
require('../chunk-
|
|
8
|
-
require('../chunk-
|
|
9
|
-
require('../chunk-
|
|
3
|
+
var _chunkY4IXQFWLcjs = require('../chunk-Y4IXQFWL.cjs');
|
|
4
|
+
require('../chunk-PZRWTLLB.cjs');
|
|
5
|
+
require('../chunk-I2LDEVLA.cjs');
|
|
6
|
+
require('../chunk-OVHASRID.cjs');
|
|
7
|
+
require('../chunk-75EJ4ARB.cjs');
|
|
8
|
+
require('../chunk-BMPCVT3B.cjs');
|
|
9
|
+
require('../chunk-HXABDVLZ.cjs');
|
|
10
|
+
require('../chunk-PCSVBPOR.cjs');
|
|
10
11
|
|
|
11
12
|
// src/react/index.ts
|
|
12
13
|
var _react = require('react');
|
|
@@ -20,7 +21,7 @@ function useMarkloom(initialDoc, opts = {}) {
|
|
|
20
21
|
const host = ref.current;
|
|
21
22
|
if (!host)
|
|
22
23
|
return;
|
|
23
|
-
const ed = new (0,
|
|
24
|
+
const ed = new (0, _chunkY4IXQFWLcjs.Editor)(host, initialDoc, {
|
|
24
25
|
...optsRef.current,
|
|
25
26
|
onChange: (d) => {
|
|
26
27
|
setDoc(d);
|
package/dist/react/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { MutableRefObject } from 'react';
|
|
3
|
-
import { E as ElementNode } from '../types-
|
|
4
|
-
import { E as EditorOptions, k as Editor } from '../controller-
|
|
5
|
-
import '../versions-
|
|
3
|
+
import { E as ElementNode } from '../types-BkHlmUFL.cjs';
|
|
4
|
+
import { E as EditorOptions, k as Editor } from '../controller-CHznEhAR.cjs';
|
|
5
|
+
import '../versions-DNFf8zVz.cjs';
|
|
6
6
|
import 'preact';
|
|
7
|
-
import '../
|
|
8
|
-
import '../client-
|
|
7
|
+
import '../word-count-DNLn1h_t.cjs';
|
|
8
|
+
import '../client-Ciy7Fa_k.cjs';
|
|
9
9
|
|
|
10
10
|
declare function useMarkloom(initialDoc: ElementNode, opts?: EditorOptions): {
|
|
11
11
|
ref: react.RefObject<HTMLDivElement | null>;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { MutableRefObject } from 'react';
|
|
3
|
-
import { E as ElementNode } from '../types-
|
|
4
|
-
import { E as EditorOptions, k as Editor } from '../controller-
|
|
5
|
-
import '../versions-
|
|
3
|
+
import { E as ElementNode } from '../types-BkHlmUFL.js';
|
|
4
|
+
import { E as EditorOptions, k as Editor } from '../controller-DLqI8_jm.js';
|
|
5
|
+
import '../versions-DOkOyh2J.js';
|
|
6
6
|
import 'preact';
|
|
7
|
-
import '../
|
|
8
|
-
import '../client-
|
|
7
|
+
import '../word-count-BPw9G2Bg.js';
|
|
8
|
+
import '../client-BvvyHjhh.js';
|
|
9
9
|
|
|
10
10
|
declare function useMarkloom(initialDoc: ElementNode, opts?: EditorOptions): {
|
|
11
11
|
ref: react.RefObject<HTMLDivElement | null>;
|
package/dist/react/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Editor
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-4Q7PAR2T.js";
|
|
4
|
+
import "../chunk-YLVSMDIO.js";
|
|
5
|
+
import "../chunk-PSAXWBNM.js";
|
|
6
|
+
import "../chunk-QO7JEZDB.js";
|
|
7
|
+
import "../chunk-MQLRZQZL.js";
|
|
8
|
+
import "../chunk-EFYT2223.js";
|
|
9
|
+
import "../chunk-ZL6WT6OY.js";
|
|
10
|
+
import "../chunk-WSJUXPAG.js";
|
|
10
11
|
|
|
11
12
|
// src/react/index.ts
|
|
12
13
|
import { createElement, useEffect, useRef, useState } from "react";
|
|
@@ -16,6 +16,10 @@ interface Mark {
|
|
|
16
16
|
declare function isText(n: Node | null | undefined): n is TextNode;
|
|
17
17
|
declare function isElement(n: Node | null | undefined): n is ElementNode;
|
|
18
18
|
declare function isInlineAtom(n: Node): boolean;
|
|
19
|
+
declare function isFootnoteDef(n: Node): boolean;
|
|
20
|
+
declare function footnoteKey(label: string): string;
|
|
21
|
+
declare function isCallout(n: Node): boolean;
|
|
22
|
+
declare function isAiCompose(n: Node): boolean;
|
|
19
23
|
type Path = number[];
|
|
20
24
|
interface Position {
|
|
21
25
|
path: Path;
|
|
@@ -27,4 +31,4 @@ interface Selection {
|
|
|
27
31
|
}
|
|
28
32
|
type Doc = ElementNode;
|
|
29
33
|
|
|
30
|
-
export { type Doc as D, type ElementNode as E, type Mark as M, type Node as N, type Path as P, type Selection as S, type TextNode as T, type Position as a,
|
|
34
|
+
export { type Doc as D, type ElementNode as E, type Mark as M, type Node as N, type Path as P, type Selection as S, type TextNode as T, type Position as a, isCallout as b, isElement as c, isFootnoteDef as d, isInlineAtom as e, footnoteKey as f, isText as g, isAiCompose as i };
|
|
@@ -16,6 +16,10 @@ interface Mark {
|
|
|
16
16
|
declare function isText(n: Node | null | undefined): n is TextNode;
|
|
17
17
|
declare function isElement(n: Node | null | undefined): n is ElementNode;
|
|
18
18
|
declare function isInlineAtom(n: Node): boolean;
|
|
19
|
+
declare function isFootnoteDef(n: Node): boolean;
|
|
20
|
+
declare function footnoteKey(label: string): string;
|
|
21
|
+
declare function isCallout(n: Node): boolean;
|
|
22
|
+
declare function isAiCompose(n: Node): boolean;
|
|
19
23
|
type Path = number[];
|
|
20
24
|
interface Position {
|
|
21
25
|
path: Path;
|
|
@@ -27,4 +31,4 @@ interface Selection {
|
|
|
27
31
|
}
|
|
28
32
|
type Doc = ElementNode;
|
|
29
33
|
|
|
30
|
-
export { type Doc as D, type ElementNode as E, type Mark as M, type Node as N, type Path as P, type Selection as S, type TextNode as T, type Position as a,
|
|
34
|
+
export { type Doc as D, type ElementNode as E, type Mark as M, type Node as N, type Path as P, type Selection as S, type TextNode as T, type Position as a, isCallout as b, isElement as c, isFootnoteDef as d, isInlineAtom as e, footnoteKey as f, isText as g, isAiCompose as i };
|