aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-05-13 11:44:36 -0400
committerbobzel <zzzman@gmail.com>2023-05-13 11:44:36 -0400
commit0849fbd97c61688d51e5fea6cf8edc47989df5de (patch)
tree422bf02e72429f0d77b5cd885274a8a74aa731ea /src/client/views/nodes
parentdca61505ba138eef3819b16b760ec81becf9329e (diff)
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)
Diffstat (limited to 'src/client/views/nodes')
-rw-r--r--src/client/views/nodes/FieldView.tsx48
-rw-r--r--src/client/views/nodes/ScreenshotBox.tsx2
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.scss2
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx18
4 files changed, 22 insertions, 48 deletions
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<FieldViewProps> {
}
render() {
const field = this.field;
- if (field === undefined) {
- return <p>{'<null>'}</p>;
- }
- // if (typeof field === "string") {
- // return <p>{field}</p>;
- // }
- // else if (field instanceof RichTextField) {
- // return <FormattedTextBox {...this.props} />;
- // }
- // else if (field instanceof ImageField) {
- // return <ImageBox {...this.props} />;
- // }
- // else if (field instaceof PresBox) {
- // return <PresBox {...this.props} />;
- // }
- // else if (field instanceof VideoField) {
- // return <VideoBox {...this.props} />;
- // }
- // else if (field instanceof AudioField) {
- // return <AudioBox {...this.props} />;
- //}
- else if (field instanceof DateField) {
- return <p>{field.date.toLocaleString()}</p>;
- } else if (field instanceof Doc) {
- return (
- <p>
- <b>{field.title?.toString()}</b>
- </p>
- );
- } else if (field instanceof List) {
- return <div> {field.length ? field.map(f => Field.toString(f)).join(', ') : ''} </div>;
- }
- // bcz: this belongs here, but it doesn't render well so taking it out for now
- else if (field instanceof WebField) {
- return <p>{Field.toString(field.url.href)}</p>;
- } else if (!(field instanceof Promise)) {
- return <p>{Field.toString(field)}</p>;
- } else {
- return <p> {'Waiting for server...'} </p>;
- }
+ // prettier-ignore
+ if (field instanceof Doc) return <p> <b>{field.title?.toString()}</b></p>;
+ if (field === undefined) return <p>{'<null>'}</p>;
+ if (field instanceof DateField) return <p>{field.date.toLocaleString()}</p>;
+ if (field instanceof List) return <div> {field.map(f => Field.toString(f)).join(', ')} </div>;
+ if (field instanceof WebField) return <p>{Field.toString(field.url.href)}</p>;
+ if (!(field instanceof Promise)) return <p>{Field.toString(field)}</p>;
+ return <p> {'Waiting for server...'} </p>;
}
}
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<ViewBoxAnnotatabl
</>
</CollectionFreeFormView>
</div>
- <div style={{ position: 'relative', height: this.formattedPanelHeight() }}>
+ <div style={{ background: 'white', position: 'relative', height: this.formattedPanelHeight() }}>
{!(this.dataDoc[this.fieldKey + '-dictation'] instanceof Doc) ? null : (
<FormattedTextBox
{...this.props}
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.scss b/src/client/views/nodes/formattedText/FormattedTextBox.scss
index b5a3c5d84..109b62e6f 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.scss
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.scss
@@ -41,7 +41,7 @@ audiotag:hover {
flex-direction: row;
transition: opacity 1s;
width: 100%;
- position: absolute;
+ position: relative;
top: 0;
left: 0;
}
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 68160ac9b..88adba1e7 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -74,8 +74,11 @@ const translateGoogleApi = require('translate-google-api');
export const GoogleRef = 'googleDocId';
type PullHandler = (exportState: Opt<GoogleApiClientUtils.Docs.ImportResult>, dataDoc: Doc) => void;
+export interface FormattedTextBoxProps {
+ allowScroll?: boolean;
+}
@observer
-export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
+export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps & FormattedTextBoxProps>() {
public static LayoutString(fieldStr: string) {
return FieldView.LayoutString(FormattedTextBox, fieldStr);
}
@@ -612,7 +615,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps
if (Array.from(highlights).join('') === FormattedTextBox._globalHighlightsCache) return;
setTimeout(() => (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<FieldViewProps
const margins = 2 * NumCast(this.layoutDoc._yMargin, this.props.yPadding || 0);
const children = this.ProseRef?.children.length ? Array.from(this.ProseRef.children[0].children) : undefined;
if (children) {
- const proseHeight = !this.ProseRef
- ? 0
- : children.reduce((p, child) => 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<FieldViewProps
r?.addEventListener(
'wheel', // if scrollTop is 0, then don't let wheel trigger scroll on any container (which it would since onScroll won't be triggered on this)
(e: WheelEvent) => {
- if (this.props.isContentActive()) {
+ if (this.props.isContentActive() && !this.props.allowScroll) {
if (!NumCast(this.layoutDoc._scrollTop) && e.deltaY <= 0) e.preventDefault();
e.stopPropagation();
}