diff --git a/manifest-beta.json b/manifest-beta.json index 521ae62..c05cc44 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "2.14.0", + "version": "2.14.1-beta-1", "minAppVersion": "1.5.7", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/package.json b/package.json index 51bd0f2..04d8671 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "license": "MIT", "dependencies": { "@popperjs/core": "^2.11.8", - "@zsviczian/excalidraw": "0.18.0-25", + "@zsviczian/excalidraw": "0.18.0-26", "chroma-js": "^3.1.2", "clsx": "^2.0.0", "@zsviczian/colormaster": "^1.2.2", diff --git a/rollup.config.js b/rollup.config.js index d2bbc34..f81bc7e 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -49,7 +49,7 @@ const jsxRuntimeShim = ` const mathjaxtosvg_pkg = isLib ? "" : fs.readFileSync("./MathjaxToSVG/dist/index.js", "utf8"); -const LANGUAGES = ['ru', 'zh-cn', 'zh-tw']; //english is not compressed as it is always loaded by default +const LANGUAGES = ['ru', 'zh-cn', 'zh-tw', 'es']; //english is not compressed as it is always loaded by default function trimLastSemicolon(input) { if (input.endsWith(";")) { diff --git a/src/shared/Dialogs/Messages.ts b/src/shared/Dialogs/Messages.ts index efc9afc..141c7bb 100644 --- a/src/shared/Dialogs/Messages.ts +++ b/src/shared/Dialogs/Messages.ts @@ -17,6 +17,15 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
Buy Me a Coffee at ko-fi.com
`, +"2.14.1":` +## New +- Added Spanish translation by [@Joakim31](https://github.com/Joakim31) [#2425](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2425) +- Incremental minor updates from the main Excalidraw project. + +## Fixed +- Styling issues impacting native Obsidian search/replace dialogs. [#2420](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2420) +- Now using native Obsidian attachment location function. 🙏 [mnaoumov](https://github.com/mnaoumov) [#2421](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2421), potentially fixes [#179](https://github.com/RainCat1998/obsidian-custom-attachment-location/issues/179) of the Obsidian Custom Attachment Location plugin issue. +`, "2.14.0":` ## A Big "Small" Update - Added search to Excalidraw Settings, plus added a link to access the public NotebookLM workbook pre-loaded with everything about the plugin diff --git a/src/shared/Scripts.ts b/src/shared/Scripts.ts index d89e831..4ca3f4f 100644 --- a/src/shared/Scripts.ts +++ b/src/shared/Scripts.ts @@ -191,7 +191,7 @@ export class ScriptEngine { ...this.scriptIconMap, }; const splitname = splitFolderAndFilename(name) - this.scriptIconMap[scriptPath] = { name:splitname.filename, group: splitname.folderpath === "/" ? "" : splitname.folderpath, svgString }; + this.scriptIconMap[scriptPath] = { name:splitname.filename, group: splitname.folderpath, svgString }; this.updateToolPannels(); } diff --git a/src/shared/components/ContentSearcher.ts b/src/shared/components/ContentSearcher.ts index 63a60f8..4b0e0e4 100644 --- a/src/shared/components/ContentSearcher.ts +++ b/src/shared/components/ContentSearcher.ts @@ -28,7 +28,7 @@ export class ContentSearcher { * Creates search UI elements styled like Obsidian's native search */ private createSearchElements(): void { - this.searchBarWrapper = createDiv("document-search-container"); + this.searchBarWrapper = createDiv("excalidraw-search document-search-container"); const documentSearch = createDiv("document-search"); this.inputContainer = createDiv("search-input-container document-search-input"); this.searchBar = createEl("input",{type: "text", placeholder: "Find..."}); diff --git a/src/utils/carveout.ts b/src/utils/carveout.ts index b1e90a4..378dcb5 100644 --- a/src/utils/carveout.ts +++ b/src/utils/carveout.ts @@ -2,7 +2,7 @@ import { ExcalidrawEmbeddableElement, ExcalidrawFrameElement, ExcalidrawImageEle import { Mutable } from "@zsviczian/excalidraw/types/common/src/utility-types"; import { getEA } from "src/core"; import { ExcalidrawAutomate } from "src/shared/ExcalidrawAutomate"; -import { getCropFileNameAndFolder, getListOfTemplateFiles, splitFolderAndFilename } from "./fileUtils"; +import { getCropFileNameAndFolder, getListOfTemplateFiles } from "./fileUtils"; import { Notice, TFile } from "obsidian"; import { Radians } from "@zsviczian/excalidraw/types/math/src/types"; diff --git a/src/utils/fileUtils.ts b/src/utils/fileUtils.ts index 1a40523..d205a33 100644 --- a/src/utils/fileUtils.ts +++ b/src/utils/fileUtils.ts @@ -11,7 +11,7 @@ import ExcalidrawView from "src/view/ExcalidrawView"; /** * Splits a full path including a folderpath and a filename into separate folderpath and filename components * @param filepath - * @returns folderpath will be normalized. This means "/" for root folder and no trailing "/" for other folders + * @returns returns "" for root folder and normalized path for subfolders (no trailing "/", e.g. "folder/subfolder") */ type ImageExtension = keyof typeof IMAGE_MIME_TYPES; @@ -23,11 +23,13 @@ export function splitFolderAndFilename(filepath: string): { } { const lastIndex = filepath.lastIndexOf("/"); const filename = lastIndex == -1 ? filepath : filepath.substring(lastIndex + 1); + const lastDotIndex = filename.lastIndexOf("."); + const folderpath = filepath.substring(0, lastIndex); return { - folderpath: normalizePath(filepath.substring(0, lastIndex)), + folderpath: folderpath ? normalizePath(folderpath) : "", filename, basename: filename.replace(/\.[^/.]+$/, ""), - extension: filename.substring(filename.lastIndexOf(".") + 1), + extension: lastDotIndex > 0 ? filename.substring(lastDotIndex + 1) : "", }; } @@ -540,7 +542,7 @@ export async function importFileToVault(app: App, fname: string, content: string export async function createOrOverwriteFile(app: App, path: string, content: string | ArrayBuffer | Blob): Promise { const {folderpath} = splitFolderAndFilename(path); - if(folderpath && folderpath !== "/") { + if(folderpath) { await checkAndCreateFolder(folderpath); } const file = app.vault.getAbstractFileByPath(normalizePath(path)); diff --git a/src/utils/obsidianUtils.ts b/src/utils/obsidianUtils.ts index c43dae5..673a69a 100644 --- a/src/utils/obsidianUtils.ts +++ b/src/utils/obsidianUtils.ts @@ -3,10 +3,10 @@ import { Editor, FrontMatterCache, MarkdownView, - normalizePath, OpenViewState, parseFrontMatterEntry, TFile, View, ViewState, Workspace, WorkspaceLeaf, WorkspaceSplit + OpenViewState, parseFrontMatterEntry, TFile, View, ViewState, Workspace, WorkspaceLeaf, WorkspaceSplit } from "obsidian"; import ExcalidrawPlugin from "../core/main"; -import { checkAndCreateFolder, splitFolderAndFilename } from "./fileUtils"; +import { splitFolderAndFilename } from "./fileUtils"; import { linkClickModifierType, ModifierKeys } from "./modifierkeyHelper"; import { DEVICE, EXCALIDRAW_PLUGIN, REG_BLOCK_REF_CLEAN, REG_SECTION_REF_CLEAN, VIEW_TYPE_EXCALIDRAW } from "src/constants/constants"; import yaml from "js-yaml"; @@ -174,16 +174,12 @@ export const getAttachmentsFolderAndFilePath = async ( activeViewFilePath: string, newFileName: string ): Promise<{ folder: string; filepath: string; }> => { - const NOT_FOUND_INDEX = -1; - const extensionSeparatorIndex = newFileName.lastIndexOf("."); - const attachmentFileBasename = extensionSeparatorIndex === NOT_FOUND_INDEX ? newFileName : newFileName.slice(0, extensionSeparatorIndex); - const attachmentFileExtension = extensionSeparatorIndex === NOT_FOUND_INDEX ? "" : newFileName.slice(extensionSeparatorIndex + 1); + const { basename, extension } = splitFolderAndFilename(newFileName); const activeViewFile = app.vault.getFileByPath(activeViewFilePath); - const attachmentFilePath = await app.vault.getAvailablePathForAttachments(attachmentFileBasename, attachmentFileExtension, activeViewFile); - const folderSeparatorIndex = attachmentFilePath.lastIndexOf("/"); - const attachmentFolderPath = folderSeparatorIndex === NOT_FOUND_INDEX ? "" : attachmentFilePath.slice(0, folderSeparatorIndex); + const attachmentFilePath = await app.vault.getAvailablePathForAttachments(basename, extension, activeViewFile); + const { folderpath } = splitFolderAndFilename(attachmentFilePath); return { - folder: attachmentFolderPath, + folder: folderpath, filepath: attachmentFilePath }; }; diff --git a/src/view/ExcalidrawView.ts b/src/view/ExcalidrawView.ts index 7aeec72..df52c54 100644 --- a/src/view/ExcalidrawView.ts +++ b/src/view/ExcalidrawView.ts @@ -4041,7 +4041,11 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ if(st.newElement?.type === "freedraw") { this.freedrawLastActiveTimestamp = Date.now(); } - if (st.newElement || st.editingTextElement || st.editingLinearElement) { + if ( + st.newElement || + st.editingTextElement || + (st.selectedLinearElement && st.selectedLinearElement.isEditing) + ) { this.plugin.wasPenModeActivePreviously = st.penMode; } this.viewModeEnabled = st.viewModeEnabled; @@ -4083,7 +4087,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ /*st.resizingElement === null && st.newElement === null && st.editingGroupId === null &&*/ - st.editingLinearElement === null + (st.selectedLinearElement === null || !st.selectedLinearElement.isEditing) ) { this.checkSceneVersion(et); } diff --git a/styles.css b/styles.css index b87c36c..e6fdbad 100644 --- a/styles.css +++ b/styles.css @@ -765,7 +765,7 @@ textarea.excalidraw-wysiwyg, .excalidraw input { margin-left: auto; } -.document-search-container { +.excalidraw-search.document-search-container { display: flex; flex-direction: column; background: var(--background-secondary); @@ -780,12 +780,12 @@ textarea.excalidraw-wysiwyg, .excalidraw input { margin-left: 1rem; } -.document-search { +.excalidraw-search .document-search { align-items: center; max-width: none; } -.search-input-container.document-search-input { +.excalidraw-search .search-input-container.document-search-input { display: flex; align-items: center; flex: 1 1 auto; @@ -795,13 +795,13 @@ textarea.excalidraw-wysiwyg, .excalidraw input { min-width: 0; } -.search-input-container .clickable-icon { +.excalidraw-search .search-input-container .clickable-icon { display: flex; align-items: center; color: var(--text-faint); } -.search-input-container input[type="text"] { +.excalidraw-search .search-input-container input[type="text"] { background: transparent; border: none; outline: none; @@ -812,7 +812,7 @@ textarea.excalidraw-wysiwyg, .excalidraw input { margin: 0; } -.document-search-count { +.excalidraw-search .document-search-count { margin-left: 0.5em; color: var(--text-faint); font-size: 0.95em; @@ -821,13 +821,13 @@ textarea.excalidraw-wysiwyg, .excalidraw input { text-align: right; } -.document-search-buttons { +.excalidraw-search .document-search-buttons { display: flex; align-items: center; gap: 2px; } -.document-search-button { +.excalidraw-search .document-search-button { background: none; border: none; outline: none; @@ -845,12 +845,12 @@ textarea.excalidraw-wysiwyg, .excalidraw input { justify-content: center; } -.document-search-button:hover, .document-search-button:focus { +.excalidraw-search .document-search-button:hover, .excalidraw-search .document-search-button:focus { background: var(--background-modifier-hover); color: var(--text-accent); } -.document-search-button svg { +.excalidraw-search .document-search-button svg { width: 1.3em; height: 1.3em; stroke: currentColor;