aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/LabelBox.tsx
diff options
context:
space:
mode:
authorsharkiecodes <lanyi_stroud@brown.edu>2025-06-10 11:12:23 -0400
committersharkiecodes <lanyi_stroud@brown.edu>2025-06-10 11:12:23 -0400
commit272534c8a7517d08c70928c96d487d84b14772f6 (patch)
tree0e3e9a8cc83b8ba96b2bd49c9fc726b16411d60c /src/client/views/nodes/LabelBox.tsx
parentc5981504058e0696827b4048fcd908a58fb0b0d3 (diff)
parentb91057d00512446339e48fb8488a97a1e5ef03d5 (diff)
Merge branch 'master' into lanyi-branch
Diffstat (limited to 'src/client/views/nodes/LabelBox.tsx')
-rw-r--r--src/client/views/nodes/LabelBox.tsx8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/client/views/nodes/LabelBox.tsx b/src/client/views/nodes/LabelBox.tsx
index 4cbe01b82..e1ecc2018 100644
--- a/src/client/views/nodes/LabelBox.tsx
+++ b/src/client/views/nodes/LabelBox.tsx
@@ -9,7 +9,7 @@ import { TraceMobx } from '../../../fields/util';
import { DocumentType } from '../../documents/DocumentTypes';
import { Docs } from '../../documents/Documents';
import { DragManager } from '../../util/DragManager';
-import { undoable } from '../../util/UndoManager';
+import { undoable, UndoManager } from '../../util/UndoManager';
import { ViewBoxBaseComponent } from '../DocComponent';
import { PinDocView, PinProps } from '../PinFuncs';
import { StyleProp } from '../StyleProp';
@@ -28,6 +28,7 @@ export class LabelBox extends ViewBoxBaseComponent<FieldViewProps>() {
private _timeout: NodeJS.Timeout | undefined;
private _divRef: HTMLDivElement | null = null;
private _disposers: { [key: string]: IReactionDisposer } = {};
+ private _liveTextUndo: UndoManager.Batch | undefined; // captured undo batch when typing a new text note into a collection
constructor(props: FieldViewProps) {
super(props);
@@ -220,8 +221,7 @@ export class LabelBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.setText(this._divRef?.innerText ?? '');
if (!FormattedTextBox.tryKeepingFocus(e.relatedTarget, () => this._divRef?.focus())) {
RichTextMenu.Instance?.updateMenu(undefined, undefined, undefined, undefined);
- FormattedTextBox.LiveTextUndo?.end();
- FormattedTextBox.LiveTextUndo = undefined;
+ this._liveTextUndo?.end();
}
}}
dangerouslySetInnerHTML={{
@@ -236,6 +236,8 @@ export class LabelBox extends ViewBoxBaseComponent<FieldViewProps>() {
if (DocumentView.SelectOnLoad === this.Document) {
DocumentView.SetSelectOnLoad(undefined);
+ this._liveTextUndo = FormattedTextBox.LiveTextUndo;
+ FormattedTextBox.LiveTextUndo = undefined;
this._divRef.focus();
}
this.fitTextToBox(this._divRef);