aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/formattedText
diff options
context:
space:
mode:
authorSophie Zhang <sophie_zhang@brown.edu>2024-01-25 11:28:40 -0500
committerSophie Zhang <sophie_zhang@brown.edu>2024-01-25 11:28:40 -0500
commitb5c5410b4af5d2c68d2107d3f064f6e3ec4ac3f2 (patch)
tree15daa2781bb4c7286a5608ea8f3096c262a1c158 /src/client/views/nodes/formattedText
parent6c7e97e2aebf79307453bcee94522381ff4c7ba7 (diff)
add setting bg color
Diffstat (limited to 'src/client/views/nodes/formattedText')
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 5fdfbce99..563b6a25d 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -1145,20 +1145,22 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps
return Doc.NativeAspect(this.rootDoc, this.dataDoc, false) ? this.props.NativeDimScaling?.() || 1 : 1;
}
+ @action
checkBackgroundColor() {
- console.log('checking bg color');
+ console.log('checking bg color 1');
+ if (BoolCast(Doc.UserDoc().settingBgColor)) return;
+ console.log('checking bg color 2');
+ let fontColor = '#000000';
if (isDarkMode(StrCast(this.rootDoc._backgroundColor))) {
- console.log('in dark mode');
- // set text to white
- if (!this._editorView) return;
- const tr = this._editorView?.state.tr;
-
- tr.setSelection(TextSelection.create(tr.doc, 0, tr.doc.content.size));
- tr.addMark(0, tr.doc.content.size, schema.marks.pFontColor.create({ color: '#ffffff' }));
- this._editorView.dispatch(tr);
- } else {
- // leave as is
+ fontColor = '#ffffff';
}
+ // set text to white
+ if (!this._editorView) return;
+ const tr = this._editorView?.state.tr;
+
+ tr.setSelection(TextSelection.create(tr.doc, 0, tr.doc.content.size));
+ tr.addMark(0, tr.doc.content.size, schema.marks.pFontColor.create({ color: fontColor }));
+ this._editorView.dispatch(tr);
}
componentDidMount() {
@@ -1183,7 +1185,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps
({ width, scrollHeight, layout_autoHeight }) => width && layout_autoHeight && this.resetNativeHeight(scrollHeight),
{ fireImmediately: true }
);
- this._disposers.width = reaction(
+ this._disposers.bgColor = reaction(
() => this.rootDoc._backgroundColor,
color => this.checkBackgroundColor()
);