mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2025-08-06 05:46:28 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9251d4f1d |
@@ -11,7 +11,7 @@
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@zsviczian/excalidraw": "0.9.0-obsidian-13",
|
||||
"@zsviczian/excalidraw": "0.10.0-obsidian-1",
|
||||
"monkey-around": "^2.2.0",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
|
||||
@@ -79,7 +79,6 @@ export default class ExcalidrawView extends TextFileView {
|
||||
private ctrlKeyDown = false;
|
||||
private shiftKeyDown = false;
|
||||
private altKeyDown = false;
|
||||
private mouseEvent:any = null;
|
||||
|
||||
id: string = (this.leaf as any).id;
|
||||
|
||||
@@ -760,6 +759,18 @@ export default class ExcalidrawView extends TextFileView {
|
||||
if (transfer.types?.includes('text/html') || transfer.types?.includes('text/plain')) return 'copy';
|
||||
}
|
||||
|
||||
let viewModeEnabled = false;
|
||||
const handleLinkClick = () => {
|
||||
selectedTextElement = getTextElementAtPointer(currentPosition);
|
||||
if(selectedTextElement) {
|
||||
const event = new MouseEvent("click", {ctrlKey: true, shiftKey: this.shiftKeyDown, altKey:this.altKeyDown});
|
||||
this.handleLinkClick(this,event);
|
||||
selectedTextElement = null;
|
||||
}
|
||||
}
|
||||
|
||||
let mouseEvent:any = null;
|
||||
|
||||
const excalidrawDiv = React.createElement(
|
||||
"div",
|
||||
{
|
||||
@@ -799,7 +810,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
this.plugin.hover.sourcePath = this.file.path;
|
||||
hoverPreviewTarget = this.contentEl; //e.target;
|
||||
this.app.workspace.trigger('hover-link', {
|
||||
event: this.mouseEvent,
|
||||
event: mouseEvent,
|
||||
source: VIEW_TYPE_EXCALIDRAW,
|
||||
hoverParent: hoverPreviewTarget,
|
||||
targetEl: hoverPreviewTarget,
|
||||
@@ -830,7 +841,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
},
|
||||
onMouseMove: (e:MouseEvent) => {
|
||||
//@ts-ignore
|
||||
this.mouseEvent = e.nativeEvent;
|
||||
mouseEvent = e.nativeEvent;
|
||||
},
|
||||
onMouseOver: (e:MouseEvent) => {
|
||||
clearHoverPreview();
|
||||
@@ -864,17 +875,9 @@ export default class ExcalidrawView extends TextFileView {
|
||||
onPointerUpdate: (p:any) => {
|
||||
currentPosition = p.pointer;
|
||||
if(hoverPreviewTarget && (Math.abs(hoverPoint.x-p.pointer.x)>50 || Math.abs(hoverPoint.y-p.pointer.y)>50)) clearHoverPreview();
|
||||
if(!this.excalidrawRef.current.getAppState().viewModeEnabled) return;
|
||||
const handleLinkClick = () => {
|
||||
selectedTextElement = getTextElementAtPointer(p.pointer);
|
||||
if(selectedTextElement) {
|
||||
const event = new MouseEvent("click", {ctrlKey: true, shiftKey: this.shiftKeyDown, altKey:this.altKeyDown});
|
||||
this.handleLinkClick(this,event);
|
||||
selectedTextElement = null;
|
||||
}
|
||||
}
|
||||
if(!viewModeEnabled) return;
|
||||
|
||||
const buttonDown = !blockOnMouseButtonDown && p.button=="down";
|
||||
const buttonDown = !blockOnMouseButtonDown && p.button === "down";
|
||||
if(buttonDown) {
|
||||
blockOnMouseButtonDown = true;
|
||||
|
||||
@@ -892,11 +895,12 @@ export default class ExcalidrawView extends TextFileView {
|
||||
timestamp = now;
|
||||
return;
|
||||
}
|
||||
if (p.button=="up") {
|
||||
if (p.button === "up") {
|
||||
blockOnMouseButtonDown=false;
|
||||
}
|
||||
},
|
||||
onChange: (et:ExcalidrawElement[],st:AppState) => {
|
||||
viewModeEnabled = st.viewModeEnabled;
|
||||
if(this.justLoaded) {
|
||||
this.justLoaded = false;
|
||||
this.zoomToFit(false);
|
||||
|
||||
@@ -1062,10 +1062,10 @@
|
||||
dependencies:
|
||||
"@types/estree" "*"
|
||||
|
||||
"@zsviczian/excalidraw@0.9.0-obsidian-13":
|
||||
"integrity" "sha512-oHXNHsdtbFsKJDeibsJi6DFeqTgb0OrZjE0W1ZgE3VN3CeqC0Ad9okzHMXQgPicpw/XFx1IOtCqZtpQ2Cch/Sw=="
|
||||
"resolved" "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.9.0-obsidian-13.tgz"
|
||||
"version" "0.9.0-obsidian-13"
|
||||
"@zsviczian/excalidraw@0.10.0-obsidian-1":
|
||||
"integrity" "sha512-k9xPYTp8wJlWwcJwVBLjZcbccthEYqiFkIAZRRIGPVAxGUOpyxZdJ5X4/QsmOfiRqErtiq3JboAPnYEHGtLjIg=="
|
||||
"resolved" "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.10.0-obsidian-1.tgz"
|
||||
"version" "0.10.0-obsidian-1"
|
||||
|
||||
"abab@^1.0.3":
|
||||
"integrity" "sha1-X6rZwsB/YN12dw9xzwJbYqY8/U4="
|
||||
|
||||
Reference in New Issue
Block a user