From e329ac0aea297e63401c7853fbf2d9d6b280cc2d Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 10 Oct 2024 15:54:13 -0400 Subject: change the default flashcard to have a thin border and have text fill the card and be vertically and horizontally centered. --- src/client/documents/Documents.ts | 1 + src/client/util/CurrentUserUtils.ts | 2 +- src/client/views/SidebarAnnos.tsx | 1 - src/client/views/nodes/ComparisonBox.tsx | 8 +++++--- src/client/views/nodes/formattedText/FormattedTextBox.tsx | 1 + 5 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index feaf41dfc..358bc227e 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -292,6 +292,7 @@ export class DocumentOptions { _text_fontSize?: string; _text_fontFamily?: string; _text_fontWeight?: string; + text_align?: STRt = new StrInfo('horizontal text alignment default'); fontSize?: string; _pivotField?: string; // field key used to determine headings for sections in stacking, masonry, pivot views diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index e7a4cbeeb..6b692a2aa 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -369,7 +369,7 @@ pie title Minerals in my tap water creator:(opts:DocumentOptions)=> Doc // how to create the empty thing if it doesn't exist }[] = [ {key: "Note", creator: opts => Docs.Create.TextDocument("", opts), opts: { _width: 200, _layout_autoHeight: true }}, - {key: "Flashcard", creator: opts => Docs.Create.ComparisonDocument("", opts), opts: { _layout_isFlashcard: true, _width: 300, _height: 300}}, + {key: "Flashcard", creator: opts => Docs.Create.ComparisonDocument("", opts), opts: { _layout_isFlashcard: true, _layout_fitWidth: true, _width: 300, _height: 300}}, {key: "Image", creator: opts => Docs.Create.ImageDocument("", opts), opts: { _width: 400, _height:400 }}, {key: "Equation", creator: opts => Docs.Create.EquationDocument("",opts), opts: { _width: 300, _height: 35, }}, {key: "Noteboard", creator: opts => Docs.Create.NoteTakingDocument([], opts), opts: { _width: 250, _height: 200, _layout_fitWidth: true}}, diff --git a/src/client/views/SidebarAnnos.tsx b/src/client/views/SidebarAnnos.tsx index dd60bfa65..1f3ad8444 100644 --- a/src/client/views/SidebarAnnos.tsx +++ b/src/client/views/SidebarAnnos.tsx @@ -232,7 +232,6 @@ export class SidebarAnnos extends ObservableReactComponent () )} - {DocCast(this.Document.embedContainer)?.type_collection === CollectionViewType.Carousel ? null : ( + {DocCast(this.Document.embedContainer)?.type_collection !== CollectionViewType.Freeform ? null : ( <> Create a flashcard pile}>
this.createFlashcardPile([this.Document], false)}> @@ -411,6 +411,8 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent() _height: NumCast(this.layoutDoc['_' + this._props.fieldKey + '_width'], 200) + 50, _layout_fitWidth: false, _layout_autoHeight: true, + _xMargin: 5, + _yMargin: 5, }); newCol.x = this.layoutDoc.x; newCol.y = NumCast(this.layoutDoc.y) + 50; @@ -727,13 +729,13 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent() // add text box to each side when comparison box is first created if (!this.dataDoc[this.fieldKey + '_0'] && !this._isEmpty) { const dataSplit = StrCast(this.dataDoc.data).includes('Keyword: ') ? StrCast(this.dataDoc.data).split('Keyword: ') : StrCast(this.dataDoc.data).split('Answer: '); - const newDoc = Docs.Create.TextDocument(dataSplit[1], { _layout_autoHeight: true }); + const newDoc = Docs.Create.TextDocument(dataSplit[1], { title: 'answer', _layout_autoHeight: true, _layout_centered: true, text_align: 'center', _layout_fitWidth: true }); this.addDoc(newDoc, this.fieldKey + '_0'); } if (!this.dataDoc[this.fieldKey + '_1'] && !this._isEmpty) { const dataSplit = StrCast(this.dataDoc.data).includes('Keyword: ') ? StrCast(this.dataDoc.data).split('Keyword: ') : StrCast(this.dataDoc.data).split('Answer: '); - const newDoc = Docs.Create.TextDocument(dataSplit[0], { _layout_autoHeight: true }); + const newDoc = Docs.Create.TextDocument(dataSplit[0], { title: 'question', _layout_autoHeight: true, _layout_centered: true, text_align: 'center', _layout_fitWidth: true }); this.addDoc(newDoc, this.fieldKey + '_1'); } diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx index dac869f56..448dd5646 100644 --- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx +++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx @@ -1517,6 +1517,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent { this._editorView!.dispatch(tr.replaceSelectionWith(state.schema.nodes.paragraph.create({ align: textAlign }))); }); + this.tryUpdateDoc(true); } } this._editorView.TextView = this; -- cgit v1.2.3-70-g09d2