From 0849fbd97c61688d51e5fea6cf8edc47989df5de Mon Sep 17 00:00:00 2001 From: bobzel Date: Sat, 13 May 2023 11:44:36 -0400 Subject: fixed caption scrolling in carousel view. fixed display of audio tags in textboxes. fixed screengrab video upload and made dictation view possible (but needs reworking) --- src/client/documents/Documents.ts | 2 +- .../views/collections/CollectionCarouselView.tsx | 5 ++- .../views/collections/CollectionTreeView.tsx | 2 +- .../collectionSchema/SchemaTableCell.tsx | 2 +- src/client/views/nodes/FieldView.tsx | 48 ++++------------------ src/client/views/nodes/ScreenshotBox.tsx | 2 +- .../nodes/formattedText/FormattedTextBox.scss | 2 +- .../views/nodes/formattedText/FormattedTextBox.tsx | 18 +++++--- src/server/DashUploadUtils.ts | 3 +- 9 files changed, 30 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index bb12ce568..e28e29267 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -643,7 +643,7 @@ export namespace Docs { DocumentType.SCREENSHOT, { layout: { view: ScreenshotBox, dataField: defaultDataKey }, - options: {}, + options: { nativeDimModifiable: true, nativeHeightUnfrozen: true }, }, ], [ diff --git a/src/client/views/collections/CollectionCarouselView.tsx b/src/client/views/collections/CollectionCarouselView.tsx index 0e4556eb4..02f925bea 100644 --- a/src/client/views/collections/CollectionCarouselView.tsx +++ b/src/client/views/collections/CollectionCarouselView.tsx @@ -4,7 +4,7 @@ import { observer } from 'mobx-react'; import * as React from 'react'; import { Doc, Opt } from '../../../fields/Doc'; import { NumCast, ScriptCast, StrCast } from '../../../fields/Types'; -import { emptyFunction, returnFalse, returnZero } from '../../../Utils'; +import { emptyFunction, returnFalse, returnZero, StopEvent } from '../../../Utils'; import { DragManager } from '../../util/DragManager'; import { DocumentView, DocumentViewProps } from '../nodes/DocumentView'; import { FormattedTextBox } from '../nodes/formattedText/FormattedTextBox'; @@ -73,6 +73,7 @@ export class CollectionCarouselView extends CollectionSubView() {
- +
); diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx index f81c17a7b..f774781ab 100644 --- a/src/client/views/collections/CollectionTreeView.tsx +++ b/src/client/views/collections/CollectionTreeView.tsx @@ -229,7 +229,7 @@ export class CollectionTreeView extends CollectionSubView { fieldProps.isContentActive = this.selectedFunc; return (
- {this.selected ? : (field => (field ? Field.toString(field) : ''))(FieldValue(fieldProps.Document[fieldProps.fieldKey]))} + {this.selected ? : (field => (field ? Field.toString(field) : ''))(FieldValue(fieldProps.Document[fieldProps.fieldKey]))}
); } diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx index 86779e0dd..7eae4e938 100644 --- a/src/client/views/nodes/FieldView.tsx +++ b/src/client/views/nodes/FieldView.tsx @@ -55,45 +55,13 @@ export class FieldView extends React.Component { } render() { const field = this.field; - if (field === undefined) { - return

{''}

; - } - // if (typeof field === "string") { - // return

{field}

; - // } - // else if (field instanceof RichTextField) { - // return ; - // } - // else if (field instanceof ImageField) { - // return ; - // } - // else if (field instaceof PresBox) { - // return ; - // } - // else if (field instanceof VideoField) { - // return ; - // } - // else if (field instanceof AudioField) { - // return ; - //} - else if (field instanceof DateField) { - return

{field.date.toLocaleString()}

; - } else if (field instanceof Doc) { - return ( -

- {field.title?.toString()} -

- ); - } else if (field instanceof List) { - return
{field.length ? field.map(f => Field.toString(f)).join(', ') : ''}
; - } - // bcz: this belongs here, but it doesn't render well so taking it out for now - else if (field instanceof WebField) { - return

{Field.toString(field.url.href)}

; - } else if (!(field instanceof Promise)) { - return

{Field.toString(field)}

; - } else { - return

{'Waiting for server...'}

; - } + // prettier-ignore + if (field instanceof Doc) return

