ducjs 2.0.0 → 2.1.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 +1 -1
- package/dist/flatbuffers/duc/duc-feature-control-frame-style.d.ts +0 -3
- package/dist/flatbuffers/duc/duc-feature-control-frame-style.js +0 -8
- package/dist/flatbuffers/duc/duc-leader-style.d.ts +0 -3
- package/dist/flatbuffers/duc/duc-leader-style.js +0 -8
- package/dist/flatbuffers/duc/duc-plot-style.d.ts +1 -4
- package/dist/flatbuffers/duc/duc-plot-style.js +1 -10
- package/dist/flatbuffers/duc/duc-table-style.d.ts +0 -3
- package/dist/flatbuffers/duc/duc-table-style.js +0 -8
- package/dist/flatbuffers/duc/duc-text-style.d.ts +0 -3
- package/dist/flatbuffers/duc/duc-text-style.js +0 -8
- package/dist/flatbuffers/duc/duc-viewport-style.d.ts +1 -4
- package/dist/flatbuffers/duc/duc-viewport-style.js +1 -10
- package/dist/flatbuffers/duc/duc-xray-style.d.ts +1 -4
- package/dist/flatbuffers/duc/duc-xray-style.js +1 -10
- package/dist/flatbuffers/duc/exported-data-state.d.ts +3 -0
- package/dist/flatbuffers/duc/exported-data-state.js +8 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/parse.d.ts +5 -5
- package/dist/parse.js +57 -20
- package/dist/restore/restoreDataState.d.ts +14 -10
- package/dist/restore/restoreDataState.js +29 -22
- package/dist/restore/restoreElements.d.ts +2 -2
- package/dist/restore/restoreElements.js +21 -14
- package/dist/restore/restoreStandards.d.ts +2 -2
- package/dist/restore/restoreStandards.js +4 -4
- package/dist/serialize.d.ts +3 -2
- package/dist/serialize.js +14 -27
- package/dist/technical/measurements.d.ts +2 -2
- package/dist/technical/measurements.js +1 -1
- package/dist/technical/scopes.d.ts +4 -4
- package/dist/technical/scopes.js +1 -1
- package/dist/technical/standards.d.ts +4 -4
- package/dist/types/elements/index.d.ts +13 -13
- package/dist/types/elements/typeChecks.d.ts +5 -4
- package/dist/types/elements/typeChecks.js +5 -2
- package/dist/types/geometryTypes.d.ts +2 -2
- package/dist/types/index.d.ts +11 -8
- package/dist/types/index.js +1 -0
- package/dist/types/typeChecks.d.ts +5 -0
- package/dist/types/typeChecks.js +10 -0
- package/dist/utils/bounds.d.ts +3 -3
- package/dist/utils/bounds.js +3 -3
- package/dist/utils/constants.d.ts +5 -3
- package/dist/utils/constants.js +3 -5
- package/dist/utils/elements/frameElement.d.ts +2 -1
- package/dist/utils/elements/frameElement.js +13 -1
- package/dist/utils/elements/freedrawElement.d.ts +1 -1
- package/dist/utils/elements/freedrawElement.js +1 -1
- package/dist/utils/elements/index.d.ts +4 -4
- package/dist/utils/elements/index.js +17 -21
- package/dist/utils/elements/linearElement.d.ts +6 -6
- package/dist/utils/elements/linearElement.js +4 -4
- package/dist/utils/elements/newElement.d.ts +3 -3
- package/dist/utils/elements/newElement.js +26 -26
- package/dist/utils/elements/textElement.d.ts +7 -7
- package/dist/utils/elements/textElement.js +11 -9
- package/dist/utils/elements/viewportElement.d.ts +1 -1
- package/dist/utils/functionCodec.js +2 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/math/algebra/gadirections.d.ts +1 -1
- package/dist/utils/math/algebra/gadirections.js +1 -1
- package/dist/utils/math/algebra/galines.d.ts +1 -1
- package/dist/utils/math/algebra/galines.js +1 -1
- package/dist/utils/math/algebra/gapoints.d.ts +1 -1
- package/dist/utils/math/algebra/gapoints.js +3 -3
- package/dist/utils/math/algebra/gatransforms.d.ts +1 -1
- package/dist/utils/math/algebra/gatransforms.js +2 -2
- package/dist/utils/math/bbox.d.ts +2 -2
- package/dist/utils/math/geometry.d.ts +3 -3
- package/dist/utils/math/geometry.js +2 -2
- package/dist/utils/math/index.d.ts +6 -6
- package/dist/utils/math/index.js +3 -3
- package/dist/utils/normalize.d.ts +2 -2
- package/dist/utils/normalize.js +2 -2
- package/dist/utils/shape.d.ts +2 -2
- package/dist/utils/shape.js +8 -8
- package/dist/utils/state/grid.d.ts +1 -1
- package/dist/utils/state/grid.js +3 -3
- package/dist/utils/state/index.d.ts +1 -1
- package/dist/utils/state/index.js +7 -7
- package/dist/utils/traverse.d.ts +22 -0
- package/dist/utils/traverse.js +87 -0
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.js +1 -1
- package/package.json +4 -2
- package/dist/legacy/index.d.ts +0 -1
- package/dist/legacy/index.js +0 -1
- package/dist/legacy/v1/duc/app-state.d.ts +0 -124
- package/dist/legacy/v1/duc/app-state.js +0 -388
- package/dist/legacy/v1/duc/binary-file-data.d.ts +0 -27
- package/dist/legacy/v1/duc/binary-file-data.js +0 -90
- package/dist/legacy/v1/duc/binary-files-entry.d.ts +0 -16
- package/dist/legacy/v1/duc/binary-files-entry.js +0 -43
- package/dist/legacy/v1/duc/binary-files.d.ts +0 -17
- package/dist/legacy/v1/duc/binary-files.js +0 -55
- package/dist/legacy/v1/duc/binding-point.d.ts +0 -15
- package/dist/legacy/v1/duc/binding-point.js +0 -48
- package/dist/legacy/v1/duc/bound-element.d.ts +0 -17
- package/dist/legacy/v1/duc/bound-element.js +0 -48
- package/dist/legacy/v1/duc/duc-block-attribute-details.d.ts +0 -22
- package/dist/legacy/v1/duc/duc-block-attribute-details.js +0 -57
- package/dist/legacy/v1/duc/duc-block-attribute.d.ts +0 -16
- package/dist/legacy/v1/duc/duc-block-attribute.js +0 -43
- package/dist/legacy/v1/duc/duc-block-instance-element-override.d.ts +0 -17
- package/dist/legacy/v1/duc/duc-block-instance-element-override.js +0 -48
- package/dist/legacy/v1/duc/duc-block.d.ts +0 -34
- package/dist/legacy/v1/duc/duc-block.js +0 -110
- package/dist/legacy/v1/duc/duc-element.d.ts +0 -273
- package/dist/legacy/v1/duc/duc-element.js +0 -865
- package/dist/legacy/v1/duc/duc-group.d.ts +0 -40
- package/dist/legacy/v1/duc/duc-group.js +0 -114
- package/dist/legacy/v1/duc/duc-line-reference.d.ts +0 -15
- package/dist/legacy/v1/duc/duc-line-reference.js +0 -43
- package/dist/legacy/v1/duc/duc-line.d.ts +0 -15
- package/dist/legacy/v1/duc/duc-line.js +0 -43
- package/dist/legacy/v1/duc/duc-path.d.ts +0 -26
- package/dist/legacy/v1/duc/duc-path.js +0 -69
- package/dist/legacy/v1/duc/duc-table-cell.d.ts +0 -22
- package/dist/legacy/v1/duc/duc-table-cell.js +0 -57
- package/dist/legacy/v1/duc/duc-table-column.d.ts +0 -18
- package/dist/legacy/v1/duc/duc-table-column.js +0 -50
- package/dist/legacy/v1/duc/duc-table-row.d.ts +0 -18
- package/dist/legacy/v1/duc/duc-table-row.js +0 -50
- package/dist/legacy/v1/duc/duc-table-style-props.d.ts +0 -39
- package/dist/legacy/v1/duc/duc-table-style-props.js +0 -114
- package/dist/legacy/v1/duc/duc-table-style.d.ts +0 -14
- package/dist/legacy/v1/duc/duc-table-style.js +0 -41
- package/dist/legacy/v1/duc/element-background.d.ts +0 -14
- package/dist/legacy/v1/duc/element-background.js +0 -41
- package/dist/legacy/v1/duc/element-content-base.d.ts +0 -22
- package/dist/legacy/v1/duc/element-content-base.js +0 -64
- package/dist/legacy/v1/duc/element-stroke.d.ts +0 -23
- package/dist/legacy/v1/duc/element-stroke.js +0 -66
- package/dist/legacy/v1/duc/exported-data-state.d.ts +0 -51
- package/dist/legacy/v1/duc/exported-data-state.js +0 -155
- package/dist/legacy/v1/duc/image-crop.d.ts +0 -23
- package/dist/legacy/v1/duc/image-crop.js +0 -80
- package/dist/legacy/v1/duc/linear-element-editor.d.ts +0 -44
- package/dist/legacy/v1/duc/linear-element-editor.js +0 -119
- package/dist/legacy/v1/duc/point-binding.d.ts +0 -25
- package/dist/legacy/v1/duc/point-binding.js +0 -72
- package/dist/legacy/v1/duc/point.d.ts +0 -20
- package/dist/legacy/v1/duc/point.js +0 -63
- package/dist/legacy/v1/duc/pointer-down-state.d.ts +0 -32
- package/dist/legacy/v1/duc/pointer-down-state.js +0 -90
- package/dist/legacy/v1/duc/renderer-state.d.ts +0 -17
- package/dist/legacy/v1/duc/renderer-state.js +0 -54
- package/dist/legacy/v1/duc/segment-midpoint-state.d.ts +0 -18
- package/dist/legacy/v1/duc/segment-midpoint-state.js +0 -57
- package/dist/legacy/v1/duc/simple-point.d.ts +0 -15
- package/dist/legacy/v1/duc/simple-point.js +0 -48
- package/dist/legacy/v1/duc/stroke-sides.d.ts +0 -23
- package/dist/legacy/v1/duc/stroke-sides.js +0 -66
- package/dist/legacy/v1/duc/stroke-style.d.ts +0 -31
- package/dist/legacy/v1/duc/stroke-style.js +0 -102
- package/dist/legacy/v1/duc/tiling-properties.d.ts +0 -21
- package/dist/legacy/v1/duc/tiling-properties.js +0 -75
- package/dist/legacy/v1/duc.d.ts +0 -35
- package/dist/legacy/v1/duc.js +0 -37
- package/dist/legacy/v1/index.d.ts +0 -1
- package/dist/legacy/v1/index.js +0 -1
- package/dist/legacy/v1/parse/index.d.ts +0 -67
- package/dist/legacy/v1/parse/index.js +0 -101
- package/dist/legacy/v1/parse/parseAppStateFromBinary.d.ts +0 -3
- package/dist/legacy/v1/parse/parseAppStateFromBinary.js +0 -139
- package/dist/legacy/v1/parse/parseBinaryFilesFromBinary.d.ts +0 -4
- package/dist/legacy/v1/parse/parseBinaryFilesFromBinary.js +0 -32
- package/dist/legacy/v1/parse/parseBlockFromBinary.d.ts +0 -3
- package/dist/legacy/v1/parse/parseBlockFromBinary.js +0 -70
- package/dist/legacy/v1/parse/parseElementFromBinary.d.ts +0 -8
- package/dist/legacy/v1/parse/parseElementFromBinary.js +0 -387
- package/dist/legacy/v1/parse/parseGroupFromBinary.d.ts +0 -4
- package/dist/legacy/v1/parse/parseGroupFromBinary.js +0 -36
- package/dist/legacy/v1/parse/parseRendererStateFromBinary.d.ts +0 -4
- package/dist/legacy/v1/parse/parseRendererStateFromBinary.js +0 -15
- package/dist/legacy/v1/serialize/index.d.ts +0 -5
- package/dist/legacy/v1/serialize/index.js +0 -81
- package/dist/legacy/v1/serialize/serializationUtils.d.ts +0 -17
- package/dist/legacy/v1/serialize/serializationUtils.js +0 -27
- package/dist/legacy/v1/serialize/serializeAppStateFromDuc.d.ts +0 -4
- package/dist/legacy/v1/serialize/serializeAppStateFromDuc.js +0 -145
- package/dist/legacy/v1/serialize/serializeBinaryFilesFromDuc.d.ts +0 -4
- package/dist/legacy/v1/serialize/serializeBinaryFilesFromDuc.js +0 -46
- package/dist/legacy/v1/serialize/serializeBlockFromDuc.d.ts +0 -3
- package/dist/legacy/v1/serialize/serializeBlockFromDuc.js +0 -60
- package/dist/legacy/v1/serialize/serializeElementFromDuc.d.ts +0 -8
- package/dist/legacy/v1/serialize/serializeElementFromDuc.js +0 -435
- package/dist/legacy/v1/serialize/serializeGroupFromDuc.d.ts +0 -3
- package/dist/legacy/v1/serialize/serializeGroupFromDuc.js +0 -37
- package/dist/legacy/v1/serialize/serializeRendererStateFromDuc.d.ts +0 -4
- package/dist/legacy/v1/serialize/serializeRendererStateFromDuc.js +0 -7
- package/dist/legacy/v1/types/elements/index.d.ts +0 -480
- package/dist/legacy/v1/types/elements/index.js +0 -1
- package/dist/legacy/v1/types/elements/typeChecks.d.ts +0 -40
- package/dist/legacy/v1/types/elements/typeChecks.js +0 -179
- package/dist/legacy/v1/types/geometryTypes.d.ts +0 -78
- package/dist/legacy/v1/types/geometryTypes.js +0 -1
- package/dist/legacy/v1/types/index.d.ts +0 -496
- package/dist/legacy/v1/types/index.js +0 -1
- package/dist/legacy/v1/types/utility-types.d.ts +0 -31
- package/dist/legacy/v1/types/utility-types.js +0 -1
- package/dist/legacy/v1/utils/bounds.d.ts +0 -76
- package/dist/legacy/v1/utils/bounds.js +0 -415
- package/dist/legacy/v1/utils/constants.d.ts +0 -370
- package/dist/legacy/v1/utils/constants.js +0 -571
- package/dist/legacy/v1/utils/elements/index.d.ts +0 -26
- package/dist/legacy/v1/utils/elements/index.js +0 -108
- package/dist/legacy/v1/utils/elements/linearElement.d.ts +0 -133
- package/dist/legacy/v1/utils/elements/linearElement.js +0 -544
- package/dist/legacy/v1/utils/elements/textElement.d.ts +0 -89
- package/dist/legacy/v1/utils/elements/textElement.js +0 -563
- package/dist/legacy/v1/utils/index.d.ts +0 -26
- package/dist/legacy/v1/utils/index.js +0 -40
- package/dist/legacy/v1/utils/math/algebra/ga.d.ts +0 -63
- package/dist/legacy/v1/utils/math/algebra/ga.js +0 -268
- package/dist/legacy/v1/utils/math/algebra/gadirections.d.ts +0 -9
- package/dist/legacy/v1/utils/math/algebra/gadirections.js +0 -18
- package/dist/legacy/v1/utils/math/algebra/galines.d.ts +0 -23
- package/dist/legacy/v1/utils/math/algebra/galines.js +0 -32
- package/dist/legacy/v1/utils/math/algebra/gapoints.d.ts +0 -8
- package/dist/legacy/v1/utils/math/algebra/gapoints.js +0 -30
- package/dist/legacy/v1/utils/math/algebra/gatransforms.d.ts +0 -10
- package/dist/legacy/v1/utils/math/algebra/gatransforms.js +0 -23
- package/dist/legacy/v1/utils/math/bbox.d.ts +0 -10
- package/dist/legacy/v1/utils/math/bbox.js +0 -42
- package/dist/legacy/v1/utils/math/geometry.d.ts +0 -102
- package/dist/legacy/v1/utils/math/geometry.js +0 -790
- package/dist/legacy/v1/utils/math/index.d.ts +0 -309
- package/dist/legacy/v1/utils/math/index.js +0 -1140
- package/dist/legacy/v1/utils/math/random.d.ts +0 -4
- package/dist/legacy/v1/utils/math/random.js +0 -25
- package/dist/legacy/v1/utils/measurements.d.ts +0 -33
- package/dist/legacy/v1/utils/measurements.js +0 -65
- package/dist/legacy/v1/utils/normalize.d.ts +0 -14
- package/dist/legacy/v1/utils/normalize.js +0 -49
- package/dist/legacy/v1/utils/restore.d.ts +0 -197
- package/dist/legacy/v1/utils/restore.js +0 -1255
- package/dist/legacy/v1/utils/scopes.d.ts +0 -260
- package/dist/legacy/v1/utils/scopes.js +0 -661
- package/dist/legacy/v1/utils/standards.d.ts +0 -12
- package/dist/legacy/v1/utils/standards.js +0 -10
- package/dist/legacy/v1/utils/state/index.d.ts +0 -2
- package/dist/legacy/v1/utils/state/index.js +0 -68
- package/dist/legacy/v1/utils/url.d.ts +0 -8
- package/dist/legacy/v1/utils/url.js +0 -33
package/dist/types/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export * from "./elements";
|
|
2
2
|
export * from "./geometryTypes";
|
|
3
3
|
export * from "./utility-types";
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
4
|
+
export * from "./typeChecks";
|
|
5
|
+
import { OBJECT_SNAP_MODE, PRUNING_LEVEL } from "../flatbuffers/duc";
|
|
6
|
+
import { SupportedMeasures } from "../technical/scopes";
|
|
7
|
+
import { Standard } from "../technical/standards";
|
|
8
|
+
import { DucBindableElement, DucBlock, DucElement, DucElementType, DucGroup, DucIframeLikeElement, DucLayer, DucLinearElement, DucPoint, DucRegion, DucTextElement, ElementBackground, ElementStroke, ExternalFileId, FontFamilyValues, LineHead, NonDeleted, TextAlign } from "./elements";
|
|
9
|
+
import { GeometricPoint, Percentage, Radian, ScaleFactor } from "./geometryTypes";
|
|
10
|
+
import { MakeBrand, MaybePromise, ValueOf } from "./utility-types";
|
|
11
|
+
import type { GRID_DISPLAY_TYPE, GRID_TYPE, SNAP_MARKER_SHAPE, SNAP_MODE, SNAP_OVERRIDE_BEHAVIOR } from "../utils/constants";
|
|
11
12
|
/**
|
|
12
13
|
* Root data structure for the stored data state
|
|
13
14
|
*/
|
|
@@ -30,6 +31,8 @@ export interface ExportedDataState {
|
|
|
30
31
|
files: DucExternalFiles | undefined;
|
|
31
32
|
/** In case it is needed to embed the version control into the file format */
|
|
32
33
|
versionGraph: VersionGraph | undefined;
|
|
34
|
+
/** Actual file id */
|
|
35
|
+
id: string | undefined;
|
|
33
36
|
}
|
|
34
37
|
export type ExportedDataStateContent = Omit<ExportedDataState, "type" | "version" | "source">;
|
|
35
38
|
/**
|
|
@@ -106,7 +109,7 @@ export type SuggestedPointBinding = [
|
|
|
106
109
|
"start" | "end" | "both",
|
|
107
110
|
NonDeleted<DucBindableElement>
|
|
108
111
|
];
|
|
109
|
-
export type ToolType = "selection" | "rectangle" | "polygon" | "ellipse" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "embeddable" | "ruler" | "lasso" | "laser" | "table";
|
|
112
|
+
export type ToolType = "selection" | "rectangle" | "polygon" | "ellipse" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "plot" | "embeddable" | "ruler" | "lasso" | "laser" | "table";
|
|
110
113
|
export type ElementOrToolType = DucElementType | ToolType | "custom";
|
|
111
114
|
/**
|
|
112
115
|
* Defines the global, persistent settings for the drawing. These are fundamental
|
package/dist/types/index.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard to check if an object is a PrecisionValue
|
|
3
|
+
*/
|
|
4
|
+
export const isPrecisionValue = (obj) => {
|
|
5
|
+
return obj !== null &&
|
|
6
|
+
typeof obj === 'object' &&
|
|
7
|
+
typeof obj.value === 'number' &&
|
|
8
|
+
typeof obj.scoped === 'number' &&
|
|
9
|
+
Object.keys(obj).length === 2;
|
|
10
|
+
};
|
package/dist/utils/bounds.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Scope, ScopedValue } from "
|
|
2
|
-
import { DucElement, DucFreeDrawElement, DucLine, DucLinearElement, DucPoint, DucTextContainer, DucTextElement, DucTextElementWithContainer, ElementsMap } from "
|
|
3
|
-
import { Bounds, GeometricPoint } from "
|
|
1
|
+
import { Scope, ScopedValue } from "../types";
|
|
2
|
+
import { DucElement, DucFreeDrawElement, DucLine, DucLinearElement, DucPoint, DucTextContainer, DucTextElement, DucTextElementWithContainer, ElementsMap } from "../types/elements";
|
|
3
|
+
import { Bounds, GeometricPoint } from "../types/geometryTypes";
|
|
4
4
|
type SV = ScopedValue;
|
|
5
5
|
/**
|
|
6
6
|
* Common bounds calculation interface
|
package/dist/utils/bounds.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isArrowElement, isFreeDrawElement, isLinearElement, isTextElement } from "
|
|
2
|
-
import { getBoundTextElementPosition, getLinearElementAbsoluteCoords } from "
|
|
3
|
-
import { getCubicBezierBoundingBox, getQuadraticBezierBoundingBox, rescaleLines, rescalePoints, rotate } from "
|
|
1
|
+
import { isArrowElement, isFreeDrawElement, isLinearElement, isTextElement } from "../types/elements/typeChecks";
|
|
2
|
+
import { getBoundTextElementPosition, getLinearElementAbsoluteCoords } from "./elements/linearElement";
|
|
3
|
+
import { getCubicBezierBoundingBox, getQuadraticBezierBoundingBox, rescaleLines, rescalePoints, rotate } from "./math";
|
|
4
4
|
export const getElementAbsoluteCoords = (element, elementsMap, currentScope, includeBoundText = false, returnUnrotatedBoundsOnly = true) => {
|
|
5
5
|
if (isFreeDrawElement(element)) {
|
|
6
6
|
return getFreeDrawElementAbsoluteCoords(element);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GridSettings, RawValue, SnapSettings } from "
|
|
2
|
-
import { DucElement, DucEllipseElement, DucFreeDrawElement, DucTextElement, ElementBackground, ElementStroke, FontFamilyValues } from "
|
|
3
|
-
import { MAX_ZOOM, MIN_ZOOM } from "
|
|
1
|
+
import { GridSettings, RawValue, SnapSettings } from "../types";
|
|
2
|
+
import { DucElement, DucEllipseElement, DucFreeDrawElement, DucTextElement, ElementBackground, ElementStroke, FontFamilyValues } from "../types/elements";
|
|
3
|
+
import { MAX_ZOOM, MIN_ZOOM } from "../technical/scopes";
|
|
4
4
|
export declare const COLOR_PALETTE: {
|
|
5
5
|
readonly transparent: "transparent";
|
|
6
6
|
readonly black: "#1e1e1e";
|
|
@@ -47,6 +47,8 @@ export declare const MIME_TYPES: {
|
|
|
47
47
|
readonly "excalidraw.svg": "image/svg+xml";
|
|
48
48
|
readonly "excalidraw.png": "image/png";
|
|
49
49
|
readonly binary: "application/octet-stream";
|
|
50
|
+
readonly pdf: "application/pdf";
|
|
51
|
+
readonly zip: "application/zip";
|
|
50
52
|
};
|
|
51
53
|
export declare const EXPORT_IMAGE_TYPES: {
|
|
52
54
|
readonly png: "png";
|
package/dist/utils/constants.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ELEMENT_CONTENT_PREFERENCE, OBJECT_SNAP_MODE, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, TEXT_ALIGN, VERTICAL_ALIGN } from "
|
|
2
|
-
import { MAX_ZOOM, MIN_ZOOM, NEUTRAL_SCOPE } from "
|
|
1
|
+
import { ELEMENT_CONTENT_PREFERENCE, OBJECT_SNAP_MODE, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, TEXT_ALIGN, VERTICAL_ALIGN } from "../flatbuffers/duc";
|
|
2
|
+
import { MAX_ZOOM, MIN_ZOOM, NEUTRAL_SCOPE } from "../technical/scopes";
|
|
3
3
|
export const COLOR_PALETTE = {
|
|
4
4
|
transparent: "transparent",
|
|
5
5
|
black: "#1e1e1e",
|
|
@@ -37,9 +37,7 @@ export const MIME_TYPES = Object.assign({ json: "application/json",
|
|
|
37
37
|
// excalidraw data
|
|
38
38
|
duc: "application/vnd.duc-cad", ducfig: "application/vnd.duc-config", excalidrawlib: "application/vnd.excalidrawlib+json",
|
|
39
39
|
// image-encoded excalidraw data
|
|
40
|
-
"excalidraw.svg": "image/svg+xml", "excalidraw.png": "image/png",
|
|
41
|
-
// binary
|
|
42
|
-
binary: "application/octet-stream" }, IMAGE_MIME_TYPES);
|
|
40
|
+
"excalidraw.svg": "image/svg+xml", "excalidraw.png": "image/png", binary: "application/octet-stream", pdf: "application/pdf", zip: "application/zip" }, IMAGE_MIME_TYPES);
|
|
43
41
|
export const EXPORT_IMAGE_TYPES = {
|
|
44
42
|
png: "png",
|
|
45
43
|
svg: "svg",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DucElement, DucElementsIncludingDeleted, DucFrameLikeElement, ElementsMap } from "
|
|
1
|
+
import { DucElement, DucElementsIncludingDeleted, DucFrameLikeElement, ElementsMap } from "../../types/elements";
|
|
2
2
|
export declare const getContainingFrame: (element: DucElement, elementsMap: ElementsMap) => DucFrameLikeElement | null;
|
|
3
3
|
export declare const getFrameLikeElements: (allElements: DucElementsIncludingDeleted) => DucFrameLikeElement[];
|
|
4
|
+
export declare const canFrameLikeContainElement: (frame: DucFrameLikeElement, element: DucElement) => boolean;
|
|
4
5
|
export declare const getFrameLikeTitle: (element: DucFrameLikeElement) => string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isFrameLikeElement } from "
|
|
1
|
+
import { isFrameElement, isFrameLikeElement, isPlotElement } from "../../types/elements/typeChecks";
|
|
2
2
|
export const getContainingFrame = (element, elementsMap) => {
|
|
3
3
|
if (!element.frameId) {
|
|
4
4
|
return null;
|
|
@@ -9,6 +9,18 @@ export const getContainingFrame = (element, elementsMap) => {
|
|
|
9
9
|
export const getFrameLikeElements = (allElements) => {
|
|
10
10
|
return allElements.filter((element) => isFrameLikeElement(element));
|
|
11
11
|
};
|
|
12
|
+
export const canFrameLikeContainElement = (frame, element) => {
|
|
13
|
+
if (frame.id === element.id) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (isPlotElement(element)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (isFrameElement(element)) {
|
|
20
|
+
return frame.type === "plot";
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
12
24
|
export const getFrameLikeTitle = (element) => {
|
|
13
25
|
return element.label === null
|
|
14
26
|
? "Frame"
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DucFreeDrawElement } from "
|
|
1
|
+
import { DucFreeDrawElement } from "../../types/elements";
|
|
2
2
|
export declare function getFreeDrawSvgPath(element: DucFreeDrawElement): string;
|
|
@@ -4,10 +4,10 @@ export * from "./linearElement";
|
|
|
4
4
|
export * from "./textElement";
|
|
5
5
|
export * from "./frameElement";
|
|
6
6
|
export * from "./viewportElement";
|
|
7
|
-
import { Scope } from "
|
|
8
|
-
import { _DucStackBase, DucElement, DucNonSelectionElement, DucTableElement, DucTextStyle, ElementConstructorOpts, NonDeleted } from "
|
|
9
|
-
import { GeometricPoint, TuplePoint } from "
|
|
10
|
-
import { Mutable } from "
|
|
7
|
+
import { Scope } from "../../types";
|
|
8
|
+
import { _DucStackBase, DucElement, DucNonSelectionElement, DucTableElement, DucTextStyle, ElementConstructorOpts, NonDeleted } from "../../types/elements";
|
|
9
|
+
import { GeometricPoint, TuplePoint } from "../../types/geometryTypes";
|
|
10
|
+
import { Mutable } from "../../types/utility-types";
|
|
11
11
|
/**
|
|
12
12
|
* Returns a default DucTextStyle object for the given scope.
|
|
13
13
|
*/
|
|
@@ -4,24 +4,17 @@ export * from "./linearElement";
|
|
|
4
4
|
export * from "./textElement";
|
|
5
5
|
export * from "./frameElement";
|
|
6
6
|
export * from "./viewportElement";
|
|
7
|
-
import { LINE_SPACING_TYPE, TABLE_CELL_ALIGNMENT, TABLE_FLOW_DIRECTION } from "
|
|
8
|
-
import { isFreeDrawElement, isLinearElement } from "
|
|
9
|
-
import { getUpdatedTimestamp } from "
|
|
10
|
-
import { DEFAULT_ELEMENT_PROPS, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_TEXT_ALIGN, DEFAULT_VERTICAL_ALIGN, FONT_FAMILY } from "
|
|
11
|
-
import { randomInteger } from "
|
|
12
|
-
import { getPrecisionValueFromRaw } from "
|
|
7
|
+
import { LINE_SPACING_TYPE, TABLE_CELL_ALIGNMENT, TABLE_FLOW_DIRECTION } from "../../flatbuffers/duc";
|
|
8
|
+
import { isFreeDrawElement, isLinearElement } from "../../types/elements/typeChecks";
|
|
9
|
+
import { getUpdatedTimestamp } from "..";
|
|
10
|
+
import { DEFAULT_ELEMENT_PROPS, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_TEXT_ALIGN, DEFAULT_VERTICAL_ALIGN, FONT_FAMILY } from "../constants";
|
|
11
|
+
import { randomInteger } from "../math/random";
|
|
12
|
+
import { getPrecisionValueFromRaw } from "../../technical/scopes";
|
|
13
13
|
/**
|
|
14
14
|
* Returns a default DucTextStyle object for the given scope.
|
|
15
15
|
*/
|
|
16
16
|
export function getDefaultTextStyle(currentScope) {
|
|
17
17
|
return {
|
|
18
|
-
roundness: DEFAULT_ELEMENT_PROPS.roundness,
|
|
19
|
-
blending: undefined,
|
|
20
|
-
strokeColor: undefined,
|
|
21
|
-
backgroundColor: undefined,
|
|
22
|
-
background: [DEFAULT_ELEMENT_PROPS.background],
|
|
23
|
-
stroke: [DEFAULT_ELEMENT_PROPS.stroke],
|
|
24
|
-
opacity: DEFAULT_ELEMENT_PROPS.opacity,
|
|
25
18
|
isLtr: true,
|
|
26
19
|
fontFamily: DEFAULT_FONT_FAMILY,
|
|
27
20
|
bigFontFamily: "sans-serif",
|
|
@@ -83,7 +76,12 @@ export const getDefaultTableData = (currentScope) => {
|
|
|
83
76
|
// A practical starting column width
|
|
84
77
|
const defaultColumnWidth = getPrecisionValueFromRaw(140, currentScope, currentScope);
|
|
85
78
|
// Base/default styling for cells
|
|
86
|
-
const baseCellStyle =
|
|
79
|
+
const baseCellStyle = {
|
|
80
|
+
stroke: [DEFAULT_ELEMENT_PROPS.stroke],
|
|
81
|
+
background: [DEFAULT_ELEMENT_PROPS.background],
|
|
82
|
+
roundness: DEFAULT_ELEMENT_PROPS.roundness,
|
|
83
|
+
opacity: DEFAULT_ELEMENT_PROPS.opacity,
|
|
84
|
+
textStyle: {
|
|
87
85
|
isLtr: true,
|
|
88
86
|
fontFamily: FONT_FAMILY.Virgil,
|
|
89
87
|
bigFontFamily: "sans-serif",
|
|
@@ -97,18 +95,16 @@ export const getDefaultTableData = (currentScope) => {
|
|
|
97
95
|
widthFactor: 1,
|
|
98
96
|
isUpsideDown: false,
|
|
99
97
|
isBackwards: false,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
stroke: [DEFAULT_ELEMENT_PROPS.stroke],
|
|
103
|
-
opacity: DEFAULT_ELEMENT_PROPS.opacity,
|
|
104
|
-
}, margins: {
|
|
98
|
+
},
|
|
99
|
+
margins: {
|
|
105
100
|
top: vMargin,
|
|
106
101
|
right: hMargin,
|
|
107
102
|
bottom: vMargin,
|
|
108
103
|
left: hMargin,
|
|
109
|
-
},
|
|
104
|
+
},
|
|
110
105
|
// Left + middle is a great general-purpose default for tables
|
|
111
|
-
alignment: TABLE_CELL_ALIGNMENT.MIDDLE_LEFT
|
|
106
|
+
alignment: TABLE_CELL_ALIGNMENT.MIDDLE_LEFT,
|
|
107
|
+
};
|
|
112
108
|
// Create default columns
|
|
113
109
|
const columns = Object.fromEntries(columnIds.map((id) => [id, { id, width: defaultColumnWidth }]));
|
|
114
110
|
// Create default rows (taller header row)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { HANDLE_TYPE } from "
|
|
2
|
-
import type { PrecisionValue, RawValue, Scope } from "
|
|
3
|
-
import type { DucLine, DucLinearElement, DucLinearLikeElement, DucPoint, DucTextElementWithContainer, ElementsMap, NonDeleted } from "
|
|
4
|
-
import { Bounds, GeometricPoint } from "
|
|
5
|
-
import type { ValueOf } from "
|
|
6
|
-
import { ElementAbsoluteCoords } from "
|
|
1
|
+
import { HANDLE_TYPE } from "../../flatbuffers/duc";
|
|
2
|
+
import type { PrecisionValue, RawValue, Scope } from "../../types";
|
|
3
|
+
import type { DucLine, DucLinearElement, DucLinearLikeElement, DucPoint, DucTextElementWithContainer, ElementsMap, NonDeleted } from "../../types/elements";
|
|
4
|
+
import { Bounds, GeometricPoint } from "../../types/geometryTypes";
|
|
5
|
+
import type { ValueOf } from "../../types/utility-types";
|
|
6
|
+
import { ElementAbsoluteCoords } from "../bounds";
|
|
7
7
|
export type HandleType = ValueOf<typeof HANDLE_TYPE> | null;
|
|
8
8
|
export type HandleInfo = {
|
|
9
9
|
pointIndex: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, getScopedBezierPointFromDucPoint } from "
|
|
2
|
-
import { getBoundTextElement, getElementAbsoluteCoords, getElementPointsCoords } from "
|
|
3
|
-
import { LINE_CONFIRM_THRESHOLD } from "
|
|
4
|
-
import { centerPoint, getBezierXY, getControlPointsForBezierCurve, getCubicBezierBoundingBox, getQuadraticBezierBoundingBox, mapIntervalToBezierT, rotate, rotatePoint } from "
|
|
1
|
+
import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, getScopedBezierPointFromDucPoint } from "../../technical/scopes";
|
|
2
|
+
import { getBoundTextElement, getElementAbsoluteCoords, getElementPointsCoords } from "../bounds";
|
|
3
|
+
import { LINE_CONFIRM_THRESHOLD } from "../constants";
|
|
4
|
+
import { centerPoint, getBezierXY, getControlPointsForBezierCurve, getCubicBezierBoundingBox, getQuadraticBezierBoundingBox, mapIntervalToBezierT, rotate, rotatePoint } from "../math";
|
|
5
5
|
/**
|
|
6
6
|
* Merges overlapping points using the line-based system
|
|
7
7
|
* Returns updated points and lines arrays
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Scope } from "
|
|
2
|
-
import { DucArrowElement, DucDimensionElement, DucDocElement, DucElement, DucEllipseElement, DucEmbeddableElement, DucFeatureControlFrameElement, DucFrameElement, DucFreeDrawElement, DucGenericElement, DucImageElement, DucLeaderElement, DucLinearElement, DucMermaidElement, DucParametricElement, DucPdfElement, DucPlotElement, DucPolygonElement, DucTableElement, DucTextElement, DucViewportElement, DucXRayElement,
|
|
3
|
-
import { Mutable } from "
|
|
1
|
+
import { Scope } from "../../types";
|
|
2
|
+
import { DucArrowElement, DucBlockInstanceElement, DucDimensionElement, DucDocElement, DucElement, DucEllipseElement, DucEmbeddableElement, DucFeatureControlFrameElement, DucFrameElement, DucFreeDrawElement, DucGenericElement, DucImageElement, DucLeaderElement, DucLinearElement, DucMermaidElement, DucParametricElement, DucPdfElement, DucPlotElement, DucPolygonElement, DucTableElement, DucTextElement, DucViewportElement, DucXRayElement, ElementConstructorOpts, ElementUpdate, NonDeleted } from "../../types/elements";
|
|
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 */
|
|
6
6
|
force?: boolean) => TElement;
|
|
@@ -9,14 +9,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
12
|
+
import { getUpdatedTimestamp, getZoom } from "..";
|
|
13
|
+
import { BLOCK_ATTACHMENT, COLUMN_TYPE, DATUM_BRACKET_STYLE, IMAGE_STATUS, LINE_SPACING_TYPE, PARAMETRIC_SOURCE_TYPE, STACKED_TEXT_ALIGN, TEXT_FLOW_DIRECTION, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT } from "../../flatbuffers/duc";
|
|
14
|
+
import { getPrecisionValueFromRaw } from "../../technical/scopes";
|
|
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
|
+
import { randomId, randomInteger } from "../math/random";
|
|
17
|
+
import { normalizeText } from "../normalize";
|
|
18
|
+
import { getDefaultStackProperties, getDefaultTableData, getDefaultTextStyle } from "./";
|
|
19
|
+
import { getFontString, getTextElementPositionOffsets, measureText, } from "./textElement";
|
|
20
20
|
export const newElementWith = (element, updates,
|
|
21
21
|
/** pass `true` to always regenerate */
|
|
22
22
|
force = false) => {
|
|
@@ -81,18 +81,18 @@ export const newElement = (currentScope, opts) => _newElementBase(opts.type, cur
|
|
|
81
81
|
export const newEmbeddableElement = (currentScope, opts) => {
|
|
82
82
|
return Object.assign(Object.assign({}, opts), _newElementBase(opts.type, currentScope, opts));
|
|
83
83
|
};
|
|
84
|
-
export const newFrameElement = (currentScope, opts) => (Object.assign(Object.assign(Object.assign({},
|
|
85
|
-
export const newPlotElement = (currentScope, opts) => (Object.assign(Object.assign(Object.assign({},
|
|
84
|
+
export const newFrameElement = (currentScope, opts) => (Object.assign(Object.assign(Object.assign(Object.assign({}, getDefaultStackProperties()), { clip: false, labelVisible: true, standardOverride: null }), _newElementBase("frame", currentScope, opts)), { type: "frame" }));
|
|
85
|
+
export const newPlotElement = (currentScope, opts) => (Object.assign(Object.assign(Object.assign(Object.assign({}, getDefaultStackProperties()), { clip: false, labelVisible: true, standardOverride: null, layout: {
|
|
86
86
|
margins: {
|
|
87
|
-
top: getPrecisionValueFromRaw(
|
|
88
|
-
right: getPrecisionValueFromRaw(
|
|
89
|
-
bottom: getPrecisionValueFromRaw(
|
|
90
|
-
left: getPrecisionValueFromRaw(
|
|
87
|
+
top: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
88
|
+
right: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
89
|
+
bottom: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
90
|
+
left: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
91
91
|
}
|
|
92
|
-
} }));
|
|
92
|
+
} }), _newElementBase("plot", currentScope, opts)), { type: "plot" }));
|
|
93
93
|
export const newViewportElement = (currentScope, opts) => {
|
|
94
94
|
var _a, _b, _c;
|
|
95
|
-
return (Object.assign(Object.assign(Object.assign({},
|
|
95
|
+
return (Object.assign(Object.assign(Object.assign(Object.assign({}, getDefaultStackProperties()), { points: [], lines: [], pathOverrides: [], lastCommittedPoint: null, startBinding: null, endBinding: null, standardOverride: null, view: {
|
|
96
96
|
scrollX: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
97
97
|
scrollY: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
98
98
|
zoom: getZoom((_a = opts.zoom) !== null && _a !== void 0 ? _a : 1, (_b = opts.mainScope) !== null && _b !== void 0 ? _b : currentScope, (_c = opts.scopeExponentThreshold) !== null && _c !== void 0 ? _c : 2),
|
|
@@ -102,7 +102,7 @@ export const newViewportElement = (currentScope, opts) => {
|
|
|
102
102
|
y: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
103
103
|
},
|
|
104
104
|
scope: currentScope,
|
|
105
|
-
}, scale: 1, shadePlot: VIEWPORT_SHADE_PLOT.AS_DISPLAYED, frozenGroupIds: [], scaleIndicatorVisible: true }));
|
|
105
|
+
}, scale: 1, shadePlot: VIEWPORT_SHADE_PLOT.AS_DISPLAYED, frozenGroupIds: [], scaleIndicatorVisible: true }), _newElementBase("viewport", currentScope, opts)), { type: "viewport" }));
|
|
106
106
|
};
|
|
107
107
|
export const newEllipseElement = (currentScope, opts) => {
|
|
108
108
|
return Object.assign(Object.assign({}, _newElementBase(opts.type, currentScope, opts)), { ratio: opts.ratio || DEFAULT_ELLIPSE_ELEMENT.ratio, startAngle: opts.startAngle || DEFAULT_ELLIPSE_ELEMENT.startAngle, endAngle: opts.endAngle || DEFAULT_ELLIPSE_ELEMENT.endAngle, showAuxCrosshair: opts.showAuxCrosshair || DEFAULT_ELLIPSE_ELEMENT.showAuxCrosshair });
|
|
@@ -155,19 +155,19 @@ export const newDocElement = (currentScope, opts) => {
|
|
|
155
155
|
// DucDocStyle properties
|
|
156
156
|
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 } } }));
|
|
157
157
|
};
|
|
158
|
-
export const newPdfElement = (currentScope, opts) => (Object.assign(Object.assign({}, _newElementBase("pdf", currentScope, opts)), { type: "pdf"
|
|
159
|
-
export const newMermaidElement = (currentScope, opts) => (Object.assign(Object.assign({}, _newElementBase("mermaid", currentScope, opts)), { type: "mermaid"
|
|
160
|
-
export const newXRayElement = (currentScope, opts) => (Object.assign(Object.assign({
|
|
158
|
+
export const newPdfElement = (currentScope, opts) => (Object.assign(Object.assign({ fileId: null }, _newElementBase("pdf", currentScope, opts)), { type: "pdf" }));
|
|
159
|
+
export const newMermaidElement = (currentScope, opts) => (Object.assign(Object.assign({ source: "", theme: undefined, svgPath: null }, _newElementBase("mermaid", currentScope, opts)), { type: "mermaid" }));
|
|
160
|
+
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" }));
|
|
161
161
|
export const newLeaderElement = (currentScope, opts) => {
|
|
162
162
|
var _a, _b;
|
|
163
|
-
return Object.assign(Object.assign({
|
|
163
|
+
return Object.assign(Object.assign({ points: [], lines: [], pathOverrides: [], lastCommittedPoint: null, startBinding: null, endBinding: null, headsOverride: undefined, dogleg: getPrecisionValueFromRaw(10, currentScope, currentScope), textStyle: opts.textStyle || getDefaultTextStyle(currentScope), textAttachment: opts.textAttachment || VERTICAL_ALIGN.TOP, blockAttachment: opts.blockAttachment || BLOCK_ATTACHMENT.CENTER_EXTENTS, leaderContent: (_a = opts.leaderContent) !== null && _a !== void 0 ? _a : null, contentAnchor: (_b = opts.contentAnchor) !== null && _b !== void 0 ? _b : {
|
|
164
164
|
x: 0,
|
|
165
165
|
y: 0,
|
|
166
|
-
} });
|
|
166
|
+
} }, _newElementBase("leader", currentScope, opts)), { type: "leader" });
|
|
167
167
|
};
|
|
168
168
|
export const newDimensionElement = (currentScope, opts) => (Object.assign(Object.assign({}, _newElementBase("dimension", currentScope, opts)), { type: 'dimension' }));
|
|
169
169
|
export const newFeatureControlFrameElement = (currentScope, opts) => {
|
|
170
|
-
return Object.assign(Object.assign({
|
|
170
|
+
return Object.assign(Object.assign({ rows: [], leaderElementId: null, textStyle: getDefaultTextStyle(currentScope), layout: {
|
|
171
171
|
padding: getPrecisionValueFromRaw(4, currentScope, currentScope),
|
|
172
172
|
segmentSpacing: getPrecisionValueFromRaw(4, currentScope, currentScope),
|
|
173
173
|
rowSpacing: getPrecisionValueFromRaw(2, currentScope, currentScope),
|
|
@@ -175,13 +175,13 @@ export const newFeatureControlFrameElement = (currentScope, opts) => {
|
|
|
175
175
|
scale: 1,
|
|
176
176
|
}, datumStyle: {
|
|
177
177
|
bracketStyle: DATUM_BRACKET_STYLE.SQUARE
|
|
178
|
-
} });
|
|
178
|
+
} }, _newElementBase("featurecontrolframe", currentScope, opts)), { type: "featurecontrolframe" });
|
|
179
179
|
};
|
|
180
180
|
export const newBlockInstanceElement = (currentScope, opts) => {
|
|
181
181
|
var _a, _b, _c;
|
|
182
182
|
return (Object.assign(Object.assign({}, _newElementBase("blockinstance", currentScope, opts)), { type: "blockinstance", blockId: opts.blockId, elementOverrides: (_a = opts.elementOverrides) !== null && _a !== void 0 ? _a : {}, attributeValues: (_b = opts.attributeValues) !== null && _b !== void 0 ? _b : {}, duplicationArray: (_c = opts.duplicationArray) !== null && _c !== void 0 ? _c : null }));
|
|
183
183
|
};
|
|
184
|
-
export const newParametricElement = (currentScope, opts) => (Object.assign(Object.assign({}, _newElementBase("parametric", currentScope, opts)), { type: 'parametric'
|
|
184
|
+
export const newParametricElement = (currentScope, opts) => (Object.assign(Object.assign({ source: { type: PARAMETRIC_SOURCE_TYPE.CODE, code: "" } }, _newElementBase("parametric", currentScope, opts)), { type: 'parametric' }));
|
|
185
185
|
// Simplified deep clone for the purpose of cloning DucElement.
|
|
186
186
|
//
|
|
187
187
|
// Only clones plain objects and arrays. Doesn't clone Date, RegExp, Map, Set,
|
|
@@ -202,7 +202,7 @@ const _deepCopyElement = (val, depth = 0) => {
|
|
|
202
202
|
? Object.create(Object.getPrototypeOf(val))
|
|
203
203
|
: {};
|
|
204
204
|
for (const key in val) {
|
|
205
|
-
if (
|
|
205
|
+
if (Object.prototype.hasOwnProperty.call(val, key)) {
|
|
206
206
|
// don't copy non-serializable objects like these caches. They'll be
|
|
207
207
|
// populated when the element is rendered.
|
|
208
208
|
if (depth === 0 && (key === "shape" || key === "canvas")) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DucLocalState, RawValue, Scope, ScopedValue } from "
|
|
2
|
-
import { DucElement, DucElementType, DucTextContainer, DucTextElement, DucTextElementWithContainer, ElementsMap, FontFamilyValues, FontString, NonDeletedDucElement } from "
|
|
3
|
-
import { GeometricPoint } from "
|
|
4
|
-
import { ExtractSetType } from "
|
|
5
|
-
import { getBoundTextElementPosition } from "
|
|
6
|
-
import { SupportedMeasures } from "
|
|
1
|
+
import { DucLocalState, RawValue, Scope, ScopedValue } from "../../types";
|
|
2
|
+
import { DucElement, DucElementType, DucTextContainer, DucTextElement, DucTextElementWithContainer, ElementsMap, FontFamilyValues, FontString, NonDeletedDucElement } from "../../types/elements";
|
|
3
|
+
import { GeometricPoint } from "../../types/geometryTypes";
|
|
4
|
+
import { ExtractSetType } from "../../types/utility-types";
|
|
5
|
+
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;
|
|
@@ -34,7 +34,7 @@ export declare const getContainerCoords: (container: NonDeletedDucElement) => {
|
|
|
34
34
|
x: RawValue;
|
|
35
35
|
y: RawValue;
|
|
36
36
|
};
|
|
37
|
-
export declare const getTextElementAngle: (textElement: DucTextElement, container: DucTextContainer | null) => import("
|
|
37
|
+
export declare const getTextElementAngle: (textElement: DucTextElement, container: DucTextContainer | null) => import("../..").Radian;
|
|
38
38
|
export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedDucElement[], elementsMap: ElementsMap) => boolean;
|
|
39
39
|
export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedDucElement[], elementsMap: ElementsMap) => boolean;
|
|
40
40
|
declare const VALID_CONTAINER_TYPES: Set<string>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { TEXT_ALIGN, VERTICAL_ALIGN } from "
|
|
2
|
-
import { isArrowElement, isBoundToContainer, isTextElement } from "
|
|
3
|
-
import { getContainerElement, getElementAbsoluteCoords, getResizedElementAbsoluteCoords } from "
|
|
4
|
-
import { ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO, ARROW_LABEL_WIDTH_FRACTION, BOUND_TEXT_PADDING, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, FONT_FAMILY, WINDOWS_EMOJI_FALLBACK_FONT } from "
|
|
5
|
-
import { getBoundTextElementPosition, getPointGlobalCoordinates, getPointsGlobalCoordinates, getSegmentMidPoint } from "
|
|
6
|
-
import { adjustXYWithRotation } from "
|
|
7
|
-
import { normalizeText } from "
|
|
8
|
-
import { getPrecisionValueFromRaw, getScopedBezierPointFromDucPoint } from "
|
|
1
|
+
import { TEXT_ALIGN, VERTICAL_ALIGN } from "../../flatbuffers/duc";
|
|
2
|
+
import { isArrowElement, isBoundToContainer, isTextElement } from "../../types/elements/typeChecks";
|
|
3
|
+
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, FONT_FAMILY, WINDOWS_EMOJI_FALLBACK_FONT } from "../constants";
|
|
5
|
+
import { getBoundTextElementPosition, getPointGlobalCoordinates, getPointsGlobalCoordinates, getSegmentMidPoint } from "./linearElement";
|
|
6
|
+
import { adjustXYWithRotation } from "../math";
|
|
7
|
+
import { normalizeText } from "../normalize";
|
|
8
|
+
import { getPrecisionValueFromRaw, getScopedBezierPointFromDucPoint } from "../../technical/scopes";
|
|
9
9
|
export const computeBoundTextPosition = (container, boundTextElement, elementsMap, currentScope) => {
|
|
10
10
|
if (isArrowElement(container)) {
|
|
11
11
|
const coords = getBoundTextElementPosition(container, boundTextElement, elementsMap, currentScope);
|
|
@@ -470,8 +470,10 @@ export const getTextFromElements = (elements, separator = "\n\n") => {
|
|
|
470
470
|
return text;
|
|
471
471
|
};
|
|
472
472
|
export const getFontFamilyString = ({ fontFamily, }) => {
|
|
473
|
+
// Handle both number and string fontFamily values
|
|
474
|
+
const fontFamilyNum = typeof fontFamily === 'string' ? parseInt(fontFamily, 10) : fontFamily;
|
|
473
475
|
for (const [fontFamilyString, id] of Object.entries(FONT_FAMILY)) {
|
|
474
|
-
if (id ===
|
|
476
|
+
if (id === fontFamilyNum) {
|
|
475
477
|
return `${fontFamilyString}, ${WINDOWS_EMOJI_FALLBACK_FONT}`;
|
|
476
478
|
}
|
|
477
479
|
}
|
|
@@ -48,8 +48,8 @@ export function reviveEncodedFunction(val) {
|
|
|
48
48
|
return val;
|
|
49
49
|
try {
|
|
50
50
|
// Wrap in parentheses to handle arrow functions and function declarations uniformly
|
|
51
|
-
// eslint-disable-next-line no-
|
|
52
|
-
const revived =
|
|
51
|
+
// eslint-disable-next-line no-new-func
|
|
52
|
+
const revived = new Function(`return (${code})`)();
|
|
53
53
|
if (typeof revived === "function")
|
|
54
54
|
return revived;
|
|
55
55
|
return val;
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GAPoint, GALine } from "
|
|
1
|
+
import type { GAPoint, GALine } from "./ga";
|
|
2
2
|
export declare const fromPoint: ([x, y]: readonly [number, number]) => GAPoint;
|
|
3
3
|
export declare const toTuple: (point: GAPoint) => [number, number];
|
|
4
4
|
export declare const abs: (point: GAPoint) => GAPoint;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as GA from "
|
|
2
|
-
import * as GALines from "
|
|
3
|
-
import { join } from "
|
|
1
|
+
import * as GA from "./ga";
|
|
2
|
+
import * as GALines from "./galines";
|
|
3
|
+
import { join } from "./ga";
|
|
4
4
|
export const fromPoint = ([x, y]) => [
|
|
5
5
|
0,
|
|
6
6
|
0,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Bounds, LineSegment } from "
|
|
2
|
-
import { GeometricPoint } from "
|
|
1
|
+
import { Bounds, LineSegment } from "../../types/geometryTypes";
|
|
2
|
+
import { GeometricPoint } from "../../types/geometryTypes";
|
|
3
3
|
export declare function getBBox(line: LineSegment): Bounds;
|
|
4
4
|
export declare function crossProduct(a: GeometricPoint, b: GeometricPoint): number;
|
|
5
5
|
export declare function doBBoxesIntersect(a: Bounds, b: Bounds): boolean;
|