@stll/folio-core 0.8.0 → 0.9.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 +39 -0
- package/dist/ai-edits/apply.js +18 -4
- package/dist/ai-edits/headless.d.ts +31 -4
- package/dist/ai-edits/headless.js +148 -35
- package/dist/ai-edits/index.d.ts +3 -3
- package/dist/ai-edits/index.js +2 -1
- package/dist/ai-edits/snapshot.js +40 -3
- package/dist/ai-edits/types.d.ts +2 -1
- package/dist/compat/eigenpal.d.ts +6 -4
- package/dist/compat/eigenpal.js +5 -3
- package/dist/controller/latestRequestGate.d.ts +13 -0
- package/dist/controller/latestRequestGate.js +16 -0
- package/dist/controller/layoutPipeline.js +12 -1
- package/dist/document-operations.d.ts +10 -3
- package/dist/document-operations.js +29 -14
- package/dist/docx/blockContentParser.js +2 -2
- package/dist/docx/commentParser.js +1 -1
- package/dist/docx/compatibility.d.ts +3 -7
- package/dist/docx/compatibility.js +0 -11
- package/dist/docx/encryption/agileDecryption.js +1 -1
- package/dist/docx/encryption/encryptionInfo.js +1 -1
- package/dist/docx/encryption/openEncryptedDocx.js +1 -1
- package/dist/docx/fontTableParser.d.ts +6 -0
- package/dist/docx/fontTableParser.js +72 -0
- package/dist/docx/groupDrawingParser.js +7 -2
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/normalizeBaseDirection.js +1 -1
- package/dist/docx/numberingParser.js +1 -0
- package/dist/docx/paragraphParser.js +12 -1
- package/dist/docx/parser.d.ts +1 -1
- package/dist/docx/parser.js +12 -9
- package/dist/docx/rezip.js +70 -5
- package/dist/docx/runConsolidator.js +4 -0
- package/dist/docx/runParser.js +19 -1
- package/dist/docx/selectiveSave.js +3 -3
- package/dist/docx/serializer/fontTableSerializer.d.ts +6 -0
- package/dist/docx/serializer/fontTableSerializer.js +26 -0
- package/dist/docx/serializer/headerFooterSerializer.js +1 -1
- package/dist/docx/serializer/paragraphSerializer.js +4 -0
- package/dist/docx/serializer/runSerializer.js +7 -0
- package/dist/docx/serializer/settingsSerializer.d.ts +6 -0
- package/dist/docx/serializer/settingsSerializer.js +16 -0
- package/dist/docx/serializer/stylesSerializer.d.ts +6 -0
- package/dist/docx/serializer/stylesSerializer.js +56 -0
- package/dist/docx/serializer/tableSerializer.js +25 -26
- package/dist/docx/serializer/themeSerializer.d.ts +6 -0
- package/dist/docx/serializer/themeSerializer.js +36 -0
- package/dist/docx/settingsParser.js +46 -0
- package/dist/docx/styleParser.js +26 -1
- package/dist/docx/tableParser.js +11 -1
- package/dist/docx/vmlImageParser.js +1 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +5916 -5916
- package/dist/i18n/messages/catalogs.gen.js +5910 -5910
- package/dist/index.d.ts +6 -4
- package/dist/index.js +5 -3
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +3 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +3 -1
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +3 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +14 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +51 -14
- package/dist/layout-bridge/engine/measuring/index.d.ts +2 -1
- package/dist/layout-bridge/engine/measuring/index.js +2 -1
- package/dist/layout-engine/index.js +36 -28
- package/dist/layout-engine/measure/cache.js +11 -3
- package/dist/layout-engine/measure/font-metrics.worker.js +1 -0
- package/dist/layout-engine/measure/index.d.ts +2 -1
- package/dist/layout-engine/measure/index.js +2 -1
- package/dist/layout-engine/measure/lineBreakProvider.d.ts +33 -0
- package/dist/layout-engine/measure/lineBreakProvider.js +252 -0
- package/dist/layout-engine/measure/lineBreaks.d.ts +7 -2
- package/dist/layout-engine/measure/lineBreaks.js +11 -18
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.js +12 -6
- package/dist/layout-engine/measure/measureBlocks.d.ts +1 -2
- package/dist/layout-engine/measure/measureBlocks.js +6 -36
- package/dist/layout-engine/measure/measureContainer.js +32 -9
- package/dist/layout-engine/measure/measureHelpers.js +5 -2
- package/dist/layout-engine/measure/measureParagraph.js +335 -72
- package/dist/layout-engine/measure/measureTypes.d.ts +2 -1
- package/dist/layout-engine/measure/measureWorker.d.ts +2 -2
- package/dist/layout-engine/measure/measureWorker.js +8 -19
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +3 -14
- package/dist/layout-engine/measure/tableCellFloating.d.ts +10 -3
- package/dist/layout-engine/measure/tableCellFloating.js +37 -29
- package/dist/layout-engine/measure/tableCellFlow.d.ts +27 -0
- package/dist/layout-engine/measure/tableCellFlow.js +73 -0
- package/dist/layout-engine/measure/tableCellGrid.js +1 -1
- package/dist/layout-engine/measure/textMeasurementPolicy.d.ts +18 -0
- package/dist/layout-engine/measure/textMeasurementPolicy.js +24 -0
- package/dist/layout-engine/renderedBreakReconciliation.d.ts +6 -1
- package/dist/layout-engine/renderedBreakReconciliation.js +34 -11
- package/dist/layout-engine/tableRowBreak.d.ts +5 -2
- package/dist/layout-engine/tableRowBreak.js +62 -29
- package/dist/layout-engine/types.d.ts +40 -7
- package/dist/layout-painter/anchoredImagePosition.d.ts +23 -0
- package/dist/layout-painter/anchoredImagePosition.js +95 -0
- package/dist/layout-painter/borderStroke.d.ts +23 -0
- package/dist/layout-painter/borderStroke.js +39 -0
- package/dist/layout-painter/renderImage.d.ts +5 -4
- package/dist/layout-painter/renderImage.js +18 -4
- package/dist/layout-painter/renderPage.d.ts +2 -27
- package/dist/layout-painter/renderPage.js +13 -99
- package/dist/layout-painter/renderParagraph.js +41 -23
- package/dist/layout-painter/renderTable.d.ts +2 -0
- package/dist/layout-painter/renderTable.js +223 -43
- package/dist/managers/DocumentLoaderManager.d.ts +1 -1
- package/dist/managers/DocumentLoaderManager.js +2 -2
- package/dist/prosemirror/attrs/index.d.ts +4 -2
- package/dist/prosemirror/attrs/index.js +21 -2
- package/dist/prosemirror/commands/propertyChangeScope.js +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +33 -18
- package/dist/prosemirror/conversion/toProseDoc.js +50 -18
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +7 -2
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +1 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +1 -0
- package/dist/prosemirror/extensions/marks/HighlightExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/LanguageExtension.d.ts +7 -0
- package/dist/prosemirror/extensions/marks/LanguageExtension.js +30 -0
- package/dist/prosemirror/extensions/marks/RunShadingExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +1 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +12 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +4 -2
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/marks.d.ts +6 -1
- package/dist/prosemirror/schema/nodes.d.ts +13 -11
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +1 -0
- package/dist/prosemirror/utils/tabCalculator.d.ts +3 -1
- package/dist/prosemirror/utils/tabCalculator.js +12 -10
- package/dist/prosemirror/validation.js +4 -1
- package/dist/redline.js +13 -3
- package/dist/server.d.ts +6 -3
- package/dist/server.js +5 -2
- package/dist/style-sets/extract.d.ts +35 -0
- package/dist/style-sets/extract.js +123 -0
- package/dist/style-sets/stellaStyle.d.ts +13 -0
- package/dist/style-sets/stellaStyle.js +516 -0
- package/dist/style-sets/types.d.ts +31 -0
- package/dist/style-sets/types.js +5 -0
- package/dist/utils/createDocument.d.ts +12 -2
- package/dist/utils/createDocument.js +42 -31
- package/dist/utils/fontResolver.js +6 -6
- package/dist/utils/formatToStyle.js +1 -1
- package/dist/utils/paragraphFormattingMerge.d.ts +14 -3
- package/dist/utils/paragraphFormattingMerge.js +14 -4
- package/package.json +5 -1
- package/dist/docx/capabilities.d.ts +0 -41
- package/dist/docx/capabilities.js +0 -322
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { setMeasureProvider } from "./measureProvider.js";
|
|
2
|
+
import { getFontKerningMode } from "./textMeasurementPolicy.js";
|
|
2
3
|
import { buildFontString, getResolvedData, ptToPx } from "./measureHelpers.js";
|
|
3
4
|
import { hasCjk, isCjkCodePoint, segmentByScript } from "../../utils/scriptSegments.js";
|
|
4
5
|
import { getCachedFontMetrics, getCachedTextWidth, getTextWidthCacheGeneration, setCachedFontMetrics, setCachedTextWidth } from "./cache.js";
|
|
@@ -46,13 +47,14 @@ function getCanvasContext() {
|
|
|
46
47
|
function resetCanvasContext() {
|
|
47
48
|
canvasContext = null;
|
|
48
49
|
}
|
|
49
|
-
function getWorkerFontFingerprintWidth(ctx, font) {
|
|
50
|
+
function getWorkerFontFingerprintWidth(ctx, font, fontCacheKey, fontKerning) {
|
|
50
51
|
const generation = getTextWidthCacheGeneration();
|
|
51
|
-
const cached = workerFontFingerprintCache.get(
|
|
52
|
+
const cached = workerFontFingerprintCache.get(fontCacheKey);
|
|
52
53
|
if (cached?.generation === generation) return cached.width;
|
|
53
54
|
ctx.font = font;
|
|
55
|
+
ctx.fontKerning = fontKerning;
|
|
54
56
|
const width = ctx.measureText(WORKER_FONT_FINGERPRINT_TEXT).width;
|
|
55
|
-
workerFontFingerprintCache.set(
|
|
57
|
+
workerFontFingerprintCache.set(fontCacheKey, {
|
|
56
58
|
generation,
|
|
57
59
|
width
|
|
58
60
|
});
|
|
@@ -86,6 +88,7 @@ function canvasGetFontMetrics(style) {
|
|
|
86
88
|
try {
|
|
87
89
|
const ctx = getCanvasContext();
|
|
88
90
|
ctx.font = buildFontString(style);
|
|
91
|
+
ctx.fontKerning = getFontKerningMode(style);
|
|
89
92
|
const metrics = ctx.measureText("Hg");
|
|
90
93
|
if (typeof metrics.actualBoundingBoxAscent === "number" && typeof metrics.actualBoundingBoxDescent === "number") {
|
|
91
94
|
ascent = metrics.actualBoundingBoxAscent;
|
|
@@ -120,10 +123,12 @@ function canvasMeasureTextWidth(text, style) {
|
|
|
120
123
|
const font = buildFontString(style);
|
|
121
124
|
const letterSpacing = style.letterSpacing ?? 0;
|
|
122
125
|
const horizontalScale = getHorizontalScaleFactor(style);
|
|
123
|
-
const
|
|
126
|
+
const fontKerning = getFontKerningMode(style);
|
|
127
|
+
const fontCacheKey = style.kerning ? `${font}|kerning:normal|scale:${horizontalScale}` : `${font}|scale:${horizontalScale}`;
|
|
124
128
|
const cached = getCachedTextWidth(measuredText, fontCacheKey, letterSpacing);
|
|
125
129
|
if (cached !== void 0) return cached;
|
|
126
130
|
ctx.font = font;
|
|
131
|
+
ctx.fontKerning = fontKerning;
|
|
127
132
|
let width = ctx.measureText(measuredText).width;
|
|
128
133
|
if (letterSpacing) {
|
|
129
134
|
const codePoints = countCodePoints(measuredText);
|
|
@@ -132,9 +137,17 @@ function canvasMeasureTextWidth(text, style) {
|
|
|
132
137
|
const scaledWidth = width * horizontalScale;
|
|
133
138
|
setCachedTextWidth(measuredText, fontCacheKey, letterSpacing, scaledWidth);
|
|
134
139
|
if (!canPrefetchMeasurement()) return scaledWidth;
|
|
135
|
-
const fontFingerprintWidth = getWorkerFontFingerprintWidth(ctx, font);
|
|
136
|
-
prefetchMeasurement(
|
|
137
|
-
|
|
140
|
+
const fontFingerprintWidth = getWorkerFontFingerprintWidth(ctx, font, fontCacheKey, fontKerning);
|
|
141
|
+
prefetchMeasurement({
|
|
142
|
+
text: measuredText,
|
|
143
|
+
font,
|
|
144
|
+
letterSpacing,
|
|
145
|
+
horizontalScale,
|
|
146
|
+
fontCacheKey,
|
|
147
|
+
fontFingerprintWidth,
|
|
148
|
+
fontKerning
|
|
149
|
+
});
|
|
150
|
+
prefetchBinarySearchProbes(measuredText, font, fontCacheKey, fontFingerprintWidth, letterSpacing, horizontalScale, fontKerning);
|
|
138
151
|
return scaledWidth;
|
|
139
152
|
}
|
|
140
153
|
/**
|
|
@@ -150,6 +163,7 @@ function glyphAdvanceStyle(style, fontFamily) {
|
|
|
150
163
|
if (style.bold !== void 0) result.bold = style.bold;
|
|
151
164
|
if (style.italic !== void 0) result.italic = style.italic;
|
|
152
165
|
if (style.fontVariant !== void 0) result.fontVariant = style.fontVariant;
|
|
166
|
+
if (style.kerning !== void 0) result.kerning = style.kerning;
|
|
153
167
|
return result;
|
|
154
168
|
}
|
|
155
169
|
/**
|
|
@@ -186,12 +200,20 @@ function measureMixedScriptWidth(measuredText, style) {
|
|
|
186
200
|
* pays the main-thread cost as usual. When the worker wins, that probe
|
|
187
201
|
* lands on a hit.
|
|
188
202
|
*/
|
|
189
|
-
function prefetchBinarySearchProbes(text, font, fontCacheKey, fontFingerprintWidth, letterSpacing, horizontalScale) {
|
|
203
|
+
function prefetchBinarySearchProbes(text, font, fontCacheKey, fontFingerprintWidth, letterSpacing, horizontalScale, fontKerning) {
|
|
190
204
|
if (text.length < 4) return;
|
|
191
205
|
for (let denom = 2; denom <= 8; denom *= 2) {
|
|
192
206
|
const len = Math.floor(text.length / denom);
|
|
193
207
|
if (len < 2) break;
|
|
194
|
-
prefetchMeasurement(
|
|
208
|
+
prefetchMeasurement({
|
|
209
|
+
text: text.slice(0, len),
|
|
210
|
+
font,
|
|
211
|
+
letterSpacing,
|
|
212
|
+
horizontalScale,
|
|
213
|
+
fontCacheKey,
|
|
214
|
+
fontFingerprintWidth,
|
|
215
|
+
fontKerning
|
|
216
|
+
});
|
|
195
217
|
}
|
|
196
218
|
}
|
|
197
219
|
/**
|
|
@@ -224,6 +246,7 @@ function canvasMeasureRun(text, style) {
|
|
|
224
246
|
const ctx = getCanvasContext();
|
|
225
247
|
const baseFont = buildFontString(style);
|
|
226
248
|
ctx.font = baseFont;
|
|
249
|
+
ctx.fontKerning = style.kerning ? "normal" : "none";
|
|
227
250
|
const eastAsiaFont = style.eastAsiaFontFamily !== void 0 && !style.letterSpacing ? buildFontString({
|
|
228
251
|
...style,
|
|
229
252
|
fontFamily: style.eastAsiaFontFamily
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveFontFamily } from "../../utils/fontResolver.js";
|
|
2
2
|
import "../../utils/fontWeights.js";
|
|
3
|
+
import { FONT_KERNING_MODE, getRunFontKerningMode } from "./textMeasurementPolicy.js";
|
|
3
4
|
//#region src/layout-engine/measure/measureHelpers.ts
|
|
4
5
|
/**
|
|
5
6
|
* Pure measurement helpers — no canvas, no DOM, no worker.
|
|
@@ -23,16 +24,18 @@ const DEFAULT_FONT_FAMILY = "Calibri";
|
|
|
23
24
|
* and size fallbacks for runs that declare neither.
|
|
24
25
|
*/
|
|
25
26
|
function buildRunFontStyle(run, fallbackFontFamily, fallbackFontSize) {
|
|
27
|
+
const fontSize = run.fontSize ?? fallbackFontSize;
|
|
26
28
|
return {
|
|
27
29
|
fontFamily: run.fontFamily ?? fallbackFontFamily,
|
|
28
30
|
...run.eastAsiaFontFamily !== void 0 ? { eastAsiaFontFamily: run.eastAsiaFontFamily } : {},
|
|
29
|
-
fontSize
|
|
31
|
+
fontSize,
|
|
30
32
|
...run.bold !== void 0 ? { bold: run.bold } : {},
|
|
31
33
|
...run.italic !== void 0 ? { italic: run.italic } : {},
|
|
32
34
|
...run.letterSpacing !== void 0 ? { letterSpacing: run.letterSpacing } : {},
|
|
33
35
|
...run.allCaps ? { textTransform: "uppercase" } : {},
|
|
34
36
|
...run.smallCaps ? { fontVariant: "small-caps" } : {},
|
|
35
|
-
...run.horizontalScale !== void 0 ? { horizontalScale: run.horizontalScale } : {}
|
|
37
|
+
...run.horizontalScale !== void 0 ? { horizontalScale: run.horizontalScale } : {},
|
|
38
|
+
kerning: getRunFontKerningMode(run, fallbackFontSize) === FONT_KERNING_MODE.enabled
|
|
36
39
|
};
|
|
37
40
|
}
|
|
38
41
|
/** Cache for resolved font data */
|