2.6.0-beta-4

This commit is contained in:
zsviczian
2024-10-26 14:41:10 +02:00
parent 5bbe66900e
commit ee9364b645
5 changed files with 58 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
"version": "2.6.0-beta-3",
"version": "2.6.0-beta-4",
"minAppVersion": "1.1.6",
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
"author": "Zsolt Viczian",

View File

@@ -754,7 +754,7 @@ export class ExcalidrawData {
notice.noticeEl.oncontextmenu = () => {
displayFontMessage(this.app);
}
},2000);
},5000);
await loadSceneFonts(this.scene.elements);
clearTimeout(timer);

View File

@@ -5878,6 +5878,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
}
) {
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.instantiateExcalidraw, "ExcalidrawView.instantiateExcalidraw", initdata);
await this.plugin.awaitInit();
while(!this.semaphores.scriptsReady) {
await sleep(50);
}

View File

@@ -0,0 +1,44 @@
import { FileView, TextFileView, View, WorkspaceLeaf } from "obsidian";
import ExcalidrawPlugin from "src/main";
import { setExcalidrawView } from "src/utils/ObsidianUtils";
export default class ExcalidrawLoading extends FileView {
constructor(leaf: WorkspaceLeaf, private plugin: ExcalidrawPlugin) {
super(leaf);
this.switchToeExcalidraw();
this.displayLoadingText();
}
public onload() {
super.onload();
this.displayLoadingText();
}
private async switchToeExcalidraw() {
await this.plugin.awaitInit();
setExcalidrawView(this.leaf);
}
getViewType(): string {
return "excalidra-loading";
}
getDisplayText() {
return "Loading Excalidraw... " + (this.file?.basename ?? "");
}
private displayLoadingText() {
// Create a div element for displaying the text
const loadingTextEl = this.contentEl.createEl("div", {
text: this.getDisplayText()
});
// Apply styling to center the text
loadingTextEl.style.display = "flex";
loadingTextEl.style.alignItems = "center";
loadingTextEl.style.justifyContent = "center";
loadingTextEl.style.height = "100%";
loadingTextEl.style.fontSize = "1.5em"; // Adjust size as needed
}
}

View File

@@ -143,6 +143,7 @@ import { RankMessage } from "./dialogs/RankMessage";
import { initCompressionWorker, terminateCompressionWorker } from "./workers/compression-worker";
import { WeakArray } from "./utils/WeakArray";
import { getCJKDataURLs } from "./utils/CJKLoader";
import ExcalidrawLoading from "./dialogs/ExcalidrawLoading";
declare let EXCALIDRAW_PACKAGE:string;
declare let REACT_PACKAGES:string;
@@ -351,8 +352,17 @@ export default class ExcalidrawPlugin extends Plugin {
async onload() {
this.registerView(
VIEW_TYPE_EXCALIDRAW,
(leaf: WorkspaceLeaf) => new ExcalidrawView(leaf, this),
(leaf: WorkspaceLeaf) => {
if(this.isReady) {
return new ExcalidrawView(leaf, this);
} else {
return new ExcalidrawLoading(leaf, this);
}
},
);
//Compatibility mode with .excalidraw files
this.registerExtensions(["excalidraw"], VIEW_TYPE_EXCALIDRAW);
await this.loadSettings({reEnableAutosave:true});
const updateSettings = !this.settings.onceOffCompressFlagReset || !this.settings.onceOffGPTVersionReset;
if(!this.settings.onceOffCompressFlagReset) {
@@ -370,8 +380,6 @@ export default class ExcalidrawPlugin extends Plugin {
this.addSettingTab(new ExcalidrawSettingTab(this.app, this));
this.ea = await initExcalidrawAutomate(this);
//Compatibility mode with .excalidraw files
this.registerExtensions(["excalidraw"], VIEW_TYPE_EXCALIDRAW);
this.addMarkdownPostProcessor();
this.app.workspace.onLayoutReady(async () => {