canvu-react 0.4.26 → 0.4.28
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/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/native.cjs +36 -3
- package/dist/native.cjs.map +1 -1
- package/dist/native.js +36 -3
- package/dist/native.js.map +1 -1
- package/dist/react.cjs +4 -3
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +4 -3
- package/dist/react.js.map +1 -1
- package/dist/tldraw.cjs.map +1 -1
- package/dist/tldraw.js.map +1 -1
- package/package.json +1 -1
package/dist/native.js
CHANGED
|
@@ -37,6 +37,7 @@ function escapeHtmlText(s) {
|
|
|
37
37
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
38
38
|
}
|
|
39
39
|
var DEFAULT_TEXT_FONT_SIZE = 18;
|
|
40
|
+
var DEFAULT_TEXT_TOOL_FONT_SIZE = 28;
|
|
40
41
|
var TEXT_FONT_FAMILY = "Inter, -apple-system, BlinkMacSystemFont, ui-sans-serif, system-ui, sans-serif";
|
|
41
42
|
var LINE_HEIGHT_RATIO = 22 / 18;
|
|
42
43
|
var FIRST_LINE_BASELINE_RATIO = 20 / 18;
|
|
@@ -77,6 +78,12 @@ function lineHeightFor(fontSize) {
|
|
|
77
78
|
function firstLineBaselineY(fontSize) {
|
|
78
79
|
return fontSize * FIRST_LINE_BASELINE_RATIO;
|
|
79
80
|
}
|
|
81
|
+
function textBaselineYFor(fontSize) {
|
|
82
|
+
return firstLineBaselineY(fontSize);
|
|
83
|
+
}
|
|
84
|
+
function textLineHeightFor(fontSize) {
|
|
85
|
+
return lineHeightFor(fontSize);
|
|
86
|
+
}
|
|
80
87
|
function measureTextBoundsLocal(content, fontSize = DEFAULT_TEXT_FONT_SIZE) {
|
|
81
88
|
const cacheKey = textMeasureCacheKey(content, fontSize);
|
|
82
89
|
const cached = textMeasureCache.get(cacheKey);
|
|
@@ -3059,6 +3066,25 @@ var DEFAULT_NATIVE_OVERFLOW_TOOL_IDS = [
|
|
|
3059
3066
|
"laser",
|
|
3060
3067
|
"image"
|
|
3061
3068
|
];
|
|
3069
|
+
var ARCHITECTURAL_CLOUD_ICON_PATH = "M1.5 12 A 4.94 5.23 0 0 1 9.07 6 A 4.94 5.23 0 0 1 14.93 6 A 4.94 5.23 0 0 1 22.5 12 A 4.94 5.23 0 0 1 14.93 18 A 4.94 5.23 0 0 1 9.07 18 A 4.94 5.23 0 0 1 1.5 12 Z";
|
|
3070
|
+
function NativeArchitecturalCloudIcon({
|
|
3071
|
+
color,
|
|
3072
|
+
size = 19,
|
|
3073
|
+
strokeWidth = 2
|
|
3074
|
+
}) {
|
|
3075
|
+
const scale = size / 24;
|
|
3076
|
+
return /* @__PURE__ */ jsx(Canvas, { style: { width: size, height: size }, children: /* @__PURE__ */ jsx(Group, { transform: [{ scale }], children: /* @__PURE__ */ jsx(
|
|
3077
|
+
Path,
|
|
3078
|
+
{
|
|
3079
|
+
path: ARCHITECTURAL_CLOUD_ICON_PATH,
|
|
3080
|
+
color,
|
|
3081
|
+
style: "stroke",
|
|
3082
|
+
strokeWidth,
|
|
3083
|
+
strokeCap: "round",
|
|
3084
|
+
strokeJoin: "round"
|
|
3085
|
+
}
|
|
3086
|
+
) }) });
|
|
3087
|
+
}
|
|
3062
3088
|
var DEFAULT_NATIVE_VECTOR_TOOLS = [
|
|
3063
3089
|
{ id: "hand", label: "Hand", shortcutHint: "H", shortLabel: "H" },
|
|
3064
3090
|
{ id: "select", label: "Select", shortcutHint: "V", shortLabel: "V" },
|
|
@@ -3355,6 +3381,9 @@ function renderNativeToolButton(input) {
|
|
|
3355
3381
|
);
|
|
3356
3382
|
}
|
|
3357
3383
|
function renderNativeToolFallback(tool, foregroundColor, toolLabelStyle) {
|
|
3384
|
+
if (tool.id === "architectural-cloud") {
|
|
3385
|
+
return /* @__PURE__ */ jsx(NativeArchitecturalCloudIcon, { color: foregroundColor });
|
|
3386
|
+
}
|
|
3358
3387
|
return /* @__PURE__ */ jsx(Text$1, { style: [styles2.shortLabel, { color: foregroundColor }, toolLabelStyle], children: tool.shortLabel ?? tool.label.slice(0, 1).toUpperCase() });
|
|
3359
3388
|
}
|
|
3360
3389
|
var styles2 = StyleSheet.create({
|
|
@@ -4628,17 +4657,21 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
4628
4657
|
if (!change) return;
|
|
4629
4658
|
if (st.tool === "text") {
|
|
4630
4659
|
const id = createShapeId();
|
|
4660
|
+
const fs = DEFAULT_TEXT_TOOL_FONT_SIZE;
|
|
4661
|
+
const baseline = textBaselineYFor(fs);
|
|
4662
|
+
const lh = textLineHeightFor(fs);
|
|
4663
|
+
const minH = Math.max(26, baseline + Math.max(4, lh * 0.2));
|
|
4631
4664
|
const item = createTextItem(
|
|
4632
4665
|
id,
|
|
4633
4666
|
{
|
|
4634
4667
|
x: st.startWorld.x - 4,
|
|
4635
|
-
y: st.startWorld.y -
|
|
4668
|
+
y: st.startWorld.y - baseline,
|
|
4636
4669
|
width: 160,
|
|
4637
|
-
height:
|
|
4670
|
+
height: minH
|
|
4638
4671
|
},
|
|
4639
4672
|
"Text",
|
|
4640
4673
|
strokeStyleRef.current,
|
|
4641
|
-
|
|
4674
|
+
fs
|
|
4642
4675
|
);
|
|
4643
4676
|
change([...itemsRef.current, item]);
|
|
4644
4677
|
onSelectionChangeRef.current?.([id]);
|