@univerjs/engine-render 0.4.0-alpha.0 → 0.4.0-alpha.2
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/lib/cjs/index.js +1 -1
- package/lib/es/index.js +43 -29
- package/lib/types/canvas.d.ts +2 -0
- package/lib/types/components/docs/extensions/font-and-base-line.d.ts +1 -1
- package/lib/types/engine.d.ts +1 -0
- package/lib/types/render-manager/render-manager.service.d.ts +3 -3
- package/lib/types/scene.transformer.d.ts +2 -2
- package/lib/types/shape/rect.d.ts +2 -2
- package/lib/types/shape/shape.d.ts +3 -1
- package/lib/umd/index.js +1 -1
- package/package.json +4 -5
package/lib/es/index.js
CHANGED
|
@@ -4286,6 +4286,9 @@ const _Canvas = class _Canvas {
|
|
|
4286
4286
|
getHeight() {
|
|
4287
4287
|
return this._height;
|
|
4288
4288
|
}
|
|
4289
|
+
setId(id) {
|
|
4290
|
+
this._canvasEle.id = id;
|
|
4291
|
+
}
|
|
4289
4292
|
setSize(width, height, pixelRatioParam) {
|
|
4290
4293
|
var _a10;
|
|
4291
4294
|
this._pixelRatio = pixelRatioParam || getDevicePixelRatio();
|
|
@@ -26232,7 +26235,7 @@ const UNIQUE_KEY$2 = "DefaultDocsBorderExtension", _Border = class _Border exten
|
|
|
26232
26235
|
__name(_Border, "Border");
|
|
26233
26236
|
let Border = _Border;
|
|
26234
26237
|
DocumentsSpanAndLineExtensionRegistry.add(new Border());
|
|
26235
|
-
const SHAPE_OBJECT_ARRAY = [
|
|
26238
|
+
const BASE_OBJECT_ARRAY_Set = new Set(BASE_OBJECT_ARRAY), SHAPE_OBJECT_ARRAY = [
|
|
26236
26239
|
"hoverCursor",
|
|
26237
26240
|
"moveCursor",
|
|
26238
26241
|
"fillRule",
|
|
@@ -26410,7 +26413,7 @@ const SHAPE_OBJECT_ARRAY = [
|
|
|
26410
26413
|
return themeKeys.length === 0 ? this : (themeKeys.forEach((key) => {
|
|
26411
26414
|
if (props[key] === void 0)
|
|
26412
26415
|
return !0;
|
|
26413
|
-
|
|
26416
|
+
BASE_OBJECT_ARRAY_Set.has(key) || (this[`_${key}`] = props[key]);
|
|
26414
26417
|
}), this.makeDirty(!0), this);
|
|
26415
26418
|
}
|
|
26416
26419
|
toJson() {
|
|
@@ -26432,10 +26435,15 @@ const SHAPE_OBJECT_ARRAY = [
|
|
|
26432
26435
|
return;
|
|
26433
26436
|
const transformState = {};
|
|
26434
26437
|
let hasTransformState = !1;
|
|
26438
|
+
const hasRotateEnabled = (props == null ? void 0 : props.rotateEnabled) !== void 0, hasResizeEnabled = (props == null ? void 0 : props.resizeEnabled) !== void 0;
|
|
26439
|
+
if (hasRotateEnabled || hasResizeEnabled) {
|
|
26440
|
+
const transformerConfig = this.transformerConfig || {};
|
|
26441
|
+
hasRotateEnabled && (transformerConfig.rotateEnabled = props == null ? void 0 : props.rotateEnabled), hasResizeEnabled && (transformerConfig.resizeEnabled = props == null ? void 0 : props.resizeEnabled), this.transformerConfig = { ...transformerConfig };
|
|
26442
|
+
}
|
|
26435
26443
|
themeKeys.forEach((key) => {
|
|
26436
26444
|
if (props[key] === void 0)
|
|
26437
26445
|
return !0;
|
|
26438
|
-
|
|
26446
|
+
BASE_OBJECT_ARRAY_Set.has(key) ? (transformState[key] = props[key], hasTransformState = !0) : this[`_${key}`] = props[key];
|
|
26439
26447
|
}), hasTransformState && this.transformByState(transformState), this.makeDirty(!0);
|
|
26440
26448
|
}
|
|
26441
26449
|
};
|
|
@@ -27907,9 +27915,10 @@ const UNIQUE_KEY$1 = "DefaultDocsFontAndBaseLineExtension", DOC_EXTENSION_Z_INDE
|
|
|
27907
27915
|
else {
|
|
27908
27916
|
const CHECKED_GLYPH = "☑";
|
|
27909
27917
|
if ((content === "☐" || content === CHECKED_GLYPH) && glyph.glyphType === GlyphType.LIST) {
|
|
27910
|
-
ctx.save();
|
|
27911
27918
|
const size = Math.ceil(((_b = (_a10 = glyph.ts) == null ? void 0 : _a10.fs) != null ? _b : 12) * 1.2);
|
|
27912
|
-
ctx.
|
|
27919
|
+
ctx.save();
|
|
27920
|
+
const fontWidth = glyph.bBox.width, fontHeight = glyph.bBox.aba - glyph.bBox.abd, bottom = spanPointWithFont.y, top = bottom - fontHeight, left = spanPointWithFont.x, right = left + fontWidth, topOffset = top + (bottom - top - size) / 2, leftOffset = left + (right - left - size) / 2, BORDER_WIDTH = 1;
|
|
27921
|
+
ctx.translate(leftOffset - BORDER_WIDTH / 2, topOffset - BORDER_WIDTH / 2), Checkbox.drawWith(ctx, {
|
|
27913
27922
|
width: size,
|
|
27914
27923
|
height: size,
|
|
27915
27924
|
checked: content === CHECKED_GLYPH
|
|
@@ -29428,6 +29437,7 @@ const _ThinEngine = class _ThinEngine extends Disposable {
|
|
|
29428
29437
|
__name(_ThinEngine, "ThinEngine");
|
|
29429
29438
|
let ThinEngine = _ThinEngine;
|
|
29430
29439
|
const _Engine = class _Engine extends ThinEngine {
|
|
29440
|
+
// unitId
|
|
29431
29441
|
constructor(elemWidth = 1, elemHeight = 1, pixelRatio, mode) {
|
|
29432
29442
|
super();
|
|
29433
29443
|
__publicField(this, "renderEvenInBackground", !0);
|
|
@@ -29479,6 +29489,7 @@ const _Engine = class _Engine extends ThinEngine {
|
|
|
29479
29489
|
__publicField(this, "_isUsingFirefox", navigator.userAgent.indexOf("Firefox") !== -1);
|
|
29480
29490
|
__publicField(this, "_previousWidth", -1e3);
|
|
29481
29491
|
__publicField(this, "_previousHeight", -1e3);
|
|
29492
|
+
__publicField(this, "_unitId", "");
|
|
29482
29493
|
this._canvas = new Canvas({
|
|
29483
29494
|
mode,
|
|
29484
29495
|
width: elemWidth,
|
|
@@ -31322,7 +31333,7 @@ const TransformerManagerTypeArray = [
|
|
|
31322
31333
|
}), this._transformerControlMap.clear();
|
|
31323
31334
|
}
|
|
31324
31335
|
_createControl(applyObject, isSkipOnCropper = !0) {
|
|
31325
|
-
const { left = 0, top = 0, height = 0, width = 0 } = applyObject.getState(), angle = applyObject.angle, { isCropper, resizeEnabled, rotateAnchorOffset, rotateSize, rotateCornerRadius, borderEnabled, borderStroke, borderStrokeWidth, borderSpacing, enabledAnchors } = this._getConfig(applyObject);
|
|
31336
|
+
const { left = 0, top = 0, height = 0, width = 0 } = applyObject.getState(), angle = applyObject.angle, { isCropper, resizeEnabled, rotateEnabled, rotateAnchorOffset, rotateSize, rotateCornerRadius, borderEnabled, borderStroke, borderStrokeWidth, borderSpacing, enabledAnchors } = this._getConfig(applyObject);
|
|
31326
31337
|
if (isSkipOnCropper && isCropper)
|
|
31327
31338
|
return;
|
|
31328
31339
|
const oKey = applyObject.oKey, zIndex = this._selectedObjectMap.size + applyObject.maxZIndex + DEFAULT_CONTROL_PLUS_INDEX, layerIndex = applyObject.getLayerIndex() || DEFAULT_TRANSFORMER_LAYER_INDEX, groupElements = [];
|
|
@@ -31342,29 +31353,32 @@ const TransformerManagerTypeArray = [
|
|
|
31342
31353
|
height,
|
|
31343
31354
|
width,
|
|
31344
31355
|
applyObject
|
|
31345
|
-
)
|
|
31346
|
-
|
|
31347
|
-
|
|
31348
|
-
|
|
31349
|
-
|
|
31350
|
-
|
|
31351
|
-
|
|
31352
|
-
|
|
31353
|
-
|
|
31354
|
-
|
|
31355
|
-
|
|
31356
|
-
|
|
31357
|
-
|
|
31358
|
-
|
|
31359
|
-
|
|
31360
|
-
|
|
31361
|
-
|
|
31362
|
-
|
|
31363
|
-
|
|
31364
|
-
|
|
31365
|
-
|
|
31366
|
-
|
|
31367
|
-
|
|
31356
|
+
);
|
|
31357
|
+
if (rotateEnabled) {
|
|
31358
|
+
const rotateLine = new Rect(`__SpreadsheetTransformerRotateLine___${zIndex}`, {
|
|
31359
|
+
zIndex: zIndex - 1,
|
|
31360
|
+
evented: !1,
|
|
31361
|
+
left: lineLeft,
|
|
31362
|
+
top: lineTop,
|
|
31363
|
+
height: rotateAnchorOffset,
|
|
31364
|
+
width: 1,
|
|
31365
|
+
strokeWidth: borderStrokeWidth,
|
|
31366
|
+
stroke: borderStroke
|
|
31367
|
+
}), { left: left2, top: top2 } = this._getRotateAnchorPosition("__SpreadsheetTransformerRotate__", height, width, applyObject), cursor = this._getRotateAnchorCursor(
|
|
31368
|
+
"__SpreadsheetTransformerRotate__"
|
|
31369
|
+
/* ROTATE */
|
|
31370
|
+
), rotate = new Rect(`__SpreadsheetTransformerRotate___${zIndex}`, {
|
|
31371
|
+
zIndex: zIndex - 1,
|
|
31372
|
+
left: left2,
|
|
31373
|
+
top: top2,
|
|
31374
|
+
height: rotateSize,
|
|
31375
|
+
width: rotateSize,
|
|
31376
|
+
radius: rotateCornerRadius,
|
|
31377
|
+
strokeWidth: borderStrokeWidth * 2,
|
|
31378
|
+
stroke: borderStroke
|
|
31379
|
+
});
|
|
31380
|
+
this._attachEventToRotate(rotate, applyObject), this._attachHover(rotate, cursor, CURSOR_TYPE.DEFAULT), groupElements.push(rotateLine, rotate);
|
|
31381
|
+
}
|
|
31368
31382
|
}
|
|
31369
31383
|
if (resizeEnabled)
|
|
31370
31384
|
for (let i = 0, len = enabledAnchors.length; i < len; i++) {
|
package/lib/types/canvas.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ interface ICanvasProps {
|
|
|
19
19
|
height?: number;
|
|
20
20
|
pixelRatio?: number;
|
|
21
21
|
mode?: CanvasRenderMode;
|
|
22
|
+
id?: string;
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* View Renderer constructor. It is a wrapper around native canvas element.
|
|
@@ -48,6 +49,7 @@ export declare class Canvas {
|
|
|
48
49
|
getPixelRatio(): number;
|
|
49
50
|
getWidth(): number;
|
|
50
51
|
getHeight(): number;
|
|
52
|
+
setId(id: string): void;
|
|
51
53
|
setSize(width?: number, height?: number, pixelRatioParam?: number): void;
|
|
52
54
|
setPixelRatio(pixelRatio: number): void;
|
|
53
55
|
dispose(): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IScale } from '@univerjs/core';
|
|
2
|
-
import { docExtension } from '../doc-extension';
|
|
3
2
|
import { IDocumentSkeletonGlyph } from '../../../basics/i-document-skeleton-cached';
|
|
4
3
|
import { UniverRenderingContext } from '../../../context';
|
|
4
|
+
import { docExtension } from '../doc-extension';
|
|
5
5
|
export declare class FontAndBaseLine extends docExtension {
|
|
6
6
|
uKey: string;
|
|
7
7
|
Z_INDEX: number;
|
package/lib/types/engine.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ export declare class Engine extends ThinEngine<Scene> {
|
|
|
54
54
|
private _isUsingFirefox;
|
|
55
55
|
private _previousWidth;
|
|
56
56
|
private _previousHeight;
|
|
57
|
+
private _unitId;
|
|
57
58
|
constructor(elemWidth?: number, elemHeight?: number, pixelRatio?: number, mode?: CanvasRenderMode);
|
|
58
59
|
_init(): void;
|
|
59
60
|
get elapsedTime(): number;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Dependency, DependencyIdentifier, IDisposable, Nullable, UnitModel, UnitType, Disposable, Injector, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { Engine } from '../engine';
|
|
4
|
-
import { IRender, RenderUnit } from './render-unit';
|
|
5
3
|
import { BaseObject } from '../base-object';
|
|
6
4
|
import { DocComponent } from '../components/docs/doc-component';
|
|
7
5
|
import { SheetComponent } from '../components/sheets/sheet-component';
|
|
8
6
|
import { Slide } from '../components/slides/slide';
|
|
7
|
+
import { Engine } from '../engine';
|
|
8
|
+
import { IRender, RenderUnit } from './render-unit';
|
|
9
9
|
export type RenderComponentType = SheetComponent | DocComponent | Slide | BaseObject;
|
|
10
10
|
export interface IRenderManagerService extends IDisposable {
|
|
11
11
|
/** @deprecated */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Nullable, Disposable } from '@univerjs/core';
|
|
2
2
|
import { BaseObject } from './base-object';
|
|
3
3
|
import { IMouseEvent, IPointerEvent } from './basics/i-events';
|
|
4
|
-
import { Group } from './group';
|
|
5
|
-
import { Scene } from './scene';
|
|
6
4
|
import { ITransformerConfig } from './basics/transformer-config';
|
|
5
|
+
import { Scene } from './scene';
|
|
6
|
+
import { Group } from './group';
|
|
7
7
|
declare enum MoveObserverType {
|
|
8
8
|
MOVE_START = 0,
|
|
9
9
|
MOVING = 1,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Nullable } from '@univerjs/core';
|
|
2
|
-
import { ObjectType } from '../base-object';
|
|
3
|
-
import { Shape, IShapeProps } from './shape';
|
|
4
2
|
import { UniverRenderingContext } from '../context';
|
|
3
|
+
import { IShapeProps, Shape } from './shape';
|
|
4
|
+
import { ObjectType } from '../base-object';
|
|
5
5
|
export interface IRectProps extends IShapeProps {
|
|
6
6
|
radius?: number;
|
|
7
7
|
visualHeight?: number;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { IOffset, IScale, ISize, Nullable } from '@univerjs/core';
|
|
2
|
-
import { BaseObject, ObjectType } from '../base-object';
|
|
3
2
|
import { IObjectFullState } from '../basics/interfaces';
|
|
4
3
|
import { IViewportInfo, Vector2 } from '../basics/vector2';
|
|
5
4
|
import { UniverRenderingContext } from '../context';
|
|
5
|
+
import { BaseObject, ObjectType } from '../base-object';
|
|
6
6
|
export type LineJoin = 'round' | 'bevel' | 'miter';
|
|
7
7
|
export type LineCap = 'butt' | 'round' | 'square';
|
|
8
8
|
export type PaintFirst = 'fill' | 'stroke';
|
|
9
9
|
export interface IShapeProps extends IObjectFullState, ISize, IOffset, IScale {
|
|
10
|
+
rotateEnabled?: boolean;
|
|
11
|
+
resizeEnabled?: boolean;
|
|
10
12
|
hoverCursor?: Nullable<string>;
|
|
11
13
|
moveCursor?: string | null;
|
|
12
14
|
fillRule?: string;
|