canvu-react 0.4.26 → 0.4.27
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 +14 -3
- package/dist/native.cjs.map +1 -1
- package/dist/native.js +14 -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);
|
|
@@ -4628,17 +4635,21 @@ var NativeVectorViewport = forwardRef(function NativeVectorViewport2({
|
|
|
4628
4635
|
if (!change) return;
|
|
4629
4636
|
if (st.tool === "text") {
|
|
4630
4637
|
const id = createShapeId();
|
|
4638
|
+
const fs = DEFAULT_TEXT_TOOL_FONT_SIZE;
|
|
4639
|
+
const baseline = textBaselineYFor(fs);
|
|
4640
|
+
const lh = textLineHeightFor(fs);
|
|
4641
|
+
const minH = Math.max(26, baseline + Math.max(4, lh * 0.2));
|
|
4631
4642
|
const item = createTextItem(
|
|
4632
4643
|
id,
|
|
4633
4644
|
{
|
|
4634
4645
|
x: st.startWorld.x - 4,
|
|
4635
|
-
y: st.startWorld.y -
|
|
4646
|
+
y: st.startWorld.y - baseline,
|
|
4636
4647
|
width: 160,
|
|
4637
|
-
height:
|
|
4648
|
+
height: minH
|
|
4638
4649
|
},
|
|
4639
4650
|
"Text",
|
|
4640
4651
|
strokeStyleRef.current,
|
|
4641
|
-
|
|
4652
|
+
fs
|
|
4642
4653
|
);
|
|
4643
4654
|
change([...itemsRef.current, item]);
|
|
4644
4655
|
onSelectionChangeRef.current?.([id]);
|