From 54c5ef5774b001e8acd4feb2e44e010d050cc687 Mon Sep 17 00:00:00 2001 From: alyssaf16 Date: Wed, 24 Jul 2024 15:23:46 -0400 Subject: drag boxes --- src/client/views/nodes/LabelBox.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/client/views/nodes/LabelBox.tsx') diff --git a/src/client/views/nodes/LabelBox.tsx b/src/client/views/nodes/LabelBox.tsx index f80ff5f94..9c86fafcc 100644 --- a/src/client/views/nodes/LabelBox.tsx +++ b/src/client/views/nodes/LabelBox.tsx @@ -119,7 +119,7 @@ export class LabelBox extends ViewBoxBaseComponent() { singleLine: boolean; whiteSpace: string; } => { - const singleLine = BoolCast(this.layoutDoc._singleLine, true); + const singleLine = BoolCast(this.layoutDoc._singleLine, true); // bcz: this is ugly--- should default ot false?? const params = { rotateText: null, fontSizeFactor: 1, @@ -150,6 +150,8 @@ export class LabelBox extends ViewBoxBaseComponent() { BigText(r, params); return params; }; + _divRef: HTMLDivElement | null = null; + // (!missingParams || !missingParams.length ? "" : "(" + missingParams.map(m => m + ":").join(" ") + ")") render() { const boxParams = this.fitTextToBox(null); // this causes mobx to trigger re-render when data changes @@ -172,6 +174,13 @@ export class LabelBox extends ViewBoxBaseComponent() { style={{ boxShadow: this._props.styleProvider?.(this.layoutDoc, this._props, StyleProp.BoxShadow) }}>
(this._divRef = r)} + onKeyDown={e => e.stopPropagation()} + onKeyUp={e => { + e.stopPropagation(); + e.key === 'Enter' && (this.dataDoc.text = this._divRef?.textContent ?? ''); + }} style={{ backgroundColor: this.hoverColor, fontSize: StrCast(this.layoutDoc._text_fontSize), @@ -187,7 +196,11 @@ export class LabelBox extends ViewBoxBaseComponent() { height: this._props.PanelHeight(), whiteSpace: 'singleLine' in boxParams && boxParams.singleLine ? 'pre' : 'pre-wrap', }}> - this.fitTextToBox(r))}> + { + this.fitTextToBox(r); + })}> {label.startsWith('#') ? null : label.replace(/([^a-zA-Z])/g, '$1\u200b')}
-- cgit v1.2.3-70-g09d2