aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/DocumentView.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/DocumentView.tsx')
-rw-r--r--src/client/views/nodes/DocumentView.tsx41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 0193fd328..595abc7f8 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -131,6 +131,7 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
style = (doc: Doc, sprop: StyleProp | string) => this._props.styleProvider?.(doc, this._props, sprop);
@computed get opacity() { return this.style(this.layoutDoc, StyleProp.Opacity) as number; } // prettier-ignore
@computed get boxShadow() { return this.style(this.layoutDoc, StyleProp.BoxShadow) as string; } // prettier-ignore
+ @computed get border() { return this.style(this.layoutDoc, StyleProp.Border) as string || ""; } // prettier-ignore
@computed get borderRounding() { return this.style(this.layoutDoc, StyleProp.BorderRounding) as string; } // prettier-ignore
@computed get widgetDecorations() { return this.style(this.layoutDoc, StyleProp.Decorations) as JSX.Element; } // prettier-ignore
@computed get backgroundBoxColor(){ return this.style(this.layoutDoc, StyleProp.BackgroundColor + ':docView') as string; } // prettier-ignore
@@ -278,16 +279,17 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
setTimeout(() => this._titleRef.current?.setIsFocused(true)); // use timeout in case title wasn't shown to allow re-render so that titleref will be defined
};
onBrowseClick = (e: React.MouseEvent) => {
- const browseTransitionTime = 500;
+ //const browseTransitionTime = 500;
DocumentView.DeselectAll();
DocumentView.showDocument(this.Document, { zoomScale: 0.8, willZoomCentered: true }, (focused: boolean) => {
- const options: FocusViewOptions = { pointFocus: { X: e.clientX, Y: e.clientY }, zoomTime: browseTransitionTime };
+ // const options: FocusViewOptions = { pointFocus: { X: e.clientX, Y: e.clientY }, zoomTime: browseTransitionTime };
if (!focused && this._docView) {
- this._docView
- .docViewPath()
- .reverse()
- .forEach(cont => cont.ComponentView?.focus?.(cont.Document, options));
- Doc.linkFollowHighlight(this.Document, false);
+ DocumentView.showDocument(this.Document, { zoomScale: 0.3, willZoomCentered: true });
+ // this._docView
+ // .docViewPath()
+ // .reverse()
+ // .forEach(cont => cont.ComponentView?.focus?.(cont.Document, options));
+ // Doc.linkFollowHighlight(this.Document, false);
}
});
e.stopPropagation();
@@ -684,14 +686,14 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
};
rootSelected = () => this._rootSelected;
- panelHeight = () => this._props.PanelHeight() - this.headerMargin;
+ panelHeight = () => this._props.PanelHeight() - this.headerMargin - 2 * NumCast(this.Document.borderWidth);
screenToLocalContent = () =>
this._props
.ScreenToLocalTransform()
- .translate(0, -this.headerMargin)
+ .translate(-NumCast(this.Document.borderWidth), -this.headerMargin - NumCast(this.Document.borderWidth))
.scale(this._props.showAIEditor ? (this._props.PanelHeight() || 1) / this.aiContentsHeight() : 1);
onClickFunc = this.disableClickScriptFunc ? undefined : () => this.onClickHdlr;
- setHeight = (height: number) => { !this._props.suppressSetHeight && (this.layoutDoc._height = Math.min(NumCast(this.layoutDoc._maxHeight, Number.MAX_SAFE_INTEGER), height)); } // prettier-ignore
+ setHeight = (height: number) => { !this._props.suppressSetHeight && (this.layoutDoc._height = Math.min(NumCast(this.layoutDoc._maxHeight, Number.MAX_SAFE_INTEGER), height + 2 * NumCast(this.Document.borderWidth))); } // prettier-ignore
setContentView = action((view: ViewBoxInterface<FieldViewProps>) => { this._componentView = view; }); // prettier-ignore
isContentActive = (): boolean | undefined => this._isContentActive;
childFilters = () => [...this._props.childFilters(), ...StrListCast(this.layoutDoc.childFilters)];
@@ -777,9 +779,9 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
style={{
width: `${100 / this.uiBtnScaling}%`, //
transform: `scale(${this.uiBtnScaling})`,
- bottom: this.maxWidgetSize,
+ bottom: Number.isNaN(this.maxWidgetSize) ? undefined : this.maxWidgetSize,
}}>
- {this._props.DocumentView?.() ? <TagsView Views={[this._props.DocumentView?.()]} /> : null}
+ {this._props.DocumentView?.() && !this._props.docViewPath().slice(-2)[0].ComponentView?.isUnstyledView?.() ? <TagsView Views={[this._props.DocumentView?.()]} /> : null}
</div>
) : (
<>
@@ -796,6 +798,7 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
<div
className="documentView-editorView"
style={{
+ background: SnappingManager.userVariantColor,
width: `${100 / this.uiBtnScaling}%`, //
transform: `scale(${this.uiBtnScaling})`,
}}
@@ -989,15 +992,11 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
highlightStroke: undefined,
};
const { clipPath, jsx } = (borderPath as { clipPath: string; jsx: JSX.Element }) ?? { clipPath: undefined, jsx: undefined };
- const boxShadow = !highlighting
- ? this.boxShadow
- : highlighting && this.borderRounding && highlightStyle !== 'dashed'
- ? `0 0 0 ${highlightIndex}px ${highlightColor}`
- : this.boxShadow || (this.Document.isTemplateForField ? 'black 0.2vw 0.2vw 0.8vw' : undefined);
+ const boxShadow = this.boxShadow;
const renderDoc = this.renderDoc({
borderRadius: this.borderRounding,
- outline: highlighting && !this.borderRounding && !highlightStroke ? `${highlightColor} ${highlightStyle} ${highlightIndex}px` : 'solid 0px',
- border: highlighting && this.borderRounding && highlightStyle === 'dashed' ? `${highlightStyle} ${highlightColor} ${highlightIndex}px` : undefined,
+ outline: highlighting && !highlightStroke ? `${highlightColor} ${highlightStyle} ${highlightIndex}px` : 'solid 0px',
+ border: this._componentView?.isUnstyledView?.() ? undefined : this.border,
boxShadow,
clipPath,
});
@@ -1013,7 +1012,7 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document
onPointerOver={() => (!SnappingManager.IsDragging || SnappingManager.CanEmbed) && Doc.BrushDoc(this.Document)}
onPointerLeave={e => !isParentOf(this._contentDiv, document.elementFromPoint(e.nativeEvent.x, e.nativeEvent.y)) && Doc.UnBrushDoc(this.Document)}
style={{
- borderRadius: this.borderRounding,
+ borderRadius: this._componentView?.isUnstyledView?.() ? undefined : this.borderRounding,
pointerEvents: this._pointerEvents === 'visiblePainted' ? 'none' : this._pointerEvents, // visible painted means that the underlying doc contents are irregular and will process their own pointer events (otherwise, the contents are expected to fill the entire doc view box so we can handle pointer events here)
}}>
{this._componentView?.isUnstyledView?.() || this.Document.type === DocumentType.CONFIG || !renderDoc ? renderDoc : DocumentViewInternal.AnimationEffect(renderDoc, this.Document[Animation], this.Document)}
@@ -1487,7 +1486,7 @@ export class DocumentView extends DocComponent<DocumentViewProps>() {
ShouldNotScale = () => this.shouldNotScale;
NativeWidth = () => this.effectiveNativeWidth;
NativeHeight = () => this.effectiveNativeHeight;
- PanelWidth = () => this.panelWidth;
+ PanelWidth = () => this.panelWidth - 2 * NumCast(this.Document.borderWidth);
PanelHeight = () => this.panelHeight;
ReducedPanelWidth = () => this.panelWidth / 2;
ReducedPanelHeight = () => this.panelWidth / 2;