ducjs 2.2.3 → 2.4.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/flatbuffers/duc/document-grid-align-items.d.ts +5 -0
- package/dist/flatbuffers/duc/document-grid-align-items.js +8 -0
- package/dist/flatbuffers/duc/document-grid-config.d.ts +24 -0
- package/dist/flatbuffers/duc/document-grid-config.js +81 -0
- package/dist/flatbuffers/duc/duc-doc-element.d.ts +6 -0
- package/dist/flatbuffers/duc/duc-doc-element.js +16 -1
- package/dist/flatbuffers/duc/duc-model-element.d.ts +26 -0
- package/dist/flatbuffers/duc/duc-model-element.js +79 -0
- package/dist/flatbuffers/duc/duc-pdf-element.d.ts +3 -1
- package/dist/flatbuffers/duc/duc-pdf-element.js +9 -7
- package/dist/flatbuffers/duc/element.d.ts +5 -3
- package/dist/flatbuffers/duc/element.js +4 -0
- package/dist/flatbuffers/duc.d.ts +3 -0
- package/dist/flatbuffers/duc.js +3 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -3
- package/dist/lazy-files.d.ts +84 -0
- package/dist/lazy-files.js +207 -0
- package/dist/parse.d.ts +35 -2
- package/dist/parse.js +244 -14
- package/dist/restore/restoreDataState.d.ts +1 -6
- package/dist/restore/restoreDataState.js +4 -11
- package/dist/restore/restoreElements.js +51 -26
- package/dist/serialize.js +56 -27
- package/dist/types/elements/index.d.ts +32 -31
- package/dist/types/elements/typeChecks.d.ts +4 -1
- package/dist/types/elements/typeChecks.js +7 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +1 -1
- package/dist/utils/constants.d.ts +18 -14
- package/dist/utils/constants.js +28 -15
- package/dist/utils/elements/freedrawElement.d.ts +6 -0
- package/dist/utils/elements/freedrawElement.js +28 -11
- package/dist/utils/elements/newElement.d.ts +2 -2
- package/dist/utils/elements/newElement.js +14 -5
- package/dist/utils/elements/textElement.d.ts +3 -3
- package/dist/utils/elements/textElement.js +43 -16
- package/dist/utils/state/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Scope } from "../../types";
|
|
2
|
-
import { DucArrowElement, DucDimensionElement, DucDocElement, DucElement, DucEllipseElement, DucEmbeddableElement, DucFeatureControlFrameElement, DucFrameElement, DucFreeDrawElement, DucGenericElement, DucImageElement, DucLeaderElement, DucLinearElement, DucMermaidElement,
|
|
2
|
+
import { DucArrowElement, DucDimensionElement, DucDocElement, DucElement, DucEllipseElement, DucEmbeddableElement, DucFeatureControlFrameElement, DucFrameElement, DucFreeDrawElement, DucGenericElement, DucImageElement, DucLeaderElement, DucLinearElement, DucMermaidElement, DucModelElement, DucPdfElement, DucPlotElement, DucPolygonElement, DucTableElement, DucTextElement, DucViewportElement, DucXRayElement, ElementConstructorOpts, ElementUpdate, NonDeleted } from "../../types/elements";
|
|
3
3
|
import { Mutable } from "../../types/utility-types";
|
|
4
4
|
export declare const newElementWith: <TElement extends DucElement>(element: TElement, updates: ElementUpdate<TElement>,
|
|
5
5
|
/** pass `true` to always regenerate */
|
|
@@ -46,7 +46,7 @@ export declare const newXRayElement: (currentScope: Scope, opts: ElementConstruc
|
|
|
46
46
|
export declare const newLeaderElement: (currentScope: Scope, opts: Partial<DucLeaderElement> & ElementConstructorOpts) => NonDeleted<DucLeaderElement>;
|
|
47
47
|
export declare const newDimensionElement: (currentScope: Scope, opts: ElementConstructorOpts) => NonDeleted<DucDimensionElement>;
|
|
48
48
|
export declare const newFeatureControlFrameElement: (currentScope: Scope, opts: ElementConstructorOpts) => NonDeleted<DucFeatureControlFrameElement>;
|
|
49
|
-
export declare const newParametricElement: (currentScope: Scope, opts: ElementConstructorOpts) => NonDeleted<
|
|
49
|
+
export declare const newParametricElement: (currentScope: Scope, opts: ElementConstructorOpts) => NonDeleted<DucModelElement>;
|
|
50
50
|
/**
|
|
51
51
|
* Clones DucElement data structure. Does not regenerate id, nonce, or
|
|
52
52
|
* any value. The purpose is to to break object references for immutability
|
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { getUpdatedTimestamp, getZoom } from "..";
|
|
13
|
-
import { BLOCK_ATTACHMENT, COLUMN_TYPE, DATUM_BRACKET_STYLE, IMAGE_STATUS, LINE_SPACING_TYPE,
|
|
13
|
+
import { BLOCK_ATTACHMENT, COLUMN_TYPE, DATUM_BRACKET_STYLE, IMAGE_STATUS, LINE_SPACING_TYPE, STACKED_TEXT_ALIGN, TEXT_FLOW_DIRECTION, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT } from "../../flatbuffers/duc";
|
|
14
14
|
import { getPrecisionValueFromRaw } from "../../technical/scopes";
|
|
15
15
|
import { DEFAULT_ELEMENT_PROPS, DEFAULT_ELLIPSE_ELEMENT, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FREEDRAW_ELEMENT, DEFAULT_POLYGON_SIDES, DEFAULT_TEXT_ALIGN, DEFAULT_VERTICAL_ALIGN } from "../constants";
|
|
16
16
|
import { randomId, randomInteger } from "../math/random";
|
|
@@ -123,13 +123,22 @@ export const newTextElement = (currentScope, opts) => {
|
|
|
123
123
|
const textAlign = opts.textAlign || DEFAULT_TEXT_ALIGN;
|
|
124
124
|
const verticalAlign = opts.verticalAlign || DEFAULT_VERTICAL_ALIGN;
|
|
125
125
|
const offsets = getTextElementPositionOffsets({ textAlign, verticalAlign }, metrics);
|
|
126
|
+
// Minimum dimensions: at least 1px wide, at least one line high (NaN-safe)
|
|
127
|
+
const rawMinLineHeight = fontSize.value * lineHeight;
|
|
128
|
+
const minLineHeight = (Number.isFinite(rawMinLineHeight) && rawMinLineHeight > 0)
|
|
129
|
+
? rawMinLineHeight
|
|
130
|
+
: DEFAULT_FONT_SIZE * lineHeight;
|
|
131
|
+
const finalWidth = (Number.isFinite(metrics.width) && metrics.width > 0) ? metrics.width : 1;
|
|
132
|
+
const finalHeight = (Number.isFinite(metrics.height) && metrics.height > 0)
|
|
133
|
+
? Math.max(metrics.height, minLineHeight)
|
|
134
|
+
: minLineHeight;
|
|
126
135
|
const x = getPrecisionValueFromRaw(opts.x.value - offsets.x, scope, currentScope);
|
|
127
136
|
const y = getPrecisionValueFromRaw(opts.y.value - offsets.y, scope, currentScope);
|
|
128
137
|
return Object.assign(Object.assign({}, _newElementBase("text", currentScope, Object.assign(Object.assign({}, opts), { x, y }))), { type: "text", text,
|
|
129
138
|
fontSize,
|
|
130
139
|
fontFamily,
|
|
131
140
|
textAlign,
|
|
132
|
-
verticalAlign, width: getPrecisionValueFromRaw(
|
|
141
|
+
verticalAlign, width: getPrecisionValueFromRaw(finalWidth, scope, currentScope), height: getPrecisionValueFromRaw(finalHeight, scope, currentScope), containerId: opts.containerId || null, originalText: (_b = opts.originalText) !== null && _b !== void 0 ? _b : text, autoResize: (_c = opts.autoResize) !== null && _c !== void 0 ? _c : true, lineHeight,
|
|
133
142
|
// DucTextStyle properties
|
|
134
143
|
isLtr: (_d = opts.isLtr) !== null && _d !== void 0 ? _d : true, bigFontFamily: opts.bigFontFamily || "sans-serif", lineSpacing: opts.lineSpacing || { type: LINE_SPACING_TYPE.MULTIPLE, value: lineHeight }, obliqueAngle: opts.obliqueAngle || 0, paperTextHeight: opts.paperTextHeight, widthFactor: opts.widthFactor || 1, isUpsideDown: (_e = opts.isUpsideDown) !== null && _e !== void 0 ? _e : false, isBackwards: (_f = opts.isBackwards) !== null && _f !== void 0 ? _f : false, dynamic: opts.dynamic || [] });
|
|
135
144
|
};
|
|
@@ -153,11 +162,11 @@ export const newImageElement = (currentScope, opts) => {
|
|
|
153
162
|
export const newTableElement = (currentScope, opts) => (Object.assign(Object.assign(Object.assign({}, _newElementBase("table", currentScope, opts)), getDefaultTableData(currentScope)), { type: "table" }));
|
|
154
163
|
export const newDocElement = (currentScope, opts) => {
|
|
155
164
|
var _a, _b, _c, _d;
|
|
156
|
-
return (Object.assign(Object.assign({}, _newElementBase("doc", currentScope, opts)), { type: "doc", text: opts.text || "", dynamic: opts.dynamic || [], flowDirection: opts.flowDirection || TEXT_FLOW_DIRECTION.TOP_TO_BOTTOM, columns: opts.columns || { type: COLUMN_TYPE.NO_COLUMNS, definitions: [], autoHeight: true }, autoResize: (_a = opts.autoResize) !== null && _a !== void 0 ? _a : true,
|
|
165
|
+
return (Object.assign(Object.assign({}, _newElementBase("doc", currentScope, opts)), { type: "doc", text: opts.text || "", dynamic: opts.dynamic || [], flowDirection: opts.flowDirection || TEXT_FLOW_DIRECTION.TOP_TO_BOTTOM, columns: opts.columns || { type: COLUMN_TYPE.NO_COLUMNS, definitions: [], autoHeight: true }, autoResize: (_a = opts.autoResize) !== null && _a !== void 0 ? _a : true, fileId: null, gridConfig: { columns: 1, gapX: 0, gapY: 0, alignItems: 'start', firstPageAlone: false, scale: 1 },
|
|
157
166
|
// DucDocStyle properties
|
|
158
167
|
isLtr: (_b = opts.isLtr) !== null && _b !== void 0 ? _b : true, fontFamily: opts.fontFamily || DEFAULT_FONT_FAMILY, bigFontFamily: opts.bigFontFamily || "sans-serif", textAlign: opts.textAlign || DEFAULT_TEXT_ALIGN, verticalAlign: opts.verticalAlign || DEFAULT_VERTICAL_ALIGN, lineHeight: opts.lineHeight || 1.2, lineSpacing: opts.lineSpacing || { type: LINE_SPACING_TYPE.MULTIPLE, value: 1.2 }, obliqueAngle: opts.obliqueAngle || 0, fontSize: opts.fontSize || getPrecisionValueFromRaw(DEFAULT_FONT_SIZE, currentScope, currentScope), paperTextHeight: opts.paperTextHeight, widthFactor: opts.widthFactor || 1, isUpsideDown: (_c = opts.isUpsideDown) !== null && _c !== void 0 ? _c : false, isBackwards: (_d = opts.isBackwards) !== null && _d !== void 0 ? _d : false, paragraph: opts.paragraph || { firstLineIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), hangingIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), leftIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), rightIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), spaceBefore: getPrecisionValueFromRaw(0, currentScope, currentScope), spaceAfter: getPrecisionValueFromRaw(0, currentScope, currentScope), tabStops: [] }, stackFormat: opts.stackFormat || { autoStack: false, stackChars: [], properties: { upperScale: 0.7, lowerScale: 0.7, alignment: STACKED_TEXT_ALIGN.CENTER } } }));
|
|
159
168
|
};
|
|
160
|
-
export const newPdfElement = (currentScope, opts) => (Object.assign(Object.assign({ fileId: null }, _newElementBase("pdf", currentScope, opts)), { type: "pdf" }));
|
|
169
|
+
export const newPdfElement = (currentScope, opts) => (Object.assign(Object.assign({ fileId: null, gridConfig: { columns: 1, gapX: 0, gapY: 0, alignItems: 'start', firstPageAlone: false, scale: 1 } }, _newElementBase("pdf", currentScope, opts)), { type: "pdf" }));
|
|
161
170
|
export const newMermaidElement = (currentScope, opts) => (Object.assign(Object.assign({ source: "", theme: undefined, svgPath: null }, _newElementBase("mermaid", currentScope, opts)), { type: "mermaid" }));
|
|
162
171
|
export const newXRayElement = (currentScope, opts) => (Object.assign(Object.assign({ origin: { x: getPrecisionValueFromRaw(0, currentScope, currentScope), y: getPrecisionValueFromRaw(0, currentScope, currentScope) }, direction: { x: getPrecisionValueFromRaw(1, currentScope, currentScope), y: getPrecisionValueFromRaw(0, currentScope, currentScope) }, startFromOrigin: false, color: '#FF00FF' }, _newElementBase("xray", currentScope, opts)), { type: "xray" }));
|
|
163
172
|
export const newLeaderElement = (currentScope, opts) => {
|
|
@@ -179,7 +188,7 @@ export const newFeatureControlFrameElement = (currentScope, opts) => {
|
|
|
179
188
|
bracketStyle: DATUM_BRACKET_STYLE.SQUARE
|
|
180
189
|
} }, _newElementBase("featurecontrolframe", currentScope, opts)), { type: "featurecontrolframe" });
|
|
181
190
|
};
|
|
182
|
-
export const newParametricElement = (currentScope, opts) => (Object.assign(Object.assign({ source:
|
|
191
|
+
export const newParametricElement = (currentScope, opts) => (Object.assign(Object.assign({ source: "", svgPath: null, fileIds: [] }, _newElementBase("model", currentScope, opts)), { type: 'model' }));
|
|
183
192
|
// Simplified deep clone for the purpose of cloning DucElement.
|
|
184
193
|
//
|
|
185
194
|
// Only clones plain objects and arrays. Doesn't clone Date, RegExp, Map, Set,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { SupportedMeasures } from "../../technical/scopes";
|
|
1
2
|
import { DucLocalState, RawValue, Scope, ScopedValue } from "../../types";
|
|
2
3
|
import { DucElement, DucElementType, DucTextContainer, DucTextElement, DucTextElementWithContainer, ElementsMap, FontFamilyValues, FontString, NonDeletedDucElement } from "../../types/elements";
|
|
3
4
|
import { GeometricPoint } from "../../types/geometryTypes";
|
|
4
5
|
import { ExtractSetType } from "../../types/utility-types";
|
|
5
6
|
import { getBoundTextElementPosition } from "./linearElement";
|
|
6
|
-
import { SupportedMeasures } from "../../technical/scopes";
|
|
7
7
|
export declare const computeBoundTextPosition: (container: DucElement, boundTextElement: DucTextElementWithContainer, elementsMap: ElementsMap, currentScope: SupportedMeasures) => {
|
|
8
8
|
x: ScopedValue;
|
|
9
9
|
y: ScopedValue;
|
|
@@ -49,12 +49,12 @@ export declare const getMinTextElementWidth: (font: FontString, lineHeight: DucT
|
|
|
49
49
|
/** retrieves text from text elements and concatenates to a single string */
|
|
50
50
|
export declare const getTextFromElements: (elements: readonly DucElement[], separator?: string) => string;
|
|
51
51
|
export declare const getFontFamilyString: ({ fontFamily, }: {
|
|
52
|
-
fontFamily: FontFamilyValues;
|
|
52
|
+
fontFamily: FontFamilyValues | string;
|
|
53
53
|
}) => string;
|
|
54
54
|
/** returns fontSize+fontFamily string for assignment to DOM elements */
|
|
55
55
|
export declare const getFontString: ({ fontSize, fontFamily, }: {
|
|
56
56
|
fontSize: DucTextElement["fontSize"];
|
|
57
|
-
fontFamily: FontFamilyValues;
|
|
57
|
+
fontFamily: FontFamilyValues | string;
|
|
58
58
|
}) => FontString;
|
|
59
59
|
/** computes element x/y offset based on textAlign/verticalAlign */
|
|
60
60
|
export declare const getTextElementPositionOffsets: (opts: {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { TEXT_ALIGN, VERTICAL_ALIGN } from "../../flatbuffers/duc";
|
|
2
|
+
import { getPrecisionValueFromRaw, getScopedBezierPointFromDucPoint } from "../../technical/scopes";
|
|
2
3
|
import { isArrowElement, isBoundToContainer, isTextElement } from "../../types/elements/typeChecks";
|
|
3
4
|
import { getContainerElement, getElementAbsoluteCoords, getResizedElementAbsoluteCoords } from "../bounds";
|
|
4
|
-
import { ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO, ARROW_LABEL_WIDTH_FRACTION, BOUND_TEXT_PADDING, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE,
|
|
5
|
-
import { getBoundTextElementPosition, getPointGlobalCoordinates, getPointsGlobalCoordinates, getSegmentMidPoint } from "./linearElement";
|
|
5
|
+
import { ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO, ARROW_LABEL_WIDTH_FRACTION, BOUND_TEXT_PADDING, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, LEGACY_FONT_ID_TO_NAME, WINDOWS_EMOJI_FALLBACK_FONT } from "../constants";
|
|
6
6
|
import { adjustXYWithRotation } from "../math";
|
|
7
7
|
import { normalizeText } from "../normalize";
|
|
8
|
-
import {
|
|
8
|
+
import { getBoundTextElementPosition, getPointGlobalCoordinates, getPointsGlobalCoordinates, getSegmentMidPoint } from "./linearElement";
|
|
9
9
|
export const computeBoundTextPosition = (container, boundTextElement, elementsMap, currentScope) => {
|
|
10
10
|
if (isArrowElement(container)) {
|
|
11
11
|
const coords = getBoundTextElementPosition(container, boundTextElement, elementsMap, currentScope);
|
|
@@ -54,10 +54,19 @@ export const measureText = (text, font, lineHeight, currentScope) => {
|
|
|
54
54
|
// lines would be stripped from computation
|
|
55
55
|
.map((x) => x || " ")
|
|
56
56
|
.join("\n");
|
|
57
|
-
const
|
|
57
|
+
const parsedFontSize = parseFloat(font);
|
|
58
|
+
// Guard: if font string produced an unparseable size (NaN) or zero,
|
|
59
|
+
// fall back to DEFAULT_FONT_SIZE so measurements are never degenerate.
|
|
60
|
+
const safeFontSize = (Number.isFinite(parsedFontSize) && parsedFontSize > 0)
|
|
61
|
+
? parsedFontSize
|
|
62
|
+
: DEFAULT_FONT_SIZE;
|
|
63
|
+
const fontSize = getPrecisionValueFromRaw(safeFontSize, currentScope, currentScope);
|
|
58
64
|
const height = getTextHeight(text, fontSize, lineHeight);
|
|
59
65
|
const width = getTextWidth(text, font);
|
|
60
|
-
return
|
|
66
|
+
// Defensive: ensure we never return 0 or NaN dimensions
|
|
67
|
+
const safeWidth = (Number.isFinite(width) && width > 0) ? width : 1;
|
|
68
|
+
const safeHeight = (Number.isFinite(height) && height > 0) ? height : (safeFontSize * lineHeight);
|
|
69
|
+
return { width: safeWidth, height: safeHeight };
|
|
61
70
|
};
|
|
62
71
|
/**
|
|
63
72
|
* We calculate the line height from the font size and the unitless line height,
|
|
@@ -104,15 +113,15 @@ const getLineWidth = (text, font, forceAdvanceWidth, isTestEnv) => {
|
|
|
104
113
|
// fallback to advance width if the actual width is zero, i.e. on text editing start
|
|
105
114
|
// or when actual width does not respect whitespace chars, i.e. spaces
|
|
106
115
|
// otherwise actual width should always be bigger
|
|
107
|
-
return Math.max(actualWidth, advanceWidth);
|
|
116
|
+
return Math.ceil(Math.max(actualWidth, advanceWidth));
|
|
108
117
|
}
|
|
109
118
|
// since in test env the canvas measureText algo
|
|
110
119
|
// doesn't measure text and instead just returns number of
|
|
111
120
|
// characters hence we assume that each letteris 10px
|
|
112
121
|
if (isTestEnv) {
|
|
113
|
-
return advanceWidth * 10;
|
|
122
|
+
return Math.ceil(advanceWidth * 10);
|
|
114
123
|
}
|
|
115
|
-
return advanceWidth;
|
|
124
|
+
return Math.ceil(advanceWidth);
|
|
116
125
|
};
|
|
117
126
|
export const getTextWidth = (text, font, forceAdvanceWidth) => {
|
|
118
127
|
const lines = splitIntoLines(text);
|
|
@@ -470,14 +479,20 @@ export const getTextFromElements = (elements, separator = "\n\n") => {
|
|
|
470
479
|
return text;
|
|
471
480
|
};
|
|
472
481
|
export const getFontFamilyString = ({ fontFamily, }) => {
|
|
473
|
-
// Handle
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
if (
|
|
477
|
-
return `${
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
|
|
482
|
+
// Handle legacy numeric font IDs from old files
|
|
483
|
+
if (typeof fontFamily === "number") {
|
|
484
|
+
const name = LEGACY_FONT_ID_TO_NAME[fontFamily];
|
|
485
|
+
if (name)
|
|
486
|
+
return `${name}, ${WINDOWS_EMOJI_FALLBACK_FONT}`;
|
|
487
|
+
return WINDOWS_EMOJI_FALLBACK_FONT;
|
|
488
|
+
}
|
|
489
|
+
// Handle stringified numeric IDs (e.g. "10")
|
|
490
|
+
const parsed = Number(fontFamily);
|
|
491
|
+
if (!Number.isNaN(parsed) && LEGACY_FONT_ID_TO_NAME[parsed]) {
|
|
492
|
+
return `${LEGACY_FONT_ID_TO_NAME[parsed]}, ${WINDOWS_EMOJI_FALLBACK_FONT}`;
|
|
493
|
+
}
|
|
494
|
+
// New path: fontFamily is already a string name
|
|
495
|
+
return `${fontFamily}, ${WINDOWS_EMOJI_FALLBACK_FONT}`;
|
|
481
496
|
};
|
|
482
497
|
/** returns fontSize+fontFamily string for assignment to DOM elements */
|
|
483
498
|
export const getFontString = ({ fontSize, fontFamily, }) => {
|
|
@@ -504,6 +519,18 @@ export const refreshTextDimensions = (textElement, container, elementsMap, curre
|
|
|
504
519
|
: textElement.width.scoped);
|
|
505
520
|
}
|
|
506
521
|
const dimensions = getAdjustedDimensions(textElement, elementsMap, text, currentScope);
|
|
522
|
+
// Defensive minimums — ensure height is always at least one line.
|
|
523
|
+
// Use negated >= to also catch NaN (NaN < x is always false).
|
|
524
|
+
const rawMinLineHeight = textElement.fontSize.value * textElement.lineHeight;
|
|
525
|
+
const minLineHeight = (Number.isFinite(rawMinLineHeight) && rawMinLineHeight > 0)
|
|
526
|
+
? rawMinLineHeight
|
|
527
|
+
: DEFAULT_FONT_SIZE * textElement.lineHeight;
|
|
528
|
+
if (!(dimensions.height >= minLineHeight)) {
|
|
529
|
+
dimensions.height = minLineHeight;
|
|
530
|
+
}
|
|
531
|
+
if (!(dimensions.width > 0)) {
|
|
532
|
+
dimensions.width = (textElement.autoResize ? 1 : textElement.width.value);
|
|
533
|
+
}
|
|
507
534
|
return Object.assign({ text }, dimensions);
|
|
508
535
|
};
|
|
509
536
|
export const splitIntoLines = (text) => {
|
|
@@ -78,7 +78,7 @@ export const getDefaultGlobalState = () => {
|
|
|
78
78
|
return {
|
|
79
79
|
name: null,
|
|
80
80
|
viewBackgroundColor: typeof window !== "undefined" ? (window.matchMedia("(prefers-color-scheme: dark)").matches ? COLOR_PALETTE.night : COLOR_PALETTE.white) : COLOR_PALETTE.white,
|
|
81
|
-
scopeExponentThreshold:
|
|
81
|
+
scopeExponentThreshold: 3,
|
|
82
82
|
mainScope: NEUTRAL_SCOPE,
|
|
83
83
|
dashSpacingScale: 1,
|
|
84
84
|
isDashSpacingAffectedByViewportScale: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ducjs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "The duc 2D CAD file format is a cornerstone of our advanced design system, conceived to cater to professionals seeking precision and efficiency in their design work.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|