mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2025-08-06 05:46:28 +00:00
Compare commits
10 Commits
2.6.7
...
2.6.8-beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b3f3a56ad | ||
|
|
f746b4f4ac | ||
|
|
3e4a3ace56 | ||
|
|
c72f6add40 | ||
|
|
6cfb125a38 | ||
|
|
c91e57e341 | ||
|
|
0ddd75e5fe | ||
|
|
382d4ca827 | ||
|
|
198e8f8cb7 | ||
|
|
d3baa74ce7 |
1147
ea-scripts/Image Occlusion.md
Normal file
1147
ea-scripts/Image Occlusion.md
Normal file
File diff suppressed because it is too large
Load Diff
20
ea-scripts/Image Occlusion.svg
Normal file
20
ea-scripts/Image Occlusion.svg
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
||||
<!-- Blue star background -->
|
||||
<path
|
||||
d="M50 5 L61 40 L98 40 L68 62 L79 95 L50 75 L21 95 L32 62 L2 40 L39 40 Z"
|
||||
fill="#4a9eff"
|
||||
stroke="#1e1e1e"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<!-- White "A" text -->
|
||||
<text
|
||||
x="50"
|
||||
y="65"
|
||||
font-family="Arial"
|
||||
font-size="40"
|
||||
fill="white"
|
||||
text-anchor="middle"
|
||||
dominant-baseline="middle"
|
||||
>A</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 517 B |
@@ -130,6 +130,7 @@ I would love to include your contribution in the script library. If you have a s
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Select%20Similar%20Elements.svg"/></div>|[[#Select Similar Elements]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Slideshow.svg"/></div>|[[#Slideshow]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Split%20Ellipse.svg"/></div>|[[#Split Ellipse]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Image%20Occlusion.svg"/></div>|[[#Image Occlusion]]|
|
||||
|
||||
## Collaboration and Export
|
||||
**Keywords**: Sharing, Teamwork, Exporting, Distribution, Cooperative, Publish
|
||||
@@ -154,6 +155,7 @@ I would love to include your contribution in the script library. If you have a s
|
||||
|----|-----|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Crop%20Vintage%20Mask.svg"/></div>|[[#Crop Vintage Mask]]|
|
||||
|
||||
|
||||
---
|
||||
|
||||
# Description and Installation
|
||||
@@ -267,6 +269,8 @@ https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea
|
||||
```
|
||||
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/zsviczian'>@zsviczian</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Crop%20Vintage%20Mask.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">Adds a rounded mask to the image by adding a full cover black mask and a rounded rectangle white mask. The script is also useful for adding just a black mask. In this case, run the script, then delete the white mask and add your custom white mask.<br><img src='https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-crop-vintage.jpg'></td></tr></table>
|
||||
|
||||
|
||||
|
||||
## Custom Zoom
|
||||
```excalidraw-script-install
|
||||
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Custom%20Zoom.md
|
||||
@@ -395,6 +399,12 @@ https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea
|
||||
```
|
||||
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/zsviczian'>@zsviczian</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/GPT-Draw-a-UI.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">This script was discontinued in favor of ExcaliAI. Draw a UI and let GPT create the code for you.<br><iframe width="400" height="225" src="https://www.youtube.com/embed/y3kHl_6Ll4w" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><img src='https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-draw-a-ui.jpg'></td></tr></table>
|
||||
|
||||
## Image Occlusion
|
||||
```excalidraw-script-install
|
||||
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Image%20Occlusion.md
|
||||
```
|
||||
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/TrillStones'>@TrillStones</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Image%20Occlusion.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">An Excalidraw script for creating Anki image occlusion cards in Obsidian, similar to Anki's Image Occlusion Enhanced add-on but integrated into your Obsidian workflow.<br><img src='https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-image-occlusion.png'></td></tr></table>
|
||||
|
||||
## Invert colors
|
||||
```excalidraw-script-install
|
||||
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Invert%20colors.md
|
||||
|
||||
BIN
images/scripts-image-occlusion.png
Normal file
BIN
images/scripts-image-occlusion.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 139 KiB |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.6.7",
|
||||
"version": "2.6.8-beta-3",
|
||||
"minAppVersion": "1.1.6",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@zsviczian/excalidraw": "0.17.6-14",
|
||||
"@zsviczian/excalidraw": "0.17.6-17",
|
||||
"chroma-js": "^2.4.2",
|
||||
"clsx": "^2.0.0",
|
||||
"@zsviczian/colormaster": "^1.2.2",
|
||||
|
||||
@@ -52,14 +52,15 @@ if (!isLib) console.log(manifest.version);
|
||||
|
||||
const packageString = isLib
|
||||
? ""
|
||||
: ';' + lzstring_pkg +
|
||||
: ';const INITIAL_TIMESTAMP=Date.now();' + lzstring_pkg +
|
||||
'\nlet REACT_PACKAGES = `' +
|
||||
jsesc(react_pkg + reactdom_pkg, { quotes: 'backtick' }) +
|
||||
'`;\n' +
|
||||
'let EXCALIDRAW_PACKAGE = ""; const unpackExcalidraw = () => {EXCALIDRAW_PACKAGE = LZString.decompressFromBase64("' + LZString.compressToBase64(excalidraw_pkg) + '");};\n' +
|
||||
'let {react, reactDOM } = window.eval.call(window, `(function() {' + '${REACT_PACKAGES};' + 'return {react: React, reactDOM: ReactDOM};})();`);\n' +
|
||||
`let excalidrawLib = {};\n` +
|
||||
'let PLUGIN_VERSION="' + manifest.version + '";';
|
||||
'const PLUGIN_VERSION="' + manifest.version + '";';
|
||||
|
||||
|
||||
const BASE_CONFIG = {
|
||||
input: 'src/main.ts',
|
||||
|
||||
@@ -17,7 +17,7 @@ import { MimeType } from "./EmbeddedFileLoader";
|
||||
import { Editor, normalizePath, Notice, OpenViewState, RequestUrlResponse, TFile, TFolder, WorkspaceLeaf } from "obsidian";
|
||||
import * as obsidian_module from "obsidian";
|
||||
import ExcalidrawView, { ExportSettings, TextMode, getTextMode } from "src/ExcalidrawView";
|
||||
import { ExcalidrawData, getMarkdownDrawingSection, REGEX_LINK } from "src/ExcalidrawData";
|
||||
import { ExcalidrawData, getExcalidrawMarkdownHeaderSection, getMarkdownDrawingSection, REGEX_LINK } from "src/ExcalidrawData";
|
||||
import {
|
||||
FRONTMATTER,
|
||||
nanoid,
|
||||
@@ -133,6 +133,10 @@ export class ExcalidrawAutomate {
|
||||
return DEVICE;
|
||||
}
|
||||
|
||||
public printStartupBreakdown() {
|
||||
this.plugin.printStarupBreakdown();
|
||||
}
|
||||
|
||||
public help(target: Function | string) {
|
||||
if (!target) {
|
||||
log("Usage: ea.help(ea.functionName) or ea.help('propertyName') or ea.help('utils.functionName') - notice property name and utils function name is in quotes");
|
||||
@@ -650,6 +654,13 @@ export class ExcalidrawAutomate {
|
||||
0
|
||||
)
|
||||
: null;
|
||||
if (template?.plaintext) {
|
||||
if(params.plaintext) {
|
||||
params.plaintext = params.plaintext + "\n\n" + template.plaintext;
|
||||
} else {
|
||||
params.plaintext = template.plaintext;
|
||||
}
|
||||
}
|
||||
let elements = template ? template.elements : [];
|
||||
elements = elements.concat(this.getElements());
|
||||
let frontmatter: string;
|
||||
@@ -675,7 +686,13 @@ export class ExcalidrawAutomate {
|
||||
: FRONTMATTER;
|
||||
}
|
||||
|
||||
frontmatter += params.plaintext ? params.plaintext + "\n\n" : "";
|
||||
frontmatter += params.plaintext
|
||||
? (params.plaintext.endsWith("\n\n")
|
||||
? params.plaintext
|
||||
: (params.plaintext.endsWith("\n")
|
||||
? params.plaintext + "\n"
|
||||
: params.plaintext + "\n\n"))
|
||||
: "";
|
||||
if(template?.frontmatter && params?.frontmatterKeys) {
|
||||
//the frontmatter tags supplyed to create take priority
|
||||
frontmatter = mergeMarkdownFiles(template.frontmatter,frontmatter);
|
||||
@@ -1820,7 +1837,7 @@ export class ExcalidrawAutomate {
|
||||
viewBackgroundColor: "#FFFFFF",
|
||||
gridSize: 0
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* returns true if MD file is an Excalidraw file
|
||||
@@ -2926,6 +2943,7 @@ async function getTemplate(
|
||||
frontmatter: string;
|
||||
files: any;
|
||||
hasSVGwithBitmap: boolean;
|
||||
plaintext: string; //markdown data above Excalidraw data and below YAML frontmatter
|
||||
}> {
|
||||
const app = plugin.app;
|
||||
const vault = app.vault;
|
||||
@@ -2951,6 +2969,7 @@ async function getTemplate(
|
||||
frontmatter: "",
|
||||
files: excalidrawData.scene.files,
|
||||
hasSVGwithBitmap,
|
||||
plaintext: "",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3023,7 +3042,7 @@ async function getTemplate(
|
||||
}
|
||||
|
||||
excalidrawData.destroy();
|
||||
const filehead = data.substring(0, trimLocation);
|
||||
const filehead = getExcalidrawMarkdownHeaderSection(data); // data.substring(0, trimLocation);
|
||||
let files:any = {};
|
||||
const sceneFilesSize = Object.values(scene.files).length;
|
||||
if (sceneFilesSize > 0) {
|
||||
@@ -3036,6 +3055,7 @@ async function getTemplate(
|
||||
}
|
||||
}
|
||||
|
||||
const frontmatter = filehead.match(/^---\n.*\n---\n/ms)?.[0] ?? filehead;
|
||||
return {
|
||||
elements: convertMarkdownLinksToObsidianURLs
|
||||
? updateElementLinksToObsidianLinks({
|
||||
@@ -3043,7 +3063,10 @@ async function getTemplate(
|
||||
hostFile: file,
|
||||
}) : groupElements,
|
||||
appState: scene.appState,
|
||||
frontmatter: filehead.match(/^---\n.*\n---\n/ms)?.[0] ?? filehead,
|
||||
frontmatter,
|
||||
plaintext: frontmatter !== filehead
|
||||
? (filehead.split(/^---\n.*\n---\n/ms)?.[1] ?? "")
|
||||
: "",
|
||||
files,
|
||||
hasSVGwithBitmap,
|
||||
};
|
||||
@@ -3054,6 +3077,7 @@ async function getTemplate(
|
||||
frontmatter: null,
|
||||
files: [],
|
||||
hasSVGwithBitmap,
|
||||
plaintext: "",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
private lastLoadedFile: TFile = null;
|
||||
//store key state for view mode link resolution
|
||||
private modifierKeyDown: ModifierKeys = {shiftKey:false, metaKey: false, ctrlKey: false, altKey: false}
|
||||
public currentPosition: {x:number,y:number} = { x: 0, y: 0 };
|
||||
public currentPosition: {x:number,y:number} = { x: 0, y: 0 }; //these are scene coord thus would be more apt to call them sceneX and sceneY, however due to scrits already using x and y, I will keep it as is
|
||||
//Obsidian 0.15.0
|
||||
private draginfoDiv: HTMLDivElement;
|
||||
public canvasNodeFactory: CanvasNodeFactory;
|
||||
@@ -3546,7 +3546,10 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
|
||||
private clearHoverPreview() {
|
||||
if (this.hoverPopover) {
|
||||
//@ts-ignore
|
||||
const hoverContainerEl = this.hoverPopover?.containerEl;
|
||||
//don't auto hide hover-editor
|
||||
if (this.hoverPopover && !hoverContainerEl?.parentElement?.hasClass("hover-editor")) {
|
||||
this.hoverPreviewTarget = null;
|
||||
//@ts-ignore
|
||||
if(this.hoverPopover.embed?.editor) {
|
||||
@@ -4657,8 +4660,20 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
|
||||
//returns the raw text of the element which is the original text without parsing
|
||||
//in compatibility mode, returns the original text, and for backward compatibility the text if originalText is not available
|
||||
private onBeforeTextEdit (textElement: ExcalidrawTextElement) {
|
||||
private onBeforeTextEdit (textElement: ExcalidrawTextElement, isExistingElement: boolean): string {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.onBeforeTextEdit, "ExcalidrawView.onBeforeTextEdit", textElement);
|
||||
/*const api = this.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
const st = api.getAppState();
|
||||
setDynamicStyle(
|
||||
this.plugin.ea,
|
||||
this,
|
||||
st.viewBackgroundColor === "transparent" ? "white" : st.viewBackgroundColor,
|
||||
this.plugin.settings.dynamicStyling,
|
||||
api.getColorAtScenePoint({sceneX: this.currentPosition.x, sceneY: this.currentPosition.y})
|
||||
);*/
|
||||
if(!isExistingElement) {
|
||||
return;
|
||||
}
|
||||
window.clearTimeout(this.isEditingTextResetTimer);
|
||||
this.isEditingTextResetTimer = null;
|
||||
this.semaphores.isEditingText = true; //to prevent autoresize on mobile when keyboard pops up
|
||||
|
||||
@@ -886,6 +886,7 @@ export const markdownPostProcessor = async (
|
||||
el: HTMLElement,
|
||||
ctx: MarkdownPostProcessorContext,
|
||||
) => {
|
||||
await plugin.awaitSettings();
|
||||
const isPrinting = Boolean(document.body.querySelectorAll("body > .print").length>0);
|
||||
//firstElementChild: https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1956
|
||||
const isFrontmatter = el.hasClass("mod-frontmatter") ||
|
||||
|
||||
@@ -16,6 +16,18 @@ export const RELEASE_NOTES: { [k: string]: string } = {
|
||||
I develop this plugin as a hobby, spending my free time doing this. If you find it valuable, then please say THANK YOU or...
|
||||
|
||||
<div class="ex-coffee-div"><a href="https://ko-fi.com/zsolt"><img src="https://storage.ko-fi.com/cdn/kofi6.png?v=6" border="0" alt="Buy Me a Coffee at ko-fi.com" height=45></a></div>
|
||||
`,
|
||||
"2.6.8":`
|
||||
## New
|
||||
- Text Element cursor color matched the text color.
|
||||
|
||||
## Fixed
|
||||
- BUG: icon on the ribbon menu keeps reappearing even if you hide it every time you reopen Obsidian [#2115](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2115)
|
||||
- In pen mode, when single-finger panning is enabled, allow actions with the mouse.
|
||||
- When editing an Excalidraw file in split mode (drawing on one side, markdown view on the other), editing the markdown sometimes causes the drawing to re-zoom and jump away from the selected area.
|
||||
- Hover-Editor compatibility
|
||||
- ${String.fromCharCode(96)}ExcalidrawAutomate.create() ${String.fromCharCode(96)} will now correctly include the markdown text in templates above Excalidraw Data and below YAML front matter. This also fixes the same issue with the Deconstruct Selected Element script.
|
||||
|
||||
`,
|
||||
"2.6.7":`
|
||||
Hoping to finally move on to 2.7.0... but still have one last bug to fix in 2.6.x!
|
||||
|
||||
112
src/main.ts
112
src/main.ts
@@ -145,7 +145,6 @@ import { WeakArray } from "./utils/WeakArray";
|
||||
import { getCJKDataURLs } from "./utils/CJKLoader";
|
||||
import { ExcalidrawLoading, switchToExcalidraw } from "./dialogs/ExcalidrawLoading";
|
||||
import { insertImageToView } from "./utils/ExcalidrawViewUtils";
|
||||
import tr from "./lang/locale/tr";
|
||||
|
||||
declare let EXCALIDRAW_PACKAGE:string;
|
||||
declare let REACT_PACKAGES:string;
|
||||
@@ -153,7 +152,8 @@ declare const unpackExcalidraw: Function;
|
||||
declare let react:any;
|
||||
declare let reactDOM:any;
|
||||
declare let excalidrawLib: typeof ExcalidrawLib;
|
||||
declare let PLUGIN_VERSION:string;
|
||||
declare const PLUGIN_VERSION:string;
|
||||
declare const INITIAL_TIMESTAMP: number;
|
||||
|
||||
export default class ExcalidrawPlugin extends Plugin {
|
||||
public eaInstances = new WeakArray<ExcalidrawAutomate>();
|
||||
@@ -199,13 +199,17 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
//if set, the next time this file is opened it will be opened as markdown
|
||||
public forceToOpenInMarkdownFilepath: string = null;
|
||||
//private slob:string;
|
||||
private ribbonIcon:HTMLElement;
|
||||
public loadTimestamp:number;
|
||||
private isLocalCJKFontAvailabe:boolean = undefined
|
||||
public isReady = false;
|
||||
private startupAnalytics: string[] = [];
|
||||
private lastLogTimestamp: number;
|
||||
private settingsReady: boolean = false;
|
||||
|
||||
constructor(app: App, manifest: PluginManifest) {
|
||||
super(app, manifest);
|
||||
this.loadTimestamp = INITIAL_TIMESTAMP;
|
||||
this.lastLogTimestamp = this.loadTimestamp;
|
||||
this.packageMap.set(window,{react, reactDOM, excalidrawLib});
|
||||
this.filesMaster = new Map<
|
||||
FileId,
|
||||
@@ -219,6 +223,16 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
}*/
|
||||
}
|
||||
|
||||
private logStartupEvent(message:string) {
|
||||
const timestamp = Date.now();
|
||||
this.startupAnalytics.push(`${message}\nTotal: ${timestamp - this.loadTimestamp}ms Delta: ${timestamp - this.lastLogTimestamp}ms\n`);
|
||||
this.lastLogTimestamp = timestamp;
|
||||
}
|
||||
|
||||
public printStarupBreakdown() {
|
||||
console.log(`Excalidraw ${PLUGIN_VERSION} startup breakdown:\n`+this.startupAnalytics.join("\n"));
|
||||
}
|
||||
|
||||
get locale() {
|
||||
return LOCALE;
|
||||
}
|
||||
@@ -352,6 +366,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
}
|
||||
|
||||
async onload() {
|
||||
this.logStartupEvent("Plugin Constructor ready, starting onload()");
|
||||
this.registerView(
|
||||
VIEW_TYPE_EXCALIDRAW,
|
||||
(leaf: WorkspaceLeaf) => {
|
||||
@@ -365,26 +380,34 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
//Compatibility mode with .excalidraw files
|
||||
this.registerExtensions(["excalidraw"], VIEW_TYPE_EXCALIDRAW);
|
||||
|
||||
addIcon(ICON_NAME, EXCALIDRAW_ICON);
|
||||
addIcon(SCRIPTENGINE_ICON_NAME, SCRIPTENGINE_ICON);
|
||||
addIcon(EXPORT_IMG_ICON_NAME, EXPORT_IMG_ICON);
|
||||
this.addRibbonIcon(ICON_NAME, t("CREATE_NEW"), this.actionRibbonClick.bind(this));
|
||||
|
||||
try {
|
||||
await this.loadSettings({reEnableAutosave:true});
|
||||
const updateSettings = !this.settings.onceOffCompressFlagReset || !this.settings.onceOffGPTVersionReset;
|
||||
if(!this.settings.onceOffCompressFlagReset) {
|
||||
this.settings.compress = true;
|
||||
this.settings.onceOffCompressFlagReset = true;
|
||||
}
|
||||
if(!this.settings.onceOffGPTVersionReset) {
|
||||
if(this.settings.openAIDefaultVisionModel === "gpt-4-vision-preview") {
|
||||
this.settings.openAIDefaultVisionModel = "gpt-4o";
|
||||
this.loadSettings({reEnableAutosave:true}).then(async () => {
|
||||
const updateSettings = !this.settings.onceOffCompressFlagReset || !this.settings.onceOffGPTVersionReset;
|
||||
if(!this.settings.onceOffCompressFlagReset) {
|
||||
this.settings.compress = true;
|
||||
this.settings.onceOffCompressFlagReset = true;
|
||||
}
|
||||
}
|
||||
if(updateSettings) {
|
||||
await this.saveSettings();
|
||||
}
|
||||
this.addSettingTab(new ExcalidrawSettingTab(this.app, this));
|
||||
if(!this.settings.onceOffGPTVersionReset) {
|
||||
if(this.settings.openAIDefaultVisionModel === "gpt-4-vision-preview") {
|
||||
this.settings.openAIDefaultVisionModel = "gpt-4o";
|
||||
}
|
||||
}
|
||||
if(updateSettings) {
|
||||
await this.saveSettings();
|
||||
}
|
||||
this.addSettingTab(new ExcalidrawSettingTab(this.app, this));
|
||||
this.settingsReady = true;
|
||||
});
|
||||
} catch (e) {
|
||||
new Notice("Error loading plugin settings", 6000);
|
||||
console.error("Error loading plugin settings", e);
|
||||
}
|
||||
this.logStartupEvent("Settings loaded");
|
||||
|
||||
try {
|
||||
// need it her for ExcaliBrain
|
||||
@@ -393,6 +416,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error initializing Excalidraw Automate", 6000);
|
||||
console.error("Error initializing Excalidraw Automate", e);
|
||||
}
|
||||
this.logStartupEvent("Excalidraw Automate initialized");
|
||||
|
||||
try {
|
||||
//Licat: Are you registering your post processors in onLayoutReady? You should register them in onload instead
|
||||
@@ -401,8 +425,14 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error adding markdown post processor", 6000);
|
||||
console.error("Error adding markdown post processor", e);
|
||||
}
|
||||
this.logStartupEvent("Markdown post processor added");
|
||||
|
||||
this.app.workspace.onLayoutReady(async () => {
|
||||
this.loadTimestamp = Date.now();
|
||||
this.lastLogTimestamp = this.loadTimestamp;
|
||||
this.logStartupEvent("\n----------------------------------\nWorkspace onLayoutReady event fired (these actions are outside the plugin initialization)");
|
||||
await this.awaitSettings();
|
||||
this.logStartupEvent("Settings awaited");
|
||||
try {
|
||||
unpackExcalidraw();
|
||||
excalidrawLib = window.eval.call(window,`(function() {${EXCALIDRAW_PACKAGE};return ExcalidrawLib;})()`);
|
||||
@@ -412,6 +442,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error loading the Excalidraw package", 6000);
|
||||
console.error("Error loading the Excalidraw package", e);
|
||||
}
|
||||
this.logStartupEvent("Excalidraw package unpacked");
|
||||
|
||||
try {
|
||||
initCompressionWorker();
|
||||
@@ -419,11 +450,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error initializing compression worker", 6000);
|
||||
console.error("Error initializing compression worker", e);
|
||||
}
|
||||
|
||||
this.loadTimestamp = Date.now();
|
||||
addIcon(ICON_NAME, EXCALIDRAW_ICON);
|
||||
addIcon(SCRIPTENGINE_ICON_NAME, SCRIPTENGINE_ICON);
|
||||
addIcon(EXPORT_IMG_ICON_NAME, EXPORT_IMG_ICON);
|
||||
this.logStartupEvent("Compression worker initialized");
|
||||
|
||||
try {
|
||||
this.excalidrawConfig = new ExcalidrawConfig(this);
|
||||
@@ -431,6 +458,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error initializing Excalidraw config", 6000);
|
||||
console.error("Error initializing Excalidraw config", e);
|
||||
}
|
||||
this.logStartupEvent("Excalidraw config initialized");
|
||||
|
||||
try {
|
||||
await loadMermaid();
|
||||
@@ -438,6 +466,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error loading Mermaid", 6000);
|
||||
console.error("Error loading Mermaid", e);
|
||||
}
|
||||
this.logStartupEvent("Mermaid loaded");
|
||||
|
||||
try {
|
||||
this.addThemeObserver();
|
||||
@@ -445,6 +474,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error adding theme observer", 6000);
|
||||
console.error("Error adding theme observer", e);
|
||||
}
|
||||
this.logStartupEvent("Theme observer added");
|
||||
|
||||
try {
|
||||
//inspiration taken from kanban:
|
||||
@@ -454,6 +484,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error registering monkey patches", 6000);
|
||||
console.error("Error registering monkey patches", e);
|
||||
}
|
||||
this.logStartupEvent("Monkey patches registered");
|
||||
|
||||
try {
|
||||
this.stylesManager = new StylesManager(this);
|
||||
@@ -461,6 +492,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error initializing styles manager", 6000);
|
||||
console.error("Error initializing styles manager", e);
|
||||
}
|
||||
this.logStartupEvent("Styles manager initialized");
|
||||
|
||||
try {
|
||||
this.scriptEngine = new ScriptEngine(this);
|
||||
@@ -468,6 +500,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error initializing script engine", 6000);
|
||||
console.error("Error initializing script engine", e);
|
||||
}
|
||||
this.logStartupEvent("Script engine initialized");
|
||||
|
||||
try {
|
||||
await this.initializeFonts();
|
||||
@@ -475,6 +508,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error initializing fonts", 6000);
|
||||
console.error("Error initializing fonts", e);
|
||||
}
|
||||
this.logStartupEvent("Fonts initialized");
|
||||
|
||||
try {
|
||||
imageCache.initializeDB(this);
|
||||
@@ -482,6 +516,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error initializing image cache", 6000);
|
||||
console.error("Error initializing image cache", e);
|
||||
}
|
||||
this.logStartupEvent("Image cache initialized");
|
||||
|
||||
try {
|
||||
this.isReady = true;
|
||||
@@ -491,6 +526,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error switching views to Excalidraw", 6000);
|
||||
console.error("Error switching views to Excalidraw", e);
|
||||
}
|
||||
this.logStartupEvent("Switched to Excalidraw views");
|
||||
|
||||
try {
|
||||
if (this.settings.showReleaseNotes) {
|
||||
@@ -509,6 +545,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error opening release notes", 6000);
|
||||
console.error("Error opening release notes", e);
|
||||
}
|
||||
this.logStartupEvent("Release notes opened");
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//initialization that can happen after Excalidraw views are initialized
|
||||
@@ -519,6 +556,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error registering event listeners", 6000);
|
||||
console.error("Error registering event listeners", e);
|
||||
}
|
||||
this.logStartupEvent("Event listeners registered");
|
||||
|
||||
try {
|
||||
this.runStartupScript();
|
||||
@@ -526,6 +564,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error running startup script", 6000);
|
||||
console.error("Error running startup script", e);
|
||||
}
|
||||
this.logStartupEvent("Startup script run");
|
||||
|
||||
try {
|
||||
this.editorHandler = new EditorHandler(this);
|
||||
@@ -534,6 +573,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error setting up editor handler", 6000);
|
||||
console.error("Error setting up editor handler", e);
|
||||
}
|
||||
this.logStartupEvent("Editor handler initialized");
|
||||
|
||||
try {
|
||||
this.registerInstallCodeblockProcessor();
|
||||
@@ -541,6 +581,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error registering script install-codeblock processor", 6000);
|
||||
console.error("Error registering script install-codeblock processor", e);
|
||||
}
|
||||
this.logStartupEvent("Script install-codeblock processor registered");
|
||||
|
||||
try {
|
||||
this.experimentalFileTypeDisplayToggle(this.settings.experimentalFileType);
|
||||
@@ -548,6 +589,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error setting up experimental file type display", 6000);
|
||||
console.error("Error setting up experimental file type display", e);
|
||||
}
|
||||
this.logStartupEvent("Experimental file type display set");
|
||||
|
||||
try {
|
||||
this.registerCommands();
|
||||
@@ -555,6 +597,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error registering commands", 6000);
|
||||
console.error("Error registering commands", e);
|
||||
}
|
||||
this.logStartupEvent("Commands registered");
|
||||
|
||||
try {
|
||||
this.registerEditorSuggest(new FieldSuggester(this));
|
||||
@@ -562,6 +605,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error registering editor suggester", 6000);
|
||||
console.error("Error registering editor suggester", e);
|
||||
}
|
||||
this.logStartupEvent("Editor suggester registered");
|
||||
|
||||
try {
|
||||
this.setPropertyTypes();
|
||||
@@ -569,6 +613,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error setting up property types", 6000);
|
||||
console.error("Error setting up property types", e);
|
||||
}
|
||||
this.logStartupEvent("Property types set");
|
||||
|
||||
try {
|
||||
this.taskbone = new Taskbone(this);
|
||||
@@ -576,9 +621,17 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
new Notice("Error setting up taskbone", 6000);
|
||||
console.error("Error setting up taskbone", e);
|
||||
}
|
||||
this.logStartupEvent("Taskbone set up");
|
||||
});
|
||||
this.logStartupEvent("Workspace ready event handler added");
|
||||
}
|
||||
|
||||
public async awaitSettings() {
|
||||
let counter = 0;
|
||||
while(!this.settingsReady && counter < 150) {
|
||||
await sleep(20);
|
||||
}
|
||||
}
|
||||
|
||||
public async awaitInit() {
|
||||
let counter = 0;
|
||||
@@ -1083,8 +1136,6 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
this.importSVGDialog = new ImportSVGDialog(this);
|
||||
this.insertMDDialog = new InsertMDDialog(this);
|
||||
|
||||
this.ribbonIcon = this.addRibbonIcon(ICON_NAME, t("CREATE_NEW"), this.actionRibbonClick.bind(this));
|
||||
|
||||
const createNewAction = (e: MouseEvent | KeyboardEvent, file: TFile) => {
|
||||
let folderpath = file.path;
|
||||
if (file instanceof TFile) {
|
||||
@@ -3248,7 +3299,11 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
}
|
||||
//if the user hasn't touched the file for 5 minutes, don't synchronize, reload.
|
||||
//this is to avoid complex sync scenarios of multiple remote changes outside an active collaboration session
|
||||
if(excalidrawView.lastSaveTimestamp + 300000 < Date.now()) {
|
||||
const activeView = this.app.workspace.activeLeaf.view;
|
||||
const isEditingMarkdownSideInSplitView = (activeView !== excalidrawView) &&
|
||||
activeView instanceof MarkdownView && activeView.file === excalidrawView.file;
|
||||
|
||||
if(!isEditingMarkdownSideInSplitView && (excalidrawView.lastSaveTimestamp + 300000 < Date.now())) {
|
||||
excalidrawView.reload(true, excalidrawView.file);
|
||||
return;
|
||||
}
|
||||
@@ -3496,11 +3551,6 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
window.clearTimeout(versionUpdateCheckTimer);
|
||||
}
|
||||
|
||||
if(this.ribbonIcon) {
|
||||
this.ribbonIcon.remove();
|
||||
this.ribbonIcon = null;
|
||||
}
|
||||
|
||||
if(this.scriptEngine) {
|
||||
this.scriptEngine.destroy();
|
||||
this.scriptEngine = null;
|
||||
@@ -3602,7 +3652,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
EXCALIDRAW_PACKAGE = "";
|
||||
REACT_PACKAGES = "";
|
||||
//pluginPackages = null;
|
||||
PLUGIN_VERSION = null;
|
||||
//PLUGIN_VERSION = null;
|
||||
//@ts-ignore
|
||||
delete window.PolyBool;
|
||||
this.deletePackage(window);
|
||||
|
||||
@@ -13,6 +13,7 @@ export const setDynamicStyle = (
|
||||
view: ExcalidrawView, //the excalidraw view
|
||||
color: string,
|
||||
dynamicStyle: DynamicStyle,
|
||||
textBackgroundColor?: string,
|
||||
) => {
|
||||
if(dynamicStyle === "none") {
|
||||
view.excalidrawContainer?.removeAttribute("style");
|
||||
@@ -116,7 +117,9 @@ export const setDynamicStyle = (
|
||||
[`--h3-color`]: str(text),
|
||||
[`--h4-color`]: str(text),
|
||||
[`color`]: str(text),
|
||||
['--excalidraw-caret-color']: str(isLightTheme ? text : cmBG()),
|
||||
['--excalidraw-caret-color']: textBackgroundColor
|
||||
? str(isLightTheme ? invertColor(textBackgroundColor) : ea.getCM(textBackgroundColor))
|
||||
: str(isLightTheme ? text : cmBG()),
|
||||
[`--select-highlight-color`]: str(gray1()),
|
||||
[`--color-gray-90`]: str(isDark?text.darkerBy(5):text.lighterBy(5)), //search background
|
||||
[`--color-gray-80`]: str(isDark?text.darkerBy(10):text.lighterBy(10)), //frame
|
||||
|
||||
Reference in New Issue
Block a user