@braincrew-lab/langchain-canvas 0.7.7 → 0.7.8
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.
|
@@ -142,6 +142,45 @@ function docxStats(root) {
|
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
// src/io/docxAlignment.ts
|
|
146
|
+
var PLACEMENT = {
|
|
147
|
+
// [margin-left, margin-right] — an empty string leaves the side alone.
|
|
148
|
+
center: ["auto", "auto"],
|
|
149
|
+
right: ["auto", ""]
|
|
150
|
+
};
|
|
151
|
+
function ownRows(table) {
|
|
152
|
+
return Array.from(table.rows ?? []);
|
|
153
|
+
}
|
|
154
|
+
function takeBlockAlignment(element) {
|
|
155
|
+
const stated = element.style.textAlign;
|
|
156
|
+
if (stated) element.style.removeProperty("text-align");
|
|
157
|
+
return stated;
|
|
158
|
+
}
|
|
159
|
+
function placed(table) {
|
|
160
|
+
return Boolean(table.style.marginLeft || table.style.marginRight);
|
|
161
|
+
}
|
|
162
|
+
function agreedAlignment(rows) {
|
|
163
|
+
if (rows.length === 0) return "";
|
|
164
|
+
const first = rows[0];
|
|
165
|
+
return rows.every((value) => value === first) ? first : "";
|
|
166
|
+
}
|
|
167
|
+
function separateBlockAlignment(root) {
|
|
168
|
+
const fix = { rows: 0, placed: 0 };
|
|
169
|
+
for (const table of Array.from(root.querySelectorAll("table"))) {
|
|
170
|
+
takeBlockAlignment(table);
|
|
171
|
+
const rows = ownRows(table);
|
|
172
|
+
const stated = rows.map((row) => takeBlockAlignment(row)).filter((value) => value !== "");
|
|
173
|
+
fix.rows += stated.length;
|
|
174
|
+
if (stated.length !== rows.length || placed(table)) continue;
|
|
175
|
+
const margins = PLACEMENT[agreedAlignment(stated)];
|
|
176
|
+
if (!margins) continue;
|
|
177
|
+
if (margins[0]) table.style.marginLeft = margins[0];
|
|
178
|
+
if (margins[1]) table.style.marginRight = margins[1];
|
|
179
|
+
fix.placed += 1;
|
|
180
|
+
}
|
|
181
|
+
return fix;
|
|
182
|
+
}
|
|
183
|
+
|
|
145
184
|
// src/io/docxShapes.ts
|
|
146
185
|
var VML_NS = "urn:schemas-microsoft-com:vml";
|
|
147
186
|
var VML_SHAPES = /* @__PURE__ */ new Set([
|
|
@@ -400,6 +439,7 @@ function DocxPreview({
|
|
|
400
439
|
keepOrigin: true
|
|
401
440
|
});
|
|
402
441
|
if (!live) return;
|
|
442
|
+
separateBlockAlignment(host);
|
|
403
443
|
stampDocxAddresses(host);
|
|
404
444
|
setRedrawn(redrawnFonts(restoreSymbolBullets(host)));
|
|
405
445
|
setMissingShapes(tallyShapes(host, storedParts(parsed)).missing);
|
|
@@ -10,7 +10,7 @@ function formatSize(size) {
|
|
|
10
10
|
return `${(size / (1024 * 1024)).toFixed(1)} MB`;
|
|
11
11
|
}
|
|
12
12
|
var DocxPreview = lazy(
|
|
13
|
-
() => import('./DocxPreview-
|
|
13
|
+
() => import('./DocxPreview-MAS4GRDG.js').then((m) => ({ default: m.DocxPreview }))
|
|
14
14
|
);
|
|
15
15
|
function iconFor(mediaType, name) {
|
|
16
16
|
if (mediaType?.startsWith("image/")) return "\u{1F5BC}\uFE0F";
|
package/dist/index.js
CHANGED
|
@@ -2264,7 +2264,7 @@ var ChartRenderer = lazy(() => import('./ChartRenderer-TBTWNPV7.js').then((m) =>
|
|
|
2264
2264
|
var DocumentRenderer = lazy(() => import('./DocumentRenderer-ZGJXDVKG.js').then((m) => ({ default: m.DocumentRenderer })));
|
|
2265
2265
|
var TableRenderer = lazy(() => import('./TableRenderer-YTOF2ZIC.js').then((m) => ({ default: m.TableRenderer })));
|
|
2266
2266
|
var SlidesRenderer = lazy(() => import('./SlidesRenderer-4QWZVWWD.js').then((m) => ({ default: m.SlidesRenderer })));
|
|
2267
|
-
var FileRenderer = lazy(() => import('./FileRenderer-
|
|
2267
|
+
var FileRenderer = lazy(() => import('./FileRenderer-66GPPGMK.js').then((m) => ({ default: m.FileRenderer })));
|
|
2268
2268
|
var builtinRenderers = {
|
|
2269
2269
|
html: HtmlRenderer,
|
|
2270
2270
|
document: DocumentRenderer,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@braincrew-lab/langchain-canvas",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.8",
|
|
4
4
|
"description": "A live canvas for LangChain agents — stream documents, charts, and rich artifacts into a React panel.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Brain Crew (https://github.com/braincrew-lab)",
|