@haklex/rich-litexml 0.22.0 → 0.23.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/dist/browser.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createDefaultRegistry, c as LitexmlRegistry, d as registerParseHTML, i as deserializeNodesFromXml, l as registerCustomReaders, n as serializeToXml, o as registerCustomWriters, r as deserializeFromXml, s as registerBuiltinWriters, t as serializeNodesToXml, u as registerBuiltinReaders } from "./src-
|
|
1
|
+
import { a as createDefaultRegistry, c as LitexmlRegistry, d as registerParseHTML, i as deserializeNodesFromXml, l as registerCustomReaders, n as serializeToXml, o as registerCustomWriters, r as deserializeFromXml, s as registerBuiltinWriters, t as serializeNodesToXml, u as registerBuiltinReaders } from "./src-BHEK3mCO.js";
|
|
2
2
|
//#region src/index-browser.ts
|
|
3
3
|
registerParseHTML((html) => new DOMParser().parseFromString(html, "text/html"));
|
|
4
4
|
//#endregion
|
package/dist/node.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createDefaultRegistry, c as LitexmlRegistry, d as registerParseHTML, i as deserializeNodesFromXml, l as registerCustomReaders, n as serializeToXml, o as registerCustomWriters, r as deserializeFromXml, s as registerBuiltinWriters, t as serializeNodesToXml, u as registerBuiltinReaders } from "./src-
|
|
1
|
+
import { a as createDefaultRegistry, c as LitexmlRegistry, d as registerParseHTML, i as deserializeNodesFromXml, l as registerCustomReaders, n as serializeToXml, o as registerCustomWriters, r as deserializeFromXml, s as registerBuiltinWriters, t as serializeNodesToXml, u as registerBuiltinReaders } from "./src-BHEK3mCO.js";
|
|
2
2
|
import { parseHTML } from "linkedom";
|
|
3
3
|
//#region src/index-node.ts
|
|
4
4
|
registerParseHTML((html) => parseHTML(html).document);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../src/readers/custom.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../src/readers/custom.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAoDnD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAidrE"}
|
|
@@ -158,6 +158,20 @@ function numAttr(el, name) {
|
|
|
158
158
|
const v = el.getAttribute(name);
|
|
159
159
|
return v !== null ? Number(v) : void 0;
|
|
160
160
|
}
|
|
161
|
+
var IMAGE_LAYOUTS = new Set([
|
|
162
|
+
"align-left",
|
|
163
|
+
"align-right",
|
|
164
|
+
"float-left",
|
|
165
|
+
"float-right"
|
|
166
|
+
]);
|
|
167
|
+
function imageDisplayWidthAttr(el) {
|
|
168
|
+
const v = numAttr(el, "display-width");
|
|
169
|
+
return v !== void 0 && Number.isFinite(v) && v >= 10 && v <= 100 ? v : void 0;
|
|
170
|
+
}
|
|
171
|
+
function imageLayoutAttr(el) {
|
|
172
|
+
const v = el.getAttribute("layout");
|
|
173
|
+
return v !== null && IMAGE_LAYOUTS.has(v) ? v : void 0;
|
|
174
|
+
}
|
|
161
175
|
/**
|
|
162
176
|
* Extract CDATA text content from an element.
|
|
163
177
|
* linkedom (HTML parser) converts <![CDATA[...]]> to a comment node
|
|
@@ -186,6 +200,8 @@ function registerCustomReaders(registry) {
|
|
|
186
200
|
caption: el.getAttribute("caption") ?? void 0,
|
|
187
201
|
thumbhash: el.getAttribute("thumbhash") ?? void 0,
|
|
188
202
|
accent: el.getAttribute("accent") ?? void 0,
|
|
203
|
+
displayWidth: imageDisplayWidthAttr(el),
|
|
204
|
+
layout: imageLayoutAttr(el),
|
|
189
205
|
version: 1
|
|
190
206
|
};
|
|
191
207
|
});
|
|
@@ -386,7 +402,7 @@ function registerCustomReaders(registry) {
|
|
|
386
402
|
registry.registerReader("excalidraw", (el) => ({
|
|
387
403
|
type: "excalidraw",
|
|
388
404
|
...extractBlockId(el),
|
|
389
|
-
snapshot: extractCdataText(el) || el.getAttribute("snapshot") || "",
|
|
405
|
+
snapshot: extractCdataText(el) || el.getAttribute("snapshot") || el.textContent?.trim() || "",
|
|
390
406
|
version: 1
|
|
391
407
|
}));
|
|
392
408
|
registry.registerReader("grid", (el, ctx) => {
|
|
@@ -638,13 +654,15 @@ function registerCustomWriters(registry) {
|
|
|
638
654
|
tag: "img",
|
|
639
655
|
attrs: optAttr({
|
|
640
656
|
...blockId(n),
|
|
641
|
-
src: n.src,
|
|
642
|
-
alt: n.altText,
|
|
643
|
-
width: n.width != null ? String(n.width) : void 0,
|
|
644
|
-
height: n.height != null ? String(n.height) : void 0,
|
|
645
|
-
caption: n.caption,
|
|
646
|
-
thumbhash: n.thumbhash,
|
|
647
|
-
accent: n.accent
|
|
657
|
+
"src": n.src,
|
|
658
|
+
"alt": n.altText,
|
|
659
|
+
"width": n.width != null ? String(n.width) : void 0,
|
|
660
|
+
"height": n.height != null ? String(n.height) : void 0,
|
|
661
|
+
"caption": n.caption,
|
|
662
|
+
"thumbhash": n.thumbhash,
|
|
663
|
+
"accent": n.accent,
|
|
664
|
+
"display-width": n.displayWidth != null ? String(n.displayWidth) : void 0,
|
|
665
|
+
"layout": n.layout
|
|
648
666
|
}),
|
|
649
667
|
selfClosing: true
|
|
650
668
|
};
|
|
@@ -766,6 +784,11 @@ function registerCustomWriters(registry) {
|
|
|
766
784
|
attrs: optAttr(blockId(n)),
|
|
767
785
|
selfClosing: true
|
|
768
786
|
};
|
|
787
|
+
if (/^(?:https?:\/\/|blob:|ref:)\S+$/.test(n.snapshot.trim())) return {
|
|
788
|
+
tag: "excalidraw",
|
|
789
|
+
attrs: optAttr(blockId(n)),
|
|
790
|
+
children: [n.snapshot.trim()]
|
|
791
|
+
};
|
|
769
792
|
return {
|
|
770
793
|
tag: "excalidraw",
|
|
771
794
|
attrs: optAttr(blockId(n)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../src/writers/custom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAenD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../src/writers/custom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAenD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAwUrE"}
|