mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2025-08-06 05:46:28 +00:00
1.9.9
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "1.9.8",
|
||||
"version": "1.9.9",
|
||||
"minAppVersion": "1.1.6",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "obsidian-excalidraw-plugin",
|
||||
"version": "1.9.9",
|
||||
"version": "1.9.9-2",
|
||||
"description": "This is an Obsidian.md plugin that lets you view and edit Excalidraw drawings",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
scaleLoadedImage,
|
||||
wrapTextAtCharLength,
|
||||
} from "src/utils/Utils";
|
||||
import { getAttachmentsFolderAndFilePath, getNewOrAdjacentLeaf, isObsidianThemeDark } from "src/utils/ObsidianUtils";
|
||||
import { getAttachmentsFolderAndFilePath, getLeaf, getNewOrAdjacentLeaf, isObsidianThemeDark } from "src/utils/ObsidianUtils";
|
||||
import { AppState, BinaryFileData, ExcalidrawImperativeAPI, Point } from "@zsviczian/excalidraw/types/types";
|
||||
import { EmbeddedFile, EmbeddedFilesLoader, FileData } from "src/EmbeddedFileLoader";
|
||||
import { tex2dataURL } from "src/LaTeX";
|
||||
@@ -152,6 +152,20 @@ export class ExcalidrawAutomate {
|
||||
return await newFilePrompt.waitForClose;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new Obsidian Leaf following Excalidraw plugin settings such as open in Main Workspace or not, open in adjacent pane if avaialble, etc.
|
||||
* @param origo // the currently active leaf, the origin of the new leaf
|
||||
* @param targetPane //type PaneTarget = "active-pane"|"new-pane"|"popout-window"|"new-tab"|"md-properties";
|
||||
* @returns
|
||||
*/
|
||||
public getLeaf (
|
||||
origo: WorkspaceLeaf,
|
||||
targetPane?: PaneTarget,
|
||||
): WorkspaceLeaf {
|
||||
const modifierKeys = emulateKeysForLinkClick(targetPane??"new-tab");
|
||||
return getLeaf(this.plugin,origo,modifierKeys);
|
||||
}
|
||||
|
||||
plugin: ExcalidrawPlugin;
|
||||
elementsDict: {[key:string]:any}; //contains the ExcalidrawElements currently edited in Automate indexed by el.id
|
||||
imagesDict: {[key: FileId]: any}; //the images files including DataURL, indexed by fileId
|
||||
|
||||
@@ -116,7 +116,7 @@ import { getTextElementAtPointer, getImageElementAtPointer, getElementWithLinkAt
|
||||
import { ICONS, saveIcon } from "./menu/ActionIcons";
|
||||
import { ExportDialog } from "./dialogs/ExportDialog";
|
||||
import { getEA } from "src";
|
||||
import { emulateCTRLClickForLinks, externalDragModifierType, internalDragModifierType, isALT, isCTRL, isMETA, isSHIFT, linkClickModifierType, mdPropModifier, ModifierKeys } from "./utils/ModifierkeyHelper";
|
||||
import { anyModifierKeysPressed, emulateCTRLClickForLinks, emulateKeysForLinkClick, externalDragModifierType, internalDragModifierType, isALT, isCTRL, isMETA, isSHIFT, linkClickModifierType, mdPropModifier, ModifierKeys } from "./utils/ModifierkeyHelper";
|
||||
import { setDynamicStyle } from "./utils/DynamicStyling";
|
||||
import { InsertPDFModal } from "./dialogs/InsertPDFModal";
|
||||
import { CustomEmbeddable, renderWebView } from "./customEmbeddable";
|
||||
@@ -1043,9 +1043,8 @@ export default class ExcalidrawView extends TextFileView {
|
||||
new NewFileActions(this.plugin, linkText, keys, this).open();
|
||||
return;
|
||||
}
|
||||
if(this.linksAlwaysOpenInANewPane) {
|
||||
keys.ctrlKey = true;
|
||||
keys.altKey = true;
|
||||
if(this.linksAlwaysOpenInANewPane && !anyModifierKeysPressed(keys)) {
|
||||
keys = emulateKeysForLinkClick("new-pane");
|
||||
}
|
||||
const leaf = getLeaf(this.plugin,this.leaf,keys);
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ function RenderObsidianView(
|
||||
setTimeout(() => {
|
||||
//@ts-ignore
|
||||
view.ownerWindow.electronWindow.setAlwaysOnTop(false);
|
||||
}, 150);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
leafRef.current.node = view.canvasNodeFactory.createFileNote(file, subpath, containerRef.current, element.id);
|
||||
|
||||
@@ -28,40 +28,65 @@ This will avoid any issues with converted files and let you enjoy the new featur
|
||||
|
||||
Thank you for your understanding. If you have any questions, feel free to reach out.
|
||||
|
||||
---
|
||||
|
||||
## Fixed:
|
||||
- PNG image caching resulting in broken images after Obsidian restarts
|
||||
- SVG export now displays embedded iframes with the correct embed link (note this feature only works when you open the SVGs in a browser outside Obsidian).
|
||||
|
||||
## Updated / fixed / new in Excalidraw Automate
|
||||
- I updated the [ExcalidrawAutomateInterface](https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/src/types.d.ts) type definition
|
||||
- Added new ExcalidrawAutomate function: ${String.fromCharCode(96)} addEmbeddable(topX: number, topY: number, width: number, height: number, url?: string, file?: TFile): string;${String.fromCharCode(96)}
|
||||
## Updated / fixed in Excalidraw Automate
|
||||
- I updated ${String.fromCharCode(96)}lib/ExcalidrawAutomate.d.ts${String.fromCharCode(96)} and published a new version of obsidian-excalidraw-plugin type library to npmjs.
|
||||
- Added new ExcalidrawAutomate functions: ${String.fromCharCode(96)} addEmbeddable()${String.fromCharCode(96)}, ${String.fromCharCode(96)}DEVICE${String.fromCharCode(96)}, ${String.fromCharCode(96)}newFilePrompt()${String.fromCharCode(96)}, and ${String.fromCharCode(96)}getLeaf()${String.fromCharCode(96)}
|
||||
- ${String.fromCharCode(96)}addImage${String.fromCharCode(96)} and ${String.fromCharCode(96)}addElementsToView${String.fromCharCode(96)} were extended with 1-1 additional optional parameter. As a result of ${String.fromCharCode(96)}shouldRestoreElements${String.fromCharCode(96)} defaulting to false, all elements in the scene will no longer be updated (iframes will not blink) when you add elements via script.
|
||||
- There is a new event hook: onPasteHook. This will be called whenever the user pastes something to the canvas. You can use this callback in case you want to do something additional when the onPaste event occurs. In case you want to prevent the Excalidraw default onPaste action you must return false
|
||||
- There is a new event hook: ${String.fromCharCode(96)}onPasteHook${String.fromCharCode(96)}. This will be called whenever the user pastes something to the canvas. You can use this callback if you want to do something additional during the onPaste event. In case you want to prevent the Excalidraw default onPaste action you must return false
|
||||
|
||||
${String.fromCharCode(96,96,96)}typescript
|
||||
async addImage(
|
||||
topX: number,
|
||||
topY: number,
|
||||
imageFile: TFile | string,
|
||||
scale: boolean = true, //default is true which will scale the image to MAX_IMAGE_SIZE, false will insert image at 100% of its size
|
||||
anchor: boolean = true, //only has an effect if "scale" is false. If "anchor" is true the image path will include |100%, if false the image will be inserted at 100%, but if resized by the user it won't pop back to 100% the next time Excalidraw is opened.
|
||||
scale: boolean = true,
|
||||
anchor: boolean = true,
|
||||
): Promise<string>;
|
||||
|
||||
async addElementsToView(
|
||||
repositionToCursor: boolean = false,
|
||||
save: boolean = true,
|
||||
newElementsOnTop: boolean = false,
|
||||
shouldRestoreElements: boolean = false, //restore elements - auto-corrects broken, incomplete or old elements included in the update
|
||||
shouldRestoreElements: boolean = false,
|
||||
): Promise<boolean>;
|
||||
|
||||
onPasteHook: (data: {
|
||||
ea: ExcalidrawAutomate;
|
||||
payload: ClipboardData;
|
||||
event: ClipboardEvent;
|
||||
excalidrawFile: TFile; //the file receiving the paste event
|
||||
view: ExcalidrawView; //the excalidraw view receiving the paste
|
||||
pointerPosition: { x: number; y: number }; //the pointer position on canvas
|
||||
excalidrawFile: TFile;
|
||||
view: ExcalidrawView;
|
||||
pointerPosition: { x: number; y: number };
|
||||
}) => boolean = null;
|
||||
|
||||
addEmbeddable(
|
||||
topX: number,
|
||||
topY: number,
|
||||
width: number,
|
||||
height: number,
|
||||
url?: string,
|
||||
file?: TFile
|
||||
): string;
|
||||
|
||||
get DEVICE(): DeviceType;
|
||||
|
||||
newFilePrompt(
|
||||
newFileNameOrPath: string,
|
||||
shouldOpenNewFile: boolean,
|
||||
targetPane?: PaneTarget,
|
||||
parentFile?: TFile
|
||||
): Promise<TFile | null>;
|
||||
|
||||
getLeaf(
|
||||
origo: WorkspaceLeaf,
|
||||
targetPane?: PaneTarget
|
||||
): WorkspaceLeaf;
|
||||
${String.fromCharCode(96,96,96)}
|
||||
`,
|
||||
"1.9.8":`
|
||||
|
||||
@@ -374,7 +374,7 @@ FILENAME_HEAD: "Filename",
|
||||
"or a PNG or an SVG copy. You need to enable auto-export PNG / SVG (see below under Export Settings) for those image types to be available in the dropdown. For drawings that do not have a " +
|
||||
"a corresponding PNG or SVG readily available the command palette action will insert a broken link. You need to open the original drawing and initiate export manually. " +
|
||||
"This option will not autogenerate PNG/SVG files, but will simply reference the already existing files.",
|
||||
EMBED_WIKILINK_NAME: "Embed SVG or PNG as Wiki link",
|
||||
EMBED_WIKILINK_NAME: "Embed Drawing using Wiki link",
|
||||
EMBED_WIKILINK_DESC:
|
||||
"Toggle ON: Excalidraw will embed a [[wiki link]]. Toggle OFF: Excalidraw will embed a [markdown](link).",
|
||||
EXPORT_PNG_SCALE_NAME: "PNG export image scale",
|
||||
|
||||
3
src/lang/locale/hu.ts
Normal file
3
src/lang/locale/hu.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
// Magyar
|
||||
|
||||
export default {};
|
||||
19
src/types.d.ts
vendored
19
src/types.d.ts
vendored
@@ -1,15 +1,4 @@
|
||||
import { ExcalidrawBindableElement, ExcalidrawElement, ExcalidrawImageElement, FileId, FillStyle, NonDeletedExcalidrawElement, RoundnessType, StrokeRoundness, StrokeStyle } from "@zsviczian/excalidraw/types/element/types";
|
||||
import { AppState, BinaryFileData, ExcalidrawImperativeAPI, Point } from "@zsviczian/excalidraw/types/types";
|
||||
import { TFile, WorkspaceLeaf } from "obsidian";
|
||||
import { EmbeddedFilesLoader } from "./EmbeddedFileLoader";
|
||||
import { ExcalidrawAutomate } from "./ExcalidrawAutomate";
|
||||
import ExcalidrawView, { ExportSettings } from "./ExcalidrawView";
|
||||
import ExcalidrawPlugin from "./main";
|
||||
import { ColorMaster } from "colormaster";
|
||||
import { TInput } from "colormaster/types";
|
||||
import { ClipboardData } from "@zsviczian/excalidraw/types/clipboard";
|
||||
import { PaneTarget } from "./utils/ModifierkeyHelper";
|
||||
|
||||
|
||||
export type ConnectionPoint = "top" | "bottom" | "left" | "right" | null;
|
||||
|
||||
@@ -33,4 +22,10 @@ export type DeviceType = {
|
||||
isWindows: boolean,
|
||||
isIOS: boolean,
|
||||
isAndroid: boolean
|
||||
};
|
||||
};
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
ExcalidrawAutomate: ExcalidrawAutomate;
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ export function getEmbedFilename(
|
||||
: settings.useExcalidrawExtension
|
||||
? ".excalidraw.md"
|
||||
: ".md")
|
||||
);
|
||||
).trim();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -108,4 +108,8 @@ export const emulateKeysForLinkClick = (action: PaneTarget): ModifierKeys => {
|
||||
break;
|
||||
}
|
||||
return ev;
|
||||
}
|
||||
|
||||
export const anyModifierKeysPressed = (e: ModifierKeys): boolean => {
|
||||
return e.shiftKey || e.ctrlKey || e.metaKey || e.altKey;
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
"**/*.tsx", "src/Dialogs/OpenDrawing.ts"
|
||||
"**/*.tsx", "src/Dialogs/OpenDrawing.ts",
|
||||
"src/types.d.ts"
|
||||
]
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
"**/*.tsx", "src/Dialogs/OpenDrawing.ts"
|
||||
"**/*.tsx", "src/Dialogs/OpenDrawing.ts",
|
||||
"src/types.d.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user