diff --git a/manifest.json b/manifest.json index 37acb0b..b7f2a41 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "2.2.10", + "version": "2.2.11", "minAppVersion": "1.1.6", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/package.json b/package.json index 9f2458f..6dc9bb1 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "license": "MIT", "dependencies": { "@popperjs/core": "^2.11.8", - "@zsviczian/excalidraw": "0.17.1-obsidian-32", + "@zsviczian/excalidraw": "0.17.1-obsidian-34", "chroma-js": "^2.4.2", "clsx": "^2.0.0", "colormaster": "^1.2.1", diff --git a/rollup.config.js b/rollup.config.js index b1e871d..331e579 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -107,7 +107,7 @@ const BUILD_CONFIG = { babel({ presets: [['@babel/preset-env', { targets: { - esmodules: true, + ios: "15", // ios Compatibility //esmodules: true, }, }]], exclude: "node_modules/**", diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts index e3293ba..5b2a7a2 100644 --- a/src/ExcalidrawView.ts +++ b/src/ExcalidrawView.ts @@ -119,7 +119,7 @@ import { ObsidianMenu } from "./menu/ObsidianMenu"; import { ToolsPanel } from "./menu/ToolsPanel"; import { ScriptEngine } from "./Scripts"; import { getTextElementAtPointer, getImageElementAtPointer, getElementWithLinkAtPointer } from "./utils/GetElementAtPointer"; -import { ICONS, LogoWrapper, saveIcon } from "./menu/ActionIcons"; +import { excalidrawSword, ICONS, LogoWrapper, Rank, saveIcon, SwordColors } from "./menu/ActionIcons"; import { ExportDialog } from "./dialogs/ExportDialog"; import { getEA } from "src" import { anyModifierKeysPressed, emulateKeysForLinkClick, webbrowserDragModifierType, internalDragModifierType, isWinALTorMacOPT, isWinCTRLorMacCMD, isWinMETAorMacCTRL, isSHIFT, linkClickModifierType, localFileDragModifierType, ModifierKeys, modifierKeyTooltipMessages } from "./utils/ModifierkeyHelper"; @@ -1901,6 +1901,25 @@ export default class ExcalidrawView extends TextFileView { return; } + if (state.rename === "all") { + (async () => { + let filename = await ScriptEngine.inputPrompt( + this, + this.plugin, + this.plugin.app, + "Note Title", + "Filename without extension", + this.file.basename, + ); + if (!filename) { + return; + } + const {folderpath} = splitFolderAndFilename(filename); + this.app.vault.rename(this.file, normalizePath(`${folderpath}/${filename}.md`)); + })(); + return; + } + let query: string[] = null; if ( @@ -4997,7 +5016,10 @@ export default class ExcalidrawView extends TextFileView { private renderWelcomeScreen () { const React = this.packages.react; const {WelcomeScreen} = this.packages.excalidrawLib; - + const filecount = this.app.vault.getFiles().filter(f=>this.plugin.isExcalidrawFile(f)).length; + const rank = filecount < 200 ? "Bronze" : filecount < 750 ? "Silver" : filecount < 2000 ? "Gold" : "Platinum"; + const nextRankDelta = filecount < 200 ? 200 - filecount : filecount < 750 ? 750 - filecount : filecount < 2000 ? 2000 - filecount : 0; + const {decoration, title} = SwordColors[rank as Rank]; return React.createElement( WelcomeScreen, {}, @@ -5010,9 +5032,17 @@ export default class ExcalidrawView extends TextFileView { React.createElement( LogoWrapper, {}, - ICONS.ExcalidrawSword, + excalidrawSword(rank as Rank), ), ), + React.createElement( + WelcomeScreen.Center.Heading, + { + color: decoration, + message: nextRankDelta > 0 ? `${rank}: ${nextRankDelta} more drawings until the next rank!` : `${rank}: You're at the top. Keep on being legendary!`, + }, + title, + ), React.createElement( WelcomeScreen.Center.Heading, {}, @@ -5043,9 +5073,9 @@ export default class ExcalidrawView extends TextFileView { icon: ICONS.Discord, href: "https://discord.gg/DyfAXFwUHc", shortcut: null, - "aria-label": "Join the Visual Thinking Discord Server", + "aria-label": "Join the Discord Server", }, - " Join the Visual Thinking Discord Server" + " Join the Discord Server" ), React.createElement( WelcomeScreen.Center.MenuItemLink, @@ -5057,6 +5087,16 @@ export default class ExcalidrawView extends TextFileView { }, " Follow me on Twitter" ), + React.createElement( + WelcomeScreen.Center.MenuItemLink, + { + icon: ICONS.Learn, + href: "https://visual-thinking-workshop.com", + shortcut: null, + "aria-label": "Learn Visual PKM", + }, + " Sign up for the Visual Thinking Workshop" + ), React.createElement( WelcomeScreen.Center.MenuItemLink, { diff --git a/src/customEmbeddable.tsx b/src/customEmbeddable.tsx index 39534c3..c12ce41 100644 --- a/src/customEmbeddable.tsx +++ b/src/customEmbeddable.tsx @@ -223,6 +223,7 @@ function RenderObsidianView( } else { const workspaceLeaf:HTMLDivElement = rootSplit.containerEl.querySelector("div.workspace-leaf"); if(workspaceLeaf) workspaceLeaf.style.borderRadius = "var(--embeddable-radius)"; + rootSplit.containerEl.addClass("mod-visible"); containerRef.current.appendChild(rootSplit.containerEl); setColors(containerRef.current, element, mdProps, canvasColor); } diff --git a/src/dialogs/Messages.ts b/src/dialogs/Messages.ts index 543ae8a..a5516e9 100644 --- a/src/dialogs/Messages.ts +++ b/src/dialogs/Messages.ts @@ -17,6 +17,20 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
`, +"2.2.11": ` +\\color{white}.",
NONSTANDARD_HEAD: "Non-Excalidraw.com supported features",
NONSTANDARD_DESC: `These settings in the "Non-Excalidraw.com Supported Features" section provide customization options beyond the default Excalidraw.com features. These features are not available on excalidraw.com. When exporting the drawing to Excalidraw.com these features will appear different.
- You can configure the number of custom pens displayed next to the Obsidian Menu on the canvas, allowing you to choose from a range of options. Additionally, you can enable a fourth font option, which adds a fourth font button to the properties panel for text elements. `,
+ You can configure the number of custom pens displayed next to the Obsidian Menu on the canvas, allowing you to choose from a range of options. Additionally, you can enable a local font option, which adds a local font to the list of fonts on the element properties panel for text elements. `,
RENDER_TWEAK_HEAD: "Rendering tweaks",
MAX_IMAGE_ZOOM_IN_NAME: "Maximum image zoom in resolution",
MAX_IMAGE_ZOOM_IN_DESC: "To save on memory and because Apple Safari (Obsidian on iOS) has some hard-coded limitations, Excalidraw.com limits the max resolution of images and large objects when zooming in. You can override this limitation using a multiplicator. " +
@@ -697,16 +697,16 @@ FILENAME_HEAD: "Filename",
"Enabling this feature simplifies the use of Excalidraw front matter properties, allowing you to leverage many powerful settings. If you prefer not to load these properties automatically, " +
"you can disable this feature, but you will need to manually remove any unwanted properties from the suggester. " +
"Note that turning on this setting requires restarting the plugin as properties are loaded at startup.",
- CUSTOM_FONT_HEAD: "Fourth font",
- ENABLE_FOURTH_FONT_NAME: "Enable fourth font option",
+ CUSTOM_FONT_HEAD: "Local font",
+ ENABLE_FOURTH_FONT_NAME: "Enable local font option",
ENABLE_FOURTH_FONT_DESC:
- "By turning this on, you will see a fourth font button on the properties panel for text elements. " +
- "Files that use this fourth font will (partly) lose their platform independence. " +
+ "By turning this on, you will see a local font in the font list on the properties panel for text elements. " +
+ "Files that use this local font will (partly) lose their platform independence. " +
"Depending on the custom font set in settings, they will look differently when loaded in another vault, or at a later time. " +
"Also the 4th font will display as system default font on excalidraw.com, or other Excalidraw versions.",
- FOURTH_FONT_NAME: "Fourth font file",
+ FOURTH_FONT_NAME: "Local font file",
FOURTH_FONT_DESC:
- "Select a .ttf, .woff or .woff2 font file from your vault to use as the fourth font. " +
+ "Select a .ttf, .woff or .woff2 font file from your vault to use as the local font. " +
"If no file is selected, Excalidraw will use the Virgil font by default.",
SCRIPT_SETTINGS_HEAD: "Settings for installed Scripts",
SCRIPT_SETTINGS_DESC: "Some of the Excalidraw Automate Scripts include settings. Settings are organized by script. Settings will only become visible in this list after you have executed the newly downloaded script once.",
diff --git a/src/lang/locale/zh-cn.ts b/src/lang/locale/zh-cn.ts
index 12e2d31..6625421 100644
--- a/src/lang/locale/zh-cn.ts
+++ b/src/lang/locale/zh-cn.ts
@@ -230,7 +230,7 @@ export default {
"默认的 OpenAI API URL。请填写有效的 OpenAI API URL。" +
"Excalidraw 会通过该 URL 发送 API 请求给 OpenAI。我没有对此选项做任何错误处理,请谨慎修改。",
AI_OPENAI_DEFAULT_IMAGE_API_URL_NAME: "OpenAI 图像生成 API URL",
- AI_OPENAI_DEFAULT_VISION_MODEL_PLACEHOLDER: "gpt-4-vision-preview",
+ AI_OPENAI_DEFAULT_VISION_MODEL_PLACEHOLDER: "gpt-4o",
SAVING_HEAD: "保存",
SAVING_DESC: "包括:压缩,自动保存的时间间隔,文件的命名格式和扩展名等的设置。",
COMPRESS_NAME: "压缩 Excalidraw JSON",
diff --git a/src/main.ts b/src/main.ts
index e995c9e..509091d 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -136,6 +136,8 @@ import { EditorHandler } from "./CodeMirrorExtension/EditorHandler";
import { clearMathJaxVariables } from "./LaTeX";
import { showFrameSettings } from "./dialogs/FrameSettings";
import { ExcalidrawLib } from "./ExcalidrawLib";
+import { Rank, SwordColors } from "./menu/ActionIcons";
+import { RankMessage } from "./dialogs/RankMessage";
declare let EXCALIDRAW_PACKAGES:string;
declare let react:any;
@@ -187,6 +189,7 @@ export default class ExcalidrawPlugin extends Plugin {
public forceToOpenInMarkdownFilepath: string = null;
private slob:string;
private ribbonIcon:HTMLElement;
+ public loadTimestamp:number;
constructor(app: App, manifest: PluginManifest) {
super(app, manifest);
@@ -308,14 +311,23 @@ export default class ExcalidrawPlugin extends Plugin {
}*/
async onload() {
+ this.loadTimestamp = Date.now();
addIcon(ICON_NAME, EXCALIDRAW_ICON);
addIcon(SCRIPTENGINE_ICON_NAME, SCRIPTENGINE_ICON);
addIcon(EXPORT_IMG_ICON_NAME, EXPORT_IMG_ICON);
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";
+ }
+ }
+ if(updateSettings) {
await this.saveSettings();
}
this.excalidrawConfig = new ExcalidrawConfig(this);
@@ -3529,6 +3541,21 @@ export default class ExcalidrawPlugin extends Plugin {
errorlog({file, error: "new drawing not recognized as an excalidraw file", fn: this.createDrawing});
}
+ if(Date.now() - this.loadTimestamp > 1){//2000) {
+ const filecount = this.app.vault.getFiles().filter(f=>this.isExcalidrawFile(f)).length;
+ const rank:Rank = filecount < 200 ? "Bronze" : filecount < 750 ? "Silver" : filecount < 2000 ? "Gold" : "Platinum";
+ const {grip, decoration, blade} = SwordColors[rank];
+ if(this.settings.rank !== rank) {
+ //in case the message was already displayed on another device and it was synced in the mean time
+ await this.loadSettings();
+ if(this.settings.rank !== rank) {
+ this.settings.rank = rank;
+ await this.saveSettings();
+ new RankMessage(this.app, this, filecount, rank, decoration, blade, grip).open();
+ }
+ }
+ }
+
return file;
}
diff --git a/src/menu/ActionIcons.tsx b/src/menu/ActionIcons.tsx
index 3621b0a..0e1e8b7 100644
--- a/src/menu/ActionIcons.tsx
+++ b/src/menu/ActionIcons.tsx
@@ -59,6 +59,21 @@ export const ICONS = {