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.cjs
CHANGED
|
@@ -43,6 +43,7 @@ function escapeHtmlText(s) {
|
|
|
43
43
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
44
44
|
}
|
|
45
45
|
var DEFAULT_TEXT_FONT_SIZE = 18;
|
|
46
|
+
var DEFAULT_TEXT_TOOL_FONT_SIZE = 28;
|
|
46
47
|
var TEXT_FONT_FAMILY = "Inter, -apple-system, BlinkMacSystemFont, ui-sans-serif, system-ui, sans-serif";
|
|
47
48
|
var LINE_HEIGHT_RATIO = 22 / 18;
|
|
48
49
|
var FIRST_LINE_BASELINE_RATIO = 20 / 18;
|
|
@@ -83,6 +84,12 @@ function lineHeightFor(fontSize) {
|
|
|
83
84
|
function firstLineBaselineY(fontSize) {
|
|
84
85
|
return fontSize * FIRST_LINE_BASELINE_RATIO;
|
|
85
86
|
}
|
|
87
|
+
function textBaselineYFor(fontSize) {
|
|
88
|
+
return firstLineBaselineY(fontSize);
|
|
89
|
+
}
|
|
90
|
+
function textLineHeightFor(fontSize) {
|
|
91
|
+
return lineHeightFor(fontSize);
|
|
92
|
+
}
|
|
86
93
|
function measureTextBoundsLocal(content, fontSize = DEFAULT_TEXT_FONT_SIZE) {
|
|
87
94
|
const cacheKey = textMeasureCacheKey(content, fontSize);
|
|
88
95
|
const cached = textMeasureCache.get(cacheKey);
|
|
@@ -4634,17 +4641,21 @@ var NativeVectorViewport = react.forwardRef(function NativeVectorViewport2({
|
|
|
4634
4641
|
if (!change) return;
|
|
4635
4642
|
if (st.tool === "text") {
|
|
4636
4643
|
const id = createShapeId();
|
|
4644
|
+
const fs = DEFAULT_TEXT_TOOL_FONT_SIZE;
|
|
4645
|
+
const baseline = textBaselineYFor(fs);
|
|
4646
|
+
const lh = textLineHeightFor(fs);
|
|
4647
|
+
const minH = Math.max(26, baseline + Math.max(4, lh * 0.2));
|
|
4637
4648
|
const item = createTextItem(
|
|
4638
4649
|
id,
|
|
4639
4650
|
{
|
|
4640
4651
|
x: st.startWorld.x - 4,
|
|
4641
|
-
y: st.startWorld.y -
|
|
4652
|
+
y: st.startWorld.y - baseline,
|
|
4642
4653
|
width: 160,
|
|
4643
|
-
height:
|
|
4654
|
+
height: minH
|
|
4644
4655
|
},
|
|
4645
4656
|
"Text",
|
|
4646
4657
|
strokeStyleRef.current,
|
|
4647
|
-
|
|
4658
|
+
fs
|
|
4648
4659
|
);
|
|
4649
4660
|
change([...itemsRef.current, item]);
|
|
4650
4661
|
onSelectionChangeRef.current?.([id]);
|