Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with other Plugins #2

Closed
ndharari opened this issue Aug 21, 2023 · 8 comments
Closed

Conflict with other Plugins #2

ndharari opened this issue Aug 21, 2023 · 8 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ndharari
Copy link

Im having conflicts with other plugins that shows an error EVERY TIME I change something in a drawing. I am not knowledgeable enought to give you a hint on how to solve this.

Write me if i can help in some way tho.

Omnisearch: Error while adding "tldraw/Tldraw 2023-08-21 10.13AM.md" to live cache TypeError: Cannot read properties of undefined (reading 'getFiles')
    at Md (plugin:omnisearch:40:1968)
    at Ga.addToLiveCache (plugin:omnisearch:42:948)
    at eval (plugin:omnisearch:49:6264)
    at e.tryTrigger (app.js:1:832397)
    at e.trigger (app.js:1:832330)
    at t.trigger (app.js:1:1031330)
    at t.onChange (app.js:1:1021835)
    at e.trigger (app.js:1:611644)
    at e.<anonymous> (app.js:1:609455)
    at app.js:1:236930

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'format')
    at getDateFromFile (plugin:calendar:131:46)
    at CalendarView.onFileModified (plugin:calendar:4302:22)
    at e.tryTrigger (app.js:1:832397)
    at e.trigger (app.js:1:832330)
    at t.trigger (app.js:1:1031330)
    at t.onChange (app.js:1:1021835)
    at e.trigger (app.js:1:611644)
    at e.<anonymous> (app.js:1:609455)
    at app.js:1:236930
    at Object.next (app.js:1:237035)

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'getMarkdownFiles')
    at ObsidianTaskAdapter.generateTasksList (plugin:tasks-calendar-wrapper:36298:29)
    at _TasksTimelineView.onReloadTasks (plugin:tasks-calendar-wrapper:36514:13)
    at e.tryTrigger (app.js:1:832397)
    at e.trigger (app.js:1:832330)
    at t.trigger (app.js:1:1715574)
    at e.onStop (app.js:1:1708496)
    at e.stop (app.js:1:1144875)
    at e.<anonymous> (app.js:1:1145848)
    at app.js:1:236930
    at Object.next (app.js:1:237035)
@holxsam
Copy link
Owner

holxsam commented Aug 21, 2023

Hmm I looked into this all morning but not making much progress. I think it has to do with the custom view I made for TLDraw and/or the file cache but I'm really sure yet. Apparently switching to the TLDraw View breaks the Calendar plugin, as well as Excalidraw which I didn't notice before. What plugins are you using? It looks like Omnisearch and Calendar, but I can't pick out what that last plugin that's throwing the error is.

@holxsam holxsam self-assigned this Aug 21, 2023
@holxsam holxsam added bug Something isn't working help wanted Extra attention is needed labels Aug 21, 2023
@holxsam
Copy link
Owner

holxsam commented Aug 21, 2023

After doing some more debugging, I think I've narrowed it down to the actual Tldraw react component. Commenting out the <Tldraw ... /> component stops my plugin from breaking the other plugins and even adding it back in with no props will cause the issues again. This leaves me to believe that its not any of the code that manages the view mode switching but rather the component itself that's the issue. If anyone more experienced with the Obsidian API can weigh in on this, that'll be helpful. If I am right then the only solution for this would be to switch to another version of TLDraw or fork TLDraw and try to fix it myself.

@dimoonchepe
Copy link

For me it also breaks dataview behavior as it substitutes global app object with some of your stuff (I see it as Editor now), so app.plugins is no more available. I rely on the following lines in my dataviewjs code:

const {getPropertiesInFile} = app.plugins.plugins["metaedit"].api;
const {createButton} = app.plugins.plugins["buttons"];

So after installing your plugin it stopped working.

@holxsam
Copy link
Owner

holxsam commented Aug 22, 2023

I think you're on to something! Thank you! I'll look into this as soon as I can.

@holxsam
Copy link
Owner

holxsam commented Aug 24, 2023

Hey I think I fixed the issue, lemme know if you guys are still having problems. The most updated release is 1.0.3.

EDIT: nvm the issue still persist if you open Obsidian and your workspace has more than one tab open, and one of those tabs has a TLDraw file opened and that tab is not the active tab/file.

@holxsam
Copy link
Owner

holxsam commented Aug 24, 2023

So after diving a bit into the Tldraw source code, I found the line that causes Tldraw to replace the global app object here. So I'll be working on finding ways to fix this and may also open an issue on Tldraw's repository. Any suggestions on an approach are welcomed.

@dimoonchepe
Copy link

For me it works now, thanks. I tried to reproduce your case, but everything seems to be fine.

holxsam added a commit to holxsam/tldraw that referenced this issue Aug 24, 2023
Helps solve the problem described here holxsam/tldraw-in-obsidian#2.
Some plugins in Obsidian uses window.app (although Obsidian has deprecated this) and Tldraw replaces this with the Editor object which causes those plugins to fail.
@holxsam
Copy link
Owner

holxsam commented Aug 25, 2023

I found a way to patch that one line of code in the Tldraw repo using patch-package that will completely eliminate this problem. I'll also create an issue on the Tldraw repo but we'll use patch-package until they fix the issue. And finally, I'll update the release and close this issue once I push out the changes in a day or two because I have some related changes I still need to finish :)

@holxsam holxsam closed this as completed Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants