diff options
Diffstat (limited to 'src/client/views/nodes/DocumentView.tsx')
-rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 5962cd09f..555b4ba92 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -165,7 +165,7 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document @computed get borderPath() { return this.style(this.Document, StyleProp.BorderPath); } // prettier-ignore @computed get onClickHandler() { - return this._props.onClickScript?.() ?? this._props.onBrowseClickScript?.() ?? ScriptCast(this.Document.onClick, ScriptCast(this.layoutDoc.onClick)); + return this._props.onClickScript?.() ?? ScriptCast(this.Document.onClick, ScriptCast(this.layoutDoc.onClick)); } @computed get onDoubleClickHandler() { return this._props.onDoubleClickScript?.() ?? ScriptCast(this.layoutDoc.onDoubleClick, ScriptCast(this.Document.onDoubleClick)); @@ -189,13 +189,13 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document @computed get _rootSelected() { return this._props.isSelected() || BoolCast(this._props.TemplateDataDocument && this._props.rootSelected?.()); } - /// disable pointer events on content when there's an enabled onClick script (but not the browse script) and the contents aren't forced active, or if contents are marked inactive + /// disable pointer events on content when there's an enabled onClick script (and not in explore mode) and the contents aren't forced active, or if contents are marked inactive @computed get _contentPointerEvents() { TraceMobx(); return this._props.contentPointerEvents ?? ((!this.disableClickScriptFunc && // this.onClickHandler && - !this._props.onBrowseClickScript?.() && + !SnappingManager.ExploreMode && !this.layoutDoc.layout_isSvg && this.isContentActive() !== true) || this.isContentActive() === false) @@ -310,6 +310,20 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document if (!StrCast(this.layoutDoc._layout_showTitle)) this.layoutDoc._layout_showTitle = 'title'; 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; + SelectionManager.DeselectAll(); + DocumentManager.Instance.showDocument(this.Document, { zoomScale: 0.8, willZoomCentered: true }, (focused: boolean) => { + if (!focused && this._docView) { + this._docView + .docViewPath() + .reverse() + .find(cont => cont.ComponentView?.browseTo?.(e.clientX, e.clientY, browseTransitionTime)); + Doc.linkFollowHighlight(this.Document, false); + } + }); + e.stopPropagation(); + }; onClick = action((e: React.MouseEvent | React.PointerEvent) => { if (this._props.isGroupActive?.() === 'child' && !this._props.isDocumentActive?.()) return; const documentView = this._docView; @@ -393,10 +407,8 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document if ((Doc.ActiveTool === InkTool.None || this._props.addDocTab === returnFalse) && !(this._props.TemplateDataDocument && !(e.ctrlKey || e.button > 0))) { // click events stop here if the document is active and no modes are overriding it // if this is part of a template, let the event go up to the template root unless right/ctrl clicking - if ( - // prettier-ignore - (this._props.isDocumentActive?.() || this._props.isContentActive?.()) && - !this._props.onBrowseClickScript?.() && + if ((this._props.isDocumentActive?.() || this._props.isContentActive?.()) && + !SnappingManager.ExploreMode && !this.Document.ignoreClick && e.button === 0 && !Doc.IsInMyOverlay(this.layoutDoc) @@ -408,7 +420,7 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document if (!this.layoutDoc._lockedPosition && (!this.isContentActive() || BoolCast(this.layoutDoc._dragWhenActive, this._props.dragWhenActive))) { document.addEventListener('pointermove', this.onPointerMove); } - } + } // prettier-ignore document.addEventListener('pointerup', this.onPointerUp); } }; @@ -981,7 +993,7 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document ref={this._mainCont} onContextMenu={this.onContextMenu} onPointerDown={this.onPointerDown} - onClick={this.onClick} + onClick={SnappingManager.ExploreMode ? this.onBrowseClick : this.onClick} onPointerEnter={() => (!SnappingManager.IsDragging || SnappingManager.CanEmbed) && Doc.BrushDoc(this.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)} @@ -1055,7 +1067,7 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document recorder.start(); const stopFunc = () => { recorder.stop(); - DictationManager.Controls.stop(false); + DictationManager.Controls.stop(/* false */); dataDoc.audioAnnoState = AudioAnnoState.stopped; gumStream.getAudioTracks()[0].stop(); }; @@ -1086,9 +1098,6 @@ export class DocumentView extends DocComponent<DocumentViewProps & { CollectionF } public ViewGuid = DocumentView.UniquifyId(LightboxView.Contains(this), Utils.GenerateGuid()); // a unique id associated with the main <div>. used by LinkBox's Xanchor to find the arrowhead locations. public DocUniqueId = DocumentView.UniquifyId(LightboxView.Contains(this), this.Document[Id]); - @computed public static get exploreMode() { - return () => (SnappingManager.ExploreMode ? ScriptField.MakeScript('CollectionBrowseClick(documentView, clientX, clientY)', { documentView: 'any', clientX: 'number', clientY: 'number' })! : undefined); - } constructor(props: DocumentViewProps & { CollectionFreeFormDocumentView?: () => CollectionFreeFormDocumentView }) { super(props); |