aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-07-27 23:25:29 -0400
committerbobzel <zzzman@gmail.com>2023-07-27 23:25:29 -0400
commitbf34928ad34d45f97c69da91b965c21f47edb5bf (patch)
tree341d1fc67fd8dfa0e63035e191f07faa484977a4
parent9c18c60760098e0df4fddb6dccf391c235e6e0e4 (diff)
fixed longPress to terminate on pointerUp, not on Click. changed followLink() script for buttons to return select = true if there are no links. prevented turning off pointerevents for documentContents when isContentActive= true even if there is a click handler (this enables things like the imported docs background to deselect everything on click while still allowing the contents to be selected)
-rw-r--r--src/client/util/LinkFollower.ts14
-rw-r--r--src/client/views/MainView.tsx4
-rw-r--r--src/client/views/collections/CollectionStackingView.tsx4
-rw-r--r--src/client/views/nodes/DocumentView.tsx4
4 files changed, 15 insertions, 11 deletions
diff --git a/src/client/util/LinkFollower.ts b/src/client/util/LinkFollower.ts
index 3e526c4c0..b8fea340f 100644
--- a/src/client/util/LinkFollower.ts
+++ b/src/client/util/LinkFollower.ts
@@ -30,7 +30,7 @@ export class LinkFollower {
public static FollowLink = (linkDoc: Opt<Doc>, sourceDoc: Doc, altKey: boolean) => {
const batch = UndoManager.StartBatch('Follow Link');
runInAction(() => (LinkFollower.IsFollowing = true)); // turn off decoration bounds while following links since animations may occur, and DocDecorations is based on screenToLocal which is not always an observable value
- LinkFollower.traverseLink(
+ return LinkFollower.traverseLink(
linkDoc,
sourceDoc,
action(() => {
@@ -54,7 +54,10 @@ export class LinkFollower {
const followLinks = sourceDoc.followLinkToggle || sourceDoc.followAllLinks ? linkDocList : linkDocList.slice(0, 1);
var count = 0;
const allFinished = () => ++count === followLinks.length && finished?.();
- if (!followLinks.length) finished?.();
+ if (!followLinks.length) {
+ finished?.();
+ return false;
+ }
followLinks.forEach(async linkDoc => {
const target = (
sourceDoc === linkDoc.link_anchor_1
@@ -120,17 +123,18 @@ export class LinkFollower {
allFinished();
}
});
+ return true;
}
}
ScriptingGlobals.add(function followLink(doc: Doc, altKey: boolean) {
SelectionManager.DeselectAll();
- LinkFollower.FollowLink(undefined, doc, altKey);
+ return LinkFollower.FollowLink(undefined, doc, altKey) ? undefined : { select: true };
});
export function FollowLinkScript() {
- return ScriptField.MakeScript('followLink(this,altKey)', { altKey: 'boolean' });
+ return ScriptField.MakeScript('return followLink(this,altKey)', { altKey: 'boolean' });
}
export function IsFollowLinkScript(field: FieldResult<Field>) {
- return ScriptCast(field)?.script.originalScript.includes('followLink(');
+ return ScriptCast(field)?.script.originalScript.includes('return followLink(');
}
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index 86e8bab13..dc85fdfae 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -215,7 +215,7 @@ export class MainView extends React.Component {
window.removeEventListener('keydown', KeyManager.Instance.handle);
window.removeEventListener('pointerdown', this.globalPointerDown, true);
window.removeEventListener('pointermove', this.globalPointerMove, true);
- window.removeEventListener('mouseclick', this.globalPointerClick, true);
+ window.removeEventListener('pointerup', this.globalPointerClick, true);
window.removeEventListener('paste', KeyManager.Instance.paste as any);
document.removeEventListener('linkAnnotationToDash', Hypothesis.linkListener);
}
@@ -534,7 +534,7 @@ export class MainView extends React.Component {
// document.addEventListener("pointermove", action(e => SearchBox.Instance._undoBackground = UndoManager.batchCounter ? "#000000a8" : undefined));
document.addEventListener('pointerdown', this.globalPointerDown, true);
document.addEventListener('pointermove', this.globalPointerMove, true);
- document.addEventListener('mouseclick', this.globalPointerClick, true);
+ document.addEventListener('pointerup', this.globalPointerClick, true);
document.addEventListener(
'click',
(e: MouseEvent) => {
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index e964d41a8..a5c276125 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -58,7 +58,7 @@ export class CollectionStackingView extends CollectionSubView<Partial<collection
// map of node headers to their heights. Used in Masonry
@observable _heightMap = new Map<string, number>();
// Assuming that this is the current css cursor style
- @observable _cursor: CursorProperty = 'grab';
+ @observable _cursor: CursorProperty = 'ew-resize';
// gets reset whenever we scroll. Not sure what it is
@observable _scroll = 0; // used to force the document decoration to update when scrolling
// does this mean whether the browser is hidden? Or is chrome something else entirely?
@@ -408,7 +408,7 @@ export class CollectionStackingView extends CollectionSubView<Partial<collection
e,
this.onDividerMove,
action(() => {
- this._cursor = 'grab';
+ this._cursor = 'ew-resize';
batch.end();
}),
emptyFunction
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 977a64c2c..2990e2159 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -896,8 +896,8 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps
};
childFilters = () => [...this.props.childFilters(), ...StrListCast(this.layoutDoc.childFilters)];
- /// disable pointer events on content when there's an enabled onClick script (but not the browse script), or if contents are marked inactive
- contentPointerEvents = () => ((!this.disableClickScriptFunc && this.onClickHandler && !this.props.onBrowseClick?.()) || this.isContentActive() === false ? 'none' : this.pointerEvents);
+ /// 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
+ contentPointerEvents = () => ((!this.disableClickScriptFunc && this.onClickHandler && !this.props.onBrowseClick?.() && this.isContentActive() !== true) || this.isContentActive() === false ? 'none' : this.pointerEvents);
@computed get contents() {
TraceMobx();