{field.title?.toString()}

; + if (field === undefined) return

{''}

; + if (field instanceof DateField) return

{field.date.toLocaleString()}

; + if (field instanceof List) return
{field.map(f => Field.toString(f)).join(', ')}
; + if (field instanceof WebField) return

{Field.toString(field.url.href)}

; + if (!(field instanceof Promise)) return

{Field.toString(field)}

; + return

{'Waiting for server...'}

; } } diff --git a/src/client/views/nodes/ScreenshotBox.tsx b/src/client/views/nodes/ScreenshotBox.tsx index aa2b22e28..75e61bbeb 100644 --- a/src/client/views/nodes/ScreenshotBox.tsx +++ b/src/client/views/nodes/ScreenshotBox.tsx @@ -311,7 +311,7 @@ export class ScreenshotBox extends ViewBoxAnnotatableComponent -
+
{!(this.dataDoc[this.fieldKey + '-dictation'] instanceof Doc) ? null : ( , dataDoc: Doc) => void; +export interface FormattedTextBoxProps { + allowScroll?: boolean; +} @observer -export class FormattedTextBox extends ViewBoxAnnotatableComponent() { +export class FormattedTextBox extends ViewBoxAnnotatableComponent() { public static LayoutString(fieldStr: string) { return FieldView.LayoutString(FormattedTextBox, fieldStr); } @@ -612,7 +615,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent (FormattedTextBox._globalHighlightsCache = Array.from(highlights).join(''))); clearStyleSheetRules(FormattedTextBox._userStyleSheet); - if (highlights.includes('Audio Tags')) { + if (!highlights.includes('Audio Tags')) { addStyleSheetRule(FormattedTextBox._userStyleSheet, 'audiotag', { display: 'none' }, ''); } if (highlights.includes('Text from Others')) { @@ -1811,9 +1814,12 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent p + Number(getComputedStyle(child).height.replace('px', '')) + Number(getComputedStyle(child).marginTop.replace('px', '')) + Number(getComputedStyle(child).marginBottom.replace('px', '')), margins); + const toNum = (val: string) => Number(val.replace('px', '').replace('auto', '0')); + const toHgt = (node: Element) => { + const { height, marginTop, marginBottom } = getComputedStyle(node); + return toNum(height) + Math.max(0, toNum(marginTop)) + Math.max(0, toNum(marginBottom)); + }; + const proseHeight = !this.ProseRef ? 0 : children.reduce((p, child) => p + toHgt(child), margins); const scrollHeight = this.ProseRef && Math.min(NumCast(this.layoutDoc.docMaxAutoHeight, proseHeight), proseHeight); if (this.props.setHeight && scrollHeight && !this.props.dontRegisterView) { // if top === 0, then the text box is growing upward (as the overlay caption) which doesn't contribute to the height computation @@ -2003,7 +2009,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent { - if (this.props.isContentActive()) { + if (this.props.isContentActive() && !this.props.allowScroll) { if (!NumCast(this.layoutDoc._scrollTop) && e.deltaY <= 0) e.preventDefault(); e.stopPropagation(); } diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts index 070d49ec3..11523a9d8 100644 --- a/src/server/DashUploadUtils.ts +++ b/src/server/DashUploadUtils.ts @@ -205,6 +205,7 @@ export namespace DashUploadUtils { .videoCodec('copy') // this will copy the data instead of reencode it .save(file.path.replace('.mkv', '.mp4')) .on('end', res) + .on('error', (e: any) => console.log(e)) ); file.path = file.path.replace('.mkv', '.mp4'); format = '.mp4'; @@ -234,7 +235,7 @@ export namespace DashUploadUtils { return { source: file, result: { name: 'Unsupported video format', message: `Could not upload unsupported file (${name}). Please convert to an .mp4` } }; } } - if (videoFormats.includes(format)) { + if (videoFormats.includes(format) || format.includes('.webm')) { return MoveParsedFile(file, Directory.videos); } fs.unlink(path, () => {}); -- cgit v1.2.3-70-g09d2