mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2025-08-06 05:46:28 +00:00
2.7.0-beta-5 Cleaned up FileManager, ObserverManager and PackageManager carveout
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.7.0-beta-4",
|
||||
"version": "2.7.0-beta-5",
|
||||
"minAppVersion": "1.1.6",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
@@ -1532,7 +1532,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
|
||||
const apiMissing = Boolean(typeof this.containerEl.onWindowMigrated === "undefined")
|
||||
this.packages = this.plugin.packageManager.getPackage(this.ownerWindow);
|
||||
this.packages = this.plugin.getPackage(this.ownerWindow);
|
||||
|
||||
if(DEVICE.isDesktop && !apiMissing) {
|
||||
this.destroyers.push(
|
||||
@@ -1981,7 +1981,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
})
|
||||
if(leafcount === 0) {
|
||||
this.plugin.packageManager.deletePackage(this.ownerWindow);
|
||||
this.plugin.deletePackage(this.ownerWindow);
|
||||
}
|
||||
|
||||
this.lastMouseEvent = null;
|
||||
@@ -2893,7 +2893,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
await this.save();
|
||||
const file = await this.plugin.convertSingleExcalidrawToMD(this.file);
|
||||
await sleep(250); //dirty hack to wait for Obsidian metadata to be updated
|
||||
this.plugin.fileManager.openDrawing(
|
||||
this.plugin.openDrawing(
|
||||
file,
|
||||
"active-pane",
|
||||
true
|
||||
|
||||
@@ -430,7 +430,7 @@ const createImgElement = async (
|
||||
if(!result) return;
|
||||
const [file, linkText, subpath] = result;
|
||||
if(plugin.isExcalidrawFile(file)) {
|
||||
plugin.fileManager.openDrawing(file,linkModifier, true, subpath);
|
||||
plugin.openDrawing(file,linkModifier, true, subpath);
|
||||
return;
|
||||
}
|
||||
let paneType: boolean | PaneType = false;
|
||||
@@ -445,7 +445,7 @@ const createImgElement = async (
|
||||
})()
|
||||
return;
|
||||
}
|
||||
plugin.fileManager.openDrawing(f,linkModifier,true,srcParts[2]);
|
||||
plugin.openDrawing(f,linkModifier,true,srcParts[2]);
|
||||
} //.ctrlKey||ev.metaKey);
|
||||
};
|
||||
//https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1003
|
||||
@@ -1026,7 +1026,7 @@ const legacyExcalidrawPopoverObserverFn: MutationCallback = async (m) => {
|
||||
ev.stopImmediatePropagation();
|
||||
const src = el.getAttribute("src");
|
||||
if (src) {
|
||||
plugin.fileManager.openDrawing(
|
||||
plugin.openDrawing(
|
||||
vault.getAbstractFileByPath(src) as TFile,
|
||||
linkClickModifierType(ev)
|
||||
);
|
||||
|
||||
@@ -61,10 +61,10 @@ export class OpenFileDialog extends FuzzySuggestModal<TFile> {
|
||||
onChooseItem(item: TFile): void {
|
||||
switch (this.action) {
|
||||
case openDialogAction.openFile:
|
||||
this.plugin.fileManager.openDrawing(item, this.onNewPane?"new-pane":"active-pane",true);
|
||||
this.plugin.openDrawing(item, this.onNewPane?"new-pane":"active-pane",true);
|
||||
break;
|
||||
case openDialogAction.insertLinkToDrawing:
|
||||
this.plugin.fileManager.embedDrawing(item);
|
||||
this.plugin.embedDrawing(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ export class PublishOutOfDateFilesDialog extends Modal {
|
||||
bOpen.onclick = () => {
|
||||
filesMap.forEach((value:boolean,key:TFile) => {
|
||||
if(value) {
|
||||
this.plugin.fileManager.openDrawing(key,"new-tab",true);
|
||||
this.plugin.openDrawing(key,"new-tab",true);
|
||||
}
|
||||
});
|
||||
this.close();
|
||||
|
||||
47
src/main.ts
47
src/main.ts
@@ -147,9 +147,9 @@ declare let reactDOM:any;
|
||||
declare let excalidrawLib: typeof ExcalidrawLib;
|
||||
|
||||
export default class ExcalidrawPlugin extends Plugin {
|
||||
public fileManager: PluginFileManager;
|
||||
public observerManager: ObserverManager;
|
||||
public packageManager: PackageManager;
|
||||
private fileManager: PluginFileManager;
|
||||
private observerManager: ObserverManager;
|
||||
private packageManager: PackageManager;
|
||||
private EXCALIDRAW_PACKAGE: string;
|
||||
public eaInstances = new WeakArray<ExcalidrawAutomate>();
|
||||
public fourthFontLoaded: boolean = false;
|
||||
@@ -171,9 +171,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
sourcePath: null,
|
||||
};
|
||||
private legacyExcalidrawPopoverObserver: MutationObserver | CustomMutationObserver;
|
||||
private themeObserver: MutationObserver | CustomMutationObserver;
|
||||
private fileExplorerObserver: MutationObserver | CustomMutationObserver;
|
||||
private modalContainerObserver: MutationObserver | CustomMutationObserver;
|
||||
private workspaceDrawerLeftObserver: MutationObserver | CustomMutationObserver;
|
||||
private workspaceDrawerRightObserver: MutationObserver | CustomMutationObserver;
|
||||
public opencount: number = 0;
|
||||
@@ -3436,4 +3434,43 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
return this.fileManager.isExcalidrawFile(f);
|
||||
}
|
||||
|
||||
public openDrawing(
|
||||
drawingFile: TFile,
|
||||
location: PaneTarget,
|
||||
active: boolean = false,
|
||||
subpath?: string,
|
||||
justCreated: boolean = false,
|
||||
popoutLocation?: {x?: number, y?: number, width?: number, height?: number},
|
||||
) {
|
||||
this.fileManager.openDrawing(drawingFile, location, active, subpath, justCreated, popoutLocation);
|
||||
}
|
||||
|
||||
public async embedDrawing(file: TFile) {
|
||||
return await this.fileManager.embedDrawing(file);
|
||||
}
|
||||
|
||||
public async exportLibrary() {
|
||||
return await this.fileManager.exportLibrary();
|
||||
}
|
||||
|
||||
public addThemeObserver() {
|
||||
this.observerManager.addThemeObserver();
|
||||
}
|
||||
|
||||
public removeThemeObserver() {
|
||||
this.observerManager.removeThemeObserver();
|
||||
}
|
||||
|
||||
public experimentalFileTypeDisplayToggle(enabled: boolean) {
|
||||
this.observerManager.experimentalFileTypeDisplayToggle(enabled);
|
||||
}
|
||||
|
||||
public getPackage(win:Window):Packages {
|
||||
return this.packageManager.getPackage(win);
|
||||
}
|
||||
|
||||
public deletePackage(win: Window) {
|
||||
this.packageManager.deletePackage(win);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
}
|
||||
|
||||
actionExportLibrary() {
|
||||
this.view.plugin.fileManager.exportLibrary();
|
||||
this.view.plugin.exportLibrary();
|
||||
}
|
||||
|
||||
actionExportImage() {
|
||||
|
||||
@@ -1247,9 +1247,9 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.matchThemeTrigger = value;
|
||||
if(value) {
|
||||
this.plugin.observerManager.addThemeObserver();
|
||||
this.plugin.addThemeObserver();
|
||||
} else {
|
||||
this.plugin.observerManager.removeThemeObserver();
|
||||
this.plugin.removeThemeObserver();
|
||||
}
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
@@ -2653,7 +2653,7 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
.setValue(this.plugin.settings.experimentalFileType)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.experimentalFileType = value;
|
||||
this.plugin.observerManager.experimentalFileTypeDisplayToggle(value);
|
||||
this.plugin.experimentalFileTypeDisplayToggle(value);
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user