forked from excalidraw/excalidraw
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
31 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,37 @@ | ||
import { DOMElement } from "react"; | ||
|
||
//zsviczian, my dirty little secrets. These are hacks I am not proud of... | ||
let OBSIDIAN_PLUGIN:any; | ||
let EXCALIDRAW_CONFIG:any; | ||
const setObsidianPlugin = () => { | ||
//@ts-ignore | ||
OBSIDIAN_PLUGIN = app?.plugins?.plugins?.["obsidian-excalidraw-plugin"]; | ||
EXCALIDRAW_CONFIG = OBSIDIAN_PLUGIN?.excalidrawConfig; | ||
export let hostPlugin: any = null; | ||
|
||
export const initializeObsidianUtils = (obsidianPlugin: any) => { | ||
hostPlugin = obsidianPlugin; | ||
} | ||
|
||
export const destroyObsidianUtils = () => { | ||
hostPlugin = null; | ||
} | ||
|
||
const getExcalidrawConfig = () => hostPlugin.excalidrawConfig; | ||
|
||
export const getAreaLimit = () => { | ||
if(!OBSIDIAN_PLUGIN) { | ||
setObsidianPlugin(); | ||
} | ||
return EXCALIDRAW_CONFIG?.areaLimit ?? 16777216; | ||
return getExcalidrawConfig().areaLimit ?? 16777216; | ||
} | ||
|
||
export const getWidthHeightLimit = () => { | ||
if(!OBSIDIAN_PLUGIN) { | ||
setObsidianPlugin(); | ||
} | ||
return EXCALIDRAW_CONFIG?.widthHeightLimit ?? 32767; | ||
return getExcalidrawConfig().widthHeightLimit ?? 32767; | ||
} | ||
|
||
export const isExcaliBrainView = () => { | ||
if(!OBSIDIAN_PLUGIN) { | ||
setObsidianPlugin(); | ||
} | ||
const excalidrawView = OBSIDIAN_PLUGIN?.activeExcalidrawView; | ||
const excalidrawView = hostPlugin.activeExcalidrawView; | ||
if(!excalidrawView) return false; | ||
return excalidrawView.linksAlwaysOpenInANewPane && excalidrawView.allowFrameButtonsInViewMode; | ||
} | ||
|
||
export const getExcalidrawContentEl = ():HTMLElement => { | ||
if(!OBSIDIAN_PLUGIN) { | ||
setObsidianPlugin(); | ||
} | ||
const excalidrawView = OBSIDIAN_PLUGIN?.activeExcalidrawView; | ||
const excalidrawView = hostPlugin.activeExcalidrawView; | ||
if(!excalidrawView) return document.body; | ||
return excalidrawView.contentEl as HTMLElement; | ||
} | ||
|
||
export const hideFreedrawPenmodeCursor = () => { | ||
if(!OBSIDIAN_PLUGIN) { | ||
setObsidianPlugin(); | ||
} | ||
if(!OBSIDIAN_PLUGIN) return true; | ||
return !OBSIDIAN_PLUGIN.settings.penModeCrosshairVisible; | ||
return !hostPlugin.settings.penModeCrosshairVisible; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters