aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/formattedText/FormattedTextBox.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-10-11 22:01:50 -0400
committerbobzel <zzzman@gmail.com>2024-10-11 22:01:50 -0400
commit737efc3e6cada537536c7bc5e46f5b57970da276 (patch)
tree2be4f30196f829fea4c9579875bef4e0fe5fa393 /src/client/views/nodes/formattedText/FormattedTextBox.tsx
parentbb8fe2933154c6db70cfe5da1e890535bc9012d4 (diff)
Lots of cleanup in comparisonBox to get rid of duplicated code and siimplify long functions. Utility functions were added to ComparisonBox to simplify menu functions, and to FormattedTextBox to simplify creating centered text views.
Diffstat (limited to 'src/client/views/nodes/formattedText/FormattedTextBox.tsx')
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 29be8d285..9d3a899f5 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -76,6 +76,26 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
public static LayoutString(fieldStr: string) {
return FieldView.LayoutString(FormattedTextBox, fieldStr);
}
+ /**
+ * Creates a text box where the supplied text (and optional iimage) will be vertically
+ * and horizontally centered. If text_placeholder is set to true, then the text will be
+ * treated as placeholder text and automatically selected when the text box is selected.
+ * @param title name of text box
+ * @param text text to display in textbox
+ * @param img optional image to add to text box
+ * @param text_placeholder makes the text automatially select
+ * @returns
+ */
+ public static centeredTextCreator(title: string, text: string, img?: Doc, text_placeholder?: boolean) {
+ return Docs.Create.TextDocument(RichTextField.textToRtf(text, img?.[Id]), {
+ title, //
+ _layout_autoHeight: true,
+ _layout_centered: true,
+ text_align: 'center',
+ text_placeholder,
+ _layout_fitWidth: true,
+ });
+ }
public static MakeConfig(rules?: RichTextRules, props?: FormattedTextBoxProps) {
return {
schema,