@univerjs/engine-render 1.4.0 → 1.5.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 +17 -5
- package/lib/cjs/{worker-dzyTVvQi.js → doc-skeleton-xHfOLvcR.js} +105 -263
- package/lib/cjs/index.js +3070 -1374
- package/lib/cjs/worker.js +239 -4
- package/lib/{es/worker-BlCdBXpV.js → doc-skeleton-h5WFPD-i.js} +88 -258
- package/lib/{worker-BlCdBXpV.js → es/doc-skeleton-h5WFPD-i.js} +88 -258
- package/lib/es/index.js +2198 -502
- package/lib/es/worker.js +236 -1
- package/lib/index.js +2198 -502
- package/lib/types/base-object.d.ts +5 -0
- package/lib/types/basics/draw.d.ts +1 -1
- package/lib/types/basics/interfaces.d.ts +1 -0
- package/lib/types/components/component.d.ts +1 -0
- package/lib/types/components/docs/document-layout-presentation.d.ts +1 -0
- package/lib/types/components/docs/layout/shaping-engine/font-cache.d.ts +2 -0
- package/lib/types/components/docs/layout/tools.d.ts +2 -0
- package/lib/types/components/docs/view-model/document-view-model.d.ts +2 -1
- package/lib/types/components/extension.d.ts +5 -1
- package/lib/types/components/sheets/extensions/background.d.ts +1 -0
- package/lib/types/components/sheets/extensions/border-row-cache.d.ts +27 -0
- package/lib/types/components/sheets/extensions/border.d.ts +9 -1
- package/lib/types/components/sheets/extensions/column-header-layout.d.ts +1 -0
- package/lib/types/components/sheets/extensions/custom.d.ts +1 -0
- package/lib/types/components/sheets/extensions/font.d.ts +6 -0
- package/lib/types/components/sheets/extensions/marker.d.ts +1 -0
- package/lib/types/components/sheets/extensions/render-primitive-cache.d.ts +37 -0
- package/lib/types/components/sheets/extensions/row-header-layout.d.ts +1 -0
- package/lib/types/components/sheets/interfaces.d.ts +1 -0
- package/lib/types/components/sheets/sheet-cell-document-view-model.d.ts +2 -0
- package/lib/types/components/sheets/sheet-component.d.ts +3 -0
- package/lib/types/components/sheets/sheet.render-skeleton.d.ts +9 -0
- package/lib/types/components/sheets/spreadsheet.d.ts +25 -3
- package/lib/types/context.d.ts +3 -0
- package/lib/types/index.d.ts +0 -3
- package/lib/types/layer.d.ts +8 -1
- package/lib/types/scene.d.ts +13 -1
- package/lib/types/scene.transformer.d.ts +21 -1
- package/lib/types/shape/control.d.ts +1 -0
- package/lib/types/shape/scroll-bar.d.ts +2 -2
- package/lib/types/shape/text.d.ts +6 -1
- package/lib/types/transformer-rotation.d.ts +42 -0
- package/lib/types/viewport.d.ts +3 -2
- package/lib/umd/index.js +5 -5
- package/lib/worker.js +236 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
## Package Overview
|
|
10
10
|
|
|
11
|
-
| Package | UMD global | CSS | Locales | Facade entry |
|
|
12
|
-
| --- | --- | :---: | :---: | :---: |
|
|
13
|
-
| `@univerjs/engine-render` | `UniverEngineRender` | No | No | No |
|
|
11
|
+
| Package | UMD global | CSS | Locales | Facade entry | Worker entry |
|
|
12
|
+
| --- | --- | :---: | :---: | :---: | :---: |
|
|
13
|
+
| `@univerjs/engine-render` | `UniverEngineRender` | No | No | No | Yes |
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
@@ -20,16 +20,28 @@ pnpm add @univerjs/engine-render
|
|
|
20
20
|
npm install @univerjs/engine-render
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Keep all `@univerjs/*` packages on the same version.
|
|
24
|
-
|
|
25
23
|
## Usage
|
|
26
24
|
|
|
25
|
+
Start with the [integration setup](https://docs.univer.ai/) for your document type, including its required plugins, styles, and locale resources. The snippet below assumes that setup is complete.
|
|
26
|
+
|
|
27
27
|
```ts
|
|
28
28
|
import { UniverRenderEnginePlugin } from '@univerjs/engine-render';
|
|
29
29
|
|
|
30
30
|
univer.registerPlugin(UniverRenderEnginePlugin);
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
### Worker usage
|
|
34
|
+
|
|
35
|
+
On the main thread, import `UniverRenderEnginePlugin` from `@univerjs/engine-render`.
|
|
36
|
+
|
|
37
|
+
In the worker entry, import `DocumentLayoutSession` from `@univerjs/engine-render/worker`:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { DocumentLayoutSession } from '@univerjs/engine-render/worker';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`DocumentLayoutSession` is a layout utility, not a plugin. For Docs layout workers, use the [Docs worker setup](../docs/README.md#worker-usage), which manages the session lifecycle.
|
|
44
|
+
|
|
33
45
|
## Resources
|
|
34
46
|
|
|
35
47
|
- [Documentation](https://docs.univer.ai)
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
// \0rolldown/runtime.js
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __exportAll = (all,
|
|
4
|
-
let target = {};
|
|
3
|
+
var __exportAll = (all, flags) => {
|
|
4
|
+
let target = Object.setPrototypeOf({}, null);
|
|
5
5
|
for (var name in all) {
|
|
6
6
|
__defProp(target, name, {
|
|
7
7
|
get: all[name],
|
|
8
8
|
enumerable: true
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
if (!
|
|
11
|
+
if (!(flags & 1)) {
|
|
12
12
|
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
13
|
}
|
|
14
|
-
return target;
|
|
14
|
+
return flags & 2 ? target : Object.preventExtensions(target);
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
let _univerjs_core = require("@univerjs/core");
|
|
18
18
|
let rxjs = require("rxjs");
|
|
19
19
|
let franc_min = require("franc-min");
|
|
20
20
|
|
|
21
|
-
// \0@oxc-project+runtime@0.
|
|
21
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
22
22
|
function _typeof(o) {
|
|
23
23
|
"@babel/helpers - typeof";
|
|
24
24
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -28,25 +28,25 @@ function _typeof(o) {
|
|
|
28
28
|
}, _typeof(o);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
// \0@oxc-project+runtime@0.
|
|
32
|
-
function toPrimitive(t,
|
|
31
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
32
|
+
function toPrimitive(t, e) {
|
|
33
33
|
if ("object" != _typeof(t) || !t) return t;
|
|
34
|
-
var
|
|
35
|
-
if (void 0 !==
|
|
36
|
-
var i =
|
|
34
|
+
var r;
|
|
35
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
36
|
+
var i = r.call(t, e || "default");
|
|
37
37
|
if ("object" != _typeof(i)) return i;
|
|
38
38
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
39
39
|
}
|
|
40
|
-
return ("string" ===
|
|
40
|
+
return ("string" === e ? String : Number)(t);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
// \0@oxc-project+runtime@0.
|
|
43
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
44
44
|
function toPropertyKey(t) {
|
|
45
45
|
var i = toPrimitive(t, "string");
|
|
46
46
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
// \0@oxc-project+runtime@0.
|
|
49
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
50
50
|
function _defineProperty(e, r, t) {
|
|
51
51
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
52
52
|
value: t,
|
|
@@ -208,10 +208,14 @@ function invalidateDocumentFontMetrics(matches) {
|
|
|
208
208
|
return FontCache.invalidateMetrics(matches);
|
|
209
209
|
}
|
|
210
210
|
var FontCache = class {
|
|
211
|
+
static get metricsRevision() {
|
|
212
|
+
return this._metricsRevision;
|
|
213
|
+
}
|
|
211
214
|
static get globalFontMeasureCache() {
|
|
212
215
|
return this._globalFontMeasureCache;
|
|
213
216
|
}
|
|
214
217
|
static invalidateMetrics(matches) {
|
|
218
|
+
this._metricsRevision++;
|
|
215
219
|
let changed = false;
|
|
216
220
|
const keys = /* @__PURE__ */ new Set([
|
|
217
221
|
...this._globalFontMeasureCache.keys(),
|
|
@@ -243,6 +247,7 @@ var FontCache = class {
|
|
|
243
247
|
const content = pathArr[1];
|
|
244
248
|
(_this$_globalFontMeas = this._globalFontMeasureCache.get(fontStyle)) === null || _this$_globalFontMeas === void 0 || _this$_globalFontMeas.delete(content);
|
|
245
249
|
} else return false;
|
|
250
|
+
this._metricsRevision++;
|
|
246
251
|
return true;
|
|
247
252
|
}
|
|
248
253
|
static getFontMeasureCache(fontStyle, content) {
|
|
@@ -492,6 +497,7 @@ _defineProperty(FontCache, "_getTextHeightCache", {});
|
|
|
492
497
|
_defineProperty(FontCache, "_context", void 0);
|
|
493
498
|
_defineProperty(FontCache, "_fontDataMap", /* @__PURE__ */ new Map());
|
|
494
499
|
_defineProperty(FontCache, "_globalFontMeasureCache", /* @__PURE__ */ new Map());
|
|
500
|
+
_defineProperty(FontCache, "_metricsRevision", 0);
|
|
495
501
|
|
|
496
502
|
// src/basics/tools.ts
|
|
497
503
|
const DEG180 = 180;
|
|
@@ -2193,6 +2199,12 @@ var BaseObject = class extends _univerjs_core.Disposable {
|
|
|
2193
2199
|
_defineProperty(this, "_transformerConfig", void 0);
|
|
2194
2200
|
_defineProperty(this, "_forceRender", false);
|
|
2195
2201
|
_defineProperty(this, "_layer", void 0);
|
|
2202
|
+
_defineProperty(
|
|
2203
|
+
this,
|
|
2204
|
+
/** Opt in only when pixels depend on invalidated render state, not animation or external callbacks. */
|
|
2205
|
+
"viewportCacheReusable",
|
|
2206
|
+
false
|
|
2207
|
+
);
|
|
2196
2208
|
if (key) this._oKey = key;
|
|
2197
2209
|
else this._oKey = generateRandomKey();
|
|
2198
2210
|
}
|
|
@@ -2399,6 +2411,10 @@ var BaseObject = class extends _univerjs_core.Disposable {
|
|
|
2399
2411
|
get maxZIndex() {
|
|
2400
2412
|
return this._zIndex;
|
|
2401
2413
|
}
|
|
2414
|
+
canReuseViewportCache() {
|
|
2415
|
+
return this.viewportCacheReusable;
|
|
2416
|
+
}
|
|
2417
|
+
onViewportCacheReuse(_viewportInfo) {}
|
|
2402
2418
|
makeDirty(state = true) {
|
|
2403
2419
|
this._dirty = state;
|
|
2404
2420
|
if (state) {
|
|
@@ -2410,6 +2426,9 @@ var BaseObject = class extends _univerjs_core.Disposable {
|
|
|
2410
2426
|
}
|
|
2411
2427
|
return this;
|
|
2412
2428
|
}
|
|
2429
|
+
isForceDirty() {
|
|
2430
|
+
return this._forceDirty;
|
|
2431
|
+
}
|
|
2413
2432
|
makeForceDirty(state = true) {
|
|
2414
2433
|
this._forceDirty = state;
|
|
2415
2434
|
}
|
|
@@ -3353,7 +3372,7 @@ function setLineType(ctx, style) {
|
|
|
3353
3372
|
]);
|
|
3354
3373
|
else if (style === _univerjs_core.BorderStyleTypes.DOTTED) ctx.setLineDash([2]);
|
|
3355
3374
|
else if (style === _univerjs_core.BorderStyleTypes.DASHED || style === _univerjs_core.BorderStyleTypes.MEDIUM_DASHED) ctx.setLineDash([3]);
|
|
3356
|
-
else ctx.setLineDash([
|
|
3375
|
+
else ctx.setLineDash([]);
|
|
3357
3376
|
}
|
|
3358
3377
|
function getLineOffset() {
|
|
3359
3378
|
const ratio = getLineWith(1);
|
|
@@ -3513,6 +3532,7 @@ var UniverRenderingContext2D = class {
|
|
|
3513
3532
|
constructor(context, options) {
|
|
3514
3533
|
_defineProperty(this, "__mode", "rendering");
|
|
3515
3534
|
_defineProperty(this, "_transformCache", void 0);
|
|
3535
|
+
_defineProperty(this, "_cacheScale", false);
|
|
3516
3536
|
_defineProperty(this, "_bitmapMutationId", 0);
|
|
3517
3537
|
_defineProperty(this, "_bitmapMutationTrackingDepth", 0);
|
|
3518
3538
|
_defineProperty(this, "canvas", void 0);
|
|
@@ -3724,7 +3744,7 @@ var UniverRenderingContext2D = class {
|
|
|
3724
3744
|
* DOMMatrix.a DOMMatrix.d would affect by ctx.rotate()
|
|
3725
3745
|
*/
|
|
3726
3746
|
_getScale() {
|
|
3727
|
-
const { a, b, c, d } = this.getTransform();
|
|
3747
|
+
const { a, b, c, d } = this._cacheScale ? this._transformCache ??= this.getTransform() : this.getTransform();
|
|
3728
3748
|
return {
|
|
3729
3749
|
scaleX: Math.sqrt(a * a + b * b),
|
|
3730
3750
|
scaleY: Math.sqrt(c * c + d * d)
|
|
@@ -3733,6 +3753,18 @@ var UniverRenderingContext2D = class {
|
|
|
3733
3753
|
getScale() {
|
|
3734
3754
|
return this._getScale();
|
|
3735
3755
|
}
|
|
3756
|
+
/** Reuse scale queries during drawing; transform methods still invalidate the cached matrix. */
|
|
3757
|
+
withCachedScale(draw) {
|
|
3758
|
+
const previous = this._cacheScale;
|
|
3759
|
+
this._cacheScale = true;
|
|
3760
|
+
this._transformCache = null;
|
|
3761
|
+
try {
|
|
3762
|
+
draw();
|
|
3763
|
+
} finally {
|
|
3764
|
+
this._cacheScale = previous;
|
|
3765
|
+
this._transformCache = null;
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3736
3768
|
getContextAttributes() {
|
|
3737
3769
|
return this._context.getContextAttributes();
|
|
3738
3770
|
}
|
|
@@ -3774,7 +3806,7 @@ var UniverRenderingContext2D = class {
|
|
|
3774
3806
|
this.roundRect(x, y, w, h, radii);
|
|
3775
3807
|
}
|
|
3776
3808
|
getTransform() {
|
|
3777
|
-
return this.
|
|
3809
|
+
return this._context.getTransform();
|
|
3778
3810
|
}
|
|
3779
3811
|
resetTransform() {
|
|
3780
3812
|
this._transformCache = null;
|
|
@@ -4696,17 +4728,19 @@ var Shape = class extends BaseObject {
|
|
|
4696
4728
|
const width = Math.ceil((bounds.right - bounds.left) * pixelRatio) / pixelRatio;
|
|
4697
4729
|
const height = Math.ceil((bounds.bottom - bounds.top) * pixelRatio) / pixelRatio;
|
|
4698
4730
|
if (width <= 0 || height <= 0) return;
|
|
4731
|
+
const allocationWidth = width * (1 + 2 * Number.EPSILON);
|
|
4732
|
+
const allocationHeight = height * (1 + 2 * Number.EPSILON);
|
|
4699
4733
|
const cacheBoundsChanged = ((_this$_renderCacheBou = this._renderCacheBounds) === null || _this$_renderCacheBou === void 0 ? void 0 : _this$_renderCacheBou.left) !== bounds.left || ((_this$_renderCacheBou2 = this._renderCacheBounds) === null || _this$_renderCacheBou2 === void 0 ? void 0 : _this$_renderCacheBou2.top) !== bounds.top || ((_this$_renderCacheBou3 = this._renderCacheBounds) === null || _this$_renderCacheBou3 === void 0 ? void 0 : _this$_renderCacheBou3.right) !== bounds.right || ((_this$_renderCacheBou4 = this._renderCacheBounds) === null || _this$_renderCacheBou4 === void 0 ? void 0 : _this$_renderCacheBou4.bottom) !== bounds.bottom;
|
|
4700
4734
|
const cacheSizeChanged = ((_this$_renderCacheCan = this._renderCacheCanvas) === null || _this$_renderCacheCan === void 0 ? void 0 : _this$_renderCacheCan.getWidth()) !== width || ((_this$_renderCacheCan2 = this._renderCacheCanvas) === null || _this$_renderCacheCan2 === void 0 ? void 0 : _this$_renderCacheCan2.getHeight()) !== height || this._renderCachePixelRatio !== pixelRatio;
|
|
4701
4735
|
if (!this._renderCacheCanvas) {
|
|
4702
4736
|
var _this$getEngine;
|
|
4703
4737
|
this._renderCacheCanvas = new Canvas({
|
|
4704
4738
|
colorService: (_this$getEngine = this.getEngine()) === null || _this$getEngine === void 0 ? void 0 : _this$getEngine.canvasColorService,
|
|
4705
|
-
width,
|
|
4706
|
-
height,
|
|
4739
|
+
width: allocationWidth,
|
|
4740
|
+
height: allocationHeight,
|
|
4707
4741
|
pixelRatio
|
|
4708
4742
|
});
|
|
4709
|
-
} else if (cacheSizeChanged) this._renderCacheCanvas.setSize(
|
|
4743
|
+
} else if (cacheSizeChanged) this._renderCacheCanvas.setSize(allocationWidth, allocationHeight, pixelRatio);
|
|
4710
4744
|
if (this.isDirty() || cacheBoundsChanged || cacheSizeChanged) {
|
|
4711
4745
|
const cacheContext = this._renderCacheCanvas.getContext();
|
|
4712
4746
|
this._renderCacheCanvas.clear();
|
|
@@ -10859,6 +10893,21 @@ function hasDocsTableHorizontalViewport(viewport) {
|
|
|
10859
10893
|
}
|
|
10860
10894
|
|
|
10861
10895
|
// src/components/docs/layout/model/glyph.ts
|
|
10896
|
+
/**
|
|
10897
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
10898
|
+
*
|
|
10899
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10900
|
+
* you may not use this file except in compliance with the License.
|
|
10901
|
+
* You may obtain a copy of the License at
|
|
10902
|
+
*
|
|
10903
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10904
|
+
*
|
|
10905
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10906
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10907
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10908
|
+
* See the License for the specific language governing permissions and
|
|
10909
|
+
* limitations under the License.
|
|
10910
|
+
*/
|
|
10862
10911
|
function isSpace(char) {
|
|
10863
10912
|
return [
|
|
10864
10913
|
" ",
|
|
@@ -11205,7 +11254,15 @@ function _createSkeletonWordOrLetter(glyphType, raw, config, glyphWidth) {
|
|
|
11205
11254
|
width = 0;
|
|
11206
11255
|
xOffset = 0;
|
|
11207
11256
|
}
|
|
11208
|
-
|
|
11257
|
+
if (config.stackedText) {
|
|
11258
|
+
width = streamType === _univerjs_core.DataStreamTreeTokenType.PARAGRAPH || contentWidth === 0 ? 0 : bBox.ba + bBox.bd;
|
|
11259
|
+
xOffset = 0;
|
|
11260
|
+
if (contentWidth > bBox.ba + bBox.bd) {
|
|
11261
|
+
bBox.ba = contentWidth / 2;
|
|
11262
|
+
bBox.bd = contentWidth / 2;
|
|
11263
|
+
}
|
|
11264
|
+
}
|
|
11265
|
+
const adjustability = hasFixedTextAdvance || config.stackedText ? {
|
|
11209
11266
|
stretchability: [0, 0],
|
|
11210
11267
|
shrinkability: [0, 0]
|
|
11211
11268
|
} : baseAdjustability(content, width, documentCompatibilityPolicy.mode === "drawingml" && glyphWidth == null ? fontStyle.fontSize * (96 / 72) : width);
|
|
@@ -11223,7 +11280,7 @@ function _createSkeletonWordOrLetter(glyphType, raw, config, glyphWidth) {
|
|
|
11223
11280
|
adjustability,
|
|
11224
11281
|
count: raw.length,
|
|
11225
11282
|
raw,
|
|
11226
|
-
...!hasFixedTextAdvance && glyphWidth == null && !validationGrid(gridType, snapToGrid) && fontStyle.fontKerning === "normal" ? { kerningAdjustment: 0 } : {},
|
|
11283
|
+
...!config.stackedText && !hasFixedTextAdvance && glyphWidth == null && !validationGrid(gridType, snapToGrid) && fontStyle.fontKerning === "normal" ? { kerningAdjustment: 0 } : {},
|
|
11227
11284
|
...spacing && spacing.segments.length > 1 ? { textSpacing: spacing } : {}
|
|
11228
11285
|
};
|
|
11229
11286
|
}
|
|
@@ -14167,6 +14224,7 @@ function clearFontCreateConfigCache() {
|
|
|
14167
14224
|
fontCreateConfigCache.reset();
|
|
14168
14225
|
}
|
|
14169
14226
|
function getFontConfigFromLastGlyph(glyph, sectionBreakConfig, paragraphStyle) {
|
|
14227
|
+
var _sectionBreakConfig$r;
|
|
14170
14228
|
const { ts, fontStyle } = glyph;
|
|
14171
14229
|
const { gridType = _univerjs_core.GridType.LINES, charSpace = 0, pageSize = {
|
|
14172
14230
|
width: Number.POSITIVE_INFINITY,
|
|
@@ -14176,6 +14234,7 @@ function getFontConfigFromLastGlyph(glyph, sectionBreakConfig, paragraphStyle) {
|
|
|
14176
14234
|
const pageWidth = pageSize.width || Number.POSITIVE_INFINITY - marginLeft - marginRight;
|
|
14177
14235
|
return {
|
|
14178
14236
|
documentCompatibilityPolicy: sectionBreakConfig.documentCompatibilityPolicy ?? getDocumentCompatibilityPolicy(),
|
|
14237
|
+
stackedText: (_sectionBreakConfig$r = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r === void 0 ? void 0 : _sectionBreakConfig$r.stackedText,
|
|
14179
14238
|
fontStyle,
|
|
14180
14239
|
textStyle: ts,
|
|
14181
14240
|
balanceSingleByteDoubleByteWidth: sectionBreakConfig.balanceSingleByteDoubleByteWidth,
|
|
@@ -14242,6 +14301,7 @@ function getFontCreateConfig(index, viewModel, paragraphNode, sectionBreakConfig
|
|
|
14242
14301
|
const pageWidth = pageSize.width || Number.POSITIVE_INFINITY - marginLeft - marginRight;
|
|
14243
14302
|
const result = {
|
|
14244
14303
|
fontStyle,
|
|
14304
|
+
stackedText: renderConfig.stackedText,
|
|
14245
14305
|
textStyle: mixTextStyle,
|
|
14246
14306
|
balanceSingleByteDoubleByteWidth: sectionBreakConfig.balanceSingleByteDoubleByteWidth,
|
|
14247
14307
|
charSpace,
|
|
@@ -14436,7 +14496,7 @@ function prepareSectionBreakConfig(ctx, nodeIndex) {
|
|
|
14436
14496
|
sectionType,
|
|
14437
14497
|
sectionTypeNext,
|
|
14438
14498
|
textDirection,
|
|
14439
|
-
renderConfig,
|
|
14499
|
+
renderConfig: viewModel.getLayoutRenderConfig(renderConfig),
|
|
14440
14500
|
autoHyphenation,
|
|
14441
14501
|
spaceWidthEastAsian,
|
|
14442
14502
|
doNotHyphenateCaps,
|
|
@@ -16320,6 +16380,7 @@ function setTabAlignedTextWidths(shapedTextList) {
|
|
|
16320
16380
|
}
|
|
16321
16381
|
}
|
|
16322
16382
|
function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig) {
|
|
16383
|
+
var _sectionBreakConfig$r6;
|
|
16323
16384
|
const shapedTextList = [];
|
|
16324
16385
|
const traditionalLayout = isTraditionalDocumentCompatibility(sectionBreakConfig.documentCompatibilityPolicy ?? getDocumentCompatibilityPolicy(ctx.dataModel.documentStyle.documentFlavor));
|
|
16325
16386
|
const fixedPunctuationPairs = traditionalLayout && (sectionBreakConfig.characterSpacingControl ?? ctx.dataModel.documentStyle.characterSpacingControl) === _univerjs_core.characterSpacingControlType.doNotCompress;
|
|
@@ -16448,7 +16509,7 @@ function shaping(ctx, content, viewModel, paragraphNode, sectionBreakConfig) {
|
|
|
16448
16509
|
appendShapedText(shapedTextList, shapedGlyphs, bk.type, paragraphStyle.fixedTabStops === _univerjs_core.BooleanNumber.TRUE);
|
|
16449
16510
|
last = bk.position;
|
|
16450
16511
|
}
|
|
16451
|
-
if (sectionBreakConfig.spaceWidthEastAsian !== _univerjs_core.BooleanNumber.FALSE) addCJKLatinSpacing(shapedTextList);
|
|
16512
|
+
if (!((_sectionBreakConfig$r6 = sectionBreakConfig.renderConfig) === null || _sectionBreakConfig$r6 === void 0 ? void 0 : _sectionBreakConfig$r6.stackedText) && sectionBreakConfig.spaceWidthEastAsian !== _univerjs_core.BooleanNumber.FALSE) addCJKLatinSpacing(shapedTextList);
|
|
16452
16513
|
setTabAlignedTextWidths(shapedTextList);
|
|
16453
16514
|
return shapedTextList;
|
|
16454
16515
|
}
|
|
@@ -18835,6 +18896,9 @@ var DocumentViewModel = class DocumentViewModel {
|
|
|
18835
18896
|
getParagraphWordWrap(paragraphStyle) {
|
|
18836
18897
|
return paragraphStyle.wordWrap ?? _univerjs_core.BooleanNumber.FALSE;
|
|
18837
18898
|
}
|
|
18899
|
+
getLayoutRenderConfig(config) {
|
|
18900
|
+
return config;
|
|
18901
|
+
}
|
|
18838
18902
|
createLineBreaker(content, paragraphStyle, start) {
|
|
18839
18903
|
return createDocumentLineBreaker(this.getSnapshot(), paragraphStyle, content, start, this.getBody());
|
|
18840
18904
|
}
|
|
@@ -23962,240 +24026,6 @@ var DocumentSkeleton = class DocumentSkeleton extends _univerjs_core.Skeleton {
|
|
|
23962
24026
|
}
|
|
23963
24027
|
};
|
|
23964
24028
|
|
|
23965
|
-
// src/worker-layout.ts
|
|
23966
|
-
const MAX_PAGES_PER_PUBLICATION = 4;
|
|
23967
|
-
/**
|
|
23968
|
-
* Worker-safe owner of the document view model and incremental layout state.
|
|
23969
|
-
* Scheduling, transport, presentation and model revision ordering belong to callers.
|
|
23970
|
-
*/
|
|
23971
|
-
var DocumentLayoutSession = class extends _univerjs_core.Disposable {
|
|
23972
|
-
constructor(dataModel, localeService) {
|
|
23973
|
-
super();
|
|
23974
|
-
_defineProperty(this, "_viewModel", void 0);
|
|
23975
|
-
_defineProperty(this, "_skeleton", void 0);
|
|
23976
|
-
_defineProperty(this, "_lastPublishedPageCount", 0);
|
|
23977
|
-
_defineProperty(this, "_paginationRevision", 0);
|
|
23978
|
-
_defineProperty(this, "_layoutReason", "initial");
|
|
23979
|
-
_defineProperty(this, "_didPublishEditAnchor", false);
|
|
23980
|
-
_defineProperty(this, "_continuousPageSnapshot", null);
|
|
23981
|
-
_defineProperty(this, "_continuousReplacementOffset", void 0);
|
|
23982
|
-
_defineProperty(this, "_publishedHeaderPages", /* @__PURE__ */ new Map());
|
|
23983
|
-
_defineProperty(this, "_publishedFooterPages", /* @__PURE__ */ new Map());
|
|
23984
|
-
_defineProperty(this, "_resetPublishedResources", true);
|
|
23985
|
-
_defineProperty(this, "_pendingPaginatedCompletion", null);
|
|
23986
|
-
this._viewModel = new DocumentViewModel(dataModel);
|
|
23987
|
-
this._skeleton = DocumentSkeleton.create(this._viewModel, localeService, { isolateIncrementalPublications: false });
|
|
23988
|
-
}
|
|
23989
|
-
start(options) {
|
|
23990
|
-
var _options$invalidation;
|
|
23991
|
-
this._lastPublishedPageCount = 0;
|
|
23992
|
-
this._layoutReason = (options === null || options === void 0 ? void 0 : options.reason) ?? "initial";
|
|
23993
|
-
this._paginationRevision = 0;
|
|
23994
|
-
this._didPublishEditAnchor = false;
|
|
23995
|
-
this._publishedHeaderPages.clear();
|
|
23996
|
-
this._publishedFooterPages.clear();
|
|
23997
|
-
this._resetPublishedResources = true;
|
|
23998
|
-
this._pendingPaginatedCompletion = null;
|
|
23999
|
-
if ((options === null || options === void 0 ? void 0 : options.reason) !== "edit") this._continuousPageSnapshot = null;
|
|
24000
|
-
this._continuousReplacementOffset = (options === null || options === void 0 ? void 0 : options.reason) === "edit" ? ((_options$invalidation = options.invalidation) === null || _options$invalidation === void 0 ? void 0 : _options$invalidation.oldStart) ?? options.anchor : void 0;
|
|
24001
|
-
const generation = this._skeleton.startIncrementalLayout({
|
|
24002
|
-
...options,
|
|
24003
|
-
reuseUnaffectedTail: true
|
|
24004
|
-
});
|
|
24005
|
-
const progress = this._skeleton.getLayoutProgress();
|
|
24006
|
-
this._lastPublishedPageCount = (progress === null || progress === void 0 ? void 0 : progress.mode) === "paginated" ? progress.publishedPageCount : 0;
|
|
24007
|
-
return generation;
|
|
24008
|
-
}
|
|
24009
|
-
step(generation, budgetMs = 8, maxWorkUnits = Number.POSITIVE_INFINITY) {
|
|
24010
|
-
var _this$_pendingPaginat;
|
|
24011
|
-
if (((_this$_pendingPaginat = this._pendingPaginatedCompletion) === null || _this$_pendingPaginat === void 0 ? void 0 : _this$_pendingPaginat.generation) === generation) return this._publishPaginatedCompletionBacklog();
|
|
24012
|
-
return this._collectPublications(this._skeleton.stepIncrementalLayout(generation, budgetMs, maxWorkUnits));
|
|
24013
|
-
}
|
|
24014
|
-
publishBacklog(generation) {
|
|
24015
|
-
var _this$_pendingPaginat2;
|
|
24016
|
-
if (((_this$_pendingPaginat2 = this._pendingPaginatedCompletion) === null || _this$_pendingPaginat2 === void 0 ? void 0 : _this$_pendingPaginat2.generation) === generation) return this._publishPaginatedCompletionBacklog();
|
|
24017
|
-
return this._collectPublications(this._skeleton.publishIncrementalLayoutBacklog(generation));
|
|
24018
|
-
}
|
|
24019
|
-
getPage(pageIndex) {
|
|
24020
|
-
var _this$_skeleton$getSk;
|
|
24021
|
-
const page = (_this$_skeleton$getSk = this._skeleton.getSkeletonData()) === null || _this$_skeleton$getSk === void 0 ? void 0 : _this$_skeleton$getSk.pages[pageIndex];
|
|
24022
|
-
if (page == null || page.isLayoutPlaceholder) return null;
|
|
24023
|
-
return {
|
|
24024
|
-
pageIndex,
|
|
24025
|
-
page: serializeDocumentSkeletonPage(page, true)
|
|
24026
|
-
};
|
|
24027
|
-
}
|
|
24028
|
-
resolvePageByOffset(offset) {
|
|
24029
|
-
var _this$_skeleton$getSk2;
|
|
24030
|
-
const pages = (_this$_skeleton$getSk2 = this._skeleton.getSkeletonData()) === null || _this$_skeleton$getSk2 === void 0 ? void 0 : _this$_skeleton$getSk2.pages;
|
|
24031
|
-
if (pages == null || offset < 0) return null;
|
|
24032
|
-
let low = 0;
|
|
24033
|
-
let high = pages.length - 1;
|
|
24034
|
-
while (low <= high) {
|
|
24035
|
-
const pageIndex = Math.floor((low + high) / 2);
|
|
24036
|
-
const page = pages[pageIndex];
|
|
24037
|
-
if (offset < page.st) high = pageIndex - 1;
|
|
24038
|
-
else if (offset > page.ed) low = pageIndex + 1;
|
|
24039
|
-
else if (!page.isLayoutPlaceholder) return {
|
|
24040
|
-
pageIndex,
|
|
24041
|
-
pageNumber: page.pageNumber,
|
|
24042
|
-
startOffset: page.st,
|
|
24043
|
-
endOffset: page.ed
|
|
24044
|
-
};
|
|
24045
|
-
else return null;
|
|
24046
|
-
}
|
|
24047
|
-
return null;
|
|
24048
|
-
}
|
|
24049
|
-
cancel(generation) {
|
|
24050
|
-
var _this$_pendingPaginat3;
|
|
24051
|
-
if (generation == null || ((_this$_pendingPaginat3 = this._pendingPaginatedCompletion) === null || _this$_pendingPaginat3 === void 0 ? void 0 : _this$_pendingPaginat3.generation) === generation) this._pendingPaginatedCompletion = null;
|
|
24052
|
-
this._skeleton.cancelIncrementalLayout(generation);
|
|
24053
|
-
}
|
|
24054
|
-
resetDataModel(dataModel) {
|
|
24055
|
-
this.cancel();
|
|
24056
|
-
this._viewModel.reset(dataModel);
|
|
24057
|
-
this._skeleton.makeDirty(true);
|
|
24058
|
-
this._lastPublishedPageCount = 0;
|
|
24059
|
-
this._continuousReplacementOffset = void 0;
|
|
24060
|
-
this._pendingPaginatedCompletion = null;
|
|
24061
|
-
}
|
|
24062
|
-
getProgress() {
|
|
24063
|
-
return this._skeleton.getLayoutProgress();
|
|
24064
|
-
}
|
|
24065
|
-
static hydratePage(publication, snapshot) {
|
|
24066
|
-
return hydrateDocumentSkeletonPage(publication.page, void 0, snapshot);
|
|
24067
|
-
}
|
|
24068
|
-
dispose() {
|
|
24069
|
-
this._skeleton.dispose();
|
|
24070
|
-
super.dispose();
|
|
24071
|
-
}
|
|
24072
|
-
_collectPublications(initialProgress) {
|
|
24073
|
-
let progress = initialProgress;
|
|
24074
|
-
if ((progress.paginationRevision ?? 0) !== this._paginationRevision) {
|
|
24075
|
-
this._paginationRevision = progress.paginationRevision ?? 0;
|
|
24076
|
-
this._lastPublishedPageCount = 0;
|
|
24077
|
-
this._didPublishEditAnchor = false;
|
|
24078
|
-
}
|
|
24079
|
-
if (!progress.didPublish) return {
|
|
24080
|
-
progress,
|
|
24081
|
-
publication: null
|
|
24082
|
-
};
|
|
24083
|
-
while (progress.mode === "paginated" && !progress.complete && !progress.didPublishAnchor && progress.publishedPageCount < Math.min(this._lastPublishedPageCount + MAX_PAGES_PER_PUBLICATION, progress.pageCount - 1)) {
|
|
24084
|
-
const next = this._skeleton.publishIncrementalLayoutBacklog(progress.generation);
|
|
24085
|
-
if (!next.didPublish || next.cancelled) break;
|
|
24086
|
-
const previousPageCount = progress.publishedPageCount;
|
|
24087
|
-
progress = next;
|
|
24088
|
-
if (progress.publishedPageCount <= previousPageCount) break;
|
|
24089
|
-
}
|
|
24090
|
-
if (progress.complete && progress.mode === "paginated" && progress.publishedPageCount > this._lastPublishedPageCount + 1) {
|
|
24091
|
-
this._pendingPaginatedCompletion = progress;
|
|
24092
|
-
return this._publishPaginatedCompletionBacklog();
|
|
24093
|
-
}
|
|
24094
|
-
return this._collectPublication(progress);
|
|
24095
|
-
}
|
|
24096
|
-
_publishPaginatedCompletionBacklog() {
|
|
24097
|
-
const completion = this._pendingPaginatedCompletion;
|
|
24098
|
-
if (completion == null) throw new Error("Document layout has no paginated completion backlog.");
|
|
24099
|
-
const publishedPageCount = Math.min(completion.publishedPageCount, this._lastPublishedPageCount + (completion.didPublishAnchor && !this._didPublishEditAnchor ? 1 : MAX_PAGES_PER_PUBLICATION));
|
|
24100
|
-
const complete = publishedPageCount === completion.publishedPageCount;
|
|
24101
|
-
const progress = {
|
|
24102
|
-
...completion,
|
|
24103
|
-
publicationRevision: completion.publicationRevision + publishedPageCount,
|
|
24104
|
-
didPublish: true,
|
|
24105
|
-
didPublishAnchor: completion.didPublishAnchor && !this._didPublishEditAnchor,
|
|
24106
|
-
publishedPageCount,
|
|
24107
|
-
complete
|
|
24108
|
-
};
|
|
24109
|
-
if (complete) this._pendingPaginatedCompletion = null;
|
|
24110
|
-
return this._collectPublication(progress);
|
|
24111
|
-
}
|
|
24112
|
-
_collectPublication(progress) {
|
|
24113
|
-
const skeletonData = this._skeleton.getSkeletonData();
|
|
24114
|
-
if (skeletonData == null) throw new Error("Document layout reported a publication without skeleton data.");
|
|
24115
|
-
const resources = this._collectResourcePublication(skeletonData, progress.complete);
|
|
24116
|
-
if (progress.mode === "continuous") {
|
|
24117
|
-
const page = skeletonData.pages[0];
|
|
24118
|
-
if (page == null) throw new Error("Continuous document layout reported a publication without a logical page.");
|
|
24119
|
-
const { block, snapshot } = serializeDocumentSkeletonContinuousBlock(page, this._continuousPageSnapshot, this._continuousReplacementOffset, true);
|
|
24120
|
-
this._continuousPageSnapshot = snapshot;
|
|
24121
|
-
this._continuousReplacementOffset = void 0;
|
|
24122
|
-
return {
|
|
24123
|
-
progress,
|
|
24124
|
-
publication: {
|
|
24125
|
-
kind: "block",
|
|
24126
|
-
left: skeletonData.left,
|
|
24127
|
-
top: skeletonData.top,
|
|
24128
|
-
st: skeletonData.st,
|
|
24129
|
-
...skeletonData.ed == null ? {} : { ed: skeletonData.ed },
|
|
24130
|
-
block,
|
|
24131
|
-
resources
|
|
24132
|
-
}
|
|
24133
|
-
};
|
|
24134
|
-
}
|
|
24135
|
-
const endPageIndex = progress.publishedPageCount;
|
|
24136
|
-
const publishEditAnchor = this._layoutReason === "edit" && progress.didPublishAnchor && !this._didPublishEditAnchor;
|
|
24137
|
-
const startPageIndex = publishEditAnchor ? Math.min(this._lastPublishedPageCount, Math.max(0, endPageIndex - 1)) : this._lastPublishedPageCount;
|
|
24138
|
-
const pages = skeletonData.pages.slice(startPageIndex, endPageIndex).map((page, offset) => ({
|
|
24139
|
-
pageIndex: startPageIndex + offset,
|
|
24140
|
-
page: serializeDocumentSkeletonPage(page, true)
|
|
24141
|
-
}));
|
|
24142
|
-
this._lastPublishedPageCount = Math.max(this._lastPublishedPageCount, endPageIndex);
|
|
24143
|
-
this._didPublishEditAnchor ||= publishEditAnchor;
|
|
24144
|
-
return {
|
|
24145
|
-
progress,
|
|
24146
|
-
publication: {
|
|
24147
|
-
kind: "page",
|
|
24148
|
-
left: skeletonData.left,
|
|
24149
|
-
top: skeletonData.top,
|
|
24150
|
-
st: skeletonData.st,
|
|
24151
|
-
...skeletonData.ed == null ? {} : { ed: skeletonData.ed },
|
|
24152
|
-
pages,
|
|
24153
|
-
resources
|
|
24154
|
-
}
|
|
24155
|
-
};
|
|
24156
|
-
}
|
|
24157
|
-
_collectResourcePublication(skeletonData, complete) {
|
|
24158
|
-
if (complete) {
|
|
24159
|
-
this._publishedHeaderPages.clear();
|
|
24160
|
-
this._publishedFooterPages.clear();
|
|
24161
|
-
}
|
|
24162
|
-
const collect = (source, published) => {
|
|
24163
|
-
const patches = [];
|
|
24164
|
-
for (const [segmentId, pagesByWidth] of source) {
|
|
24165
|
-
let publishedPagesByWidth = published.get(segmentId);
|
|
24166
|
-
if (publishedPagesByWidth == null) {
|
|
24167
|
-
publishedPagesByWidth = /* @__PURE__ */ new Map();
|
|
24168
|
-
published.set(segmentId, publishedPagesByWidth);
|
|
24169
|
-
}
|
|
24170
|
-
const pagePatches = [];
|
|
24171
|
-
for (const [width, page] of pagesByWidth) {
|
|
24172
|
-
if (publishedPagesByWidth.get(width) === page) continue;
|
|
24173
|
-
publishedPagesByWidth.set(width, page);
|
|
24174
|
-
pagePatches.push([width, serializeDocumentSkeletonPage(page, true)]);
|
|
24175
|
-
}
|
|
24176
|
-
if (pagePatches.length > 0) patches.push([segmentId, pagePatches]);
|
|
24177
|
-
}
|
|
24178
|
-
return patches;
|
|
24179
|
-
};
|
|
24180
|
-
const reset = this._resetPublishedResources || complete;
|
|
24181
|
-
this._resetPublishedResources = false;
|
|
24182
|
-
return {
|
|
24183
|
-
reset,
|
|
24184
|
-
skeHeaders: collect(skeletonData.skeHeaders, this._publishedHeaderPages),
|
|
24185
|
-
skeFooters: collect(skeletonData.skeFooters, this._publishedFooterPages),
|
|
24186
|
-
skeListLevel: complete ? [...skeletonData.skeListLevel ?? []].map(([listId, levels]) => [listId, Array.from(levels, (level) => (level ?? []).map(({ bullet, paragraph }) => ({
|
|
24187
|
-
bullet,
|
|
24188
|
-
paragraph
|
|
24189
|
-
})))]) : null,
|
|
24190
|
-
drawingAnchor: complete ? [...skeletonData.drawingAnchor ?? []].map(([segmentId, anchors]) => [segmentId, [...anchors].map(([paragraphIndex, anchor]) => [paragraphIndex, {
|
|
24191
|
-
paragraphIndex: anchor.paragraphIndex,
|
|
24192
|
-
top: anchor.top,
|
|
24193
|
-
...anchor.left == null ? {} : { left: anchor.left }
|
|
24194
|
-
}])]) : null
|
|
24195
|
-
};
|
|
24196
|
-
}
|
|
24197
|
-
};
|
|
24198
|
-
|
|
24199
24029
|
Object.defineProperty(exports, "BASE_OBJECT_ARRAY", {
|
|
24200
24030
|
enumerable: true,
|
|
24201
24031
|
get: function () {
|
|
@@ -24328,12 +24158,6 @@ Object.defineProperty(exports, "DocumentEditArea", {
|
|
|
24328
24158
|
return DocumentEditArea;
|
|
24329
24159
|
}
|
|
24330
24160
|
});
|
|
24331
|
-
Object.defineProperty(exports, "DocumentLayoutSession", {
|
|
24332
|
-
enumerable: true,
|
|
24333
|
-
get: function () {
|
|
24334
|
-
return DocumentLayoutSession;
|
|
24335
|
-
}
|
|
24336
|
-
});
|
|
24337
24161
|
Object.defineProperty(exports, "DocumentSkeleton", {
|
|
24338
24162
|
enumerable: true,
|
|
24339
24163
|
get: function () {
|
|
@@ -24976,6 +24800,12 @@ Object.defineProperty(exports, "hasTibetan", {
|
|
|
24976
24800
|
return hasTibetan;
|
|
24977
24801
|
}
|
|
24978
24802
|
});
|
|
24803
|
+
Object.defineProperty(exports, "hydrateDocumentSkeletonPage", {
|
|
24804
|
+
enumerable: true,
|
|
24805
|
+
get: function () {
|
|
24806
|
+
return hydrateDocumentSkeletonPage;
|
|
24807
|
+
}
|
|
24808
|
+
});
|
|
24979
24809
|
Object.defineProperty(exports, "inViewRanges", {
|
|
24980
24810
|
enumerable: true,
|
|
24981
24811
|
get: function () {
|
|
@@ -25174,6 +25004,18 @@ Object.defineProperty(exports, "resolveHeaderFooterFieldGlyph", {
|
|
|
25174
25004
|
return resolveHeaderFooterFieldGlyph;
|
|
25175
25005
|
}
|
|
25176
25006
|
});
|
|
25007
|
+
Object.defineProperty(exports, "serializeDocumentSkeletonContinuousBlock", {
|
|
25008
|
+
enumerable: true,
|
|
25009
|
+
get: function () {
|
|
25010
|
+
return serializeDocumentSkeletonContinuousBlock;
|
|
25011
|
+
}
|
|
25012
|
+
});
|
|
25013
|
+
Object.defineProperty(exports, "serializeDocumentSkeletonPage", {
|
|
25014
|
+
enumerable: true,
|
|
25015
|
+
get: function () {
|
|
25016
|
+
return serializeDocumentSkeletonPage;
|
|
25017
|
+
}
|
|
25018
|
+
});
|
|
25177
25019
|
Object.defineProperty(exports, "setDocsCustomBlockRenderViewportProvider", {
|
|
25178
25020
|
enumerable: true,
|
|
25179
25021
|
get: function () {
|