Commit graph

74 commits

Author SHA1 Message Date
JK
980e34ef86 fix(tikz-editor): resolve statement parsing with embedded semicolons, node math rendering, and multi-selection
- Add `splitTikzStatements` in `TikzCodec` to track `{}` and `[]` nesting depth, preventing premature statement splitting on semicolons inside color definitions like `color={rgb,255:red,95;green,166;blue,221}`.
- Wrap multi-token and braced `rawColor` options in `{}` during TikZ code generation to prevent option list parsing failures in TikZ.
- Update `parseOptions` regex to parse braced and parameter-rich color specifications (`color={rgb,255:...}` and `{HTML}`).
- Enhance `makeText` to unwrap outer `{}` and `$...$` and auto-detect LaTeX math commands (`\mathrm`, `\frac`, etc.) for clean MathJax rendering in text elements.
- Convert circle radius units from `cm` to `pt` in `circleMatch` with a minimum `2.0pt` threshold so node dots are visible on the canvas SVG.
- Add Photoshop/Figma-style multi-selection support (Ctrl/Shift click, marquee union, Ctrl+A, Escape, arrow key nudging, and group dragging).
- Explicitly type string callback parameters in `cmd.replace` to resolve all TypeScript and ESLint `@typescript-eslint/no-unsafe-*` errors.
2026-07-21 16:19:30 +02:00
JK
f0ce1930b8 fix(canvas): resolve text node translation, library resolution, and canvas panning
- Fix text label positioning offset in TikZJax rendering by calculating relative offsets `(pos.h - originH)` and `(pos.v - originV)` for PGF `{?x}` and `{?y}` placeholders instead of absolute DVI page coordinates in `CustomHTMLMachine.putSVG()`.
- Expand TikZ library loader in `loader.ts` to check `pgflibrary${lib}.code.tex.gz` as well as `tikzlibrary${lib}.code.tex.gz`, enabling `arrows.meta` and arrowhead rendering.
- Strip `\begin{tikzpicture}` and `\end{tikzpicture}` environment lines prior to statement splitting in `TikzCodec.parse()` so leading `\draw` paths (e.g. x-axis) are not dropped.
- Upgrade TikZ graphical editor modal to a 4000px × 4000px workspace with transform-based 360° free panning (`translate(panX, panY)`), cursor-centered zooming, and a "Center view" action.
- Address all Obsidian Community Guidelines linting issues across TikZ editor and renderer modules, removing debug console statements, fixing unsafe types, and correcting regex escapes.
- Add unit test suite in `test_helpers/tikz-codec.test.ts` for TikZ statement parsing, loop expansion, and color mixing.
2026-07-21 15:50:06 +02:00
JK
ec2e6f7dda fix(equations): resolve display math parsing failure with adjacent inline math
- Replace naive $$ regexes and dollar counters with a state-machine parser `findDisplayMathBlocks`.
- Correctly handle adjacent single-dollar inline math delimiters (e.g. `$[\text{charge}]$$^2$`) without misinterpreting them as opening display math blocks.
- Update `findMathBlocks` in live preview, callout block equation extraction in `provider-equation`, and `checkAndFixCalloutMath` in fixer utils.
- Add unit test coverage for adjacent inline math blocks and display math boundary detection.
2026-07-20 18:54:31 +02:00
JK
77f5f739b5 feat(equations): add document-level equation prefix via hidden obsitex block
- Parse `obsitex` YAML codeblocks (`eq-prefix: S` or `- eq-prefix: S`) using Obsidian's `parseYaml` API.
- Inject document-level `eq-prefix` into equation tags rendered in Live Preview, Reading View, and PDF export.
- Support prefixed ID generation (`% id: eq-S-xxxx`) for newly auto-generated equation tags.
- Update equation ID regex patterns (`/eq-[\w.-]+/`) to support dots in prefixes.
- Register hidden `obsitex` markdown codeblock processor and CSS rules (`.block-language-obsitex`) to hide instructions across views.
- Implement `FileIO.read()` across `ActiveNoteIO` and `NonActiveNoteIO`.
- Add unit tests for `obsitex` config parsing and `getEqNumberPrefix`.
- Add user-facing and architectural documentation in `docs/features/equations.md` and `docs/configuration/settings.md`.
2026-07-20 15:19:24 +02:00
JK
2624b13385 feat(row-layout): fix column lists rendering alignment, spacing, and continuation
- Simplify tightenColumn to use native block display (`display: block`) instead of overriding flex layout on every child.
- Set `white-space: normal` on column wrappers to collapse markdown-renderer formatting newlines and resolve vertical spacing gaps in Live Preview.
- Align `ul`/`ol` list containers using `margin-left` and `margin-right` auto-margins depending on column alignment spec, keeping list items left-aligned internally so bullets align vertically.
- Preprocess column markdown in Live Preview widget to automatically terminate lists and separate non-list continuation paragraphs with empty lines.
- Parse custom column specifications (e.g. alignment specs like `left`, `right`, `centre`, and width constraints).
2026-07-18 11:26:11 +02:00
JK
16ca794de8 fix(equations): preserve LaTeX row-break dimensions in sub-equation tagging
- Update the sub-equation row split logic in live-preview-equations to use a capturing regex `/(\\\\(?:\s*\[[^\]]*\])?)/`.
- Reconstruct the equation parts by only tagging the math content and preserving the separators (e.g. `\\[0.6em]`) exactly as-is.
- Add unit tests verifying both standard and dimensioned row breaks.
2026-07-17 13:06:44 +02:00
JK
27caaa6ef4 lint(loader): improve error handling and timeout management in TikzJaxLoader 2026-06-28 12:37:47 +02:00
JK
8e7a3072ef feat(snippets): add text transform for cleaning inline double dollar equations
- Implement `Clean Inline Double Dollar Symbols` text transform snippet.
- Convert inline double dollar signs `$$` to single dollar sign `$`.
- Keep block/display equation dollar signs (`$$`) intact (e.g. multi-line blocks or single-line equations starting/ending with `$$`).
- Add unit tests in `test_helpers/transforms.test.ts` to verify behavior.
- Update documentation in `docs/features/snippets.md` to document the new and existing double-dollar cleanup transforms.
2026-06-28 12:34:59 +02:00
JK
5783d3591f fix(tikz): resolve coordinate distortion in circuitikz and prevent parser crash
- Resolved a coordinate distortion issue in TikZ diagrams (specifically circuitikz components) by preloading transitive library dependencies (`calc`, `arrows.meta`, `bending`, and associated modules) required by `circuitikz`. Without these libraries, the WebAssembly TeX engine compiled in nonstop mode with missing symbols, leading to coordinate evaluation fallbacks.
- Prevented a runtime crash (`Cannot read properties of undefined (reading 'h')`) in `CustomHTMLMachine` when parsing DVI pages that exceed stack limits. Added a `safePosition` getter to default coordinate values if the stack pop returns an empty position.
2026-06-14 20:49:11 +02:00
JK
bf725acd14 feat(tikz): enhance AssetsManager and TikzEditorModal for package management; improve canvas rendering and settings structure 2026-06-14 16:26:49 +02:00
JK
67c6e83bf9 feat(tikz): add new circuit and flowchart components to AssetsManager; enhance library tab functionality in LeftSidebar 2026-06-14 11:20:28 +02:00
JK
53def164d5 refactor(load-time): lazy load heavy dependencies and optimize startup performance
- Convert eager imports of multi-megabyte `pdf-lib` (via `ExportConfigModal`) and `dvi2html` (via `TikzRenderer`) to dynamic imports.
- Defer `TikzRenderer` instantiation and loading to `onLayoutReady`.
- Remove blocking synchronous stylesheet checks and reads of `tikzjax.css` from `TikzRenderer.onLoad()`, relying on on-demand lazy loading instead.
- Implement `LazyMathSettingTab` proxy to defer evaluation of the settings UI modals and translations.
- Defer `setupDOMObserver` registration to after layout is ready to avoid MutationObserver overhead during startup layout rendering.
- Dynamically import `processZoteroCleanup` and `TikzEditorModal` inside their respective commands/callbacks.
2026-06-14 11:10:15 +02:00
JK
1642b5cd76 feat(tikz): implement undo functionality and clean up TikZ output generation 2026-06-14 09:18:41 +02:00
JK
416e4fa987 feat(tikz): enhance canvas coordinate handling and modal overlay management 2026-06-14 00:43:56 +02:00
JK
3f0ea8c86c feat(tikz): enhance SVG parsing and element deletion; add duplication functionality 2026-06-14 00:39:18 +02:00
JK
c5acdb0a36 update docs; version bump v0.0.3 2026-06-06 12:16:18 +02:00
Jovi Koikkara
eea4d67e3e
feat(tikz): major rendering, layout, and editor enhancements (#1)
Fixes
- WebAssembly & initialization
  - Fix TikZJax WebAssembly initialization issues.

- Fonts & symbol rendering
  - Override DVI parser `machine.putText` to use split character code offsets from `tikzjax.js`.
  - Map codes 0–9 starting at 161 to fix incorrect Γ rendering (was showing as Θ).
  - Map codes 10–19 starting at 173 to resolve Ω and ⊗ collisions with soft hyphen.

- Layout & rendering
  - Fix SVG clipping by switching to `position: relative` with `overflow: visible`.
  - Adjust inline SVG behavior to prevent top-of-page clipping.

- Type compatibility
  - Cast types to `unknown` in `TikzJaxLoader` and worker functions for compatibility.

- Error handling & cleanup
  - Improve error handling across TikZ components.
  - Remove unused dependencies and unnecessary console logs.

Features
- Package loading system
  - Add robust dependency resolution in `loader.ts` for:
    - `tikz-cd`
    - `tikz-feynhand`
    - `pgfcalendar`
  - Ensure required libraries and keys load dynamically on demand.

- Rendering & layout improvements
  - Enhance SVG bounding box calculation.
  - Implement dynamic column width calculation.
  - Improve row and column layout alignment and responsiveness.

- TikZ editor enhancements
  - Add keyboard shortcut tooltips to sidebar buttons.
  - Introduce thickness control slider for elements.
  - Improve snapping system with modes:
    - grid
    - half
    - none
  - Add support for new shapes:
    - circles
    - rectangles
    - triangles
  - Improve TikZ code generation error handling.

Improvements
- Selection & editing UX
  - Add lasso selection for multiple vertices in `CanvasGrid`.
  - Support multi-element editing in `RightSidebar`.
  - Refactor `TikzEditorModal` to handle multiple selected vertices.
  - Enable batch updates for selected elements.

- Layout & styling
  - Compact `.block-language-tikz` layout:
    - margin: `1.5em 0` → `0.3em 0`
    - padding: `1rem 0` → `0`
  - Improve canvas controls and interaction styles.

- Component refactoring
  - Refactor `CanvasGrid` to use template literals.
  - Replace inline styles with `setCssStyles`.
  - Improve `TikzCodec` node naming clarity.
  - Improve `history manager` type safety with `EditorElement`.
  - Use `window.setTimeout` in asset manager for better compatibility.

- Accessibility & UI polish
  - Improve sidebar button titles and tooltips.
  - Standardize live preview overlay button titles.
  - Clean up modal styling and text consistency.

Documentation
- Revamp TeXcore plugin documentation:
  - Clarify PDF export features and settings.
  - Improve quick preview architecture explanation.
  - Enhance equation search and autocomplete docs.
  - Streamline snippets usage and transformations.
  - Expand TikZ diagrams section with graphical editor guide.
  - Improve getting started guide with clearer steps.
  - Add navigation and configuration updates.

- Update plugin manifest descriptions for clarity.
2026-06-06 12:08:11 +02:00
JK
bf83c2a9d7 feat(tikz): transition to on-demand lazy asset loading model
- Excluded `tikzjax-assets/` directory from production release configurations in `package.json` to reduce package size from ~11MB to under 1.2MB.
- Generated `assets-manifest.ts` containing static list of 210+ LaTeX dependencies to resolve package lists statically.
- Implemented dynamic downloader in `loader.ts` using Obsidian `requestUrl` to fetch missing TeX files on-demand from CDN and save them locally.
- Integrated `showNotice` notifications to notify users about download initiation, completion, and error states.
- Implemented lazy font loading in `renderer.ts` to download `tikzjax.css` dynamically on first render.
- Resolved worker typescript type overload matching compiler issue.
- Satisfied Obsidian release policies by removing unnecessary console logs and direct `Notice` constructor calls.
2026-06-05 15:27:19 +02:00
JK
bea33c7cac feat(tikz): decouple TikZJax loader and assets for fully offline, worker-based rendering
- Extracted 214 TeX libraries, packages, core formats, and WebAssembly binaries from monolithic `tikzjax.js` into local `tikzjax-assets/` folder.
- Replaced monolithic 7MB runtime JS asset download from GitHub with a lightweight loader and Web Worker compilation engine.
- Implemented `tikzjax.worker.ts` to execute the TeX engine in a background Web Worker thread using modern Web standard APIs, preventing main-thread UI locks.
- Implemented `TikzJaxLoader` to parse code block preambles, lazily load/decompress assets synchronously via native `zlib`, cache core buffers in memory, and compile diagrams via the worker.
- Refactored `renderer.ts` and `live-preview-overlay.ts` to utilize the async loader, removing DOM-polluting `<script>` tags, global mutation observers, and custom window hooks.
- Swapped unsafe `.innerHTML` DOM writes with secure browser `DOMParser` APIs for SVG parsing.
- Configured `esbuild` and `package.json` to recursively copy `tikzjax-assets/` to both development and production release locations.
- Removed temporary extraction scripts to keep runtime codebase clean.
- Added asset origin citations to module README, project root README, and MkDocs features documentation.
- Fixed all 111 ESLint type check and style errors, ensuring clean linter execution.
2026-06-05 15:19:32 +02:00
JK
4aa6d9cdac Updated Naming Convention 2026-06-05 14:50:35 +02:00
JK
2cf270523a feat: redesign settings UI, add Integrations tab, and support dynamic Zotero cleanup command
- Renamed TikZJax tab to Integrations and consolidated PDF Export, TikZJax, and Zotero cleanup under it
- Grouped PDF Export, TikZJax, and Zotero cleanup configurations inside modular gear-button modals using SettingsGroupModal
- Added an "Enable Zotero cleanup" toggle to dynamically register/unregister the `remove-duplicate-zotero-annotations` command
- Restructured headers, line separators, and vertical spacing in CSS to match the full-calendar design
- Updated translation keys in en.json and corrected casing across settings descriptions
- Verified that all lint checks, type check compilations, and Jest tests pass with zero errors
2026-06-05 14:43:16 +02:00
JK
7c08b356d4 feat(settings): redesign settings tab with categories, search, i18n, and what's new modal
- Redesigned the settings tab to support structured categories (General, PDF Export, TikZJax, Custom Notes, and What's New)
- Implemented a search-based filter in settings that dynamically hides/shows items and highlights matching terms
- Added i18n support with `en.json` and a type-safe `t()` utility to handle localized sentence-case labels
- Integrated a startup check and "What's New" modal to display the latest updates on first launch or version updates
- Declared global `activeDocument` and `activeWindow` properties on the Window interface to ensure strict TypeScript type-safety
- Fixed all ESLint issues including deprecated `display()` calls, manual HTML headings, sentence case warnings, and unused variables
- Added documentation links support and a feedback footer at the bottom of the settings tab
2026-06-05 14:29:35 +02:00
JK
3dc3333ab6 css important may backfire 2026-06-04 21:31:18 +02:00
JK
e427438d1f fix lint II 2026-06-04 21:26:06 +02:00
JK
157c0b57ab lin fix I 2026-06-04 21:01:36 +02:00
JK
b6392a5523 refactor: reorganize src into modular structure and increase test coverage 2026-06-04 20:50:07 +02:00
JK
0f00ee5f90 setting up prod release 2026-06-04 20:26:28 +02:00
JK
88cb4e38d5 fix lint more updating 2026-06-04 20:12:07 +02:00
JK
bcc1be7933 updating the plugin 2026-06-04 20:12:07 +02:00
JK
ad4ad7969b feat(tikz): add export SVG functionality and enhance overlay header 2026-06-04 20:12:07 +02:00
JK
4fb6142978 Fix tikz for PDF printing 2026-06-04 20:12:06 +02:00
JK
f1d2e81e85 feat(row-layout): enhance column formatting and width handling in row layout 2026-06-04 20:12:06 +02:00
JK
ff059cdf28 fix(tikz): prevent uncaught null reference errors in tikzjax-load-finished event 2026-06-04 20:12:06 +02:00
JK
efa8d8f94a feat(tikz): add TikZ live preview overlay functionality 2026-06-04 20:12:06 +02:00
JK
096e18bd3c fix flickering when typing outside the live render 2026-06-04 20:12:06 +02:00
JK
57f99e33fd feat(tikz): add support for fetching and applying TikZJax CSS styles 2026-06-04 20:12:06 +02:00
JK
c548bac003 feat(row-layout): aggressively compress vertical spacing for row layout
- Adds a `tightenColumn` helper to override and clear margins/paddings on all inner elements (paragraphs, math blocks, code wrappers, SVGs, MathJax containers).
- Executes spacing compression at delayed intervals (0ms, 50ms, 150ms, 500ms) to ensure late-rendered asynchronous elements are properly shrunk.
- Pulls surrounding paragraph text closer by setting the row element margin to `-0.5em 0`.
- Ensures proper component cleanups via `ctx.addChild` and `destroy()` to prevent memory leaks.
2026-06-04 20:12:06 +02:00
JK
2c48c019f0 feat(row-layout): add side-by-side row layout for Reading View and Live Preview
- Implements support for `;;;row: [widths]` and `;;` columns to render side-by-side layouts dynamically.
- Integrates a CodeMirror 6 `StateField` using `Decoration.replace` for Live Preview, enabling seamless inline layout folding.
- Adds click-to-edit handling which dispatches selection to the raw source code when clicking a rendered layout.
- Ensures robust component lifecycle management: tracks and unloads rendering components via `destroy()` in Live Preview widgets and `ctx.addChild` in Reading View to prevent memory leaks.
- Bumps manifest.json to v2.3.0.
2026-06-04 20:12:06 +02:00
JK
a460ca5bea feat: implement robust offline-first TikZ diagram rendering support
- Added a modular `TikzRenderer` in `src/features/tikz/renderer.ts` to process `tikz` code blocks.
- Fetches and caches the offline-friendly, self-contained 7MB TikZJax JS engine from artisticat1/obsidian-tikzjax.
- Dynamically patches the engine's initialization to execute immediately (bypassing window.onload and document.readyState race conditions).
- Implements a programmatic `TikzJaxCleanup` function that terminates WebAssembly worker pools and disconnects MutationObservers when the plugin unloads, supporting safe Hot Reloads.
- Simplifies block element styling to render transparently and center-aligned, matching standard notes.
- Added Settings UI controls (`enableTikzjax` and `invertColorsInDarkMode`) to manage diagram color inversion and toggle rendering status.
- Integrated `TikzRenderer` setup and cleanup into the main plugin lifecycle.
2026-06-04 20:12:06 +02:00
JK
451ff80edf feat: implement custom note management with hotkey support 2026-06-04 20:12:06 +02:00
JK
ed45018fdc fix: update regex for equation links to correctly handle sub-indices 2026-06-04 20:12:05 +02:00
JK
c5786a8913 fix lazy multiline latex in callout leads to corrupt live preview 2026-06-04 20:12:05 +02:00
JK
6018bd89a5 feat: add Zotero cleanup feature to remove duplicate annotations from active note 2026-06-04 20:12:05 +02:00
JK
e1f8b1831b feat(snippets): add 'Clean Double Dollar Symbols' text transform snippet 2026-06-04 20:12:05 +02:00
JK
80f7042a57 feat(snippets): streamline snippet management and introduce text transformation features 2026-06-04 20:12:05 +02:00
JK
d1d809f029 fix(live-preview): fixed cursor kicking when editing referenced block 2026-06-04 20:12:05 +02:00
JK
bcc862731a feat(equation-cache): NO VAULT WIDE scans at startup; remove EquationCache and integrate equation processing directly in LatexLinkProvider 2026-06-04 20:12:05 +02:00
JK
bd877592c0 fix(equations): enhance handling of list sections in equation processing 2026-06-04 20:12:05 +02:00
JK
a3d9e1e494 fix(callout): Implement custom rendering for equation links and numbers in dynamically rendered callouts. 2026-06-04 20:12:05 +02:00
JK
94cd23a4c3 Added docs 2026-06-04 20:12:04 +02:00